CMS 3D CMS Logo

L1GtTriggerMenuLite.cc
Go to the documentation of this file.
1 
24 // this class header
26 
27 // system include files
28 #include <iostream>
29 #include <iomanip>
30 
31 // user include files
32 
33 // forward declarations
34 
35 // constructor
37  : m_triggerMenuInterface("NULL"),
38  m_triggerMenuName("NULL"),
39  m_triggerMenuImplementation("NULL"),
40  m_scaleDbKey("NULL") {
41  // empty
42 }
43 
45  const L1TriggerMap& algorithmMapVal,
46  const L1TriggerMap& algorithmAliasMapVal,
47  const L1TriggerMap& technicalTriggerMapVal,
48  const std::vector<unsigned int>& triggerMaskAlgoTrigVal,
49  const std::vector<unsigned int>& triggerMaskTechTrigVal,
50  const std::vector<std::vector<int> >& prescaleFactorsAlgoTrigVal,
51  const std::vector<std::vector<int> >& prescaleFactorsTechTrigVal)
52  : m_triggerMenuInterface("NULL"),
53  m_triggerMenuName(triggerMenuNameVal),
54  m_triggerMenuImplementation("NULL"),
55  m_scaleDbKey("NULL"),
56  m_algorithmMap(algorithmMapVal),
57  m_algorithmAliasMap(algorithmAliasMapVal),
58  m_technicalTriggerMap(technicalTriggerMapVal),
59  m_triggerMaskAlgoTrig(triggerMaskAlgoTrigVal),
60  m_triggerMaskTechTrig(triggerMaskTechTrigVal),
61  m_prescaleFactorsAlgoTrig(prescaleFactorsAlgoTrigVal),
62  m_prescaleFactorsTechTrig(prescaleFactorsTechTrigVal)
63 
64 {
65  // empty
66 }
67 
68 // copy constructor
74 
75  // copy algorithm map
78 
79  // copy technical triggers
80  // (separate map for technical triggers and physics triggers)
82 
83  // copy masks
86 
87  // copy prescale factors
90 }
91 
92 // destructor
94  m_algorithmMap.clear();
95  m_algorithmAliasMap.clear();
96  m_technicalTriggerMap.clear();
97 }
98 
99 // assignment operator
101  if (this != &rhs) {
106 
109 
111 
114 
117  }
118 
119  // return the object
120  return *this;
121 }
122 
123 // equal operator
126  return false;
127  }
128 
130  return false;
131  }
132 
134  return false;
135  }
136 
137  if (m_scaleDbKey != rhs.m_scaleDbKey) {
138  return false;
139  }
140 
141  if (m_algorithmMap != rhs.m_algorithmMap) {
142  return false;
143  }
144 
146  return false;
147  }
148 
150  return false;
151  }
152 
154  return false;
155  }
156 
158  return false;
159  }
160 
162  return false;
163  }
164 
166  return false;
167  }
168 
169  // all members identical
170  return true;
171 }
172 
173 // unequal operator
174 bool L1GtTriggerMenuLite::operator!=(const L1GtTriggerMenuLite& otherObj) const { return !(otherObj == *this); }
175 
176 // merge rule: test on isProductEqual
178 
179 // set the trigger menu name
181  m_triggerMenuInterface = menuInterface;
182 }
183 
185 
187  m_triggerMenuImplementation = menuImplementation;
188 }
189 
190 // set menu associated scale key
191 void L1GtTriggerMenuLite::setGtScaleDbKey(const std::string& scaleKey) { m_scaleDbKey = scaleKey; }
192 
193 // set the algorithm map (by algorithm names)
195 
196 // set the algorithm map (by algorithm aliases)
198 
199 // set the technical trigger map
201 
202 // set the trigger mask for physics algorithms
203 void L1GtTriggerMenuLite::setGtTriggerMaskAlgoTrig(const std::vector<unsigned int>& maskValue) {
204  m_triggerMaskAlgoTrig = maskValue;
205 }
206 
207 // set the trigger mask for technical triggers
208 void L1GtTriggerMenuLite::setGtTriggerMaskTechTrig(const std::vector<unsigned int>& maskValue) {
209  m_triggerMaskTechTrig = maskValue;
210 }
211 
212 // set the prescale factors
213 void L1GtTriggerMenuLite::setGtPrescaleFactorsAlgoTrig(const std::vector<std::vector<int> >& factorValue) {
214  m_prescaleFactorsAlgoTrig = factorValue;
215 }
216 
217 void L1GtTriggerMenuLite::setGtPrescaleFactorsTechTrig(const std::vector<std::vector<int> >& factorValue) {
218  m_prescaleFactorsTechTrig = factorValue;
219 }
220 
221 // print the trigger menu
222 void L1GtTriggerMenuLite::print(std::ostream& myCout, int& printVerbosity) const {
223  //
224 
225  switch (printVerbosity) {
226  case 0: {
227  size_t nrDefinedAlgo = m_algorithmMap.size();
228  size_t nrDefinedTech = m_technicalTriggerMap.size();
229 
230  // header for printing algorithms
231 
232  myCout << "\n ********** L1 Trigger Menu - printing ********** \n"
233  << "\nL1 Trigger Menu Interface: " << m_triggerMenuInterface
234  << "\nL1 Trigger Menu Name: " << m_triggerMenuName
235  << "\nL1 Trigger Menu Implementation: " << m_triggerMenuImplementation
236  << "\nAssociated Scale DB Key: " << m_scaleDbKey << "\n\n"
237  << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined."
238  << "\n\n"
239  << "Bit Number " << std::right << std::setw(35) << "Algorithm Name"
240  << " " << std::right << std::setw(35) << "Algorithm Alias"
241  << " " << std::right << std::setw(12) << "Trigger Mask";
242  for (unsigned iSet = 0; iSet < m_prescaleFactorsAlgoTrig.size(); iSet++) {
243  myCout << std::right << std::setw(10) << "PF Set " << std::right << std::setw(2) << iSet;
244  }
245 
246  myCout << std::endl;
247 
248  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig != m_algorithmMap.end(); itTrig++) {
249  const unsigned int bitNumber = itTrig->first;
250  const std::string& aName = itTrig->second;
251 
252  std::string aAlias;
253  CItL1Trig itAlias = m_algorithmAliasMap.find(bitNumber);
254  if (itAlias != m_algorithmAliasMap.end()) {
255  aAlias = itAlias->second;
256  }
257 
258  myCout << std::setw(6) << bitNumber << " " << std::right << std::setw(35) << aName << " " << std::right
259  << std::setw(35) << aAlias << " " << std::right << std::setw(12) << m_triggerMaskAlgoTrig[bitNumber];
260  for (unsigned iSet = 0; iSet < m_prescaleFactorsAlgoTrig.size(); iSet++) {
261  myCout << std::right << std::setw(12) << m_prescaleFactorsAlgoTrig[iSet][bitNumber];
262  }
263 
264  myCout << std::endl;
265  }
266 
267  myCout << "\nL1 Technical Triggers: " << nrDefinedTech << " technical triggers defined."
268  << "\n\n"
269  << std::endl;
270  if (nrDefinedTech) {
271  myCout << std::right << std::setw(6) << "Bit Number " << std::right << std::setw(45)
272  << " Technical trigger name "
273  << " " << std::right << std::setw(12) << "Trigger Mask";
274  for (unsigned iSet = 0; iSet < m_prescaleFactorsTechTrig.size(); iSet++) {
275  myCout << std::right << std::setw(10) << "PF Set " << std::right << std::setw(2) << iSet;
276  }
277 
278  myCout << std::endl;
279  }
280 
281  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig != m_technicalTriggerMap.end(); itTrig++) {
282  unsigned int bitNumber = itTrig->first;
283  std::string aName = itTrig->second;
284 
285  myCout << std::setw(6) << bitNumber << " " << std::right << std::setw(45) << aName << std::right
286  << std::setw(12) << m_triggerMaskTechTrig[bitNumber];
287  for (unsigned iSet = 0; iSet < m_prescaleFactorsTechTrig.size(); iSet++) {
288  myCout << std::right << std::setw(12) << m_prescaleFactorsTechTrig[iSet][bitNumber];
289  }
290 
291  myCout << std::endl;
292  }
293 
294  } break;
295  default: {
296  myCout << "\n ********** L1 Trigger Menu - printing ********** \n\n"
297  << "Verbosity level: " << printVerbosity << " not implemented.\n\n"
298  << std::endl;
299  } break;
300  }
301 }
302 
303 // output stream operator
304 std::ostream& operator<<(std::ostream& streamRec, const L1GtTriggerMenuLite& result) {
305  int verbosityLevel = 0;
306 
307  result.print(streamRec, verbosityLevel);
308  return streamRec;
309 }
310 
311 // get the alias for a physics algorithm with a given bit number
312 const std::string* L1GtTriggerMenuLite::gtAlgorithmAlias(const unsigned int bitNumber, int& errorCode) const {
313  const std::string* gtAlgorithmAlias = nullptr;
314 
315  for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig != m_algorithmAliasMap.end(); itTrig++) {
316  if (itTrig->first == bitNumber) {
317  gtAlgorithmAlias = &(itTrig->second);
318 
319  errorCode = 0;
320  return gtAlgorithmAlias;
321  }
322  }
323 
324  errorCode = 1;
325  return gtAlgorithmAlias;
326 }
327 
328 // get the name for a physics algorithm or a technical trigger
329 // with a given bit number
330 const std::string* L1GtTriggerMenuLite::gtAlgorithmName(const unsigned int bitNumber, int& errorCode) const {
331  const std::string* gtAlgorithmName = nullptr;
332 
333  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig != m_algorithmMap.end(); itTrig++) {
334  if (itTrig->first == bitNumber) {
335  gtAlgorithmName = &(itTrig->second);
336 
337  errorCode = 0;
338  return gtAlgorithmName;
339  }
340  }
341 
342  errorCode = 1;
343  return gtAlgorithmName;
344 }
345 
346 const std::string* L1GtTriggerMenuLite::gtTechTrigName(const unsigned int bitNumber, int& errorCode) const {
347  const std::string* gtTechTrigName = nullptr;
348 
349  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig != m_technicalTriggerMap.end(); itTrig++) {
350  if (itTrig->first == bitNumber) {
351  gtTechTrigName = &(itTrig->second);
352 
353  errorCode = 0;
354  return gtTechTrigName;
355  }
356  }
357 
358  errorCode = 1;
359  return gtTechTrigName;
360 }
361 
362 // get the bit number for a physics algorithm or a technical trigger
363 // with a given name or alias
364 const unsigned int L1GtTriggerMenuLite::gtBitNumber(const std::string& trigName, int& errorCode) const {
365  unsigned int bitNr = 999;
366 
367  //
368  for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig != m_algorithmAliasMap.end(); itTrig++) {
369  if (itTrig->second == trigName) {
370  bitNr = itTrig->first;
371 
372  errorCode = 0;
373  return bitNr;
374  }
375  }
376 
377  //
378  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig != m_algorithmMap.end(); itTrig++) {
379  if (itTrig->second == trigName) {
380  bitNr = itTrig->first;
381  errorCode = 0;
382  return bitNr;
383  }
384  }
385 
386  //
387  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig != m_technicalTriggerMap.end(); itTrig++) {
388  if (itTrig->second == trigName) {
389  bitNr = itTrig->first;
390  errorCode = 0;
391  return bitNr;
392  }
393  }
394 
395  errorCode = 1;
396  return bitNr;
397 }
398 
399 // get the result for a physics algorithm or a technical trigger with name trigName
400 // use directly the format of decisionWord (no typedef)
402  const std::vector<bool>& decWord,
403  int& errorCode) const {
404  bool trigResult = false;
405 
406  // try first physics algorithm aliases
407 
408  for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig != m_algorithmAliasMap.end(); itTrig++) {
409  if (itTrig->second == trigName) {
410  unsigned int bitNumber = itTrig->first;
411 
412  if ((bitNumber >= decWord.size())) {
413  trigResult = false;
414  errorCode = 10;
415  } else {
416  trigResult = decWord[bitNumber];
417  errorCode = 0;
418  }
419 
420  return trigResult;
421  }
422  }
423 
424  // ... then physics algorithm names
425 
426  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig != m_algorithmMap.end(); itTrig++) {
427  if (itTrig->second == trigName) {
428  unsigned int bitNumber = itTrig->first;
429 
430  if ((bitNumber >= decWord.size())) {
431  trigResult = false;
432  errorCode = 10;
433  } else {
434  trigResult = decWord[bitNumber];
435  errorCode = 0;
436  }
437 
438  return trigResult;
439  }
440  }
441 
442  // ... then technical trigger names
443 
444  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig != m_technicalTriggerMap.end(); itTrig++) {
445  if (itTrig->second == trigName) {
446  unsigned int bitNumber = itTrig->first;
447 
448  if ((bitNumber >= decWord.size())) {
449  trigResult = false;
450  errorCode = 10;
451  } else {
452  trigResult = decWord[bitNumber];
453  errorCode = 0;
454  }
455 
456  return trigResult;
457  }
458  }
459 
460  // algorithm or technical trigger not in the menu
461 
462  errorCode = 1;
463  return false;
464 }
void setGtTriggerMenuName(const std::string &)
void setGtPrescaleFactorsAlgoTrig(const std::vector< std::vector< int > > &)
L1TriggerMap m_algorithmMap
map containing the physics algorithms (by name)
bool operator!=(const L1GtTriggerMenuLite &) const
unequal operator
L1GtTriggerMenuLite()
constructor
std::string m_triggerMenuImplementation
void print(std::ostream &, int &) const
std::string m_scaleDbKey
menu associated scale key
bool operator==(const L1GtTriggerMenuLite &) const
equal operator
L1TriggerMap m_technicalTriggerMap
map containing the technical triggers
bool isProductEqual(const L1GtTriggerMenuLite &) const
merge rule: test on isProductEqual
void setGtTriggerMenuInterface(const std::string &)
void setGtTriggerMaskTechTrig(const std::vector< unsigned int > &)
set the trigger mask for technical triggers
std::map< unsigned int, std::string > L1TriggerMap
map containing the physics algorithms or the technical triggers
verbosityLevel
L1 selection andOrL1 = cms.bool( True ), l1Algorithms = cms.vstring("L1_ZeroBias_FirstCollidingBunch"...
std::vector< unsigned int > m_triggerMaskAlgoTrig
trigger mask for physics algorithms
const std::string * gtAlgorithmAlias(const unsigned int bitNumber, int &errorCode) const
get the alias for a physics algorithm with a given bit number
const bool gtTriggerResult(const std::string &trigName, const std::vector< bool > &decWord, int &errorCode) const
void setGtTriggerMaskAlgoTrig(const std::vector< unsigned int > &)
set the trigger mask for physics algorithms
std::vector< std::vector< int > > m_prescaleFactorsAlgoTrig
prescale factors
void setGtAlgorithmAliasMap(const L1TriggerMap &)
L1TriggerMap::const_iterator CItL1Trig
iterators through map containing the physics algorithms or the technical triggers ...
std::vector< std::vector< int > > m_prescaleFactorsTechTrig
void setGtTriggerMenuImplementation(const std::string &)
void setGtPrescaleFactorsTechTrig(const std::vector< std::vector< int > > &)
const std::string * gtTechTrigName(const unsigned int bitNumber, int &errorCode) const
void setGtScaleDbKey(const std::string &)
const std::string * gtAlgorithmName(const unsigned int bitNumber, int &errorCode) const
std::string m_triggerMenuInterface
menu names
const unsigned int gtBitNumber(const std::string &trigName, int &errorCode) const
void setGtAlgorithmMap(const L1TriggerMap &)
std::vector< unsigned int > m_triggerMaskTechTrig
trigger mask for technical triggers
L1GtTriggerMenuLite & operator=(const L1GtTriggerMenuLite &)
assignment operator
void setGtTechnicalTriggerMap(const L1TriggerMap &)
L1TriggerMap m_algorithmAliasMap
map containing the physics algorithms (by alias)
std::ostream & operator<<(std::ostream &streamRec, const L1GtTriggerMenuLite &result)