CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
34 // forward declarations
35 
36 // constructor
38  m_triggerMenuInterface("NULL"), m_triggerMenuName("NULL"),
39  m_triggerMenuImplementation("NULL"), m_scaleDbKey("NULL") {
40 
41  // empty
42 
43 }
44 
46  const std::string& triggerMenuNameVal,
47  const L1TriggerMap& algorithmMapVal,
48  const L1TriggerMap& algorithmAliasMapVal,
49  const L1TriggerMap& technicalTriggerMapVal,
50  const std::vector<unsigned int>& triggerMaskAlgoTrigVal,
51  const std::vector<unsigned int>& triggerMaskTechTrigVal,
52  const std::vector<std::vector<int> >& prescaleFactorsAlgoTrigVal,
53  const std::vector<std::vector<int> >& prescaleFactorsTechTrigVal)
54  :
55  m_triggerMenuInterface("NULL"),
56  m_triggerMenuName(triggerMenuNameVal),
57  m_triggerMenuImplementation("NULL"),
58  m_scaleDbKey("NULL"),
59  m_algorithmMap(algorithmMapVal),
60  m_algorithmAliasMap(algorithmAliasMapVal),
61  m_technicalTriggerMap(technicalTriggerMapVal),
62  m_triggerMaskAlgoTrig(triggerMaskAlgoTrigVal),
63  m_triggerMaskTechTrig(triggerMaskTechTrigVal),
64  m_prescaleFactorsAlgoTrig(prescaleFactorsAlgoTrigVal),
65  m_prescaleFactorsTechTrig(prescaleFactorsTechTrigVal)
66 
67 
68  {
69 
70  // empty
71 
72 }
73 
74 // copy constructor
76 
81 
82  // copy algorithm map
85 
86  // copy technical triggers
87  // (separate map for technical triggers and physics triggers)
89 
90  // copy masks
93 
94  // copy prescale factors
97 
98 }
99 
100 // destructor
102 {
103 
104  m_algorithmMap.clear();
105  m_algorithmAliasMap.clear();
106  m_technicalTriggerMap.clear();
107 
108 }
109 
110 // assignment operator
112  const L1GtTriggerMenuLite& rhs) {
113 
114  if (this != &rhs) {
115 
120 
123 
125 
128 
131  }
132 
133  // return the object
134  return *this;
135 
136 }
137 
138 // equal operator
140 
142  return false;
143  }
144 
146  return false;
147  }
148 
150  return false;
151  }
152 
153  if (m_scaleDbKey != rhs.m_scaleDbKey) {
154  return false;
155  }
156 
157  if (m_algorithmMap != rhs.m_algorithmMap) {
158  return false;
159  }
160 
162  return false;
163  }
164 
166  return false;
167  }
168 
170  return false;
171  }
172 
174  return false;
175  }
176 
178  return false;
179  }
180 
182  return false;
183  }
184 
185  // all members identical
186  return true;
187 
188 }
189 
190 // unequal operator
192 
193  return !(otherObj == *this);
194 
195 }
196 
197 // merge rule: test on isProductEqual
199 
200  return (otherObj == *this);
201 }
202 
203 
204 // set the trigger menu name
206  const std::string& menuInterface) {
207  m_triggerMenuInterface = menuInterface;
208 }
209 
211  m_triggerMenuName = menuName;
212 }
213 
215  const std::string& menuImplementation) {
216  m_triggerMenuImplementation = menuImplementation;
217 }
218 
219 // set menu associated scale key
221  m_scaleDbKey = scaleKey;
222 }
223 
224 // set the algorithm map (by algorithm names)
226  m_algorithmMap = algoMap;
227 }
228 
229 // set the algorithm map (by algorithm aliases)
231  m_algorithmAliasMap = algoMap;
232 }
233 
234 // set the technical trigger map
236  m_technicalTriggerMap = ttMap;
237 }
238 
239 // set the trigger mask for physics algorithms
241  const std::vector<unsigned int>& maskValue) {
242 
243  m_triggerMaskAlgoTrig = maskValue;
244 
245 }
246 
247 // set the trigger mask for technical triggers
248 void L1GtTriggerMenuLite::setGtTriggerMaskTechTrig(const std::vector<unsigned int>& maskValue)
249 {
250 
251  m_triggerMaskTechTrig = maskValue;
252 
253 }
254 
255 
256 // set the prescale factors
258  const std::vector<std::vector<int> >& factorValue) {
259 
260  m_prescaleFactorsAlgoTrig = factorValue;
261 
262 }
263 
265  const std::vector<std::vector<int> >& factorValue) {
266 
267  m_prescaleFactorsTechTrig = factorValue;
268 
269 }
270 
271 // print the trigger menu
272 void L1GtTriggerMenuLite::print(std::ostream& myCout, int& printVerbosity) const {
273 
274  //
275 
276  switch (printVerbosity) {
277 
278  case 0: {
279 
280  size_t nrDefinedAlgo = m_algorithmMap.size();
281  size_t nrDefinedTech = m_technicalTriggerMap.size();
282 
283  // header for printing algorithms
284 
285  myCout << "\n ********** L1 Trigger Menu - printing ********** \n"
286  << "\nL1 Trigger Menu Interface: " << m_triggerMenuInterface
287  << "\nL1 Trigger Menu Name: " << m_triggerMenuName
288  << "\nL1 Trigger Menu Implementation: " << m_triggerMenuImplementation
289  << "\nAssociated Scale DB Key: " << m_scaleDbKey << "\n\n"
290  << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
291  << "Bit Number "
292  << std::right << std::setw(35) << "Algorithm Name" << " "
293  << std::right << std::setw(35) << "Algorithm Alias" << " "
294  << std::right << std::setw(12) << "Trigger Mask";
295  for (unsigned iSet = 0; iSet < m_prescaleFactorsAlgoTrig.size(); iSet++) {
296  myCout << std::right << std::setw(10) << "PF Set "
297  << std::right << std::setw(2) << iSet;
298  }
299 
300  myCout << std::endl;
301 
302 
303  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
304  != m_algorithmMap.end(); itTrig++) {
305 
306  const unsigned int bitNumber = itTrig->first;
307  const std::string& aName = itTrig->second;
308 
309  std::string aAlias;
310  CItL1Trig itAlias = m_algorithmAliasMap.find(bitNumber);
311  if (itAlias != m_algorithmAliasMap.end()) {
312  aAlias = itAlias->second;
313  }
314 
315  myCout << std::setw(6) << bitNumber << " "
316  << std::right << std::setw(35) << aName << " "
317  << std::right << std::setw(35) << aAlias << " "
318  << std::right << std::setw(12) << m_triggerMaskAlgoTrig[bitNumber];
319  for (unsigned iSet = 0; iSet < m_prescaleFactorsAlgoTrig.size(); iSet++) {
320  myCout << std::right << std::setw(12) << m_prescaleFactorsAlgoTrig[iSet][bitNumber];
321  }
322 
323  myCout << std::endl;
324  }
325 
326  myCout << "\nL1 Technical Triggers: " << nrDefinedTech
327  << " technical triggers defined." << "\n\n" << std::endl;
328  if (nrDefinedTech) {
329  myCout
330  << std::right << std::setw(6) << "Bit Number "
331  << std::right << std::setw(45) << " Technical trigger name " << " "
332  << std::right << std::setw(12) << "Trigger Mask";
333  for (unsigned iSet = 0; iSet < m_prescaleFactorsTechTrig.size(); iSet++) {
334  myCout << std::right << std::setw(10) << "PF Set "
335  << std::right << std::setw(2) << iSet;
336  }
337 
338  myCout << std::endl;
339  }
340 
341  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
342  != m_technicalTriggerMap.end(); itTrig++) {
343 
344  unsigned int bitNumber = itTrig->first;
345  std::string aName = itTrig->second;
346 
347  myCout << std::setw(6) << bitNumber << " "
348  << std::right << std::setw(45) << aName
349  << std::right << std::setw(12) << m_triggerMaskTechTrig[bitNumber];
350  for (unsigned iSet = 0; iSet < m_prescaleFactorsTechTrig.size(); iSet++) {
351  myCout << std::right << std::setw(12) << m_prescaleFactorsTechTrig[iSet][bitNumber];
352  }
353 
354  myCout << std::endl;
355 
356  }
357 
358 
359 
360  }
361  break;
362  default: {
363  myCout << "\n ********** L1 Trigger Menu - printing ********** \n\n"
364  << "Verbosity level: " << printVerbosity << " not implemented.\n\n"
365  << std::endl;
366  }
367  break;
368  }
369 
370 }
371 
372 // output stream operator
373 std::ostream& operator<<(std::ostream& streamRec,
374  const L1GtTriggerMenuLite& result) {
375  int verbosityLevel = 0;
376 
377  result.print(streamRec, verbosityLevel);
378  return streamRec;
379 
380 }
381 
382 // get the alias for a physics algorithm with a given bit number
384  const unsigned int bitNumber, int& errorCode) const {
385 
386  const std::string* gtAlgorithmAlias = 0;
387 
388  for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig
389  != m_algorithmAliasMap.end(); itTrig++) {
390 
391  if (itTrig->first == bitNumber) {
392 
393  gtAlgorithmAlias = &(itTrig->second);
394 
395  errorCode = 0;
396  return gtAlgorithmAlias;
397  }
398  }
399 
400  errorCode = 1;
401  return gtAlgorithmAlias;
402 
403 }
404 
405 // get the name for a physics algorithm or a technical trigger
406 // with a given bit number
408  const unsigned int bitNumber, int& errorCode) const {
409 
410  const std::string* gtAlgorithmName = 0;
411 
412  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
413  != m_algorithmMap.end(); itTrig++) {
414 
415  if (itTrig->first == bitNumber) {
416 
417  gtAlgorithmName = &(itTrig->second);
418 
419  errorCode = 0;
420  return gtAlgorithmName;
421  }
422  }
423 
424  errorCode = 1;
425  return gtAlgorithmName;
426 
427 }
428 
430  const unsigned int bitNumber, int& errorCode) const {
431 
432  const std::string* gtTechTrigName = 0;
433 
434  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
435  != m_technicalTriggerMap.end(); itTrig++) {
436 
437  if (itTrig->first == bitNumber) {
438 
439  gtTechTrigName = &(itTrig->second);
440 
441  errorCode = 0;
442  return gtTechTrigName;
443  }
444  }
445 
446  errorCode = 1;
447  return gtTechTrigName;
448 
449 }
450 
451 // get the bit number for a physics algorithm or a technical trigger
452 // with a given name or alias
454  const std::string& trigName, int& errorCode) const {
455 
456  unsigned int bitNr = 999;
457 
458  //
459  for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig
460  != m_algorithmAliasMap.end(); itTrig++) {
461 
462  if (itTrig->second == trigName) {
463 
464  bitNr = itTrig->first;
465 
466  errorCode = 0;
467  return bitNr;
468  }
469  }
470 
471  //
472  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
473  != m_algorithmMap.end(); itTrig++) {
474 
475  if (itTrig->second == trigName) {
476 
477  bitNr = itTrig->first;
478  errorCode = 0;
479  return bitNr;
480  }
481  }
482 
483  //
484  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
485  != m_technicalTriggerMap.end(); itTrig++) {
486 
487  if (itTrig->second == trigName) {
488 
489  bitNr = itTrig->first;
490  errorCode = 0;
491  return bitNr;
492  }
493  }
494 
495  errorCode = 1;
496  return bitNr;
497 
498 }
499 
500 // get the result for a physics algorithm or a technical trigger with name trigName
501 // use directly the format of decisionWord (no typedef)
503  const std::vector<bool>& decWord, int& errorCode) const {
504 
505  bool trigResult = false;
506 
507  // try first physics algorithm aliases
508 
509  for (CItL1Trig itTrig = m_algorithmAliasMap.begin(); itTrig
510  != m_algorithmAliasMap.end(); itTrig++) {
511 
512  if (itTrig->second == trigName) {
513  unsigned int bitNumber = itTrig->first;
514 
515  if ((bitNumber >= decWord.size())) {
516  trigResult = false;
517  errorCode = 10;
518  } else {
519  trigResult = decWord[bitNumber];
520  errorCode = 0;
521  }
522 
523  return trigResult;
524  }
525  }
526 
527  // ... then physics algorithm names
528 
529  for (CItL1Trig itTrig = m_algorithmMap.begin(); itTrig
530  != m_algorithmMap.end(); itTrig++) {
531 
532  if (itTrig->second == trigName) {
533  unsigned int bitNumber = itTrig->first;
534 
535  if ((bitNumber >= decWord.size())) {
536  trigResult = false;
537  errorCode = 10;
538  } else {
539  trigResult = decWord[bitNumber];
540  errorCode = 0;
541  }
542 
543  return trigResult;
544  }
545  }
546 
547  // ... then technical trigger names
548 
549  for (CItL1Trig itTrig = m_technicalTriggerMap.begin(); itTrig
550  != m_technicalTriggerMap.end(); itTrig++) {
551 
552  if (itTrig->second == trigName) {
553  unsigned int bitNumber = itTrig->first;
554 
555  if ((bitNumber >= decWord.size())) {
556  trigResult = false;
557  errorCode = 10;
558  } else {
559  trigResult = decWord[bitNumber];
560  errorCode = 0;
561  }
562 
563  return trigResult;
564  }
565  }
566 
567  // algorithm or technical trigger not in the menu
568 
569  errorCode = 1;
570  return false;
571 
572 }
573 
void setGtTriggerMenuName(const std::string &)
void setGtPrescaleFactorsAlgoTrig(const std::vector< std::vector< int > > &)
const std::string * gtAlgorithmAlias(const unsigned int bitNumber, int &errorCode) const
get the alias for a physics algorithm with a given bit number
L1TriggerMap m_algorithmMap
map containing the physics algorithms (by name)
const unsigned int gtBitNumber(const std::string &trigName, int &errorCode) const
L1GtTriggerMenuLite()
constructor
std::string m_triggerMenuImplementation
std::string m_scaleDbKey
menu associated scale key
L1TriggerMap m_technicalTriggerMap
map containing the technical triggers
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
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
bool isProductEqual(const L1GtTriggerMenuLite &) const
merge rule: test on isProductEqual
const std::string * gtTechTrigName(const unsigned int bitNumber, int &errorCode) const
std::vector< unsigned int > m_triggerMaskAlgoTrig
trigger mask for physics algorithms
void setGtTriggerMaskAlgoTrig(const std::vector< unsigned int > &)
set the trigger mask for physics algorithms
tuple result
Definition: query.py:137
std::vector< std::vector< int > > m_prescaleFactorsAlgoTrig
prescale factors
const bool gtTriggerResult(const std::string &trigName, const std::vector< bool > &decWord, int &errorCode) const
void print(std::ostream &, int &) const
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 > > &)
void setGtScaleDbKey(const std::string &)
std::string m_triggerMenuInterface
menu names
bool operator==(const L1GtTriggerMenuLite &) const
equal operator
bool operator!=(const L1GtTriggerMenuLite &) const
unequal operator
void setGtAlgorithmMap(const L1TriggerMap &)
std::vector< unsigned int > m_triggerMaskTechTrig
trigger mask for technical triggers
const std::string * gtAlgorithmName(const unsigned int bitNumber, int &errorCode) const
L1GtTriggerMenuLite & operator=(const L1GtTriggerMenuLite &)
assignment operator
void setGtTechnicalTriggerMap(const L1TriggerMap &)
L1TriggerMap m_algorithmAliasMap
map containing the physics algorithms (by alias)