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