CMS 3D CMS Logo

CmsMTDStringToEnum.cc
Go to the documentation of this file.
2 
4 
6  _map.insert(
7  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("FastTimerRegion", GeometricTimingDet::MTD));
8 
9  _map.insert(std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("BarrelTimingLayer",
11  _map.insert(
12  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("Layer1", GeometricTimingDet::BTLLayer));
13  _map.insert(std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("Rod1", GeometricTimingDet::BTLTray));
14  _map.insert(
15  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("BModule", GeometricTimingDet::BTLModule));
16  _map.insert(std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("SensorPackage",
18  _map.insert(
19  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("Crystal", GeometricTimingDet::BTLCrystal));
20 
21  _map.insert(std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("EndcapTimingLayer",
23  _map.insert(
24  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("Disc1", GeometricTimingDet::ETLDisc));
25  _map.insert(std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("Ring", GeometricTimingDet::ETLRing));
26  _map.insert(
27  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("EModule", GeometricTimingDet::ETLModule));
28  _map.insert(
29  std::pair<std::string, GeometricTimingDet::GeometricTimingEnumType>("Sensor", GeometricTimingDet::ETLSensor));
30 
31  //
32  // build reverse map
33  //
34 
35  _reverseMap.insert(
36  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::MTD, "FastTimerRegion"));
37 
38  _reverseMap.insert(std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::BTL,
39  "BarrelTimingLayer"));
40  _reverseMap.insert(
41  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::BTLLayer, "Layer"));
42  _reverseMap.insert(
43  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::BTLTray, "Rod1"));
44  _reverseMap.insert(
45  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::BTLModule, "Module"));
46  _reverseMap.insert(std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::BTLSensor,
47  "SensorPackage"));
48  _reverseMap.insert(
49  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::BTLCrystal, "Crystal"));
50 
51  _reverseMap.insert(std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::ETL,
52  "EndcapTimingLayer"));
53  _reverseMap.insert(
54  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::ETLDisc, "Disc1"));
55  _reverseMap.insert(
56  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::ETLRing, "Ring"));
57  _reverseMap.insert(
58  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::ETLModule, "Module"));
59  _reverseMap.insert(
60  std::pair<GeometricTimingDet::GeometricTimingEnumType, std::string>(GeometricTimingDet::ETLSensor, "Sensor"));
61 
62  //
63  // done
64  //
65 }
66 
68  // remove namespace if present
69  std::string_view v = s;
70  auto first = v.find_first_of(":");
71  v.remove_prefix(std::min(first + 1, v.size()));
72  MapEnumType::const_iterator p = map().find({v.data(), v.size()});
73  if (p != map().end())
74  return p->second;
76 }
77 
79  static std::string const u("Unknown");
80  ReverseMapEnumType::const_iterator p = reverseMap().find(t);
81  if (p != reverseMap().end())
82  return p->second;
83  return u;
84 }
GeometricTimingDet::GeometricTimingEnumType type(std::string const &) const
static ReverseMapEnumType const & reverseMap()
static const Impl m_impl
ReverseMapEnumType _reverseMap
std::string const & name(GeometricTimingDet::GeometricTimingEnumType) const
static MapEnumType const & map()
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
enum GeometricTimingDet::GTDEnumType GeometricTimingEnumType