CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
31  : /* default */ (*x == *y && same(x+1, y+1));
32 }
33 
34 template <class T>
35 constexpr T keyToValue(char const *label, entry<T> const *entries) {
36  return !entries->label ? entries->value
37  : same(entries->label, label) ? entries->value
38  : /*default*/ keyToValue(label, entries+1);
39 }
40 
41 template <class T>
42 constexpr char const*valueToKey(T value, entry<T> const *entries) {
43  return !entries->label ? entries->label
44  : entries->value == value ? entries->label
45  : /*default*/ valueToKey(value, entries+1);
46 }
47 constexpr entry<L1GtBoardType> l1GtBoardTypeStringToEnumMap[] = {
48  {"GTFE", GTFE},
49  {"FDL", FDL},
50  {"PSB", PSB},
51  {"GMT", GMT},
52  {"TCS", TCS},
53  {"TIM", TIM},
54  {"BoardNull", BoardNull},
55  {0, (L1GtBoardType)-1}
56 };
57 
58 constexpr entry<L1GtPsbQuad> l1GtPsbQuadStringToEnumMap[] = {
59  {"Free", Free},
60  {"TechTr", TechTr},
61  {"IsoEGQ", IsoEGQ},
62  {"NoIsoEGQ", NoIsoEGQ},
63  {"CenJetQ", CenJetQ},
64  {"ForJetQ", ForJetQ},
65  {"TauJetQ", TauJetQ},
66  {"ESumsQ", ESumsQ},
67  {"JetCountsQ", JetCountsQ},
68  {"MQB1", MQB1},
69  {"MQB2", MQB2},
70  {"MQF3", MQF3},
71  {"MQF4", MQF4},
72  {"MQB5", MQB5},
73  {"MQB6", MQB6},
74  {"MQF7", MQF7},
75  {"MQF8", MQF8},
76  {"MQB9", MQB9},
77  {"MQB10", MQB10},
78  {"MQF11", MQF11},
79  {"MQF12", MQF12},
80  {"CastorQ", CastorQ},
81  {"HfQ", HfQ},
82  {"BptxQ", BptxQ},
83  {"GtExternalQ", GtExternalQ},
84  {"PsbQuadNull", PsbQuadNull},
85  {0, (L1GtPsbQuad) - 1}
86 };
87 
88 // L1GtConditionType
89 constexpr entry<L1GtConditionType> l1GtConditionTypeStringToEnumMap[] = {
90  {"TypeNull", TypeNull},
91  {"Type1s", Type1s},
92  {"Type2s", Type2s},
93  {"Type2wsc", Type2wsc},
94  {"Type2cor", Type2cor},
95  {"Type3s", Type3s},
96  {"Type4s", Type4s},
97  {"TypeETM", TypeETM},
98  {"TypeETT", TypeETT},
99  {"TypeHTT", TypeHTT},
100  {"TypeHTM", TypeHTM},
101  {"TypeJetCounts", TypeJetCounts},
102  {"TypeCastor", TypeCastor},
103  {"TypeHfBitCounts", TypeHfBitCounts},
104  {"TypeHfRingEtSums", TypeHfRingEtSums},
105  {"TypeBptx", TypeBptx},
106  {"TypeExternal", TypeExternal},
107  {0, (L1GtConditionType) - 1}
108 };
109 
110 // L1GtConditionCategory
111 constexpr entry<L1GtConditionCategory> l1GtConditionCategoryStringToEnumMap[] = {
112  {"CondNull", CondNull},
113  {"CondMuon", CondMuon},
114  {"CondCalo", CondCalo},
115  {"CondEnergySum", CondEnergySum},
116  {"CondJetCounts", CondJetCounts},
117  {"CondCorrelation", CondCorrelation},
118  {"CondCastor", CondCastor},
119  {"CondHfBitCounts", CondHfBitCounts},
120  {"CondHfRingEtSums", CondHfRingEtSums},
121  {"CondBptx", CondBptx},
122  {"CondExternal", CondExternal},
123  {0, (L1GtConditionCategory) - 1}
124 };
125 
126 }
127 // L1GtBoardType
129  L1GtBoardType value = keyToValue(label.c_str(), l1GtBoardTypeStringToEnumMap);
130  if (value == (L1GtBoardType) - 1) {
131  edm::LogInfo("L1GtDefinitions") << "\n '" << label
132  << "' is not a recognized L1GtBoardType. \n Return BoardNull.";
133  value = BoardNull;
134  }
135 
136  if (value == BoardNull) {
137  edm::LogInfo("L1GtDefinitions")
138  << "\n BoardNull means no valid board type defined!";
139  }
140 
141  return value;
142 }
143 
145  char const *result= valueToKey(boardType, l1GtBoardTypeStringToEnumMap);
146  if (boardType == BoardNull) {
147  edm::LogInfo("L1GtDefinitions")
148  << "\n BoardNull means no valid board type defined!";
149  }
150  if (!result) {
151  edm::LogInfo("L1GtDefinitions") << "\n '" << boardType
152  << "' is not a recognized L1GtBoardType. "
153  << "\n Return BoardNull, which means no valid board type defined!";
154  return "BoardNull";
155  }
156  return result;
157 }
158 
159 
160 // L1GtPsbQuad
161 
163  L1GtPsbQuad value = keyToValue(label.c_str(), l1GtPsbQuadStringToEnumMap);
164  // in case of unrecognized L1GtPsbQuad, return PsbQuadNull
165  // to be dealt by the corresponding module
166  if (value == -1) {
167  edm::LogInfo("L1GtDefinitions") << "\n '" << label
168  << "' is not a recognized L1GtPsbQuad. \n Return PsbQuadNull.";
169  value = PsbQuadNull;
170  }
171 
172  if (value == PsbQuadNull) {
173  edm::LogInfo("L1GtDefinitions")
174  << "\n PsbQuadNull means no valid PSB quadruplet defined!";
175  }
176 
177  return value;
178 }
179 
181  char const*result = valueToKey(psbQuad, l1GtPsbQuadStringToEnumMap);
182  if (psbQuad == PsbQuadNull)
183  edm::LogInfo("L1GtDefinitions") << "\n PsbQuadNull means no valid PSB quadruplet defined!";
184  if (!result) {
185  result = "PsbQuadNull";
186  edm::LogInfo("L1GtDefinitions") << "\n '" << psbQuad
187  << "' is not a recognized L1GtPsbQuad. "
188  << "\n Return PsbQuadNull, which means no valid PSB quadruplet defined!";
189  }
190 
191  return result;
192 }
193 
194 
196  L1GtConditionType value = keyToValue(label.c_str(), l1GtConditionTypeStringToEnumMap);
197 
198  // in case of unrecognized L1GtConditionType, return TypeNull
199  // to be dealt by the corresponding module
200  if (value == (L1GtConditionType) -1) {
201  edm::LogInfo("L1GtDefinitions") << "\n '" << label
202  << "' is not a recognized L1GtConditionType. \n Return TypeNull.";
203 
204  value = TypeNull;
205  }
206 
207  if (value == TypeNull) {
208  edm::LogInfo("L1GtDefinitions")
209  << "\n TypeNull means no valid condition type defined!";
210  }
211 
212  return value;
213 }
214 
216  const char *result = valueToKey(conditionType, l1GtConditionTypeStringToEnumMap);
217  if (conditionType == TypeNull)
218  edm::LogInfo("L1GtDefinitions")
219  << "\n Return TypeNull, which means no valid condition type defined!";
220  if (!result) {
221  result = "TypeNull";
222  edm::LogInfo("L1GtDefinitions") << "\n '" << conditionType
223  << "' is not a recognized L1GtConditionType. "
224  << "\n Return TypeNull, which means no valid condition type defined!";
225  }
226  return result;
227 }
228 
230  L1GtConditionCategory value = keyToValue(label.c_str(), l1GtConditionCategoryStringToEnumMap);
231  // in case of unrecognized L1GtConditionCategory, return CondNull
232  // to be dealt by the corresponding module
233  if (value == (L1GtConditionCategory) -1) {
234  edm::LogInfo("L1GtDefinitions") << "\n '" << label
235  << "' is not a recognized L1GtConditionCategory. \n Return CondNull.";
236 
237  value = CondNull;
238  }
239 
240  if (value == CondNull) {
241  edm::LogInfo("L1GtDefinitions")
242  << "\n CondNull means no valid condition category defined!";
243  }
244 
245  return value;
246 }
247 
249  char const *result = valueToKey(conditionCategory, l1GtConditionCategoryStringToEnumMap);
250  if (conditionCategory == CondNull)
251  edm::LogInfo("L1GtDefinitions")
252  << "\n Return CondNull, which means no valid condition category defined!";
253 
254  if (!result) {
255  result = "CondNull";
256  edm::LogInfo("L1GtDefinitions") << "\n '" << conditionCategory
257  << "' is not a recognized L1GtConditionCategory. "
258  << "\n Return CondNull, which means no valid condition category defined!";
259  }
260 
261  return result;
262 }
std::string l1GtPsbQuadEnumToString(const L1GtPsbQuad &)
std::string l1GtBoardTypeEnumToString(const L1GtBoardType &)
std::string l1GtConditionCategoryEnumToString(const L1GtConditionCategory &)
L1GtConditionType
L1GtPsbQuad
quadruples sent to GT via PSB
L1GtPsbQuad l1GtPsbQuadStringToEnum(const std::string &)
L1GtConditionType l1GtConditionTypeStringToEnum(const std::string &)
L1GtBoardType l1GtBoardTypeStringToEnum(const std::string &)
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
tuple result
Definition: query.py:137
L1GtBoardType
board types in GT
L1GtConditionCategory
condition categories
L1GtConditionCategory l1GtConditionCategoryStringToEnum(const std::string &)
std::string l1GtConditionTypeEnumToString(const L1GtConditionType &)
Definition: DDAxes.h:10
long double T
#define constexpr