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 // L1TGlobalProducer.cc
2 //author: Brian Winer - Ohio State
3 
5 
6 // system include files
7 #include <memory>
8 #include <iostream>
9 #include <iomanip>
10 #include <algorithm>
11 
12 #include <boost/cstdint.hpp>
13 
24 
29 
31 
35 
37 
38 #include "TriggerMenuParser.h"
39 
40 using namespace l1t;
41 
44  // These parameters are part of the L1T/HLT interface, avoid changing if possible::
45  desc.add<edm::InputTag> ("MuonInputTag", edm::InputTag(""))->setComment("InputTag for Global Muon Trigger (required parameter: default value is invalid)");
46  desc.add<edm::InputTag> ("EGammaInputTag", edm::InputTag(""))->setComment("InputTag for Calo Trigger EGamma (required parameter: default value is invalid)");
47  desc.add<edm::InputTag> ("TauInputTag", edm::InputTag(""))->setComment("InputTag for Calo Trigger Tau (required parameter: default value is invalid)");
48  desc.add<edm::InputTag> ("JetInputTag", edm::InputTag(""))->setComment("InputTag for Calo Trigger Jet (required parameter: default value is invalid)");
49  desc.add<edm::InputTag> ("EtSumInputTag", edm::InputTag(""))->setComment("InputTag for Calo Trigger EtSum (required parameter: default value is invalid)");
50  desc.add<edm::InputTag> ("ExtInputTag", edm::InputTag(""))->setComment("InputTag for external conditions (not required, but recommend to specify explicitly in config)");
51  desc.add<bool> ("AlgorithmTriggersUnprescaled", false)->setComment("not required, but recommend to specify explicitly in config");
52  desc.add<bool> ("AlgorithmTriggersUnmasked", false)->setComment("not required, but recommend to specify explicitly in config");
53  // These parameters have well defined default values and are not currently
54  // part of the L1T/HLT interface. They can be cleaned up or updated at will:
55  desc.add<bool> ("ProduceL1GtDaqRecord",true);
56  desc.add<bool> ("ProduceL1GtObjectMapRecord",true);
57  desc.add<int> ("EmulateBxInEvent",1);
58  desc.add<int> ("L1DataBxInEvent",5);
59  desc.add<unsigned int> ("AlternativeNrBxBoardDaq",0);
60  desc.add<int> ("BstLengthBytes",-1);
61  desc.add<unsigned int> ("PrescaleSet",1);
62  desc.addUntracked<int>("Verbosity",0);
63  desc.add<std::string>("TriggerMenuLuminosity","startup");
64  desc.add<std::string>("PrescaleCSVFile","prescale_L1TGlobal.csv");
65  descriptions.add("L1TGlobalProducer", desc);
66 }
67 
68 
69 
70 // constructors
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 
80  m_produceL1GtDaqRecord(parSet.getParameter<bool> ("ProduceL1GtDaqRecord")),
81  m_produceL1GtObjectMapRecord(parSet.getParameter<bool> ("ProduceL1GtObjectMapRecord")),
82 
83  m_emulateBxInEvent(parSet.getParameter<int> ("EmulateBxInEvent")),
84  m_L1DataBxInEvent(parSet.getParameter<int> ("L1DataBxInEvent")),
85 
86  m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int> ("AlternativeNrBxBoardDaq")),
87  m_psBstLengthBytes(parSet.getParameter<int> ("BstLengthBytes")),
88 
89  m_prescaleSet(parSet.getParameter<unsigned int> ("PrescaleSet")),
90 
91  m_algorithmTriggersUnprescaled(parSet.getParameter<bool> ("AlgorithmTriggersUnprescaled")),
92  m_algorithmTriggersUnmasked(parSet.getParameter<bool> ("AlgorithmTriggersUnmasked")),
93 
94  m_verbosity(parSet.getUntrackedParameter<int>("Verbosity")),
95  m_isDebugEnabled(edm::isDebugEnabled())
96 {
97 
98  m_egInputToken = consumes <BXVector<EGamma> > (m_egInputTag);
99  m_tauInputToken = consumes <BXVector<Tau> > (m_tauInputTag);
100  m_jetInputToken = consumes <BXVector<Jet> > (m_jetInputTag);
101  m_sumInputToken = consumes <BXVector<EtSum> > (m_sumInputTag);
102  m_muInputToken = consumes <BXVector<Muon> > (m_muInputTag);
103  m_extInputToken = consumes <BXVector<GlobalExtBlk> > (m_extInputTag);
104 
105  if (m_verbosity) {
106 
107 
108  LogTrace("L1TGlobalProducer")
109  << "\nInput tag for muon collection from uGMT: " << m_muInputTag
110  << "\nInput tag for calorimeter jet collections from Cal: " << m_jetInputTag
111  << "\nInput tag for external conditions : " << m_extInputTag
112  << std::endl;
113 
114 
115  LogTrace("L1TGlobalProducer")
116  << "\nProduce the L1 uGT DAQ readout record: " << m_produceL1GtDaqRecord
117  << "\nProduce the L1 uGT Object Map record: " << m_produceL1GtObjectMapRecord
118  << " \n"
119  << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent
120  << " \n"
121  << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex
123  << " \n"
124  << "\nRun algorithm triggers unprescaled: " << m_algorithmTriggersUnprescaled
125  << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked
126  << "\n"
127  << std::endl;
128  }
129 
130 
131  if ( ( m_emulateBxInEvent > 0 ) && ( ( m_emulateBxInEvent % 2 ) == 0 )) {
133 
134  if (m_verbosity) {
135  edm::LogWarning("L1TGlobalProducer")
136  << "\nWARNING: Number of bunch crossing to be emulated rounded to: "
137  << m_emulateBxInEvent << "\n The number must be an odd number!\n"
138  << std::endl;
139  }
140  }
141 
142 
143  if ( ( m_L1DataBxInEvent > 0 ) && ( ( m_L1DataBxInEvent % 2 ) == 0 )) {
145 
146  if (m_verbosity) {
147  edm::LogWarning("L1TGlobalProducer")
148  << "\nWARNING: Number of bunch crossing for incoming L1 Data rounded to: "
149  << m_L1DataBxInEvent << "\n The number must be an odd number!\n"
150  << std::endl;
151  }
152  } else if( m_L1DataBxInEvent<0) {
153  m_L1DataBxInEvent = 1;
154 
155  if (m_verbosity) {
156  edm::LogWarning("L1TGlobalProducer")
157  << "\nWARNING: Number of bunch crossing for incoming L1 Data was changed to: "
158  << m_L1DataBxInEvent << "\n The number must be an odd positive number!\n"
159  << std::endl;
160  }
161  }
162 
163 
164 
165 
166  // register products
168  produces<GlobalAlgBlkBxCollection>();
169  //blwEXT produces<GlobalExtBlkBxCollection>();
170  }
171 
172 
174  produces<GlobalObjectMapRecord>();
175  }
176 
177 
178  // create new uGt Board
179  m_uGtBrd = new GlobalBoard();
181 
182  // initialize cached IDs
183 
184  //
185  m_l1GtParCacheID = 0ULL;
186  m_l1GtMenuCacheID = 0ULL;
187 
190 
191  m_nrL1Mu = 0;
192  m_nrL1EG = 0;
193  m_nrL1Tau = 0;
194 
195  m_nrL1Jet = 0;
196 
197 
198 
201 
202  //
203  m_l1GtParCacheID = 0ULL;
204 
205  m_totalBxInEvent = 0;
206 
208  m_bstLengthBytes = 0;
209 
210  //
211  m_l1GtBMCacheID = 0ULL;
212 
213  //
214  m_l1GtPfAlgoCacheID = 0ULL;
215 
216  m_l1GtTmAlgoCacheID = 0ULL;
217 
219 
220 
221  // directory in /data/Luminosity for the trigger menu
222  std::string menuDir = parSet.getParameter<std::string>("TriggerMenuLuminosity");
223  //std::string menuDir = "startup";
224 
225  // prescale CSV file file
226  std::string prescaleFileName = parSet.getParameter<std::string>("PrescaleCSVFile");
227 
228  // def.xml file
229  //std::string prescaleFileName = "prescale_L1TGlobal.csv";
230 
231  edm::FileInPath f1("L1Trigger/L1TGlobal/data/Luminosity/" +
232  menuDir + "/" + prescaleFileName);
233 
234  m_prescalesFile = f1.fullPath();
235 
236  unsigned int temp_numberPhysTriggers = 512;
237 
238  // Get prescale factors from CSV file for now
239  std::ifstream inputPrescaleFile;
240  inputPrescaleFile.open(m_prescalesFile);
241 
242  std::vector<std::vector<int> > vec;
243  std::vector<std::vector<int> > prescale_vec;
244 
245  std::vector<unsigned int> temp_triggerMask;
246  std::vector<unsigned int> temp_triggerVetoMask;
247 
248  if( inputPrescaleFile ){
249  std::string prefix1("#");
250  std::string prefix2("-1");
251 
252  std::string line;
253 
254  bool first = true;
255 
256  while( getline(inputPrescaleFile,line) ){
257 
258  if( !line.compare(0, prefix1.size(), prefix1) ) continue;
259  //if( !line.compare(0, prefix2.size(), prefix2) ) continue;
260 
261  istringstream split(line);
262  int value;
263  int col = 0;
264  char sep;
265 
266  while( split >> value ){
267  if( first ){
268  // Each new value read on line 1 should create a new inner vector
269  vec.push_back(std::vector<int>());
270  }
271 
272  vec[col].push_back(value);
273  ++col;
274 
275  // read past the separator
276  split>>sep;
277  }
278 
279  // Finished reading line 1 and creating as many inner
280  // vectors as required
281  first = false;
282  }
283 
284 
285  int NumPrescaleSets = 0;
286 
287  int maskColumn = -1;
288  int maskVetoColumn = -1;
289  for( int iCol=0; iCol<int(vec.size()); iCol++ ){
290  if( vec[iCol].size() > 0 ){
291  int firstRow = vec[iCol][0];
292 
293  if( firstRow > 0 ) NumPrescaleSets++;
294  else if( firstRow==-2 ) maskColumn = iCol;
295  else if( firstRow==-3 ) maskVetoColumn = iCol;
296  }
297  }
298 
299  // Fill default values for mask and veto mask
300  for( unsigned int iBit = 0; iBit < temp_numberPhysTriggers; ++iBit ){
301  unsigned int inputDefaultMask = 1;
302  unsigned int inputDefaultVetoMask = 0;
303  temp_triggerMask.push_back(inputDefaultMask);
304  temp_triggerVetoMask.push_back(inputDefaultVetoMask);
305  }
306 
307  // Fill non-trivial mask and veto mask
308  if( maskColumn>=0 || maskVetoColumn>=0 ){
309  for( int iBit=1; iBit<int(vec[0].size()); iBit++ ){
310  unsigned int algoBit = vec[0][iBit];
311  // algoBit must be less than the number of triggers
312  if( algoBit < temp_numberPhysTriggers ){
313  if( maskColumn>=0 ){
314  unsigned int triggerMask = vec[maskColumn][iBit];
315  temp_triggerMask[algoBit] = triggerMask;
316  }
317  if( maskVetoColumn>=0 ){
318  unsigned int triggerVetoMask = vec[maskVetoColumn][iBit];
319  temp_triggerVetoMask[algoBit] = triggerVetoMask;
320  }
321  }
322  }
323  }
324 
325 
326  if( NumPrescaleSets > 0 ){
327  // Fill default prescale set
328  for( int iSet=0; iSet<NumPrescaleSets; iSet++ ){
329  prescale_vec.push_back(std::vector<int>());
330  for( unsigned int iBit = 0; iBit < temp_numberPhysTriggers; ++iBit ){
331  int inputDefaultPrescale = 1;
332  prescale_vec[iSet].push_back(inputDefaultPrescale);
333  }
334  }
335 
336  // Fill non-trivial prescale set
337  for( int iBit=1; iBit<int(vec[0].size()); iBit++ ){
338  unsigned int algoBit = vec[0][iBit];
339  // algoBit must be less than the number of triggers
340  if( algoBit < temp_numberPhysTriggers ){
341  for( int iSet=0; iSet<int(vec.size()); iSet++ ){
342  int useSet = -1;
343  if( vec[iSet].size() > 0 ){
344  useSet = vec[iSet][0];
345  }
346  useSet -= 1;
347 
348  if( useSet<0 ) continue;
349 
350  int prescale = vec[iSet][iBit];
351  prescale_vec[useSet][algoBit] = prescale;
352  }
353  }
354  else{
355  LogTrace("L1TGlobalProducer")
356  << "\nPrescale file has algo bit: " << algoBit
357  << "\nThis is larger than the number of triggers: " << m_numberPhysTriggers
358  << "\nSomething is wrong. Ignoring."
359  << std::endl;
360  }
361  }
362  }
363 
364  }
365  else {
366  LogTrace("L1TGlobalProducer")
367  << "\nCould not find file: " << m_prescalesFile
368  << "\nFilling the prescale vectors with prescale 1"
369  << "\nSetting prescale set to 1"
370  << std::endl;
371 
372  m_prescaleSet = 1;
373 
374  for( int col=0; col < 1; col++ ){
375  prescale_vec.push_back(std::vector<int>());
376  for( unsigned int iBit = 0; iBit < temp_numberPhysTriggers; ++iBit ){
377  int inputDefaultPrescale = 1;
378  prescale_vec[col].push_back(inputDefaultPrescale);
379  }
380  }
381  }
382 
383  inputPrescaleFile.close();
384 
385  m_initialPrescaleFactorsAlgoTrig = prescale_vec;
386 
387  m_initialTriggerMaskAlgoTrig = temp_triggerMask;
388  m_initialTriggerMaskVetoAlgoTrig = temp_triggerVetoMask;
389 
390 }
391 
392 // destructor
394 {
395 
396  delete m_uGtBrd;
397 
398 }
399 
400 // member functions
401 
402 // method called to produce the data
404 {
405 
406 
407 
408 
409 
410  // process event iEvent
411  // get / update the stable parameters from the EventSetup
412  // local cache & check on cacheIdentifier
413 
414  unsigned long long l1GtParCacheID =
415  evSetup.get<L1TGlobalParametersRcd>().cacheIdentifier();
416 
417  if (m_l1GtParCacheID != l1GtParCacheID) {
418 
420  evSetup.get< L1TGlobalParametersRcd >().get( l1GtStablePar );
421  m_l1GtStablePar = l1GtStablePar.product();
422  const GlobalParamsHelper * data = GlobalParamsHelper::readFromEventSetup(m_l1GtStablePar);
423 
424  // number of bx
426 
427  // number of physics triggers
429 
430  // number of objects of each type
431  m_nrL1Mu = data->numberL1Mu();
432 
433  // EG
434  m_nrL1EG = data->numberL1EG();
435 
436  // jets
437  m_nrL1Jet = data->numberL1Jet();
438 
439  // taus
440  m_nrL1Tau= data->numberL1Tau();
441 
443  int minL1DataBxInEvent = (m_L1DataBxInEvent + 1)/2 - m_L1DataBxInEvent;
444  int maxL1DataBxInEvent = (m_L1DataBxInEvent + 1)/2 - 1;
445 
446  // Initialize Board
447  m_uGtBrd->init(m_numberPhysTriggers, m_nrL1Mu, m_nrL1EG, m_nrL1Tau, m_nrL1Jet, minL1DataBxInEvent, maxL1DataBxInEvent );
448 
449  //
450  m_l1GtParCacheID = l1GtParCacheID;
451 
452  }
453 
454  if (m_emulateBxInEvent < 0) {
456  }
457 
459  int minEmulBxInEvent = (m_emulateBxInEvent + 1)/2 - m_emulateBxInEvent;
460  int maxEmulBxInEvent = (m_emulateBxInEvent + 1)/2 - 1;
461 
462  // get / update the trigger menu from the EventSetup
463  // local cache & check on cacheIdentifier
464  unsigned long long l1GtMenuCacheID = evSetup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
465 
466  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
467  const GlobalParamsHelper * data = GlobalParamsHelper::readFromEventSetup(m_l1GtStablePar);
468 
470  evSetup.get< L1TUtmTriggerMenuRcd>().get(l1GtMenu) ;
471  const L1TUtmTriggerMenu* utml1GtMenu = l1GtMenu.product();
472 
473  // Instantiate Parser
474  TriggerMenuParser gtParser = TriggerMenuParser();
475 
476  gtParser.setGtNumberConditionChips(data->numberChips());
477  gtParser.setGtPinsOnConditionChip(data->pinsOnChip());
478  gtParser.setGtOrderConditionChip(data->orderOfChip());
480 
481  //Parse menu into emulator classes
482  gtParser.parseCondFormats(utml1GtMenu);
483 
484  // transfer the condition map and algorithm map from parser to L1uGtTriggerMenu
485  m_l1GtMenu = new TriggerMenu(gtParser.gtTriggerMenuName(), data->numberChips(),
486  gtParser.vecMuonTemplate(),
487  gtParser.vecCaloTemplate(),
488  gtParser.vecEnergySumTemplate(),
489  gtParser.vecExternalTemplate(),
490  gtParser.vecCorrelationTemplate(),
491  gtParser.corMuonTemplate(),
492  gtParser.corCaloTemplate(),
493  gtParser.corEnergySumTemplate()) ;
494 
495 
496  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtTriggerMenuInterface(gtParser.gtTriggerMenuInterface());
497  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtTriggerMenuImplementation(gtParser.gtTriggerMenuImplementation());
498  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtScaleDbKey(gtParser.gtScaleDbKey());
499  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtScales(gtParser.gtScales());
500  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtTriggerMenuUUID(gtParser.gtTriggerMenuUUID());
501 
502  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtAlgorithmMap(gtParser.gtAlgorithmMap());
503  (const_cast<TriggerMenu*>(m_l1GtMenu))->setGtAlgorithmAliasMap(gtParser.gtAlgorithmAliasMap());
504 
505  (const_cast<TriggerMenu*>(m_l1GtMenu))->buildGtConditionMap();
506 
507  //int printV = 2;
508  //m_l1GtMenu->print(std::cout, printV);
509 
510  m_l1GtMenuCacheID = l1GtMenuCacheID;
511  }
512 
513 
514 
515 
516 
517  // get / update the board maps from the EventSetup
518  // local cache & check on cacheIdentifier
519 
520 /* *** Drop L1GtBoard Maps for now
521  typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
522 
523  unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
524 */
525 
526 /* ** Drop board mapping for now
527  if (m_l1GtBMCacheID != l1GtBMCacheID) {
528 
529  edm::ESHandle< L1GtBoardMaps > l1GtBM;
530  evSetup.get< L1GtBoardMapsRcd >().get( l1GtBM );
531  m_l1GtBM = l1GtBM.product();
532 
533  m_l1GtBMCacheID = l1GtBMCacheID;
534 
535  }
536 
537 
538  // TODO need changes in CondFormats to cache the maps
539  const std::vector<L1GtBoard>& boardMaps = m_l1GtBM->gtBoardMaps();
540 */
541  // get / update the prescale factors from the EventSetup
542  // local cache & check on cacheIdentifier
543 
544 
545 /* **** For Now Leave out Prescale Factors ****
546  unsigned long long l1GtPfAlgoCacheID =
547  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
548 
549  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
550 
551  edm::ESHandle< L1GtPrescaleFactors > l1GtPfAlgo;
552  evSetup.get< L1GtPrescaleFactorsAlgoTrigRcd >().get( l1GtPfAlgo );
553  m_l1GtPfAlgo = l1GtPfAlgo.product();
554 
555  m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
556 
557  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
558 
559  }
560 */
561 
562 
563  // Set Prescale factors to initial
567 
568 
569  // get / update the trigger mask from the EventSetup
570  // local cache & check on cacheIdentifier
571 
572 
573 /* **** For now Leave out Masks *****
574  unsigned long long l1GtTmAlgoCacheID =
575  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
576 
577  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
578 
579  edm::ESHandle< L1GtTriggerMask > l1GtTmAlgo;
580  evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
581  m_l1GtTmAlgo = l1GtTmAlgo.product();
582 
583  m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
584 
585  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
586 
587  }
588 */
589 
590 
591 
592 /* **** For now Leave out Veto Masks *****
593  unsigned long long l1GtTmVetoAlgoCacheID =
594  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
595 
596  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
597 
598  edm::ESHandle< L1GtTriggerMask > l1GtTmVetoAlgo;
599  evSetup.get< L1GtTriggerMaskVetoAlgoTrigRcd >().get( l1GtTmVetoAlgo );
600  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
601 
602  m_triggerMaskVetoAlgoTrig = m_l1GtTmVetoAlgo->gtTriggerMask();
603 
604  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
605 
606  }
607 */
608 
609 
610 
611 // ****** Board Maps Need to be redone....hard code for now ******
612  // loop over blocks in the GT DAQ record receiving data, count them if they are active
613  // all board type are defined in CondFormats/L1TObjects/L1GtFwd
614  // &
615  // set the active flag for each object type received from GMT and GCT
616  // all objects in the GT system
617 
618  //
619  bool receiveMu = true;
620  bool receiveEG = true;
621  bool receiveTau = true;
622  bool receiveJet = true;
623  bool receiveEtSums = true;
624  bool receiveExt = true;
625 
626 /* *** Boards need redefining *****
627  for (CItBoardMaps
628  itBoard = boardMaps.begin();
629  itBoard != boardMaps.end(); ++itBoard) {
630 
631  int iPosition = itBoard->gtPositionDaqRecord();
632  if (iPosition > 0) {
633 
634  int iActiveBit = itBoard->gtBitDaqActiveBoards();
635  bool activeBoard = false;
636 
637  if (iActiveBit >= 0) {
638  activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
639  }
640 
641  // use board if: in the record, but not in ActiveBoardsMap (iActiveBit < 0)
642  // in the record and ActiveBoardsMap, and active
643  if ((iActiveBit < 0) || activeBoard) {
644 
645 // ****** Decide what board manipulation (if any we want here)
646 
647  }
648  }
649 
650  }
651 */
652 
653 
654 
655  // Produce the Output Records for the GT
656  std::auto_ptr<GlobalAlgBlkBxCollection> uGtAlgRecord( new GlobalAlgBlkBxCollection(0,minEmulBxInEvent,maxEmulBxInEvent));
657 
658  // * produce the GlobalObjectMapRecord
659  std::auto_ptr<GlobalObjectMapRecord> gtObjectMapRecord(
660  new GlobalObjectMapRecord() );
661 
662 
663  // fill the boards not depending on the BxInEvent in the L1 GT DAQ record
664  // GMT, PSB and FDL depend on BxInEvent
665 
666  // fill in emulator the same bunch crossing (12 bits - hardwired number of bits...)
667  // and the same local bunch crossing for all boards
668  int bxCross = iEvent.bunchCrossing();
669  boost::uint16_t bxCrossHw = 0;
670  if ((bxCross & 0xFFF) == bxCross) {
671  bxCrossHw = static_cast<boost::uint16_t> (bxCross);
672  }
673  else {
674  bxCrossHw = 0; // Bx number too large, set to 0!
675  if (m_verbosity) {
676 
677  LogDebug("L1TGlobalProducer")
678  << "\nBunch cross number [hex] = " << std::hex << bxCross
679  << "\n larger than 12 bits. Set to 0! \n" << std::dec
680  << std::endl;
681  }
682  }
683  LogDebug("L1TGlobalProducer") << "HW BxCross " << bxCrossHw << std::endl;
684 
685 
686  // get the prescale factor from the configuration for now
687  // Prescale set indexed by zero internally, but externally indexed by 1
688  unsigned int pfAlgoSetIndex = m_prescaleSet-1;
689 
690  // Require that prescale set be positive
691  if( m_prescaleSet<=0 ) pfAlgoSetIndex = 0;
692 
693  if( pfAlgoSetIndex > (*m_prescaleFactorsAlgoTrig).size()-1 ){
694  LogTrace("L1TGlobalProducer")
695  << "\nAttempting to access prescale algo set: " << m_prescaleSet
696  << "\nNumber of prescale algo sets available: " << (*m_prescaleFactorsAlgoTrig).size()
697  << "Setting former to latter."
698  << std::endl;
699 
700  pfAlgoSetIndex = (*m_prescaleFactorsAlgoTrig).size()-1;
701  }
702 
703  const std::vector<int>& prescaleFactorsAlgoTrig = (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
704 
705  const std::vector<unsigned int>& triggerMaskAlgoTrig = *m_triggerMaskAlgoTrig;
706  const std::vector<unsigned int>& triggerMaskVetoAlgoTrig = *m_triggerMaskVetoAlgoTrig;
707 
708  LogDebug("L1TGlobalProducer") << "Size of prescale vector" << prescaleFactorsAlgoTrig.size() << std::endl;
709 
710 
711 // Load the calorimeter input onto the uGt Board
717  receiveEG, m_nrL1EG,
718  receiveTau, m_nrL1Tau,
719  receiveJet, m_nrL1Jet,
720  receiveEtSums );
721 
723  receiveMu, m_nrL1Mu );
724 
726  receiveExt );
727 
728 
729  // loop over BxInEvent
730  for (int iBxInEvent = minEmulBxInEvent; iBxInEvent <= maxEmulBxInEvent;
731  ++iBxInEvent) {
732 
733  // run GTL
734  LogDebug("L1TGlobalProducer")
735  << "\nL1TGlobalProducer : running GTL for bx = " << iBxInEvent << "\n"
736  << std::endl;
737 
738 
739 // Run the GTL for this BX
740  m_uGtBrd->runGTL(iEvent, evSetup, m_l1GtMenu,
741  m_produceL1GtObjectMapRecord, iBxInEvent, gtObjectMapRecord,
743  m_nrL1Mu,
744  m_nrL1EG,
745  m_nrL1Tau,
746  m_nrL1Jet
747  );
748 
749 
750  // run FDL
751  LogDebug("L1TGlobalProducer")
752  << "\nL1TGlobalProducer : running FDL for bx = " << iBxInEvent << "\n"
753  << std::endl;
754 
755 
756 // Run the Final Decision Logic for this BX
757  m_uGtBrd->runFDL(iEvent,
758  iBxInEvent,
761  prescaleFactorsAlgoTrig,
762  triggerMaskAlgoTrig,
763  triggerMaskVetoAlgoTrig,
766  );
767 
768 
769 
770 // Fill in the DAQ Records
773  }
774 
775 
776 
777  } //End Loop over Bx
778 
779 
780  // Add explicit reset of Board
781  m_uGtBrd->reset();
782 
783 
784 
785  if ( m_verbosity && m_isDebugEnabled ) {
786 
787  std::ostringstream myCoutStream;
788 
789  for(int bx=minEmulBxInEvent; bx<maxEmulBxInEvent; bx++) {
790 
792  (uGtAlgRecord->at(bx,0)).print(myCoutStream);
793 
794  }
795 
796  LogTrace("L1TGlobalProducer")
797  << "\n The following L1 GT DAQ readout record was produced:\n"
798  << myCoutStream.str() << "\n"
799  << std::endl;
800 
801  myCoutStream.str("");
802  myCoutStream.clear();
803 
804  const std::vector<GlobalObjectMap> objMapVec =
805  gtObjectMapRecord->gtObjectMap();
806 
807  for (std::vector<GlobalObjectMap>::const_iterator
808  it = objMapVec.begin(); it != objMapVec.end(); ++it) {
809 
810  (*it).print(myCoutStream);
811 
812  }
813 
814 
815  LogDebug("L1TGlobalProducer")
816  << "Test gtObjectMapRecord in L1TGlobalProducer \n\n" << myCoutStream.str() << "\n\n"
817  << std::endl;
818 
819  myCoutStream.str("");
820  myCoutStream.clear();
821  }
822 
823 
824 
825 
826  // register products
828  iEvent.put( uGtAlgRecord );
829  }
830 
831 
833  iEvent.put( gtObjectMapRecord );
834  }
835 
836 
837 }
838 
839 //define this as a plug-in
#define LogDebug(id)
T getParameter(std::string const &) const
bool isDebugEnabled()
void receiveMuonObjectData(edm::Event &, const edm::EDGetTokenT< BXVector< l1t::Muon > > &, const bool receiveMu, const int nrL1Mu)
Definition: GlobalBoard.cc:315
edm::InputTag m_jetInputTag
unsigned int m_numberDaqPartitions
unsigned long long m_l1GtParCacheID
unsigned int numberL1Jet() const
get / set the number of L1 jets received by GT
unsigned long long m_l1GtTmVetoAlgoCacheID
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: GlobalBoard.cc:118
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 unsigned long gtTriggerMenuUUID() const
Definition: TriggerMenu.h:98
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
unsigned int numberL1EG() const
get / set the number of L1 e/gamma objects received by GT
std::string m_prescalesFile
CSV file for prescales.
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
void fillAlgRecord(int iBxInEvent, std::auto_ptr< GlobalAlgBlkBxCollection > &uGtAlgRecord, int prescaleSet, int menuUUID, int firmwareUUID)
Fill the Daq Records.
Definition: GlobalBoard.cc:918
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 numberPhysTriggers() const
get / set the number of physics trigger algorithms
int bunchCrossing() const
Definition: EventBase.h:65
const std::vector< std::vector< ExternalTemplate > > & vecExternalTemplate() const
unsigned int m_numberPhysTriggers
const L1TGlobalParameters * m_l1GtStablePar
cached stuff
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
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: GlobalBoard.cc:141
void setVerbosity(const int verbosity)
Definition: GlobalBoard.h:210
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
const std::vector< int > & orderOfChip() const
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
const std::string & gtTriggerMenuName() const
boost::uint16_t m_activeBoardsGtDaq
active boards in L1 GT DAQ record
const std::vector< std::vector< CaloTemplate > > & corCaloTemplate() const
void reset()
clear uGT
Definition: GlobalBoard.cc:950
void receiveExternalData(edm::Event &, const edm::EDGetTokenT< BXVector< GlobalExtBlk > > &, const bool receiveExt)
Definition: GlobalBoard.cc:364
bool m_produceL1GtDaqRecord
logical flag to produce the L1 GT DAQ readout record
edm::EDGetTokenT< BXVector< l1t::Muon > > m_muInputToken
const std::vector< std::vector< MuonTemplate > > & corMuonTemplate() const
unsigned int numberL1Tau() const
get / set the number of L1 tau received by GT
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 &)
unsigned int m_prescaleSet
prescale set used
const unsigned long gtTriggerMenuImplementation() const
Definition: TriggerMenu.h:106
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::vector< std::vector< CorrelationTemplate > > & vecCorrelationTemplate() const
edm::EDGetTokenT< BXVector< l1t::EtSum > > m_sumInputToken
int m_L1DataBxInEvent
Bx expected in Data coming to GT.
l1t::GlobalBoard * m_uGtBrd
L1TGlobalProducer(const edm::ParameterSet &)
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: GlobalBoard.cc:784
unsigned long long m_l1GtBMCacheID
const GlobalScales & gtScales() const
menu associated scales
const int gtTriggerMenuUUID() const
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)
std::vector< unsigned int > m_initialTriggerMaskVetoAlgoTrig
unsigned int m_bstLengthBytes
length of BST record (in bytes) from event setup
int totalBxInEvent() const
get / set the number of bx in hardware
const std::vector< std::vector< CaloTemplate > > & vecCaloTemplate() const
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
unsigned long long m_l1GtPfAlgoCacheID
const std::string & gtTriggerMenuInterface() const
get / set the trigger menu names
int col
Definition: cuy.py:1008
unsigned int numberL1Mu() const
get / set the number of L1 muons received by GT
const std::string & gtScaleDbKey() const
menu associated scale key
unsigned int pinsOnChip() const
get / set the number of pins on the GTL condition chips
double split
Definition: MVATrainer.cc:139
tuple size
Write out results.
const std::vector< unsigned int > * m_triggerMaskVetoAlgoTrig
const unsigned long gtTriggerMenuImplementation() const
void runGTL(edm::Event &iEvent, const edm::EventSetup &evSetup, const TriggerMenu *m_l1GtMenu, const bool produceL1GtObjectMapRecord, const int iBxInEvent, std::auto_ptr< GlobalObjectMapRecord > &gtObjectMapRecord, const unsigned int numberPhysTriggers, const int nrL1Mu, const int nrL1EG, const int nrL1Tau, const int nrL1Jet)
run the uGT GTL (Conditions and Algorithms)
Definition: GlobalBoard.cc:412
edm::EDGetTokenT< BXVector< l1t::Jet > > m_jetInputToken
unsigned int numberChips() const
get / set the number of condition chips in GTL
edm::EDGetTokenT< BXVector< l1t::EGamma > > m_egInputToken
void setGtNumberPhysTriggers(const unsigned int &)