EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICPIDDefs.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICPIDDefs.cc
1 #include "EICPIDDefs.h"
2 
3 #include <boost/algorithm/string.hpp>
4 #include <iostream>
5 #include <string>
6 
7 namespace EICPIDDefs
8 {
9 PIDDetector getPIDDetector(const std::string& name)
10 {
11  for (auto pair : PIDDetectorNameMap)
12  {
13  if (boost::iequals(pair.first, name))
14  return pair.second;
15  }
16  return InvalidDetector;
17 }
18 
19 const std::string& getPIDDetectorName(const PIDDetector det)
20 {
21  static std::map<PIDDetector, std::string> reverse_map;
22 
23  if (reverse_map.size() == 0)
24  {
25  // build reverse map
26 
27  for (const auto& pair : PIDDetectorNameMap)
28  {
29  reverse_map[pair.second] = pair.first;
30  }
31  }
32 
33  if (reverse_map.find(det) == reverse_map.end())
34  {
35  std::cout << __PRETTY_FUNCTION__
36  << " WARNING: asking for det = " << det
37  << ", which is not defined in EICPIDDefs::PIDDetectorNameMap" << std::endl;
38  }
39 
40  return reverse_map[det];
41 }
42 
43 } // namespace EICPIDDefs