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