CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TGlobalProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <iostream>
4 #include <iomanip>
5 #include <algorithm>
6 
7 #include <boost/cstdint.hpp>
8 
9 // user include files
11 
12 // Objects to produce for the output record.
15 
20 #include "TriggerMenuParser.h"
21 
27 
30 
33 
36 
39 
41 
42 using namespace l1t;
43 
44 // constructors
45 
48  // These parameters are part of the L1T/HLT interface, avoid changing if possible::
49  desc.add<edm::InputTag> ("GmtInputTag", edm::InputTag(""))->setComment("InputTag for Global Muon Trigger (required parameter: default value is invalid)");
50  desc.add<edm::InputTag> ("CaloInputTag", edm::InputTag(""))->setComment("InputTag for Calo Trigger (required parameter: default value is invalid)");
51  desc.add<edm::InputTag> ("ExtInputTag", edm::InputTag(""))->setComment("InputTag for external conditions (not required, but recommend to specify explicitly in config)");
52  desc.add<bool>("AlgorithmTriggersUnprescaled", false)->setComment("not required, but recommend to specify explicitly in config");
53  desc.add<bool>("AlgorithmTriggersUnmasked", false)->setComment("not required, but recommend to specify explicitly in config");
54  // These parameters have well defined default values and are not currently
55  // part of the L1T/HLT interface. They can be cleaned up or updated at will:
56  desc.add<bool> ("ProduceL1GtDaqRecord",true);
57  desc.add<bool> ("ProduceL1GtObjectMapRecord",true);
58  desc.add<int> ("EmulateBxInEvent",1);
59  desc.add<int> ("L1DataBxInEvent",5);
60  desc.add<unsigned int> ("AlternativeNrBxBoardDaq",0);
61  desc.add<int> ("BstLengthBytes",-1);
62  desc.add<unsigned int> ("PrescaleSet",1);
63  desc.addUntracked<int>("Verbosity",0);
64  desc.add<std::string>("TriggerMenuLuminosity","startup");
65  desc.add<std::string>("PrescaleCSVFile","prescale_L1TGlobal.csv");
66  descriptions.add("L1TGlobalProducer", desc);
67 }
68 
70  m_muInputTag(parSet.getParameter<edm::InputTag> ("GmtInputTag")),
71  m_caloInputTag(parSet.getParameter<edm::InputTag> ("CaloInputTag")),
72  m_extInputTag(parSet.getParameter<edm::InputTag> ("ExtInputTag")),
73  m_produceL1GtDaqRecord(parSet.getParameter<bool> ("ProduceL1GtDaqRecord")),
74  m_produceL1GtObjectMapRecord(parSet.getParameter<bool> ("ProduceL1GtObjectMapRecord")),
75  m_emulateBxInEvent(parSet.getParameter<int> ("EmulateBxInEvent")),
76  m_L1DataBxInEvent(parSet.getParameter<int> ("L1DataBxInEvent")),
77  m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int> ("AlternativeNrBxBoardDaq")),
78  m_psBstLengthBytes(parSet.getParameter<int> ("BstLengthBytes")),
79  m_prescaleSet(parSet.getParameter<unsigned int> ("PrescaleSet")),
80  m_algorithmTriggersUnprescaled(parSet.getParameter<bool> ("AlgorithmTriggersUnprescaled")),
81  m_algorithmTriggersUnmasked(parSet.getParameter<bool> ("AlgorithmTriggersUnmasked")),
82  m_verbosity(parSet.getUntrackedParameter<int>("Verbosity")),
83  m_isDebugEnabled(edm::isDebugEnabled())
84 {
85 
86 
87  m_egInputToken = consumes <BXVector<EGamma> > (m_caloInputTag);
88  m_tauInputToken = consumes <BXVector<Tau> > (m_caloInputTag);
89  m_jetInputToken = consumes <BXVector<Jet> > (m_caloInputTag);
90  m_sumInputToken = consumes <BXVector<EtSum> > (m_caloInputTag);
91 
92  m_muInputToken = consumes <BXVector<Muon> > (m_muInputTag);
93 
94  m_extInputToken = consumes <BXVector<GlobalExtBlk> > (m_extInputTag);
95 
96  if (m_verbosity) {
97 
98  LogDebug("l1t|Global") << std::endl;
99 
100  LogTrace("l1t|Global")
101  << "\nInput tag for muon collection from GMT: " << m_muInputTag
102  << "\nInput tag for calorimeter collections from GCT: " << m_caloInputTag
103  << "\nInput tag for external conditions : " << m_extInputTag
104  << std::endl;
105 
106 
107  LogTrace("l1t|Global")
108  << "\nProduce the L1 GT DAQ readout record: " << m_produceL1GtDaqRecord
109  << "\nProduce the L1 GT Object Map record: " << m_produceL1GtObjectMapRecord
110  << " \n"
111  << "\nWrite Psb content to L1 GT DAQ Record: " << m_writePsbL1GtDaqRecord
112  << " \n"
113  << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent
114  << " \n"
115  << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex
117  << " \n"
118  << "\nLength of BST message [bytes]: " << m_psBstLengthBytes
119  << "\n"
120  << "\nRun algorithm triggers unprescaled: " << m_algorithmTriggersUnprescaled
121  << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked
122  << "\n"
123  << std::endl;
124  }
125 
126 
127  if ( ( m_emulateBxInEvent > 0 ) && ( ( m_emulateBxInEvent % 2 ) == 0 )) {
129 
130  if (m_verbosity) {
131  edm::LogWarning("L1TGlobalProducer")
132  << "\nWARNING: Number of bunch crossing to be emulated rounded to: "
133  << m_emulateBxInEvent << "\n The number must be an odd number!\n"
134  << std::endl;
135  }
136  }
137 
138 
139  if ( ( m_L1DataBxInEvent > 0 ) && ( ( m_L1DataBxInEvent % 2 ) == 0 )) {
141 
142  if (m_verbosity) {
143  edm::LogWarning("L1TGlobalProducer")
144  << "\nWARNING: Number of bunch crossing for incoming L1 Data rounded to: "
145  << m_L1DataBxInEvent << "\n The number must be an odd number!\n"
146  << std::endl;
147  }
148  } else if( m_L1DataBxInEvent<0) {
149  m_L1DataBxInEvent = 1;
150 
151  if (m_verbosity) {
152  edm::LogWarning("L1TGlobalProducer")
153  << "\nWARNING: Number of bunch crossing for incoming L1 Data was changed to: "
154  << m_L1DataBxInEvent << "\n The number must be an odd positive number!\n"
155  << std::endl;
156  }
157  }
158 
159 
160 
161 
162  // register products
164  produces<GlobalAlgBlkBxCollection>();
165  produces<GlobalExtBlkBxCollection>();
166  }
167 
168 
170  produces<L1GlobalTriggerObjectMapRecord>();
171  }
172 
173 
174  // create new uGt Board
175  m_uGtBrd = new GtBoard();
177 
178  // initialize cached IDs
179 
180  //
181  m_l1GtStableParCacheID = 0ULL;
182  m_l1GtMenuCacheID = 0ULL;
183 
186 
187  m_nrL1Mu = 0;
188  m_nrL1EG = 0;
189  m_nrL1Tau = 0;
190 
191  m_nrL1Jet = 0;
192 
193 
194  m_nrL1JetCounts = 0;
195 
198 
199  //
200  m_l1GtParCacheID = 0ULL;
201 
202  m_totalBxInEvent = 0;
203 
205  m_bstLengthBytes = 0;
206 
207  //
208  m_l1GtBMCacheID = 0ULL;
209 
210  //
211  m_l1GtPfAlgoCacheID = 0ULL;
212 
213  m_l1GtTmAlgoCacheID = 0ULL;
214 
216 
217 
218  // directory in /data/Luminosity for the trigger menu
219  std::string menuDir = parSet.getParameter<std::string>("TriggerMenuLuminosity");
220  //std::string menuDir = "startup";
221 
222  // prescale CSV file file
223  std::string prescaleFileName = parSet.getParameter<std::string>("PrescaleCSVFile");
224 
225  // def.xml file
226  //std::string prescaleFileName = "prescale_L1TGlobal.csv";
227 
228  edm::FileInPath f1("L1Trigger/L1TGlobal/data/Luminosity/" +
229  menuDir + "/" + prescaleFileName);
230 
231  m_prescalesFile = f1.fullPath();
232 
233  unsigned int temp_numberPhysTriggers = 512;
234 
235  // Get prescale factors from CSV file for now
236  std::ifstream inputPrescaleFile;
237  inputPrescaleFile.open(m_prescalesFile);
238 
239  std::vector<std::vector<int> > vec;
240  std::vector<std::vector<int> > prescale_vec;
241 
242  std::vector<unsigned int> temp_triggerMask;
243  std::vector<unsigned int> temp_triggerVetoMask;
244 
245  if( inputPrescaleFile ){
246  std::string prefix1("#");
247  std::string prefix2("-1");
248 
249  std::string line;
250 
251  bool first = true;
252 
253  while( getline(inputPrescaleFile,line) ){
254 
255  if( !line.compare(0, prefix1.size(), prefix1) ) continue;
256  //if( !line.compare(0, prefix2.size(), prefix2) ) continue;
257 
258  istringstream split(line);
259  int value;
260  int col = 0;
261  char sep;
262 
263  while( split >> value ){
264  if( first ){
265  // Each new value read on line 1 should create a new inner vector
266  vec.push_back(std::vector<int>());
267  }
268 
269  vec[col].push_back(value);
270  ++col;
271 
272  // read past the separator
273  split>>sep;
274  }
275 
276  // Finished reading line 1 and creating as many inner
277  // vectors as required
278  first = false;
279  }
280 
281 
282  int NumPrescaleSets = 0;
283 
284  int maskColumn = -1;
285  int maskVetoColumn = -1;
286  for( int iCol=0; iCol<int(vec.size()); iCol++ ){
287  if( vec[iCol].size() > 0 ){
288  int firstRow = vec[iCol][0];
289 
290  if( firstRow > 0 ) NumPrescaleSets++;
291  else if( firstRow==-2 ) maskColumn = iCol;
292  else if( firstRow==-3 ) maskVetoColumn = iCol;
293  }
294  }
295 
296  // Fill default values for mask and veto mask
297  for( unsigned int iBit = 0; iBit < temp_numberPhysTriggers; ++iBit ){
298  unsigned int inputDefaultMask = 1;
299  unsigned int inputDefaultVetoMask = 0;
300  temp_triggerMask.push_back(inputDefaultMask);
301  temp_triggerVetoMask.push_back(inputDefaultVetoMask);
302  }
303 
304  // Fill non-trivial mask and veto mask
305  if( maskColumn>=0 || maskVetoColumn>=0 ){
306  for( int iBit=1; iBit<int(vec[0].size()); iBit++ ){
307  unsigned int algoBit = vec[0][iBit];
308  // algoBit must be less than the number of triggers
309  if( algoBit < temp_numberPhysTriggers ){
310  if( maskColumn>=0 ){
311  unsigned int triggerMask = vec[maskColumn][iBit];
312  temp_triggerMask[algoBit] = triggerMask;
313  }
314  if( maskVetoColumn>=0 ){
315  unsigned int triggerVetoMask = vec[maskVetoColumn][iBit];
316  temp_triggerVetoMask[algoBit] = triggerVetoMask;
317  }
318  }
319  }
320  }
321 
322 
323  if( NumPrescaleSets > 0 ){
324  // Fill default prescale set
325  for( int iSet=0; iSet<NumPrescaleSets; iSet++ ){
326  prescale_vec.push_back(std::vector<int>());
327  for( unsigned int iBit = 0; iBit < temp_numberPhysTriggers; ++iBit ){
328  int inputDefaultPrescale = 1;
329  prescale_vec[iSet].push_back(inputDefaultPrescale);
330  }
331  }
332 
333  // Fill non-trivial prescale set
334  for( int iBit=1; iBit<int(vec[0].size()); iBit++ ){
335  unsigned int algoBit = vec[0][iBit];
336  // algoBit must be less than the number of triggers
337  if( algoBit < temp_numberPhysTriggers ){
338  for( int iSet=0; iSet<int(vec.size()); iSet++ ){
339  int useSet = -1;
340  if( vec[iSet].size() > 0 ){
341  useSet = vec[iSet][0];
342  }
343  useSet -= 1;
344 
345  if( useSet<0 ) continue;
346 
347  int prescale = vec[iSet][iBit];
348  prescale_vec[useSet][algoBit] = prescale;
349  }
350  }
351  else{
352  LogTrace("l1t|Global")
353  << "\nPrescale file has algo bit: " << algoBit
354  << "\nThis is larger than the number of triggers: " << m_numberPhysTriggers
355  << "\nSomething is wrong. Ignoring."
356  << std::endl;
357  }
358  }
359  }
360 
361  }
362  else {
363  LogTrace("l1t|Global")
364  << "\nCould not find file: " << m_prescalesFile
365  << "\nFilling the prescale vectors with prescale 1"
366  << "\nSetting prescale set to 1"
367  << std::endl;
368 
369  m_prescaleSet = 1;
370 
371  for( int col=0; col < 1; col++ ){
372  prescale_vec.push_back(std::vector<int>());
373  for( unsigned int iBit = 0; iBit < temp_numberPhysTriggers; ++iBit ){
374  int inputDefaultPrescale = 1;
375  prescale_vec[col].push_back(inputDefaultPrescale);
376  }
377  }
378  }
379 
380  inputPrescaleFile.close();
381 
382  m_initialPrescaleFactorsAlgoTrig = prescale_vec;
383 
384  m_initialTriggerMaskAlgoTrig = temp_triggerMask;
385  m_initialTriggerMaskVetoAlgoTrig = temp_triggerVetoMask;
386 
387 }
388 
389 // destructor
391 {
392 
393  delete m_uGtBrd;
394 
395 }
396 
397 // member functions
398 
399 // method called to produce the data
401 {
402 
403  // get / update the parameters from the EventSetup
404  // local cache & check on cacheIdentifier
405 
406  unsigned long long l1GtParCacheID = evSetup.get<L1GtParametersRcd>().cacheIdentifier();
407 
408  if (m_l1GtParCacheID != l1GtParCacheID) {
409 
411  evSetup.get< L1GtParametersRcd >().get( l1GtPar );
412  m_l1GtPar = l1GtPar.product();
413 
414  // total number of Bx's in the event coming from EventSetup
416 
417  // active boards in L1 GT DAQ record and in L1 GT EVM record
419 
422 
423 
424  m_l1GtParCacheID = l1GtParCacheID;
425 
426  }
427 
428  // negative value: emulate TotalBxInEvent as given in EventSetup
429  if (m_emulateBxInEvent < 0) {
431  }
432 
433  int minEmulBxInEvent = (m_emulateBxInEvent + 1)/2 - m_emulateBxInEvent;
434  int maxEmulBxInEvent = (m_emulateBxInEvent + 1)/2 - 1;
435 
436  int minL1DataBxInEvent = (m_L1DataBxInEvent + 1)/2 - m_L1DataBxInEvent;
437  int maxL1DataBxInEvent = (m_L1DataBxInEvent + 1)/2 - 1;
438 
439  // process event iEvent
440  // get / update the stable parameters from the EventSetup
441  // local cache & check on cacheIdentifier
442 
443  unsigned long long l1GtStableParCacheID =
444  evSetup.get<L1TGlobalStableParametersRcd>().cacheIdentifier();
445 
446  if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
447 
449  evSetup.get< L1TGlobalStableParametersRcd >().get( l1GtStablePar );
450  m_l1GtStablePar = l1GtStablePar.product();
451 
452  // number of physics triggers
454 
455  // number of DAQ partitions
456  m_numberDaqPartitions = 8; // FIXME add it to stable parameters
457 
458  // number of objects of each type
459  m_nrL1Mu = static_cast<int> (m_l1GtStablePar->gtNumberL1Mu());
460  //m_nrL1Mu = static_cast<int> (8);
461 
462 // ***** Doe we need to change the StablePar class for generic. EG
463  m_nrL1EG = static_cast<int> (m_l1GtStablePar->gtNumberL1NoIsoEG());
464  m_nrL1Tau= static_cast<int> (m_l1GtStablePar->gtNumberL1TauJet());
465 
466 
467 // ********* Do we need to change the StablePar class for generic jet?
468  m_nrL1Jet = static_cast<int> (m_l1GtStablePar->gtNumberL1CenJet());
469 
470  m_nrL1JetCounts = static_cast<int> (m_l1GtStablePar->gtNumberL1JetCounts());
471 
472  // ... the rest of the objects are global
473 
476 
477 
478  // Initialize Board
479  m_uGtBrd->init(m_numberPhysTriggers, m_nrL1Mu, m_nrL1EG, m_nrL1Tau, m_nrL1Jet, minL1DataBxInEvent, maxL1DataBxInEvent );
480 
481  //
482  m_l1GtStableParCacheID = l1GtStableParCacheID;
483 
484  }
485 
486 
487  // get / update the trigger menu from the EventSetup
488  // local cache & check on cacheIdentifier
489  unsigned long long l1GtMenuCacheID = evSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
490 
491  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
492 
494  evSetup.get< L1TUtmTriggerMenuRcd>().get(l1GtMenu) ;
495  const L1TUtmTriggerMenu* utml1GtMenu = l1GtMenu.product();
496 
497  // Instantiate Parser
498  TriggerMenuParser gtParser = TriggerMenuParser();
499 
500 
505 
506  //Parse menu into emulator classes
507  gtParser.parseCondFormats(utml1GtMenu);
508 
509  // transfer the condition map and algorithm map from parser to L1uGtTriggerMenu
511  gtParser.vecMuonTemplate(),
512  gtParser.vecCaloTemplate(),
513  gtParser.vecEnergySumTemplate(),
514  gtParser.vecExternalTemplate(),
515  gtParser.vecCorrelationTemplate(),
516  gtParser.corMuonTemplate(),
517  gtParser.corCaloTemplate(),
518  gtParser.corEnergySumTemplate()) ;
519 
520 
521  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtTriggerMenuInterface(gtParser.gtTriggerMenuInterface());
522  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtTriggerMenuImplementation(gtParser.gtTriggerMenuImplementation());
523  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtScaleDbKey(gtParser.gtScaleDbKey());
524  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtScales(gtParser.gtScales());
525 
526  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtAlgorithmMap(gtParser.gtAlgorithmMap());
527  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtAlgorithmAliasMap(gtParser.gtAlgorithmAliasMap());
528 
529  (const_cast<TriggerMenu*>(m_l1GtMenu))->buildGtConditionMap();
530 
531  m_l1GtMenuCacheID = l1GtMenuCacheID;
532  }
533 
534 
535 
536 
537 
538  // get / update the board maps from the EventSetup
539  // local cache & check on cacheIdentifier
540 
541 /* *** Drop L1GtBoard Maps for now
542  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
543 
544  unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
545 */
546 
547 /* ** Drop board mapping for now
548  if (m_l1GtBMCacheID != l1GtBMCacheID) {
549 
550  edm::ESHandle< L1GtBoardMaps > l1GtBM;
551  evSetup.get< L1GtBoardMapsRcd >().get( l1GtBM );
552  m_l1GtBM = l1GtBM.product();
553 
554  m_l1GtBMCacheID = l1GtBMCacheID;
555 
556  }
557 
558 
559  // TODO need changes in CondFormats to cache the maps
560  const std::vector<L1GtBoard>& boardMaps = m_l1GtBM->gtBoardMaps();
561 */
562  // get / update the prescale factors from the EventSetup
563  // local cache & check on cacheIdentifier
564 
565 
566 /* **** For Now Leave out Prescale Factors ****
567  unsigned long long l1GtPfAlgoCacheID =
568  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
569 
570  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
571 
572  edm::ESHandle< L1GtPrescaleFactors > l1GtPfAlgo;
573  evSetup.get< L1GtPrescaleFactorsAlgoTrigRcd >().get( l1GtPfAlgo );
574  m_l1GtPfAlgo = l1GtPfAlgo.product();
575 
576  m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
577 
578  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
579 
580  }
581 */
582 
583 
584  // Set Prescale factors to initial
588 
589 
590  // // Used for testing
591  // for( int iL1Set=0; iL1Set<int(m_prescaleFactorsAlgoTrig->size()); iL1Set++ ){
592  // if( m_prescaleFactorsAlgoTrig->size()>0 ){
593  // const std::vector<int>& testPrescaleSet = (*m_prescaleFactorsAlgoTrig).at(iL1Set);
594 
595  // printf(" iL1Set=%4d", iL1Set);
596  // for( int iPrescale=0; iPrescale<int(testPrescaleSet.size()); iPrescale++ ){
597  // printf(", %2d", testPrescaleSet[iPrescale]);
598  // }
599  // printf("\n");
600  // }
601  // }
602 
603 
604  // get / update the trigger mask from the EventSetup
605  // local cache & check on cacheIdentifier
606 
607 
608 /* **** For now Leave out Masks *****
609  unsigned long long l1GtTmAlgoCacheID =
610  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
611 
612  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
613 
614  edm::ESHandle< L1GtTriggerMask > l1GtTmAlgo;
615  evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
616  m_l1GtTmAlgo = l1GtTmAlgo.product();
617 
618  m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
619 
620  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
621 
622  }
623 */
624 
625 
626 
627 /* **** For now Leave out Veto Masks *****
628  unsigned long long l1GtTmVetoAlgoCacheID =
629  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
630 
631  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
632 
633  edm::ESHandle< L1GtTriggerMask > l1GtTmVetoAlgo;
634  evSetup.get< L1GtTriggerMaskVetoAlgoTrigRcd >().get( l1GtTmVetoAlgo );
635  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
636 
637  m_triggerMaskVetoAlgoTrig = m_l1GtTmVetoAlgo->gtTriggerMask();
638 
639  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
640 
641  }
642 */
643 
644 
645 
646 // ****** Board Maps Need to be redone....hard code for now ******
647  // loop over blocks in the GT DAQ record receiving data, count them if they are active
648  // all board type are defined in CondFormats/L1TObjects/L1GtFwd
649  // enum L1GtBoardType { GTFE, FDL, PSB, GMT, TCS, TIM };
650  // &
651  // set the active flag for each object type received from GMT and GCT
652  // all objects in the GT system are defined in enum L1GtObject from
653  // DataFormats/L1Trigger/GtProducerReadoutSetupFwd
654 
655  //
656  bool receiveMu = true;
657  bool receiveEG = true;
658  bool receiveTau = true;
659  bool receiveJet = true;
660  bool receiveEtSums = true;
661  bool receiveExt = true;
662 
663 /* *** Boards need redefining *****
664  for (CItBoardMaps
665  itBoard = boardMaps.begin();
666  itBoard != boardMaps.end(); ++itBoard) {
667 
668  int iPosition = itBoard->gtPositionDaqRecord();
669  if (iPosition > 0) {
670 
671  int iActiveBit = itBoard->gtBitDaqActiveBoards();
672  bool activeBoard = false;
673 
674  if (iActiveBit >= 0) {
675  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
676  }
677 
678  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
679  // in the record and ActiveBoardsMap, and active
680  if ((iActiveBit < 0) || activeBoard) {
681 
682 // ****** Decide what board manipulation (if any we want here)
683 
684  }
685  }
686 
687  }
688 */
689 
690 
691 
692 /* *** No Output Record for Now
693  // produce the GtProducerReadoutRecord now, after we found how many
694  // BxInEvent the record has and how many boards are active
695  std::auto_ptr<GtProducerReadoutRecord> gtDaqReadoutRecord(
696  new GtProducerReadoutRecord(
697  m_emulateBxInEvent, daqNrFdlBoards, daqNrPsbBoards) );
698 
699 */
700 
701  // Produce the Output Records for the GT
702  std::auto_ptr<GlobalAlgBlkBxCollection> uGtAlgRecord( new GlobalAlgBlkBxCollection(0,minEmulBxInEvent,maxEmulBxInEvent));
703  std::auto_ptr<GlobalExtBlkBxCollection> uGtExtRecord( new GlobalExtBlkBxCollection(0,minEmulBxInEvent,maxEmulBxInEvent));
704 
705  // * produce the L1GlobalTriggerObjectMapRecord
706  std::auto_ptr<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord(
708 
709 
710  // fill the boards not depending on the BxInEvent in the L1 GT DAQ record
711  // GMT, PSB and FDL depend on BxInEvent
712 
713  // fill in emulator the same bunch crossing (12 bits - hardwired number of bits...)
714  // and the same local bunch crossing for all boards
715  int bxCross = iEvent.bunchCrossing();
716  boost::uint16_t bxCrossHw = 0;
717  if ((bxCross & 0xFFF) == bxCross) {
718  bxCrossHw = static_cast<boost::uint16_t> (bxCross);
719  }
720  else {
721  bxCrossHw = 0; // Bx number too large, set to 0!
722  if (m_verbosity) {
723 
724  LogDebug("l1t|Global")
725  << "\nBunch cross number [hex] = " << std::hex << bxCross
726  << "\n larger than 12 bits. Set to 0! \n" << std::dec
727  << std::endl;
728  }
729  }
730  LogDebug("l1t|Global") << "HW BxCross " << bxCrossHw << std::endl;
731 
732 /* ** No Record for Now
733  if (m_produceL1GtDaqRecord) {
734 
735  for (CItBoardMaps
736  itBoard = boardMaps.begin();
737  itBoard != boardMaps.end(); ++itBoard) {
738 
739  int iPosition = itBoard->gtPositionDaqRecord();
740  if (iPosition > 0) {
741 
742  int iActiveBit = itBoard->gtBitDaqActiveBoards();
743  bool activeBoard = false;
744 
745  if (iActiveBit >= 0) {
746  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
747  }
748 
749  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
750  // in the record and ActiveBoardsMap, and active
751  if ((iActiveBit < 0) || activeBoard) {
752 
753  switch (itBoard->gtBoardType()) {
754 
755  case GTFE: {
756  L1GtfeWord gtfeWordValue;
757 
758  gtfeWordValue.setBoardId( itBoard->gtBoardId() );
759 
760  // cast int to boost::uint16_t
761  // there are normally 3 or 5 BxInEvent
762  gtfeWordValue.setRecordLength(
763  static_cast<boost::uint16_t>(recordLength0));
764 
765  gtfeWordValue.setRecordLength1(
766  static_cast<boost::uint16_t>(recordLength1));
767 
768  // bunch crossing
769  gtfeWordValue.setBxNr(bxCrossHw);
770 
771  // set the list of active boards
772  gtfeWordValue.setActiveBoards(m_activeBoardsGtDaq);
773 
774  // set alternative for number of BX per board
775  gtfeWordValue.setAltNrBxBoard(
776  static_cast<boost::uint16_t> (m_alternativeNrBxBoardDaq));
777 
778  // set the TOTAL_TRIGNR as read from iEvent
779  // TODO check again - PTC stuff
780 
781  gtfeWordValue.setTotalTriggerNr(
782  static_cast<boost::uint32_t>(iEvent.id().event()));
783 
784  // ** fill L1GtfeWord in GT DAQ record
785 
786  gtDaqReadoutRecord->setGtfeWord(gtfeWordValue);
787  }
788 
789  break;
790  case TCS: {
791  // nothing
792  }
793 
794  break;
795  case TIM: {
796  // nothing
797  }
798 
799  break;
800  default: {
801  // do nothing, all blocks are given in GtBoardType enum
802  }
803 
804  break;
805  }
806  }
807  }
808 
809  }
810 
811  }
812 */
813 
814 
815  // get the prescale factor from the configuration for now
816  // Prescale set indexed by zero internally, but externally indexed by 1
817  unsigned int pfAlgoSetIndex = m_prescaleSet-1;
818 
819  // Require that prescale set be positive
820  if( m_prescaleSet<=0 ) pfAlgoSetIndex = 0;
821 
822  if( pfAlgoSetIndex > (*m_prescaleFactorsAlgoTrig).size()-1 ){
823  LogTrace("l1t|Global")
824  << "\nAttempting to access prescale algo set: " << m_prescaleSet
825  << "\nNumber of prescale algo sets available: " << (*m_prescaleFactorsAlgoTrig).size()
826  << "Setting former to latter."
827  << std::endl;
828 
829  pfAlgoSetIndex = (*m_prescaleFactorsAlgoTrig).size()-1;
830  }
831 
832  const std::vector<int>& prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
833 
834  const std::vector<unsigned int>& triggerMaskAlgoTrig = *m_triggerMaskAlgoTrig;
835  const std::vector<unsigned int>& triggerMaskVetoAlgoTrig = *m_triggerMaskVetoAlgoTrig;
836 
837  LogDebug("l1t|Global") << "Size of prescale vector" << prescaleFactorsAlgoTrig.size() << std::endl;
838 
839 
840 // Load the calorimeter input onto the uGt Board
846  receiveEG, m_nrL1EG,
847  receiveTau, m_nrL1Tau,
848  receiveJet, m_nrL1Jet,
849  receiveEtSums );
850 
852  receiveMu, m_nrL1Mu );
853 
855  receiveExt );
856 
857 
858  // loop over BxInEvent
859  for (int iBxInEvent = minEmulBxInEvent; iBxInEvent <= maxEmulBxInEvent;
860  ++iBxInEvent) {
861 
862  // run GTL
863  LogDebug("l1t|Global")
864  << "\nGtProducer : running GTL for bx = " << iBxInEvent << "\n"
865  << std::endl;
866 
867 
868 // Run the GTL for this BX
869  m_uGtBrd->runGTL(iEvent, evSetup, m_l1GtMenu,
870  m_produceL1GtObjectMapRecord, iBxInEvent, gtObjectMapRecord,
872  m_nrL1Mu,
873  m_nrL1EG,
874  m_nrL1Tau,
875  m_nrL1Jet,
876  m_nrL1JetCounts );
877 
878 
879  // run FDL
880  LogDebug("l1t|Global")
881  << "\nGtProducer : running FDL for bx = " << iBxInEvent << "\n"
882  << std::endl;
883 
884 
885 // Run the Final Decision Logic for this BX
886  m_uGtBrd->runFDL(iEvent,
887  iBxInEvent,
890  prescaleFactorsAlgoTrig,
891  triggerMaskAlgoTrig,
892  triggerMaskVetoAlgoTrig,
895  );
896 
897 
898 
899 // Fill in the DAQ Records
901 
902  // These need to be defined elsewhere
903  cms_uint64_t orbNr = iEvent.orbitNumber();
904  int abBx = iEvent.bunchCrossing();
905  m_uGtBrd->fillAlgRecord(iBxInEvent, uGtAlgRecord, orbNr, abBx);
906  m_uGtBrd->fillExtRecord(iBxInEvent, uGtExtRecord, orbNr, abBx);
907  }
908 
909 
910 
911  } //End Loop over Bx
912 
913 
914  // Add explicit reset of Board
915  m_uGtBrd->reset();
916 
917 
918 
919  if ( m_verbosity && m_isDebugEnabled ) {
920 
921  std::ostringstream myCoutStream;
922 
923  for(int bx=minEmulBxInEvent; bx<maxEmulBxInEvent; bx++) {
924 
926  (uGtAlgRecord->at(bx,0)).print(myCoutStream);
927  (uGtExtRecord->at(bx,0)).print(myCoutStream);
928 
929  }
930 
931  LogTrace("l1t|Global")
932  << "\n The following L1 GT DAQ readout record was produced:\n"
933  << myCoutStream.str() << "\n"
934  << std::endl;
935 
936  myCoutStream.str("");
937  myCoutStream.clear();
938 /*
939  const std::vector<L1GlobalTriggerObjectMap> objMapVec =
940  gtObjectMapRecord->gtObjectMap();
941 
942  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator
943  it = objMapVec.begin(); it != objMapVec.end(); ++it) {
944 
945  (*it).print(myCoutStream);
946 
947  }
948 
949 
950  LogDebug("l1t|Global")
951  << "Test gtObjectMapRecord in L1TGlobalProducer \n\n" << myCoutStream.str() << "\n\n"
952  << std::endl;
953 
954  myCoutStream.str("");
955  myCoutStream.clear();
956 */
957  }
958 
959 
960 
961 
962  // register products
964  iEvent.put( uGtAlgRecord );
965  iEvent.put( uGtExtRecord );
966  }
967 
968 
970  iEvent.put( gtObjectMapRecord );
971  }
972 
973 
974 }
975 
976 //define this as a plug-in
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
Definition: GlobalExtBlk.h:30
unsigned int gtPinsOnConditionChip() const
get / set the number of pins on the GTL condition chips
unsigned int m_numberDaqPartitions
number of DAQ partitions
unsigned long long m_l1GtParCacheID
void setVerbosity(const int verbosity)
Definition: GtBoard.h:217
unsigned int gtIfCaloEtaNumberBits() const
get / set the number of bits for eta of calorimeter objects
unsigned long long m_l1GtTmVetoAlgoCacheID
const std::vector< std::vector< EnergySumTemplate > > & vecEnergySumTemplate() const
void setGtOrderConditionChip(const std::vector< int > &)
const std::vector< unsigned int > * m_triggerMaskAlgoTrig
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
int m_verbosity
verbosity level
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
unsigned int gtNumberL1NoIsoEG() const
get / set the number of L1 e/gamma objects received by GT
const boost::uint16_t gtDaqActiveBoards() const
get / set the active boards for L1 GT DAQ record
std::string m_prescalesFile
CSV file for prescales.
const GlobalStableParameters * m_l1GtStablePar
cached stuff
const int gtTotalBxInEvent() const
get / set the total Bx&#39;s in the event
edm::EDGetTokenT< BXVector< l1t::Tau > > m_tauInputToken
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int m_psBstLengthBytes
length of BST record (in bytes) from parameter set
void receiveExternalData(edm::Event &, const edm::EDGetTokenT< BXVector< GlobalExtBlk > > &, const bool receiveExt)
Definition: GtBoard.cc:394
bool m_produceL1GtObjectMapRecord
logical flag to produce the L1 GT object map record
int m_totalBxInEvent
total number of Bx&#39;s in the event coming from EventSetup
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
unsigned int gtNumberL1Mu() const
get / set the number of L1 muons received by GT
const unsigned int gtBstLengthBytes() const
get / set length of BST message (in bytes) for L1 GT EVM record
int bunchCrossing() const
Definition: EventBase.h:65
const std::vector< std::vector< ExternalTemplate > > & vecExternalTemplate() const
unsigned int m_numberPhysTriggers
number of physics triggers
edm::EDGetTokenT< BXVector< GlobalExtBlk > > m_extInputToken
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
Definition: GlobalAlgBlk.h:31
unsigned long long m_l1GtTmAlgoCacheID
const TriggerMenu * m_l1GtMenu
std::vector< unsigned int > m_initialTriggerMaskAlgoTrig
unsigned int m_alternativeNrBxBoardDaq
const L1TGlobalScales & gtScales() const
menu associated scales
unsigned int gtNumberL1CenJet() const
get / set the number of L1 central jets received by GT
const std::string & gtTriggerMenuImplementation() const
edm::InputTag m_muInputTag
input tag for muon collection from GMT
edm::InputTag m_extInputTag
input tag for external conditions
int iEvent
Definition: GenABIO.cc:230
void setGtPinsOnConditionChip(const unsigned int &)
unsigned long long m_l1GtMenuCacheID
bool m_writePsbL1GtDaqRecord
logical flag to write the PSB content in the L1 GT DAQ record
void parseCondFormats(const L1TUtmTriggerMenu *utmMenu)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< std::vector< int > > m_initialPrescaleFactorsAlgoTrig
void receiveCaloObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::EGamma >> &, const edm::EDGetTokenT< BXVector< l1t::Tau >> &, const edm::EDGetTokenT< BXVector< l1t::Jet >> &, const edm::EDGetTokenT< BXVector< l1t::EtSum >> &, const bool receiveEG, const int nrL1EG, const bool receiveTau, const int nrL1Tau, const bool receiveJet, const int nrL1Jet, const bool receiveEtSums)
receive data from Global Muon Trigger
Definition: GtBoard.cc:167
const std::string & gtTriggerMenuName() const
unsigned int gtNumberL1TauJet() const
get / set the number of L1 tau jets received by GT
boost::uint16_t m_activeBoardsGtDaq
active boards in L1 GT DAQ record
const std::vector< std::vector< CaloTemplate > > & corCaloTemplate() const
bool m_produceL1GtDaqRecord
logical flag to produce the L1 GT DAQ readout record
unsigned int gtIfMuEtaNumberBits() const
get / set the number of bits for eta of muon objects
unsigned long long m_l1GtStableParCacheID
edm::EDGetTokenT< BXVector< l1t::Muon > > m_muInputToken
int orbitNumber() const
Definition: EventBase.h:66
const std::vector< std::vector< MuonTemplate > > & corMuonTemplate() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const std::vector< std::vector< MuonTemplate > > & vecMuonTemplate() const
get / set the vectors containing the conditions
const std::vector< std::vector< EnergySumTemplate > > & corEnergySumTemplate() const
#define LogTrace(id)
virtual void produce(edm::Event &, const edm::EventSetup &)
l1t::GtBoard * m_uGtBrd
unsigned int gtNumberPhysTriggers() const
get / set the number of physics trigger algorithms
unsigned int m_prescaleSet
prescale set used
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::vector< std::vector< CorrelationTemplate > > & vecCorrelationTemplate() const
void reset()
clear uGT
Definition: GtBoard.cc:1082
edm::InputTag m_caloInputTag
input tag for calorimeter collections from GCT
void receiveMuonObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::Muon > > &, const bool receiveMu, const int nrL1Mu)
Definition: GtBoard.cc:341
edm::EDGetTokenT< BXVector< l1t::EtSum > > m_sumInputToken
int m_L1DataBxInEvent
Bx expected in Data coming to GT.
L1TGlobalProducer(const edm::ParameterSet &)
unsigned int gtNumberConditionChips() const
hardware stuff
unsigned long long m_l1GtBMCacheID
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
void setGtNumberConditionChips(const unsigned int &)
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void add(std::string const &label, ParameterSetDescription const &psetDescription)
unsigned int gtNumberL1JetCounts() const
get / set the number of L1 jet counts received by GT
void init(const int numberPhysTriggers, const int nrL1Mu, const int nrL1EG, const int nrL1Tau, const int nrL1Jet, int bxFirst, int bxLast)
initialize the class (mainly reserve)
Definition: GtBoard.cc:133
std::vector< unsigned int > m_initialTriggerMaskVetoAlgoTrig
void runFDL(edm::Event &iEvent, const int iBxInEvent, const int totalBxInEvent, const unsigned int numberPhysTriggers, const std::vector< int > &prescaleFactorsAlgoTrig, const std::vector< unsigned int > &triggerMaskAlgoTrig, const std::vector< unsigned int > &triggerMaskVetoAlgoTrig, const bool algorithmTriggersUnprescaled, const bool algorithmTriggersUnmasked)
run the uGT FDL (Apply Prescales and Veto)
Definition: GtBoard.cc:896
unsigned int m_bstLengthBytes
length of BST record (in bytes) from event setup
void fillExtRecord(int iBxInEvent, std::auto_ptr< GlobalExtBlkBxCollection > &uGtExtRecord, cms_uint64_t orbNr, int bxNr)
Definition: GtBoard.cc:1060
const L1GtParameters * m_l1GtPar
parameters
const std::vector< int > & gtOrderConditionChip() const
const std::vector< std::vector< CaloTemplate > > & vecCaloTemplate() const
void fillAlgRecord(int iBxInEvent, std::auto_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, cms_uint64_t orbNr, int bxNr)
Fill the Daq Records.
Definition: GtBoard.cc:1030
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
unsigned long long m_l1GtPfAlgoCacheID
const std::string & gtTriggerMenuInterface() const
get / set the trigger menu names
unsigned long long cms_uint64_t
Definition: typedefs.h:17
int col
Definition: cuy.py:1008
void runGTL(edm::Event &iEvent, const edm::EventSetup &evSetup, const TriggerMenu *m_l1GtMenu, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::auto_ptr< L1GlobalTriggerObjectMapRecord > &gtObjectMapRecord, const unsigned int numberPhysTriggers, const int nrL1Mu, const int nrL1EG, const int nrL1Tau, const int nrL1Jet, const int nrL1JetCounts)
run the uGT GTL (Conditions and Algorithms)
Definition: GtBoard.cc:442
const std::string & gtScaleDbKey() const
menu associated scale key
double split
Definition: MVATrainer.cc:139
tuple size
Write out results.
const std::vector< unsigned int > * m_triggerMaskVetoAlgoTrig
edm::EDGetTokenT< BXVector< l1t::Jet > > m_jetInputToken
edm::EDGetTokenT< BXVector< l1t::EGamma > > m_egInputToken
void setGtNumberPhysTriggers(const unsigned int &)