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