CMS 3D CMS Logo

L1GtDefinitions.cc
Go to the documentation of this file.
1 
14 // this class header
16 
17 // system include files
18 #include <cstring>
19 
20 // user include files
22 namespace {
23  template <class T>
24  struct entry {
25  char const* label;
26  T value;
27  };
28 
29  constexpr bool same(char const* x, char const* y) {
30  return !*x && !*y ? true : /* default */ (*x == *y && same(x + 1, y + 1));
31  }
32 
33  template <class T>
34  constexpr T keyToValue(char const* label, entry<T> const* entries) {
35  return !entries->label ? entries->value
36  : same(entries->label, label) ? entries->value
37  : /*default*/ keyToValue(label, entries + 1);
38  }
39 
40  template <class T>
41  constexpr char const* valueToKey(T value, entry<T> const* entries) {
42  return !entries->label ? entries->label
43  : entries->value == value ? entries->label
44  : /*default*/ valueToKey(value, entries + 1);
45  }
46  constexpr entry<L1GtBoardType> l1GtBoardTypeStringToEnumMap[] = {{"GTFE", GTFE},
47  {"FDL", FDL},
48  {"PSB", PSB},
49  {"GMT", GMT},
50  {"TCS", TCS},
51  {"TIM", TIM},
52  {"BoardNull", BoardNull},
53  {nullptr, (L1GtBoardType)-1}};
54 
55  constexpr entry<L1GtPsbQuad> l1GtPsbQuadStringToEnumMap[] = {{"Free", Free},
56  {"TechTr", TechTr},
57  {"IsoEGQ", IsoEGQ},
58  {"NoIsoEGQ", NoIsoEGQ},
59  {"CenJetQ", CenJetQ},
60  {"ForJetQ", ForJetQ},
61  {"TauJetQ", TauJetQ},
62  {"ESumsQ", ESumsQ},
63  {"JetCountsQ", JetCountsQ},
64  {"MQB1", MQB1},
65  {"MQB2", MQB2},
66  {"MQF3", MQF3},
67  {"MQF4", MQF4},
68  {"MQB5", MQB5},
69  {"MQB6", MQB6},
70  {"MQF7", MQF7},
71  {"MQF8", MQF8},
72  {"MQB9", MQB9},
73  {"MQB10", MQB10},
74  {"MQF11", MQF11},
75  {"MQF12", MQF12},
76  {"CastorQ", CastorQ},
77  {"HfQ", HfQ},
78  {"BptxQ", BptxQ},
79  {"GtExternalQ", GtExternalQ},
80  {"PsbQuadNull", PsbQuadNull},
81  {nullptr, (L1GtPsbQuad)-1}};
82 
83  // L1GtConditionType
84  constexpr entry<L1GtConditionType> l1GtConditionTypeStringToEnumMap[] = {{"TypeNull", TypeNull},
85  {"Type1s", Type1s},
86  {"Type2s", Type2s},
87  {"Type2wsc", Type2wsc},
88  {"Type2cor", Type2cor},
89  {"Type3s", Type3s},
90  {"Type4s", Type4s},
91  {"TypeETM", TypeETM},
92  {"TypeETT", TypeETT},
93  {"TypeHTT", TypeHTT},
94  {"TypeHTM", TypeHTM},
95  {"TypeJetCounts", TypeJetCounts},
96  {"TypeCastor", TypeCastor},
97  {"TypeHfBitCounts", TypeHfBitCounts},
98  {"TypeHfRingEtSums", TypeHfRingEtSums},
99  {"TypeBptx", TypeBptx},
100  {"TypeExternal", TypeExternal},
101  {nullptr, (L1GtConditionType)-1}};
102 
103  // L1GtConditionCategory
104  constexpr entry<L1GtConditionCategory> l1GtConditionCategoryStringToEnumMap[] = {
105  {"CondNull", CondNull},
106  {"CondMuon", CondMuon},
107  {"CondCalo", CondCalo},
108  {"CondEnergySum", CondEnergySum},
109  {"CondJetCounts", CondJetCounts},
110  {"CondCorrelation", CondCorrelation},
111  {"CondCastor", CondCastor},
112  {"CondHfBitCounts", CondHfBitCounts},
113  {"CondHfRingEtSums", CondHfRingEtSums},
114  {"CondBptx", CondBptx},
115  {"CondExternal", CondExternal},
116  {nullptr, (L1GtConditionCategory)-1}};
117 
118 } // namespace
119 // L1GtBoardType
121  L1GtBoardType value = keyToValue(label.c_str(), l1GtBoardTypeStringToEnumMap);
122  if (value == (L1GtBoardType)-1) {
123  edm::LogInfo("L1GtDefinitions") << "\n '" << label << "' is not a recognized L1GtBoardType. \n Return BoardNull.";
124  value = BoardNull;
125  }
126 
127  if (value == BoardNull) {
128  edm::LogInfo("L1GtDefinitions") << "\n BoardNull means no valid board type defined!";
129  }
130 
131  return value;
132 }
133 
135  char const* result = valueToKey(boardType, l1GtBoardTypeStringToEnumMap);
136  if (boardType == BoardNull) {
137  edm::LogInfo("L1GtDefinitions") << "\n BoardNull means no valid board type defined!";
138  }
139  if (!result) {
140  edm::LogInfo("L1GtDefinitions") << "\n '" << boardType << "' is not a recognized L1GtBoardType. "
141  << "\n Return BoardNull, which means no valid board type defined!";
142  return "BoardNull";
143  }
144  return result;
145 }
146 
147 // L1GtPsbQuad
148 
150  L1GtPsbQuad value = keyToValue(label.c_str(), l1GtPsbQuadStringToEnumMap);
151  // in case of unrecognized L1GtPsbQuad, return PsbQuadNull
152  // to be dealt by the corresponding module
153  if (value == (L1GtPsbQuad)-1) {
154  edm::LogInfo("L1GtDefinitions") << "\n '" << label << "' is not a recognized L1GtPsbQuad. \n Return PsbQuadNull.";
155  value = PsbQuadNull;
156  }
157 
158  if (value == PsbQuadNull) {
159  edm::LogInfo("L1GtDefinitions") << "\n PsbQuadNull means no valid PSB quadruplet defined!";
160  }
161 
162  return value;
163 }
164 
166  char const* result = valueToKey(psbQuad, l1GtPsbQuadStringToEnumMap);
167  if (psbQuad == PsbQuadNull)
168  edm::LogInfo("L1GtDefinitions") << "\n PsbQuadNull means no valid PSB quadruplet defined!";
169  if (!result) {
170  result = "PsbQuadNull";
171  edm::LogInfo("L1GtDefinitions") << "\n '" << psbQuad << "' is not a recognized L1GtPsbQuad. "
172  << "\n Return PsbQuadNull, which means no valid PSB quadruplet defined!";
173  }
174 
175  return result;
176 }
177 
179  L1GtConditionType value = keyToValue(label.c_str(), l1GtConditionTypeStringToEnumMap);
180 
181  // in case of unrecognized L1GtConditionType, return TypeNull
182  // to be dealt by the corresponding module
183  if (value == (L1GtConditionType)-1) {
184  edm::LogInfo("L1GtDefinitions") << "\n '" << label
185  << "' is not a recognized L1GtConditionType. \n Return TypeNull.";
186 
187  value = TypeNull;
188  }
189 
190  if (value == TypeNull) {
191  edm::LogInfo("L1GtDefinitions") << "\n TypeNull means no valid condition type defined!";
192  }
193 
194  return value;
195 }
196 
198  const char* result = valueToKey(conditionType, l1GtConditionTypeStringToEnumMap);
199  if (conditionType == TypeNull)
200  edm::LogInfo("L1GtDefinitions") << "\n Return TypeNull, which means no valid condition type defined!";
201  if (!result) {
202  result = "TypeNull";
203  edm::LogInfo("L1GtDefinitions") << "\n '" << conditionType << "' is not a recognized L1GtConditionType. "
204  << "\n Return TypeNull, which means no valid condition type defined!";
205  }
206  return result;
207 }
208 
210  L1GtConditionCategory value = keyToValue(label.c_str(), l1GtConditionCategoryStringToEnumMap);
211  // in case of unrecognized L1GtConditionCategory, return CondNull
212  // to be dealt by the corresponding module
213  if (value == (L1GtConditionCategory)-1) {
214  edm::LogInfo("L1GtDefinitions") << "\n '" << label
215  << "' is not a recognized L1GtConditionCategory. \n Return CondNull.";
216 
217  value = CondNull;
218  }
219 
220  if (value == CondNull) {
221  edm::LogInfo("L1GtDefinitions") << "\n CondNull means no valid condition category defined!";
222  }
223 
224  return value;
225 }
226 
228  char const* result = valueToKey(conditionCategory, l1GtConditionCategoryStringToEnumMap);
229  if (conditionCategory == CondNull)
230  edm::LogInfo("L1GtDefinitions") << "\n Return CondNull, which means no valid condition category defined!";
231 
232  if (!result) {
233  result = "CondNull";
234  edm::LogInfo("L1GtDefinitions") << "\n '" << conditionCategory << "' is not a recognized L1GtConditionCategory. "
235  << "\n Return CondNull, which means no valid condition category defined!";
236  }
237 
238  return result;
239 }
TechTr
Definition: L1GtDefinitions.h:41
GTFE
Definition: L1GtDefinitions.h:28
IsoEGQ
Definition: L1GtDefinitions.h:42
CondBptx
Definition: L1GtDefinitions.h:36
MessageLogger.h
l1GtPsbQuadStringToEnum
L1GtPsbQuad l1GtPsbQuadStringToEnum(const std::string &label)
Definition: L1GtDefinitions.cc:149
TypeCastor
Definition: L1GtDefinitions.h:17
PSB
Definition: L1GtDefinitions.h:28
MQF7
Definition: L1GtDefinitions.h:55
TypeJetCounts
Definition: L1GtDefinitions.h:16
TypeBptx
Definition: L1GtDefinitions.h:20
MQB2
Definition: L1GtDefinitions.h:50
TypeETM
Definition: L1GtDefinitions.h:12
TCS
Definition: L1GtDefinitions.h:28
mps_splice.entry
entry
Definition: mps_splice.py:68
CondMuon
Definition: L1GtDefinitions.h:28
FDL
Definition: L1GtDefinitions.h:28
GtExternalQ
Definition: L1GtDefinitions.h:64
CenJetQ
Definition: L1GtDefinitions.h:44
l1GtConditionTypeStringToEnum
L1GtConditionType l1GtConditionTypeStringToEnum(const std::string &label)
Definition: L1GtDefinitions.cc:178
CondEnergySum
Definition: L1GtDefinitions.h:30
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
l1GtConditionCategoryStringToEnum
L1GtConditionCategory l1GtConditionCategoryStringToEnum(const std::string &label)
Definition: L1GtDefinitions.cc:209
l1GtBoardTypeEnumToString
std::string l1GtBoardTypeEnumToString(const L1GtBoardType &boardType)
Definition: L1GtDefinitions.cc:134
CondJetCounts
Definition: L1GtDefinitions.h:31
writeEcalDQMStatus.conditionType
conditionType
Definition: writeEcalDQMStatus.py:52
TypeHfBitCounts
Definition: L1GtDefinitions.h:18
L1GtConditionCategory
L1GtConditionCategory
condition categories
Definition: L1GtDefinitions.h:26
TypeETT
Definition: L1GtDefinitions.h:13
CondNull
Definition: L1GtDefinitions.h:27
MQB10
Definition: L1GtDefinitions.h:58
MQB6
Definition: L1GtDefinitions.h:54
TypeHTM
Definition: L1GtDefinitions.h:15
NoIsoEGQ
Definition: L1GtDefinitions.h:43
CondExternal
Definition: L1GtDefinitions.h:37
JetCountsQ
Definition: L1GtDefinitions.h:48
TIM
Definition: L1GtDefinitions.h:28
TypeExternal
Definition: L1GtDefinitions.h:21
Free
Definition: L1GtDefinitions.h:40
L1GtConditionType
L1GtConditionType
Definition: L1GtDefinitions.h:4
funct::true
true
Definition: Factorize.h:173
Type2wsc
Definition: L1GtDefinitions.h:8
TypeHfRingEtSums
Definition: L1GtDefinitions.h:19
MQF11
Definition: L1GtDefinitions.h:59
ESumsQ
Definition: L1GtDefinitions.h:47
CondCastor
Definition: L1GtDefinitions.h:33
MQF3
Definition: L1GtDefinitions.h:51
MQB9
Definition: L1GtDefinitions.h:57
Type3s
Definition: L1GtDefinitions.h:10
MQB1
Definition: L1GtDefinitions.h:49
MQF4
Definition: L1GtDefinitions.h:52
CondCalo
Definition: L1GtDefinitions.h:29
value
Definition: value.py:1
GMT
Definition: L1GtDefinitions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
l1GtConditionTypeEnumToString
std::string l1GtConditionTypeEnumToString(const L1GtConditionType &conditionType)
Definition: L1GtDefinitions.cc:197
CondHfBitCounts
Definition: L1GtDefinitions.h:34
CastorQ
Definition: L1GtDefinitions.h:61
Type2cor
Definition: L1GtDefinitions.h:9
MQB5
Definition: L1GtDefinitions.h:53
Type1s
Definition: L1GtDefinitions.h:6
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
genVertex_cff.x
x
Definition: genVertex_cff.py:13
Type2s
Definition: L1GtDefinitions.h:7
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
Type4s
Definition: L1GtDefinitions.h:11
BoardNull
Definition: L1GtDefinitions.h:28
CondHfRingEtSums
Definition: L1GtDefinitions.h:35
MQF12
Definition: L1GtDefinitions.h:60
ForJetQ
Definition: L1GtDefinitions.h:45
PsbQuadNull
Definition: L1GtDefinitions.h:65
mps_fire.result
result
Definition: mps_fire.py:311
BptxQ
Definition: L1GtDefinitions.h:63
HfQ
Definition: L1GtDefinitions.h:62
TypeNull
Definition: L1GtDefinitions.h:5
l1GtBoardTypeStringToEnum
L1GtBoardType l1GtBoardTypeStringToEnum(const std::string &label)
Definition: L1GtDefinitions.cc:120
L1GtBoardType
L1GtBoardType
board types in GT
Definition: L1GtDefinitions.h:28
TauJetQ
Definition: L1GtDefinitions.h:46
L1GtDefinitions.h
label
const char * label
Definition: PFTauDecayModeTools.cc:11
l1GtConditionCategoryEnumToString
std::string l1GtConditionCategoryEnumToString(const L1GtConditionCategory &conditionCategory)
Definition: L1GtDefinitions.cc:227
l1GtPsbQuadEnumToString
std::string l1GtPsbQuadEnumToString(const L1GtPsbQuad &psbQuad)
Definition: L1GtDefinitions.cc:165
L1GtPsbQuad
L1GtPsbQuad
quadruples sent to GT via PSB
Definition: L1GtDefinitions.h:39
TypeHTT
Definition: L1GtDefinitions.h:14
MQF8
Definition: L1GtDefinitions.h:56
CondCorrelation
Definition: L1GtDefinitions.h:32