CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerMenu.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iostream>
22 #include <iomanip>
23 
24 // user include files
27 
28 
29 // forward declarations
30 
31 // constructor
33  : m_triggerMenuInterface( "NULL" ),
34  m_triggerMenuName( "NULL" ),
35  m_triggerMenuImplementation( "NULL" ),
36  m_scaleDbKey( "NULL" )
37 {
38  // empty
39 }
40 
42  const std::string& triggerMenuNameVal,
43  const unsigned int numberConditionChips,
44  const std::vector<std::vector<MuonTemplate> >& vecMuonTemplateVal,
45  const std::vector<std::vector<CaloTemplate> >& vecCaloTemplateVal,
46  const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTemplateVal,
47  const std::vector<std::vector<ExternalTemplate> >& vecExternalTemplateVal,
48  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTemplateVal,
49  const std::vector<std::vector<MuonTemplate> >& corMuonTemplateVal,
50  const std::vector<std::vector<CaloTemplate> >& corCaloTemplateVal,
51  const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTemplateVal
52 
53 ) :
54  m_triggerMenuInterface( "NULL" ),
55  m_triggerMenuName(triggerMenuNameVal),
56  m_triggerMenuImplementation( "NULL" ),
57  m_scaleDbKey( "NULL" ),
58  m_vecMuonTemplate(vecMuonTemplateVal),
59  m_vecCaloTemplate(vecCaloTemplateVal),
60  m_vecEnergySumTemplate(vecEnergySumTemplateVal),
61  m_vecExternalTemplate(vecExternalTemplateVal),
62  m_vecCorrelationTemplate(vecCorrelationTemplateVal),
63  m_corMuonTemplate(corMuonTemplateVal),
64  m_corCaloTemplate(corCaloTemplateVal),
65  m_corEnergySumTemplate(corEnergySumTemplateVal)
66 {
67 
68  m_conditionMap.resize(numberConditionChips);
70 
71 }
72 
73 // copy constructor
75 {
76 
81 
82  // copy physics conditions
87 
92 
93  // rebuild condition map to update the pointers
94  // (only physics conditions are included in it)
95  m_conditionMap.resize(rhs.m_conditionMap.size());
96  (*this).buildGtConditionMap();
97 
98  // copy algorithm map
101 
102  // copy technical triggers
103  // (separate map for technical triggers and physics triggers)
104  //m_technicalTriggerMap = rhs.m_technicalTriggerMap;
105 
106 }
107 
108 // destructor
110 {
111 
112  // loop over condition maps (one map per condition chip)
113  for (std::vector<l1t::ConditionMap>::iterator
114  itCondOnChip = m_conditionMap.begin(); itCondOnChip != m_conditionMap.end(); itCondOnChip++) {
115 
116  itCondOnChip->clear();
117 
118  }
119 
120  m_algorithmMap.clear();
121  m_algorithmAliasMap.clear();
122 }
123 
124 // assignment operator
126 
127  if ( this != &rhs ) {
128 
132 
137 
142 
145 
146 // m_technicalTriggerMap = rhs.m_technicalTriggerMap;
147 
148  }
149 
150  // rebuild condition map to update the pointers
151  // (only physics conditions are included in it)
152  m_conditionMap.resize(rhs.m_conditionMap.size());
153  (*this).buildGtConditionMap();
154 
155  // return the object
156  return *this;
157 
158 }
159 
160 // set the condition maps
161 void TriggerMenu::setGtConditionMap(const std::vector<l1t::ConditionMap>& condMap) {
162  m_conditionMap = condMap;
163 }
164 
165 // build the condition maps
167 
168  // clear the conditions from the maps, if any
169  for (std::vector<l1t::ConditionMap>::iterator itCondOnChip =
170  m_conditionMap.begin(); itCondOnChip != m_conditionMap.end(); itCondOnChip++) {
171 
172  itCondOnChip->clear();
173 
174  }
175 
176  // always check that the size of the condition map is greater than the size
177  // of the specific condition vector
178  size_t condMapSize = m_conditionMap.size();
179 
180  //
181  size_t vecMuonSize = m_vecMuonTemplate.size();
182  if (condMapSize < vecMuonSize) {
183  m_conditionMap.resize(vecMuonSize);
184  condMapSize = m_conditionMap.size();
185  }
186 
187  int chipNr = -1;
188 
189  for (std::vector<std::vector<MuonTemplate> >::iterator
190  itCondOnChip = m_vecMuonTemplate.begin();
191  itCondOnChip != m_vecMuonTemplate.end();
192  itCondOnChip++) {
193 
194  chipNr++;
195 
196  for (std::vector<MuonTemplate>::iterator
197  itCond = itCondOnChip->begin(); itCond != itCondOnChip->end();
198  itCond++) {
199 
200  (m_conditionMap.at(chipNr))[itCond->condName()] = &(*itCond);
201  }
202  }
203 
204  //
205  size_t vecCaloSize = m_vecCaloTemplate.size();
206  if (condMapSize < vecCaloSize) {
207  m_conditionMap.resize(vecCaloSize);
208  condMapSize = m_conditionMap.size();
209  }
210 
211  chipNr = -1;
212  for (std::vector<std::vector<CaloTemplate> >::iterator
213  itCondOnChip = m_vecCaloTemplate.begin();
214  itCondOnChip != m_vecCaloTemplate.end();
215  itCondOnChip++) {
216 
217  chipNr++;
218 
219  for (std::vector<CaloTemplate>::iterator
220  itCond = itCondOnChip->begin(); itCond != itCondOnChip->end();
221  itCond++) {
222 
223  (m_conditionMap.at(chipNr))[itCond->condName()] = &(*itCond);
224  }
225  }
226 
227 
228  //
229  size_t vecEnergySumSize = m_vecEnergySumTemplate.size();
230  if (condMapSize < vecEnergySumSize) {
231  m_conditionMap.resize(vecEnergySumSize);
232  condMapSize = m_conditionMap.size();
233  }
234 
235  chipNr = -1;
236  for (std::vector<std::vector<EnergySumTemplate> >::iterator
237  itCondOnChip = m_vecEnergySumTemplate.begin();
238  itCondOnChip != m_vecEnergySumTemplate.end();
239  itCondOnChip++) {
240 
241  chipNr++;
242 
243  for (std::vector<EnergySumTemplate>::iterator
244  itCond = itCondOnChip->begin(); itCond != itCondOnChip->end();
245  itCond++) {
246 
247  (m_conditionMap.at(chipNr))[itCond->condName()] = &(*itCond);
248  }
249  }
250 
252  //
253  //
254  size_t vecExternalSize = m_vecExternalTemplate.size();
255  if (condMapSize < vecExternalSize) {
256  m_conditionMap.resize(vecExternalSize);
257  condMapSize = m_conditionMap.size();
258  }
259 
260  chipNr = -1;
261  for (std::vector<std::vector<ExternalTemplate> >::iterator
262  itCondOnChip = m_vecExternalTemplate.begin();
263  itCondOnChip != m_vecExternalTemplate.end();
264  itCondOnChip++) {
265 
266  chipNr++;
267 
268  for (std::vector<ExternalTemplate>::iterator
269  itCond = itCondOnChip->begin(); itCond != itCondOnChip->end();
270  itCond++) {
271 
272  (m_conditionMap.at(chipNr))[itCond->condName()] = &(*itCond);
273  }
274  }
275 
276 
277  //
278  size_t vecCorrelationSize = m_vecCorrelationTemplate.size();
279  if (condMapSize < vecCorrelationSize) {
280  m_conditionMap.resize(vecCorrelationSize);
281  condMapSize = m_conditionMap.size();
282  }
283 
284  chipNr = -1;
285  for (std::vector<std::vector<CorrelationTemplate> >::iterator
286  itCondOnChip = m_vecCorrelationTemplate.begin();
287  itCondOnChip != m_vecCorrelationTemplate.end();
288  itCondOnChip++) {
289 
290  chipNr++;
291 
292  for (std::vector<CorrelationTemplate>::iterator
293  itCond = itCondOnChip->begin(); itCond != itCondOnChip->end();
294  itCond++) {
295 
296  (m_conditionMap.at(chipNr))[itCond->condName()] = &(*itCond);
297  }
298  }
299 
300 
301 
302 
303 }
304 
305 // set the trigger menu name
307  m_triggerMenuInterface = menuInterface;
308 }
309 
311  m_triggerMenuName = menuName;
312 }
313 
315  m_triggerMenuImplementation = menuImplementation;
316 }
317 
318 // set menu associated scale key
320  m_scaleDbKey = scaleKey;
321 }
322 
323 // set menu associated scale key
325  m_gtScales = scales;
326 }
327 
328 // get / set the vectors containing the conditions
330  const std::vector<std::vector<MuonTemplate> >& vecMuonTempl) {
331 
332  m_vecMuonTemplate = vecMuonTempl;
333 }
334 
336  const std::vector<std::vector<CaloTemplate> >& vecCaloTempl) {
337 
338  m_vecCaloTemplate = vecCaloTempl;
339 }
340 
342  const std::vector<std::vector<EnergySumTemplate> >& vecEnergySumTempl) {
343 
344  m_vecEnergySumTemplate = vecEnergySumTempl;
345 }
346 
347 
349  const std::vector<std::vector<ExternalTemplate> >& vecExternalTempl) {
350 
351  m_vecExternalTemplate = vecExternalTempl;
352 }
353 
354 
356  const std::vector<std::vector<CorrelationTemplate> >& vecCorrelationTempl) {
357 
358  m_vecCorrelationTemplate = vecCorrelationTempl;
359 }
360 
361 // set the vectors containing the conditions for correlation templates
363  const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
364 
365  m_corMuonTemplate = corMuonTempl;
366 }
367 
369  const std::vector<std::vector<CaloTemplate> >& corCaloTempl) {
370 
371  m_corCaloTemplate = corCaloTempl;
372 }
373 
375  const std::vector<std::vector<EnergySumTemplate> >& corEnergySumTempl) {
376 
377  m_corEnergySumTemplate = corEnergySumTempl;
378 }
379 
380 
381 
382 // set the algorithm map (by algorithm names)
384  m_algorithmMap = algoMap;
385 }
386 
387 // set the algorithm map (by algorithm aliases)
389  m_algorithmAliasMap = algoMap;
390 }
391 
392 /*
393 // set the technical trigger map
394 void TriggerMenu::setGtTechnicalTriggerMap(const l1t::AlgorithmMap& ttMap) {
395  m_technicalTriggerMap = ttMap;
396 }
397 */
398 
399 // print the trigger menu (bit number, algorithm name, logical expression)
400 void TriggerMenu::print(std::ostream& myCout, int& printVerbosity) const {
401 
402  // use another map <int, L1GtAlgorithm> to get the menu sorted after bit number
403  // both algorithm and bit numbers are unique
404  std::map<int, const L1GtAlgorithm*> algoBitToAlgo;
405  typedef std::map<int, const L1GtAlgorithm*>::const_iterator CItBit;
406 
407  for (l1t::CItAlgo itAlgo = m_algorithmMap.begin(); itAlgo != m_algorithmMap.end(); itAlgo++) {
408 
409  int bitNumber = (itAlgo->second).algoBitNumber();
410  algoBitToAlgo[bitNumber] = &(itAlgo->second);
411  }
412 
413  size_t nrDefinedAlgo = algoBitToAlgo.size();
414 
415 /*
416  // idem for technical trigger map - only name and bit number are relevant for them
417  std::map<int, const L1GtAlgorithm*> ttBitToTt;
418 
419  for (l1t::CItAlgo itAlgo = m_technicalTriggerMap.begin(); itAlgo
420  != m_technicalTriggerMap.end(); itAlgo++) {
421 
422  int bitNumber = (itAlgo->second).algoBitNumber();
423  ttBitToTt[bitNumber] = &(itAlgo->second);
424  }
425 
426  size_t nrDefinedTechTrig = ttBitToTt.size();
427 */
428  //
429 
430  switch (printVerbosity) {
431 
432  case 0: {
433 
434  // header for printing algorithms
435 
436  myCout << "\n ********** L1 Trigger Menu - printing ********** \n"
437  << "\nL1 Trigger Menu Interface: " << m_triggerMenuInterface
438  << "\nL1 Trigger Menu Name: " << m_triggerMenuName
439  << "\nL1 Trigger Menu Implementation: " << m_triggerMenuImplementation
440  << "\nAssociated Scale DB Key: " << m_scaleDbKey << "\n\n"
441  << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
442  << "Bit Number "
443  << std::right << std::setw(35) << "Algorithm Name" << " "
444  << std::right << std::setw(35) << "Algorithm Alias"
445  << std::endl;
446 
447  for (CItBit itBit = algoBitToAlgo.begin(); itBit != algoBitToAlgo.end(); itBit++) {
448 
449  int bitNumber = itBit->first;
450  std::string aName = (itBit->second)->algoName();
451  std::string aAlias = (itBit->second)->algoAlias();
452 
453  myCout << std::setw(6) << bitNumber << " "
454  << std::right << std::setw(35) << aName << " "
455  << std::right << std::setw(35) << aAlias
456  << std::endl;
457  }
458 /*
459  myCout
460  << "\nL1 Technical Triggers: " << nrDefinedTechTrig
461  << " technical triggers defined." << "\n\n" << std::endl;
462  if (nrDefinedTechTrig) {
463  myCout << "Bit Number " << " Technical trigger name " << std::endl;
464  }
465 
466  for (CItBit itBit = ttBitToTt.begin(); itBit != ttBitToTt.end(); itBit++) {
467 
468  int bitNumber = itBit->first;
469  std::string aName = (itBit->second)->algoName();
470  std::string aAlias = (itBit->second)->algoAlias();
471 
472  myCout << std::setw(6) << bitNumber << " "
473  << std::right << std::setw(35) << aName << " "
474  << std::right << std::setw(35) << aAlias
475  << std::endl;
476  }
477 */
478  }
479  break;
480 
481  case 1: {
482 
483  // header for printing algorithms
484 
485  myCout << "\n ********** L1 Trigger Menu - printing ********** \n"
486  << "\nL1 Trigger Menu Interface: " << m_triggerMenuInterface
487  << "\nL1 Trigger Menu Name: " << m_triggerMenuName
488  << "\nL1 Trigger Menu Implementation: " << m_triggerMenuImplementation
489  << "\nAssociated Scale DB Key: " << m_scaleDbKey << "\n\n"
490  << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
491  << "Bit Number "
492  << std::right << std::setw(35) << "Algorithm Name" << " "
493  << std::right << std::setw(35) << "Algorithm Alias"
494  << "\n Logical Expression \n"
495  << std::endl;
496 
497  for (CItBit itBit = algoBitToAlgo.begin(); itBit != algoBitToAlgo.end(); itBit++) {
498 
499  int bitNumber = itBit->first;
500  std::string aName = (itBit->second)->algoName();
501  std::string aAlias = (itBit->second)->algoAlias();
502  std::string aLogicalExpression = (itBit->second)->algoLogicalExpression();
503 
504  myCout << std::setw(6) << bitNumber << " "
505  << std::right << std::setw(35) << aName << " "
506  << std::right << std::setw(35) << aAlias
507  << "\n Logical expression: " << aLogicalExpression << "\n"
508  << std::endl;
509  }
510 /*
511  myCout
512  << "\nL1 Technical Triggers: " << nrDefinedTechTrig
513  << " technical triggers defined." << "\n\n" << std::endl;
514  if (nrDefinedTechTrig) {
515  myCout << "Bit Number " << " Technical trigger name " << std::endl;
516  }
517 
518  for (CItBit itBit = ttBitToTt.begin(); itBit != ttBitToTt.end(); itBit++) {
519 
520  int bitNumber = itBit->first;
521  std::string aName = (itBit->second)->algoName();
522 
523  myCout << std::setw(6) << bitNumber << " " << aName << std::endl;
524  }
525 */
526  }
527  break;
528 
529  case 2: {
530 
531  // header for printing algorithms
532 
533  myCout << "\n ********** L1 Trigger Menu - printing ********** \n"
534  << "\nL1 Trigger Menu Interface: " << m_triggerMenuInterface
535  << "\nL1 Trigger Menu Name: " << m_triggerMenuName
536  << "\nL1 Trigger Menu Implementation: " << m_triggerMenuImplementation
537  << "\nAssociated Scale DB Key: " << m_scaleDbKey << "\n\n"
538  << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
539  << std::endl;
540 
541  for (CItBit itBit = algoBitToAlgo.begin(); itBit != algoBitToAlgo.end(); itBit++) {
542  (itBit->second)->print(myCout);
543  }
544 
545 
546  myCout << "\nNumber of condition chips: " << m_conditionMap.size() << "\n"
547  << std::endl;
548 
549  int chipNr = -1;
550  int totalNrConditions = 0;
551 
552  for (std::vector<l1t::ConditionMap>::const_iterator
553  itCondOnChip = m_conditionMap.begin();
554  itCondOnChip != m_conditionMap.end(); itCondOnChip++) {
555 
556  chipNr++;
557 
558  int condMapSize = itCondOnChip->size();
559  totalNrConditions += condMapSize;
560 
561  myCout << "\nTotal number of conditions on condition chip " << chipNr
562  << ": " << condMapSize
563  << " conditions.\n" << std::endl;
564 
565  for (l1t::CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end();
566  itCond++) {
567 
568  (itCond->second)->print(myCout);
569 
570  }
571 
572  }
573 
574  myCout << "\nTotal number of conditions on all condition chips: "
575  << totalNrConditions << "\n"
576  << std::endl;
577 /*
578  myCout
579  << "\nL1 Technical Triggers: " << nrDefinedTechTrig
580  << " technical triggers defined." << "\n\n" << std::endl;
581  if (nrDefinedTechTrig) {
582  myCout << "Bit Number " << " Technical trigger name " << std::endl;
583  }
584 
585  for (CItBit itBit = ttBitToTt.begin(); itBit != ttBitToTt.end(); itBit++) {
586 
587  int bitNumber = itBit->first;
588  std::string aName = (itBit->second)->algoName();
589 
590  myCout << std::setw(6) << bitNumber << " " << aName << std::endl;
591  }
592 */
593 
594  }
595  break;
596 
597  default: {
598  myCout << "\n ********** L1 Trigger Menu - printing ********** \n\n"
599  << "Verbosity level: " << printVerbosity << " not implemented.\n\n"
600  << std::endl;
601  }
602  break;
603  }
604 
605 }
606 
607 // get the result for algorithm with name algName
608 // use directly the format of decisionWord (no typedef)
609 const bool TriggerMenu::gtAlgorithmResult(const std::string& algName,
610  const std::vector<bool>& decWord) const {
611 
612  bool algResult = false;
613 
614  l1t::CItAlgo itAlgo = m_algorithmMap.find(algName);
615  if (itAlgo != m_algorithmMap.end()) {
616  int bitNumber = (itAlgo->second).algoBitNumber();
617  algResult = decWord.at(bitNumber);
618  return algResult;
619  }
620 
621  // return false if the algorithm name is not found in the menu
622  // TODO throw exception or LogInfo would be better - but the class is used in
623  // XDAQ Trigger Supervisor (outside CMSSW) hence no CMSSW dependence
624  // is allowed here...
625 
626  return false;
627 
628 }
629 
630 
std::string m_triggerMenuName
Definition: TriggerMenu.h:231
void setCorCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
Definition: TriggerMenu.cc:368
void setVecExternalTemplate(const std::vector< std::vector< ExternalTemplate > > &)
Definition: TriggerMenu.cc:348
std::string m_triggerMenuImplementation
Definition: TriggerMenu.h:232
void setCorMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
Definition: TriggerMenu.cc:362
void setGtTriggerMenuImplementation(const std::string &)
Definition: TriggerMenu.cc:314
void setGtAlgorithmMap(const l1t::AlgorithmMap &)
Definition: TriggerMenu.cc:383
std::string m_scaleDbKey
menu associated scale key
Definition: TriggerMenu.h:235
std::vector< std::vector< MuonTemplate > > m_vecMuonTemplate
Definition: TriggerMenu.h:239
std::vector< std::vector< ExternalTemplate > > m_vecExternalTemplate
Definition: TriggerMenu.h:243
std::vector< std::vector< MuonTemplate > > m_corMuonTemplate
Definition: TriggerMenu.h:246
std::vector< std::vector< CaloTemplate > > m_corCaloTemplate
Definition: TriggerMenu.h:247
virtual ~TriggerMenu()
Definition: TriggerMenu.cc:109
void setGtScaleDbKey(const std::string &)
Definition: TriggerMenu.cc:319
void setGtScales(const l1t::L1TGlobalScales &)
Definition: TriggerMenu.cc:324
ConditionMap::const_iterator CItCond
iterators through map containing the conditions
void buildGtConditionMap()
Definition: TriggerMenu.cc:166
std::vector< std::vector< EnergySumTemplate > > m_vecEnergySumTemplate
Definition: TriggerMenu.h:241
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void setVecEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
Definition: TriggerMenu.cc:341
l1t::AlgorithmMap m_algorithmMap
map containing the physics algorithms (by name)
Definition: TriggerMenu.h:251
l1t::L1TGlobalScales m_gtScales
map containing the technical triggers
Definition: TriggerMenu.h:260
void setVecMuonTemplate(const std::vector< std::vector< MuonTemplate > > &)
Definition: TriggerMenu.cc:329
void setCorEnergySumTemplate(const std::vector< std::vector< EnergySumTemplate > > &)
Definition: TriggerMenu.cc:374
void print(std::ostream &, int &) const
Definition: TriggerMenu.cc:400
void setGtConditionMap(const std::vector< l1t::ConditionMap > &)
Definition: TriggerMenu.cc:161
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
void setGtTriggerMenuName(const std::string &)
Definition: TriggerMenu.cc:310
TriggerMenu & operator=(const TriggerMenu &)
Definition: TriggerMenu.cc:125
void setVecCorrelationTemplate(const std::vector< std::vector< CorrelationTemplate > > &)
Definition: TriggerMenu.cc:355
std::vector< l1t::ConditionMap > m_conditionMap
map containing the conditions (per condition chip) - transient
Definition: TriggerMenu.h:225
void setGtAlgorithmAliasMap(const l1t::AlgorithmMap &)
Definition: TriggerMenu.cc:388
l1t::AlgorithmMap m_algorithmAliasMap
map containing the physics algorithms (by alias)
Definition: TriggerMenu.h:254
void setVecCaloTemplate(const std::vector< std::vector< CaloTemplate > > &)
Definition: TriggerMenu.cc:335
const bool gtAlgorithmResult(const std::string &algName, const std::vector< bool > &decWord) const
Definition: TriggerMenu.cc:609
void setGtTriggerMenuInterface(const std::string &)
Definition: TriggerMenu.cc:306
std::string m_triggerMenuInterface
menu names
Definition: TriggerMenu.h:230
std::vector< std::vector< EnergySumTemplate > > m_corEnergySumTemplate
Definition: TriggerMenu.h:248
std::vector< std::vector< CorrelationTemplate > > m_vecCorrelationTemplate
Definition: TriggerMenu.h:245
std::vector< std::vector< CaloTemplate > > m_vecCaloTemplate
Definition: TriggerMenu.h:240