CMS 3D CMS Logo

L1GtDataEmulAnalyzer.cc
Go to the documentation of this file.
1 
16 // this class header
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 #include <iomanip>
23 
24 // user include files
29 
33 
36 
39 
43 
44 #include "TH1.h"
45 #include "TH2.h"
46 #include "TTree.h"
47 
48 // constructor(s)
50 
51  // input tag for the L1 GT hardware DAQ/EVM record
52  m_l1GtDataInputTag = parSet.getParameter<edm::InputTag>("L1GtDataInputTag");
53 
54  // input tag for the L1 GT emulator DAQ/EVM record
55  m_l1GtEmulInputTag = parSet.getParameter<edm::InputTag>("L1GtEmulInputTag");
56 
57  // input tag for the L1 GCT hardware record
59  = parSet.getParameter<edm::InputTag>("L1GctDataInputTag");
60 
61  LogDebug("L1GtDataEmulAnalyzer")
62  << "\nInput tag for the L1 GT hardware records: "
64  << "\nInput tag for the L1 GT emulator records: "
65  << m_l1GtEmulInputTag
66  << "\nInput tag for the L1 GCT hardware record: "
67  << m_l1GctDataInputTag << std::endl;
68 
69  // initialize counters
72 
73  // cache
74  m_l1GtMenuCacheID = 0ULL;
75 
76  m_l1GtTmAlgoCacheID = 0ULL;
77  m_l1GtTmTechCacheID = 0ULL;
78 
79 
80  // book histograms
82 
83 }
84 
85 // destructor
87  // empty
88 }
89 
90 // member functions
91 
92 // method called once each job just before starting event loop
94  // empty
95 }
96 
97 //compare the GTFE board
99  const edm::EventSetup& evSetup, const L1GtfeWord& gtfeBlockData,
100  const L1GtfeWord& gtfeBlockEmul) {
101 
102  if (gtfeBlockData == gtfeBlockEmul) {
103  m_myCoutStream << "\nData and emulated GTFE blocks: identical.\n";
104  gtfeBlockData.print(m_myCoutStream);
105  }
106  else {
107  m_myCoutStream << "\nData and emulated GTFE blocks: different.\n";
108 
109  m_myCoutStream << "\nData: GTFE block\n";
110  gtfeBlockData.print(m_myCoutStream);
111 
112  m_myCoutStream << "\nEmul: GTFE block\n";
113  gtfeBlockEmul.print(m_myCoutStream);
114 
115  }
116 
117  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
118 
119  m_myCoutStream.str("");
120  m_myCoutStream.clear();
121 
122  // get BoardId value
123  const boost::uint16_t boardIdData = gtfeBlockData.boardId();
124  const boost::uint16_t boardIdEmul = gtfeBlockEmul.boardId();
125 
126  if (boardIdData == boardIdEmul) {
127  m_myCoutStream << "\nData and emulated GTFE boardId identical.";
128  m_myCoutStream << "\n boardId() = " << std::hex << "0x" << std::setw(4)
129  << std::setfill('0') << boardIdData << std::setfill(' ')
130  << std::dec;
131  m_myCoutStream << "\n";
132 
133  }
134  else {
135  m_myCoutStream << "\nData and emulated GTFE boardId different.";
136  m_myCoutStream << "\n Data: boardId() = " << std::hex << "0x"
137  << std::setw(4) << std::setfill('0') << boardIdData
138  << std::setfill(' ') << std::dec;
139  m_myCoutStream << "\n Emul: boardId() = " << std::hex << "0x"
140  << std::setw(4) << std::setfill('0') << boardIdEmul
141  << std::setfill(' ') << std::dec;
142  m_myCoutStream << "\n";
143  m_gtfeDataEmul->Fill(0);
144 
145  }
146 
148  const boost::uint16_t recordLengthData = gtfeBlockData.recordLength();
149  const boost::uint16_t recordLengthEmul = gtfeBlockEmul.recordLength();
150 
151  if (recordLengthData == recordLengthEmul) {
152  m_myCoutStream << "\nData and emulated GTFE recordLength identical.";
153  m_myCoutStream << "\n recordLength() = " << recordLengthData;
154  m_myCoutStream << "\n";
155 
156  }
157  else {
158  m_myCoutStream << "\nData and emulated GTFE recordLength different.";
159  m_myCoutStream << "\n Data: recordLength() = " << recordLengthData;
160  m_myCoutStream << "\n Emul: recordLength() = " << recordLengthEmul;
161  m_myCoutStream << "\n";
162  m_gtfeDataEmul->Fill(1);
163 
164  }
165 
167  const boost::uint16_t bxNrData = gtfeBlockData.bxNr();
168  const boost::uint16_t bxNrEmul = gtfeBlockEmul.bxNr();
169 
170  if (bxNrData == bxNrEmul) {
171  m_myCoutStream << "\nData and emulated GTFE bxNr identical.";
172  m_myCoutStream << "\n bxNr() = " << bxNrData;
173  m_myCoutStream << "\n";
174 
175  }
176  else {
177  m_myCoutStream << "\nData and emulated GTFE bxNr different.";
178  m_myCoutStream << "\n Data: bxNr() = " << bxNrData;
179  m_myCoutStream << "\n Emul: bxNr() = " << bxNrEmul;
180  m_myCoutStream << "\n";
181  m_gtfeDataEmul->Fill(2);
182 
183  }
184 
186  const boost::uint32_t setupVersionData = gtfeBlockData.setupVersion();
187  const boost::uint32_t setupVersionEmul = gtfeBlockEmul.setupVersion();
188 
189  if (setupVersionData == setupVersionEmul) {
190  m_myCoutStream << "\nData and emulated GTFE setupVersion identical.";
191  m_myCoutStream << "\n setupVersion() = " << setupVersionData;
192  m_myCoutStream << "\n";
193 
194  }
195  else {
196  m_myCoutStream << "\nData and emulated GTFE setupVersion different.";
197  m_myCoutStream << "\n Data: setupVersion() = " << setupVersionData;
198  m_myCoutStream << "\n Emul: setupVersion() = " << setupVersionEmul;
199  m_myCoutStream << "\n";
200  m_gtfeDataEmul->Fill(3);
201 
202  }
203 
205  const boost::uint16_t activeBoardsData = gtfeBlockData.activeBoards();
206  const boost::uint16_t activeBoardsEmul = gtfeBlockEmul.activeBoards();
207 
208  if (activeBoardsData == activeBoardsEmul) {
209  m_myCoutStream << "\nData and emulated GTFE activeBoards identical.";
210  m_myCoutStream << "\n activeBoards() = " << std::hex << "0x"
211  << std::setw(4) << std::setfill('0') << activeBoardsData
212  << std::setfill(' ') << std::dec;
213  m_myCoutStream << "\n";
214 
215  }
216  else {
217  m_myCoutStream << "\nData and emulated GTFE activeBoards different.";
218  m_myCoutStream << "\n Data: activeBoards() = " << std::hex << "0x"
219  << std::setw(4) << std::setfill('0') << activeBoardsData
220  << std::setfill(' ') << std::dec;
221  m_myCoutStream << "\n Emul: activeBoards() = " << std::hex << "0x"
222  << std::setw(4) << std::setfill('0') << activeBoardsEmul
223  << std::setfill(' ') << std::dec;
224  m_myCoutStream << "\n";
225  m_gtfeDataEmul->Fill(4);
226 
227  }
228 
230  const boost::uint32_t totalTriggerNrData = gtfeBlockData.totalTriggerNr();
231  const boost::uint32_t totalTriggerNrEmul = gtfeBlockEmul.totalTriggerNr();
232 
233  if (totalTriggerNrData == totalTriggerNrEmul) {
234  m_myCoutStream << "\nData and emulated GTFE totalTriggerNr identical.";
235  m_myCoutStream << "\n totalTriggerNr() = " << totalTriggerNrData;
236  m_myCoutStream << "\n";
237 
238  }
239  else {
240  m_myCoutStream << "\nData and emulated GTFE totalTriggerNr different.";
241  m_myCoutStream << "\n Data: totalTriggerNr() = " << totalTriggerNrData;
242  m_myCoutStream << "\n Emul: totalTriggerNr() = " << totalTriggerNrEmul;
243  m_myCoutStream << "\n";
244  m_gtfeDataEmul->Fill(5);
245 
246  }
247 
248  edm::LogInfo("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
249  m_myCoutStream.str("");
250  m_myCoutStream.clear();
251 
252 }
253 
254 //compare the FDL board
256  const edm::EventSetup& evSetup, const L1GtFdlWord& fdlBlockData,
257  const L1GtFdlWord& fdlBlockEmul, const int iRec) {
258 
259  // index of physics partition
260  int PhysicsPartition = 0;
261 
262  //
263  std::string recString;
264  if (iRec == 0) {
265  recString = "Daq";
266  }
267  else {
268  recString = "Evm";
269  }
270 
271  if (fdlBlockData == fdlBlockEmul) {
272  m_myCoutStream << "\n" << recString
273  << " Data and emulated FDL blocks: identical.\n";
274  fdlBlockData.print(m_myCoutStream);
275 
276  }
277  else {
278  m_myCoutStream << "\n" << recString
279  << " Data and emulated FDL blocks: different.\n";
280 
281  m_myCoutStream << "\nData: FDL block\n";
282  fdlBlockData.print(m_myCoutStream);
283 
284  m_myCoutStream << "\nEmul: FDL block\n";
285  fdlBlockEmul.print(m_myCoutStream);
286 
287  }
288 
289  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
290 
291  m_myCoutStream.str("");
292  m_myCoutStream.clear();
293 
294  // get bunch cross in the GT event record -
295  // move it first as histograms are BxInEvent dependent
296  const int bxInEventData = fdlBlockData.bxInEvent();
297  const int bxInEventEmul = fdlBlockEmul.bxInEvent();
298 
299  bool matchBxInEvent = false;
300 
301  if (bxInEventData == bxInEventEmul) {
302  m_myCoutStream << "\n" << recString
303  << " Data and emulated FDL bxInEvent identical.";
304  m_myCoutStream << "\n bxInEvent() = " << bxInEventData;
305  m_myCoutStream << "\n";
306  matchBxInEvent = true;
307 
308  }
309  else {
310  m_myCoutStream << "\n" << recString
311  << " Data and emulated FDL bxInEvent different.";
312  m_myCoutStream << "\n Data: bxInEvent() = " << bxInEventData;
313  m_myCoutStream << "\n Emul: bxInEvent() = " << bxInEventEmul;
314  m_myCoutStream << "\n";
315 
316  m_fdlDataEmul_Err[iRec]->Fill(1);
317  }
318 
319  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
320  m_myCoutStream.str("");
321  m_myCoutStream.clear();
322 
323  // symmetrize
324  bool validBxInEvent = false;
325  int histIndex = bxInEventData + (TotalBxInEvent + 1)/2 -1;
326  if ((histIndex <= TotalBxInEvent) && (histIndex >= 0)) {
327  validBxInEvent = true;
328  }
329 
330  // get / update the trigger menu from the EventSetup
331  // local cache & check on cacheIdentifier
332 
333  unsigned long long l1GtMenuCacheID = evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
334 
335  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
336 
338  evSetup.get< L1GtTriggerMenuRcd>().get(l1GtMenu) ;
339  m_l1GtMenu = l1GtMenu.product();
340 
341  m_l1GtMenuCacheID = l1GtMenuCacheID;
342 
343  }
344  // get / update the trigger mask from the EventSetup
345  // local cache & check on cacheIdentifier
346 
347  unsigned long long l1GtTmAlgoCacheID =
348  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
349 
350  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
351 
353  evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
354  m_l1GtTmAlgo = l1GtTmAlgo.product();
355 
357 
358  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
359 
360  }
361 
362 
363  unsigned long long l1GtTmTechCacheID =
364  evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
365 
366  if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
367 
369  evSetup.get< L1GtTriggerMaskTechTrigRcd >().get( l1GtTmTech );
370  m_l1GtTmTech = l1GtTmTech.product();
371 
373 
374  m_l1GtTmTechCacheID = l1GtTmTechCacheID;
375 
376  }
377 
378 
379  // loop over algorithms and increase the corresponding counters
380  // FIXME put it back in cache
381  // FIXME when the menu changes, make a copy of histograms, and clear the old one
382  // otherwise the labels are wrong
383  const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
384 
385  for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
386 
387  std::string aName = itAlgo->first;
388  const char* algName = aName.c_str();
389  int algBitNumber = (itAlgo->second).algoBitNumber();
390 
391  (m_fdlDataAlgoDecision[histIndex][iRec])->GetXaxis()->SetBinLabel(algBitNumber + 1, algName);
392  m_fdlDataAlgoDecision_Err[iRec]->GetXaxis()->SetBinLabel(algBitNumber + 1, algName);
393 
394  m_fdlEmulAlgoDecision[histIndex][iRec]->GetXaxis()->SetBinLabel(algBitNumber + 1, algName);
395  m_fdlEmulAlgoDecision_Err[iRec]->GetXaxis()->SetBinLabel(algBitNumber + 1, algName);
396 
397  m_fdlDataEmulAlgoDecision[histIndex][iRec]->GetXaxis()->SetBinLabel(algBitNumber + 1, algName);
398  m_fdlDataEmulAlgoDecision_Err[iRec]->GetXaxis()->SetBinLabel(algBitNumber + 1, algName);
399 
400  }
401 
402  // get BoardId value
403  const boost::uint16_t boardIdData = fdlBlockData.boardId();
404  const boost::uint16_t boardIdEmul = fdlBlockEmul.boardId();
405 
406  if (boardIdData == boardIdEmul) {
407  m_myCoutStream << "\n" << recString
408  << " Data and emulated FDL boardId identical.";
409  m_myCoutStream << "\n boardId() = " << std::hex << "0x" << std::setw(4)
410  << std::setfill('0') << boardIdData << std::setfill(' ')
411  << std::dec;
412  m_myCoutStream << "\n";
413 
414  }
415  else {
416  m_myCoutStream << "\n" << recString
417  << " Data and emulated FDL boardId different.";
418  m_myCoutStream << "\n Data: boardId() = " << std::hex << "0x"
419  << std::setw(4) << std::setfill('0') << boardIdData
420  << std::setfill(' ') << std::dec;
421  m_myCoutStream << "\n Emul: boardId() = " << std::hex << "0x"
422  << std::setw(4) << std::setfill('0') << boardIdEmul
423  << std::setfill(' ') << std::dec;
424  m_myCoutStream << "\n";
425 
426  if (matchBxInEvent && validBxInEvent) {
427  m_fdlDataEmul[histIndex][iRec]->Fill(0);
428  }
429  else {
430  m_fdlDataEmul_Err[iRec]->Fill(0);
431  }
432 
433  }
434 
435  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
436  m_myCoutStream.str("");
437  m_myCoutStream.clear();
438 
439  // get BxNr - bunch cross number of the actual bx
440  const boost::uint16_t bxNrData = fdlBlockData.bxNr();
441  const boost::uint16_t bxNrEmul = fdlBlockEmul.bxNr();
442 
443  if (bxNrData == bxNrEmul) {
444  m_myCoutStream << "\n" << recString
445  << " Data and emulated FDL bxNr identical.";
446  m_myCoutStream << "\n bxNr() = " << bxNrData;
447  m_myCoutStream << "\n";
448 
449  }
450  else {
451  m_myCoutStream << "\n" << recString
452  << " Data and emulated FDL bxNr different.";
453  m_myCoutStream << "\n Data: bxNr() = " << bxNrData;
454  m_myCoutStream << "\n Emul: bxNr() = " << bxNrEmul;
455  m_myCoutStream << "\n";
456 
457  if (matchBxInEvent && validBxInEvent) {
458  m_fdlDataEmul[histIndex][iRec]->Fill(2);
459  }
460  else {
461  m_fdlDataEmul_Err[iRec]->Fill(2);
462  }
463  }
464 
465  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
466  m_myCoutStream.str("");
467  m_myCoutStream.clear();
468 
469  // get event number since last L1 reset generated in FDL
470  const boost::uint32_t eventNrData = fdlBlockData.eventNr();
471  const boost::uint32_t eventNrEmul = fdlBlockEmul.eventNr();
472 
473  if (eventNrData == eventNrEmul) {
474  m_myCoutStream << "\n" << recString
475  << " Data and emulated FDL eventNr identical.";
476  m_myCoutStream << "\n eventNr() = " << eventNrData;
477  m_myCoutStream << "\n";
478 
479  }
480  else {
481  m_myCoutStream << "\n" << recString
482  << " Data and emulated FDL eventNr different.";
483  m_myCoutStream << "\n Data: eventNr() = " << eventNrData;
484  m_myCoutStream << "\n Emul: eventNr() = " << eventNrEmul;
485  m_myCoutStream << "\n";
486 
487  if (matchBxInEvent && validBxInEvent) {
488  m_fdlDataEmul[histIndex][iRec]->Fill(3);
489  }
490  else {
491  m_fdlDataEmul_Err[iRec]->Fill(3);
492  }
493 
494  }
495 
496  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
497  m_myCoutStream.str("");
498  m_myCoutStream.clear();
499 
500  // get technical trigger bits
501  const TechnicalTriggerWord gtTechnicalTriggerWordData =
502  fdlBlockData.gtTechnicalTriggerWord();
503  const TechnicalTriggerWord gtTechnicalTriggerWordEmul =
504  fdlBlockEmul.gtTechnicalTriggerWord();
505 
506  int nTechBits = gtTechnicalTriggerWordData.size();
507 
508  TechnicalTriggerWord gtTechnicalTriggerWordDataMask(nTechBits);
509  TechnicalTriggerWord gtTechnicalTriggerWordEmulMask(nTechBits);
510 
511  unsigned int triggerMask = 0;
512  unsigned int bitValue = 0;
513 
514  if (matchBxInEvent && validBxInEvent) {
515  for (int iBit = 0; iBit < nTechBits; ++iBit) {
516 
517  triggerMask = (m_triggerMaskTechTrig.at(iBit)) & (1
518  << PhysicsPartition);
519 
520  if (gtTechnicalTriggerWordData[iBit]) {
521  m_fdlDataTechDecision[histIndex][iRec]->Fill(iBit);
522 
523  bitValue = (triggerMask) ? 0 : 1;
524  gtTechnicalTriggerWordDataMask[iBit] = bitValue;
525  if (bitValue) {
526  m_fdlDataTechDecisionMask[histIndex][iRec]->Fill(iBit);
527  }
528  }
529 
530  if (gtTechnicalTriggerWordEmul.at(iBit)) {
531  m_fdlEmulTechDecision[histIndex][iRec]->Fill(iBit);
532 
533  bitValue = (triggerMask) ? 0 : 1;
534  gtTechnicalTriggerWordEmulMask[iBit] = bitValue;
535  if (bitValue) {
536  m_fdlEmulTechDecisionMask[histIndex][iRec]->Fill(iBit);
537  }
538  }
539  }
540  }
541  else {
542  for (int iBit = 0; iBit < nTechBits; ++iBit) {
543 
544  if (gtTechnicalTriggerWordData[iBit]) {
545  m_fdlDataTechDecision_Err[iRec]->Fill(iBit);
546  }
547 
548  if (gtTechnicalTriggerWordEmul.at(iBit)) {
549  m_fdlEmulTechDecision_Err[iRec]->Fill(iBit);
550  }
551  }
552  }
553 
554  if (gtTechnicalTriggerWordData == gtTechnicalTriggerWordEmul) {
555  m_myCoutStream << "\n" << recString
556  << " Data and emulated FDL gtTechnicalTriggerWord identical.\n";
558  m_myCoutStream << "\n";
559 
560  }
561  else {
562  m_myCoutStream << "\n" << recString
563  << " Data and emulated FDL gtTechnicalTriggerWord different.";
564  m_myCoutStream << "\n Data: ";
566  m_myCoutStream << "\n Emul: ";
568  m_myCoutStream << "\n";
569 
570  if (matchBxInEvent && validBxInEvent) {
571  m_fdlDataEmul[histIndex][iRec]->Fill(4);
572  }
573  else {
574  m_fdlDataEmul_Err[iRec]->Fill(4);
575  }
576 
577  if (matchBxInEvent && validBxInEvent) {
578  for (int iBit = 0; iBit < nTechBits; ++iBit) {
579  if (gtTechnicalTriggerWordData[iBit]
580  != gtTechnicalTriggerWordEmul.at(iBit)) {
581  m_fdlDataEmulTechDecision[histIndex][iRec]->Fill(iBit);
582  }
583  }
584  }
585  else {
586  for (int iBit = 0; iBit < nTechBits; ++iBit) {
587  if (gtTechnicalTriggerWordData[iBit]
588  != gtTechnicalTriggerWordEmul.at(iBit)) {
589  m_fdlDataEmulTechDecision_Err[iRec]->Fill(iBit);
590  }
591  }
592  }
593  }
594 
595  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
596  m_myCoutStream.str("");
597  m_myCoutStream.clear();
598 
599  if (gtTechnicalTriggerWordDataMask == gtTechnicalTriggerWordEmulMask) {
600  m_myCoutStream << "\n" << recString
601  << " Data and emulated FDL gtTechnicalTriggerWord after mask identical.\n";
602  m_myCoutStream << "\n";
603 
604  }
605  else {
606  m_myCoutStream << "\n" << recString
607  << " Data and emulated FDL gtTechnicalTriggerWord after mask different.";
608  m_myCoutStream << "\n Data: ";
609  m_myCoutStream << "\n Emul: ";
610  m_myCoutStream << "\n";
611 
612  if (matchBxInEvent && validBxInEvent) {
613  m_fdlDataEmul[histIndex][iRec]->Fill(5);
614  }
615  else {
616  m_fdlDataEmul_Err[iRec]->Fill(5);
617  }
618 
619  if (matchBxInEvent && validBxInEvent) {
620  for (int iBit = 0; iBit < nTechBits; ++iBit) {
621  if (gtTechnicalTriggerWordData[iBit]
622  != gtTechnicalTriggerWordEmul.at(iBit)) {
623  m_fdlDataEmulTechDecisionMask[histIndex][iRec]->Fill(iBit);
624  }
625  }
626  }
627  }
628 
629  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
630  m_myCoutStream.str("");
631  m_myCoutStream.clear();
632 
633  // get algorithms bits (decision word)
634  const DecisionWord gtDecisionWordData = fdlBlockData.gtDecisionWord();
635  const DecisionWord gtDecisionWordEmul = fdlBlockEmul.gtDecisionWord();
636 
637  int nAlgoBits = gtDecisionWordData.size();
638 
639  DecisionWord gtDecisionWordDataMask(nAlgoBits);
640  DecisionWord gtDecisionWordEmulMask(nAlgoBits);
641 
642  if (matchBxInEvent && validBxInEvent) {
643 
644  for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
645 
646  triggerMask = (m_triggerMaskAlgoTrig.at(iBit))
647  & (1 << PhysicsPartition);
648 
649  if (gtDecisionWordData[iBit]) {
650  m_fdlDataAlgoDecision[histIndex][iRec]->Fill(iBit);
651 
652  bitValue = (triggerMask) ? 0 : 1;
653  gtDecisionWordDataMask[iBit] = bitValue;
654  if (bitValue) {
655  m_fdlDataAlgoDecisionMask[histIndex][iRec]->Fill(iBit);
656  }
657  }
658 
659  if (gtDecisionWordEmul.at(iBit)) {
660  m_fdlEmulAlgoDecision[histIndex][iRec]->Fill(iBit);
661 
662  bitValue = (triggerMask) ? 0 : 1;
663  gtDecisionWordEmulMask[iBit] = bitValue;
664  if (bitValue) {
665  m_fdlEmulAlgoDecisionMask[histIndex][iRec]->Fill(iBit);
666  }
667  }
668  }
669  }
670  else {
671  for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
672  if (gtDecisionWordData[iBit]) {
673  m_fdlDataAlgoDecision_Err[iRec]->Fill(iBit);
674  }
675  }
676 
677  for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
678  if (gtDecisionWordEmul.at(iBit)) {
679  m_fdlEmulAlgoDecision_Err[iRec]->Fill(iBit);
680  }
681  }
682  }
683 
684  if (gtDecisionWordData == gtDecisionWordEmul) {
685  m_myCoutStream << "\n" << recString
686  << " Data and emulated FDL gtDecisionWord identical.";
687  fdlBlockData.printGtDecisionWord(m_myCoutStream);
688  m_myCoutStream << "\n";
689 
690  }
691  else {
692  m_myCoutStream << "\n" << recString
693  << " Data and emulated FDL gtDecisionWord different.";
694  m_myCoutStream << "\n Data: ";
695  fdlBlockData.printGtDecisionWord(m_myCoutStream);
696  m_myCoutStream << "\n Emul: ";
697  fdlBlockEmul.printGtDecisionWord(m_myCoutStream);
698  m_myCoutStream << "\n";
699 
700  if (matchBxInEvent && validBxInEvent) {
701  m_fdlDataEmul[histIndex][iRec]->Fill(6);
702  }
703  else {
704  m_fdlDataEmul_Err[iRec]->Fill(6);
705  }
706 
707  if (matchBxInEvent && validBxInEvent) {
708  for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
709  if (gtDecisionWordData[iBit] != gtDecisionWordEmul.at(iBit)) {
710  m_fdlDataEmulAlgoDecision[histIndex][iRec]->Fill(iBit);
711  }
712  }
713  }
714  else {
715  for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
716  if (gtDecisionWordData[iBit] != gtDecisionWordEmul.at(iBit)) {
717  m_fdlDataEmulAlgoDecision_Err[iRec]->Fill(iBit);
718  }
719  }
720  }
721 
722  }
723 
724  if (gtDecisionWordDataMask == gtDecisionWordEmulMask) {
725  m_myCoutStream << "\n" << recString
726  << " Data and emulated FDL gtDecisionWord after mask identical.";
727  m_myCoutStream << "\n";
728 
729  }
730  else {
731  m_myCoutStream << "\n" << recString
732  << " Data and emulated FDL gtDecisionWord after mask different.";
733  m_myCoutStream << "\n Data: ";
734  m_myCoutStream << "\n Emul: ";
735  m_myCoutStream << "\n";
736 
737  if (matchBxInEvent && validBxInEvent) {
738  m_fdlDataEmul[histIndex][iRec]->Fill(7);
739  }
740  else {
741  m_fdlDataEmul_Err[iRec]->Fill(7);
742  }
743 
744  if (matchBxInEvent && validBxInEvent) {
745  for (int iBit = 0; iBit < nAlgoBits; ++iBit) {
746  if (gtDecisionWordDataMask[iBit] != gtDecisionWordEmulMask.at(iBit)) {
747  m_fdlDataEmulAlgoDecisionMask[histIndex][iRec]->Fill(iBit);
748  }
749  }
750  }
751 
752  }
753 
754  // get extended algorithms bits (extended decision word)
755  const DecisionWordExtended gtDecisionWordExtendedData =
756  fdlBlockData.gtDecisionWordExtended();
757  const DecisionWordExtended gtDecisionWordExtendedEmul =
758  fdlBlockEmul.gtDecisionWordExtended();
759 
760  if (gtDecisionWordExtendedData == gtDecisionWordExtendedEmul) {
761  m_myCoutStream << "\n" << recString
762  << " Data and emulated FDL gtDecisionWordExtended identical.\n";
764  m_myCoutStream << "\n";
765 
766  }
767  else {
768  m_myCoutStream << "\n" << recString
769  << " Data and emulated FDL gtDecisionWordExtended different.\n";
770  m_myCoutStream << "\n Data: ";
772  m_myCoutStream << "\n Emul: ";
774  m_myCoutStream << "\n";
775 
776  if (matchBxInEvent && validBxInEvent) {
777  m_fdlDataEmul[histIndex][iRec]->Fill(8);
778  }
779  else {
780  m_fdlDataEmul_Err[iRec]->Fill(8);
781  }
782 
783  }
784 
785  // get NoAlgo
786  const boost::uint16_t noAlgoData = fdlBlockData.noAlgo();
787  const boost::uint16_t noAlgoEmul = fdlBlockEmul.noAlgo();
788 
789  if (noAlgoData == noAlgoEmul) {
790  m_myCoutStream << "\n" << recString
791  << " Data and emulated FDL noAlgo identical.";
792  m_myCoutStream << "\n noAlgo() = " << noAlgoData;
793  m_myCoutStream << "\n";
794 
795  }
796  else {
797  m_myCoutStream << "\n" << recString
798  << " Data and emulated FDL noAlgo different.";
799  m_myCoutStream << "\n Data: noAlgo() = " << noAlgoData;
800  m_myCoutStream << "\n Emul: noAlgo() = " << noAlgoEmul;
801  m_myCoutStream << "\n";
802 
803  if (matchBxInEvent && validBxInEvent) {
804  m_fdlDataEmul[histIndex][iRec]->Fill(9);
805  }
806  else {
807  m_fdlDataEmul_Err[iRec]->Fill(9);
808  }
809 
810  }
811 
812  // get "Final OR" bits
813  const boost::uint16_t finalORData = fdlBlockData.finalOR();
814  const boost::uint16_t finalOREmul = fdlBlockEmul.finalOR();
815 
816  if (finalORData == finalOREmul) {
817  m_myCoutStream << "\n" << recString
818  << " Data and emulated FDL finalOR identical.";
819  m_myCoutStream << "\n finalOR() = " << std::hex << "0x" << std::setw(2)
820  << std::setfill('0') << finalORData << std::setfill(' ')
821  << std::dec;
822  m_myCoutStream << "\n";
823 
824  }
825  else {
826  m_myCoutStream << "\n" << recString
827  << " Data and emulated FDL finalOR different.";
828  m_myCoutStream << "\n Data: finalOR() = " << std::hex << "0x"
829  << std::setw(2) << std::setfill('0') << finalORData
830  << std::setfill(' ') << std::dec;
831  m_myCoutStream << "\n Emul: finalOR() = " << std::hex << "0x"
832  << std::setw(2) << std::setfill('0') << finalOREmul
833  << std::setfill(' ') << std::dec;
834  m_myCoutStream << "\n";
835 
836  if (matchBxInEvent && validBxInEvent) {
837  m_fdlDataEmul[histIndex][iRec]->Fill(10);
838  }
839  else {
840  m_fdlDataEmul_Err[iRec]->Fill(10);
841  }
842 
843  }
844 
845  // get "Final OR" for physics partition
846  const int finalORPhysData = finalORData & (1 << PhysicsPartition);
847  const int finalORPhysEmul = finalOREmul & (1 << PhysicsPartition);
848 
849  if (finalORPhysData == finalORPhysEmul) {
850  m_myCoutStream << "\n" << recString
851  << " Data and emulated FDL finalOR for the physics partition identical.";
852  m_myCoutStream << "\n finalOR() = " << finalORPhysData;
853  m_myCoutStream << "\n";
854 
855  }
856  else {
857  m_myCoutStream << "\n" << recString
858  << " Data and emulated FDL finalOR for the physics partition different.";
859  m_myCoutStream << "\n Data: finalOR() = " << finalORPhysData;
860  m_myCoutStream << "\n Emul: finalOR() = " << finalORPhysEmul;
861  m_myCoutStream << "\n";
862 
863  if (matchBxInEvent && validBxInEvent) {
864  m_fdlDataEmul[histIndex][iRec]->Fill(11);
865  }
866  else {
867  m_fdlDataEmul_Err[iRec]->Fill(11);
868  }
869 
870  }
871 
872  // get local bunch cross number of the actual bx
873  const boost::uint16_t localBxNrData = fdlBlockData.localBxNr();
874  const boost::uint16_t localBxNrEmul = fdlBlockEmul.localBxNr();
875 
876  if (localBxNrData == localBxNrEmul) {
877  m_myCoutStream << "\n" << recString
878  << " Data and emulated FDL localBxNr identical.";
879  m_myCoutStream << "\n localBxNr() = " << localBxNrData;
880  m_myCoutStream << "\n";
881 
882  }
883  else {
884  m_myCoutStream << "\n" << recString
885  << " Data and emulated FDL localBxNr different.";
886  m_myCoutStream << "\n Data: localBxNr() = " << localBxNrData;
887  m_myCoutStream << "\n Emul: localBxNr() = " << localBxNrEmul;
888  m_myCoutStream << "\n";
889 
890  if (matchBxInEvent && validBxInEvent) {
891  m_fdlDataEmul[histIndex][iRec]->Fill(12);
892  }
893  else {
894  m_fdlDataEmul_Err[iRec]->Fill(12);
895  }
896 
897  }
898 
899  edm::LogInfo("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
900  m_myCoutStream.str("");
901  m_myCoutStream.clear();
902 
903 }
904 
905 //compare the PSB board
907  const edm::EventSetup& evSetup, const L1GtPsbWord& psbBlockData,
908  const L1GtPsbWord& psbBlockEmul) {
909 
910  if (psbBlockData == psbBlockEmul) {
911  m_myCoutStream << "\nData and emulated PSB blocks: identical.\n";
912  psbBlockData.print(m_myCoutStream);
913 
914  }
915  else {
916  m_myCoutStream << "\nData and emulated PSB blocks: different.\n";
917 
918  m_myCoutStream << "\nData: PSB block\n";
919  psbBlockData.print(m_myCoutStream);
920 
921  m_myCoutStream << "\nEmul: PSB block\n";
922  psbBlockEmul.print(m_myCoutStream);
923 
924  }
925 
926  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
927 
928  m_myCoutStream.str("");
929  m_myCoutStream.clear();
930 
931  // get BoardId value
932  const boost::uint16_t boardIdData = psbBlockData.boardId();
933  const boost::uint16_t boardIdEmul = psbBlockEmul.boardId();
934 
935  if (boardIdData == boardIdEmul) {
936  m_myCoutStream << "\nData and emulated PSB boardId identical.";
937  m_myCoutStream << "\n boardId() = " << std::hex << "0x" << std::setw(4)
938  << std::setfill('0') << boardIdData << std::setfill(' ')
939  << std::dec;
940  m_myCoutStream << "\n";
941 
942  }
943  else {
944  m_myCoutStream << "\nData and emulated PSB boardId different.";
945  m_myCoutStream << "\n Data: boardId() = " << std::hex << "0x"
946  << std::setw(4) << std::setfill('0') << boardIdData
947  << std::setfill(' ') << std::dec;
948  m_myCoutStream << "\n Emul: boardId() = " << std::hex << "0x"
949  << std::setw(4) << std::setfill('0') << boardIdEmul
950  << std::setfill(' ') << std::dec;
951  m_myCoutStream << "\n";
952 
953  }
954 
955  // get bunch cross in the GT event record
956  const int bxInEventData = psbBlockData.bxInEvent();
957  const int bxInEventEmul = psbBlockEmul.bxInEvent();
958 
959  if (bxInEventData == bxInEventEmul) {
960  m_myCoutStream << "\nData and emulated PSB bxInEvent identical.";
961  m_myCoutStream << "\n bxInEvent() = " << bxInEventData;
962  m_myCoutStream << "\n";
963 
964  }
965  else {
966  m_myCoutStream << "\nData and emulated PSB bxInEvent different.";
967  m_myCoutStream << "\n Data: bxInEvent() = " << bxInEventData;
968  m_myCoutStream << "\n Emul: bxInEvent() = " << bxInEventEmul;
969  m_myCoutStream << "\n";
970 
971  }
972 
973  // get BxNr - bunch cross number of the actual bx
974  const boost::uint16_t bxNrData = psbBlockData.bxNr();
975  const boost::uint16_t bxNrEmul = psbBlockEmul.bxNr();
976 
977  if (bxNrData == bxNrEmul) {
978  m_myCoutStream << "\nData and emulated PSB bxNr identical.";
979  m_myCoutStream << "\n bxNr() = " << bxNrData;
980  m_myCoutStream << "\n";
981 
982  }
983  else {
984  m_myCoutStream << "\nData and emulated PSB bxNr different.";
985  m_myCoutStream << "\n Data: bxNr() = " << bxNrData;
986  m_myCoutStream << "\n Emul: bxNr() = " << bxNrEmul;
987  m_myCoutStream << "\n";
988 
989  }
990 
991  // get event number since last L1 reset generated in FDL
992  const boost::uint32_t eventNrData = psbBlockData.eventNr();
993  const boost::uint32_t eventNrEmul = psbBlockEmul.eventNr();
994 
995  if (eventNrData == eventNrEmul) {
996  m_myCoutStream << "\nData and emulated PSB eventNr identical.";
997  m_myCoutStream << "\n eventNr() = " << eventNrData;
998  m_myCoutStream << "\n";
999 
1000  }
1001  else {
1002  m_myCoutStream << "\nData and emulated PSB eventNr different.";
1003  m_myCoutStream << "\n Data: eventNr() = " << eventNrData;
1004  m_myCoutStream << "\n Emul: eventNr() = " << eventNrEmul;
1005  m_myCoutStream << "\n";
1006 
1007  }
1008 
1010  boost::uint16_t valData;
1011  boost::uint16_t valEmul;
1012 
1013  for (int iA = 0; iA < psbBlockData.NumberAData; ++iA) {
1014  valData = psbBlockData.aData(iA);
1015  valEmul = psbBlockEmul.aData(iA);
1016 
1017  if (valData == valEmul) {
1018  m_myCoutStream << "\nData and emulated PSB aData(" << iA
1019  << ") identical.";
1020  m_myCoutStream << "\n aData(iA) = " << std::hex << "0x"
1021  << std::setw(4) << std::setfill('0') << valData
1022  << std::setfill(' ') << std::dec;
1023  m_myCoutStream << "\n";
1024 
1025  }
1026  else {
1027  m_myCoutStream << "\nData and emulated PSB aData(" << iA
1028  << ") different.";
1029  m_myCoutStream << "\n Data: aData(iA) = " << std::hex << "0x"
1030  << std::setw(4) << std::setfill('0') << valData
1031  << std::setfill(' ') << std::dec;
1032  m_myCoutStream << "\n Emul: aData(iA) = "<< std::hex << "0x"
1033  << std::setw(4) << std::setfill('0') << valEmul
1034  << std::setfill(' ') << std::dec;
1035  m_myCoutStream << "\n";
1036 
1037  }
1038 
1039  }
1040 
1042  for (int iB = 0; iB < psbBlockData.NumberBData; ++iB) {
1043  valData = psbBlockData.bData(iB);
1044  valEmul = psbBlockEmul.bData(iB);
1045 
1046  if (valData == valEmul) {
1047  m_myCoutStream << "\nData and emulated PSB bData(" << iB
1048  << ") identical.";
1049  m_myCoutStream << "\n bData(iA) = " << std::hex << "0x"
1050  << std::setw(4) << std::setfill('0') << valData
1051  << std::setfill(' ') << std::dec;
1052  m_myCoutStream << "\n";
1053 
1054  }
1055  else {
1056  m_myCoutStream << "\nData and emulated PSB bData(" << iB
1057  << ") different.";
1058  m_myCoutStream << "\n Data: bData(iA) = " << std::hex << "0x"
1059  << std::setw(4) << std::setfill('0') << valData
1060  << std::setfill(' ') << std::dec;
1061  m_myCoutStream << "\n Emul: bData(iA) = "<< std::hex << "0x"
1062  << std::setw(4) << std::setfill('0') << valEmul
1063  << std::setfill(' ') << std::dec;
1064  m_myCoutStream << "\n";
1065 
1066  }
1067 
1068  }
1069 
1070  // get local bunch cross number of the actual bx
1071  const boost::uint16_t localBxNrData = psbBlockData.localBxNr();
1072  const boost::uint16_t localBxNrEmul = psbBlockEmul.localBxNr();
1073 
1074  if (localBxNrData == localBxNrEmul) {
1075  m_myCoutStream << "\nData and emulated PSB localBxNr identical.";
1076  m_myCoutStream << "\n localBxNr() = " << localBxNrData;
1077  m_myCoutStream << "\n";
1078 
1079  }
1080  else {
1081  m_myCoutStream << "\nData and emulated PSB localBxNr different.";
1082  m_myCoutStream << "\n Data: localBxNr() = " << localBxNrData;
1083  m_myCoutStream << "\n Emul: localBxNr() = " << localBxNrEmul;
1084  m_myCoutStream << "\n";
1085 
1086  }
1087 
1088  edm::LogInfo("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
1089  m_myCoutStream.str("");
1090  m_myCoutStream.clear();
1091 
1092 }
1093 
1094 //compare the TCS board
1096  const edm::EventSetup& evSetup, const L1TcsWord&, const L1TcsWord&) {
1097  // empty
1098 }
1099 
1100 //L1 GT DAQ record comparison
1102  const edm::EventSetup& evSetup) {
1103 
1104  // formal index for DAQ record
1105  int iRec = 0;
1106 
1107  // get the L1 GT hardware DAQ record L1GlobalTriggerReadoutRecord
1108  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
1109  iEvent.getByLabel(m_l1GtDataInputTag, gtReadoutRecordData);
1110 
1111  bool validData = false;
1112 
1113  if (!gtReadoutRecordData.isValid()) {
1115  }
1116  else {
1117  validData = true;
1118  }
1119 
1120  // get the L1 GT emulator DAQ record L1GlobalTriggerReadoutRecord
1121  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordEmul;
1122  iEvent.getByLabel(m_l1GtEmulInputTag, gtReadoutRecordEmul);
1123 
1124  bool validEmul = false;
1125 
1126  if (!gtReadoutRecordEmul.isValid()) {
1128  }
1129  else {
1130  validEmul = true;
1131  }
1132 
1133  if ((!validData) || (!validEmul)) {
1134  edm::LogWarning("L1GtDataEmulAnalyzer") << "\n Valid data:"
1135  << validData << "\n Valid emulator:" << validEmul << std::endl;
1136  }
1137 
1138  // compare GTFE
1139  const L1GtfeWord& gtfeBlockData = gtReadoutRecordData->gtfeWord();
1140  const L1GtfeWord& gtfeBlockEmul = gtReadoutRecordEmul->gtfeWord();
1141 
1142  compareGTFE(iEvent, evSetup, gtfeBlockData, gtfeBlockEmul);
1143 
1144  // FDL comparison
1145  const std::vector<L1GtFdlWord>& gtFdlVectorData =
1146  gtReadoutRecordData->gtFdlVector();
1147  const std::vector<L1GtFdlWord>& gtFdlVectorEmul =
1148  gtReadoutRecordEmul->gtFdlVector();
1149 
1150  int gtFdlVectorDataSize = gtFdlVectorData.size();
1151  int gtFdlVectorEmulSize = gtFdlVectorEmul.size();
1152 
1153  if (gtFdlVectorDataSize == gtFdlVectorEmulSize) {
1154  m_myCoutStream << "\nData and emulated FDL vector size: identical.\n";
1155  m_myCoutStream << " Size: " << gtFdlVectorDataSize << std::endl;
1156 
1157  for (int iFdl = 0; iFdl < gtFdlVectorDataSize; ++iFdl) {
1158 
1159  const L1GtFdlWord& fdlBlockData = gtFdlVectorData[iFdl];
1160  const L1GtFdlWord& fdlBlockEmul = gtFdlVectorEmul[iFdl];
1161 
1162  compareFDL(iEvent, evSetup, fdlBlockData, fdlBlockEmul, iRec);
1163  }
1164  }
1165  else {
1166  m_myCoutStream << "\nData and emulated FDL vector size: different.\n";
1167  m_myCoutStream << " Data: size = " << gtFdlVectorDataSize << std::endl;
1168  m_myCoutStream << " Emul: size = " << gtFdlVectorEmulSize << std::endl;
1169 
1170  }
1171 
1172  LogDebug("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
1173 
1174  m_myCoutStream.str("");
1175  m_myCoutStream.clear();
1176 
1177  // PSB comparison
1178  const std::vector<L1GtPsbWord>& gtPsbVectorData =
1179  gtReadoutRecordData->gtPsbVector();
1180  const std::vector<L1GtPsbWord>& gtPsbVectorEmul =
1181  gtReadoutRecordEmul->gtPsbVector();
1182 
1183  int gtPsbVectorDataSize = gtPsbVectorData.size();
1184  int gtPsbVectorEmulSize = gtPsbVectorEmul.size();
1185 
1186  if (gtPsbVectorDataSize == gtPsbVectorEmulSize) {
1187  m_myCoutStream << "\nData and emulated PSB vector size: identical.\n";
1188  m_myCoutStream << " Size: " << gtPsbVectorDataSize << std::endl;
1189  }
1190  else {
1191  m_myCoutStream << "\nData and emulated PSB vector size: different.\n";
1192  m_myCoutStream << " Data: size = " << gtPsbVectorDataSize << std::endl;
1193  m_myCoutStream << " Emul: size = " << gtPsbVectorEmulSize << std::endl;
1194 
1195  }
1196 
1197  // the order of PSB block in the gtPsbVector is different in emulator and in data
1198  // in emulator: all active PSB in one BxInEvent, ordered L1A-1, L1A, L1A+1
1199  // in unpacker: every PSB in all BxInEvent
1200  for (int iPsb = 0; iPsb < gtPsbVectorDataSize; ++iPsb) {
1201 
1202  const L1GtPsbWord& psbBlockData = gtPsbVectorData[iPsb];
1203  const boost::uint16_t boardIdData = psbBlockData.boardId();
1204  const int bxInEventData = psbBlockData.bxInEvent();
1205 
1206  // search the corresponding PSB in the emulated record using the
1207  // BoardId and the BxInEvent
1208 
1209  bool foundPSB = false;
1210 
1211  for (int iPsbF = 0; iPsbF < gtPsbVectorEmulSize; ++iPsbF) {
1212 
1213  const L1GtPsbWord& psbBlockEmul = gtPsbVectorEmul[iPsbF];
1214  const boost::uint16_t boardIdEmul = psbBlockEmul.boardId();
1215  const int bxInEventEmul = psbBlockEmul.bxInEvent();
1216 
1217  if ((boardIdEmul == boardIdData)
1218  && (bxInEventData == bxInEventEmul)) {
1219 
1220  foundPSB = true;
1221 
1222  // compare the boards
1223  comparePSB(iEvent, evSetup, psbBlockData, psbBlockEmul);
1224  }
1225 
1226  }
1227 
1228  if (!foundPSB) {
1229  m_myCoutStream << "\nNo emulated PSB with boardId() = " << std::hex
1230  << "0x" << std::setw(4) << std::setfill('0') << boardIdData
1231  << std::setfill(' ') << std::dec << " and BxInEvent = "
1232  << bxInEventData << " was found";
1233 
1234  }
1235 
1236  }
1237 
1238  edm::LogInfo("L1GtDataEmulAnalyzer") << m_myCoutStream.str() << std::endl;
1239 
1240  m_myCoutStream.str("");
1241  m_myCoutStream.clear();
1242 
1243 }
1244 
1245 // L1 GT EVM record comparison
1247  const edm::EventSetup&) {
1248 
1249  // FIXME
1250 
1251 }
1252 
1253 // compare the GCT collections obtained from L1 GT PSB with the input
1254 // GCT collections
1256  const edm::EventSetup&) {
1257 
1258  // FIXME
1259 
1260 }
1261 
1262 // analyze each event: event loop
1264  const edm::EventSetup& evSetup) {
1265 
1266  // L1 GT DAQ record comparison
1267  compareDaqRecord(iEvent, evSetup);
1268 
1269  // L1 GT EVM record comparison
1270  compareEvmRecord(iEvent, evSetup);
1271 
1272  // GCT collections from L1 GT PSB versus unpacked GCT
1273  compareGt_Gct(iEvent, evSetup);
1274 
1275 }
1276 
1277 // book all histograms for the module
1279  // histogram service
1280  edm::Service<TFileService> histServ;
1281 
1282  // histograms
1283 
1284  // GTFE histograms
1285  TFileDirectory gtfeHist = histServ->mkdir("GTFE");
1286  m_gtfeDataEmul = gtfeHist.make<TH1F>("gtfeDataEmul", "GTFE data vs emul",
1287  6, 0., 6.);
1288  m_gtfeDataEmul->GetXaxis()->SetBinLabel(1, "BoardId");
1289  m_gtfeDataEmul->GetXaxis()->SetBinLabel(2, "RecordLength");
1290  m_gtfeDataEmul->GetXaxis()->SetBinLabel(3, "BxNr");
1291  m_gtfeDataEmul->GetXaxis()->SetBinLabel(4, "SetupVersion");
1292  m_gtfeDataEmul->GetXaxis()->SetBinLabel(5, "DaqActiveBoards");
1293  m_gtfeDataEmul->GetXaxis()->SetBinLabel(6, "TotalTriggerNr");
1294 
1295  // FDL histograms
1296 
1297  TFileDirectory fdlHist = histServ->mkdir("FDL");
1298 
1299  const unsigned int numberTechTriggers =
1301 
1302  const unsigned int numberAlgoTriggers =
1304 
1305  for (int iRec = 0; iRec < 2; ++iRec) {
1306 
1307  std::string recString;
1308  if (iRec == 0) {
1309  recString = "Daq";
1310  }
1311  else {
1312  recString = "Evm";
1313  }
1314 
1315  std::string hName;
1316  const char* histName;
1317 
1318  for (int iHist = 0; iHist < TotalBxInEvent; ++iHist) {
1319 
1320  // convert [0, TotalBxInEvent] to [-X, +X] and add to histogram name
1321  int iIndex = iHist - ((TotalBxInEvent + 1)/2 -1);
1322  int hIndex = (iIndex + 16)%16;
1323 
1324  std::stringstream ss;
1325  std::string str;
1326  ss << std::uppercase << std::hex << hIndex;
1327  ss >> str;
1328 
1329  hName = recString + "FdlDataEmul_" + str;
1330  histName = hName.c_str();
1331 
1332  std::string hTitle = "FDL data vs emul mismatch for BxInEvent = "
1333  + str;
1334  const char* histTitle = hTitle.c_str();
1335 
1336  //
1337 
1338  m_fdlDataEmul[iHist][iRec] = fdlHist.make<TH1F>(histName, histTitle,
1339  13, 0., 13.);
1340  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(1, "BoardId");
1341  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(2, "BxInEvent");
1342  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(3, "BxNr");
1343  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(4, "EventNr");
1344  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(5, "TechTrigger");
1345  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(6, "TechTriggerMask");
1346  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(7, "AlgoTrigger");
1347  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(8, "AlgoTriggerMask");
1348  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(9, "AlgoExtend");
1349  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(10, "NoAlgo");
1350  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(11, "FinalORAllParts");
1351  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(12, "FinalORPhysPart");
1352  m_fdlDataEmul[iHist][iRec]->GetXaxis()->SetBinLabel(13, "LocalBxNr");
1353 
1354  // algorithm decision
1355  // data
1356  hName = recString + "FdlDataAlgoDecision_" + str;
1357  histName = hName.c_str();
1358 
1359  hTitle = "Data: algorithm decision word for BxInEvent = " + str;
1360  histTitle = hTitle.c_str();
1361 
1362  m_fdlDataAlgoDecision[iHist][iRec] = fdlHist.make<TH1F>(histName,
1363  histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
1364 
1365  // emul
1366  hName = recString + "FdlEmulAlgoDecision_" + str;
1367  histName = hName.c_str();
1368 
1369  hTitle = "Emul: algorithm decision word for BxInEvent = " + str;
1370  histTitle = hTitle.c_str();
1371 
1372  m_fdlEmulAlgoDecision[iHist][iRec] = fdlHist.make<TH1F>(histName,
1373  histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
1374 
1375  // algorithm decision after masking (partition physics)
1376  // data
1377  hName = recString + "FdlDataAlgoDecisionMask_" + str;
1378  histName = hName.c_str();
1379 
1380  hTitle
1381  = "Data, physics partition: algorithm decision word after mask for BxInEvent = "
1382  + str;
1383  histTitle = hTitle.c_str();
1384 
1385  m_fdlDataAlgoDecisionMask[iHist][iRec] = fdlHist.make<TH1F>(histName,
1386  histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
1387 
1388  // emul
1389  hName = recString + "FdlEmulAlgoDecisionMask_" + str;
1390  histName = hName.c_str();
1391 
1392  hTitle
1393  = "Emul, physics partition: algorithm decision word after mask for BxInEvent = "
1394  + str;
1395  histTitle = hTitle.c_str();
1396 
1397  m_fdlEmulAlgoDecisionMask[iHist][iRec] = fdlHist.make<TH1F>(histName,
1398  histTitle, numberAlgoTriggers, 0., numberAlgoTriggers);
1399 
1400  //
1401  hName = recString + "FdlDataEmulAlgoDecision_" + str;
1402  histName = hName.c_str();
1403 
1404  hTitle
1405  = "Data vs emul: non-matching algorithm decision word for BxInEvent = "
1406  + str;
1407  histTitle = hTitle.c_str();
1408 
1409  m_fdlDataEmulAlgoDecision[iHist][iRec] = fdlHist.make<TH1F>(
1410  histName, histTitle, numberAlgoTriggers, 0.,
1411  numberAlgoTriggers);
1412 
1413  //
1414  hName = recString + "FdlDataEmulAlgoDecisionMask_" + str;
1415  histName = hName.c_str();
1416 
1417  hTitle
1418  = "Data vs emul, physics partition: non-matching algorithm decision word after mask for BxInEvent = "
1419  + str;
1420  histTitle = hTitle.c_str();
1421 
1422  m_fdlDataEmulAlgoDecisionMask[iHist][iRec] = fdlHist.make<TH1F>(
1423  histName, histTitle, numberAlgoTriggers, 0.,
1424  numberAlgoTriggers);
1425 
1426  // technical trigger decision
1427  // data
1428  hName = recString + "FdlDataTechDecision_" + str;
1429  histName = hName.c_str();
1430 
1431  hTitle = "Data technical trigger decision word for BxInEvent = "
1432  + str;
1433  histTitle = hTitle.c_str();
1434 
1435  m_fdlDataTechDecision[iHist][iRec] = fdlHist.make<TH1F>(histName,
1436  histTitle, numberTechTriggers, 0., numberTechTriggers);
1437 
1438  // emul
1439  hName = recString + "FdlEmulTechDecision_" + str;
1440  histName = hName.c_str();
1441 
1442  hTitle = "Emul: technical trigger decision word for BxInEvent = "
1443  + str;
1444  histTitle = hTitle.c_str();
1445 
1446  m_fdlEmulTechDecision[iHist][iRec] = fdlHist.make<TH1F>(histName,
1447  histTitle, numberTechTriggers, 0., numberTechTriggers);
1448 
1449  // technical trigger decision after masking (partition physics)
1450  hName = recString + "FdlDataTechDecisionMask_" + str;
1451  histName = hName.c_str();
1452 
1453  hTitle
1454  = "Data technical trigger decision word after mask for BxInEvent = "
1455  + str;
1456  histTitle = hTitle.c_str();
1457 
1458  m_fdlDataTechDecisionMask[iHist][iRec] = fdlHist.make<TH1F>(histName,
1459  histTitle, numberTechTriggers, 0., numberTechTriggers);
1460 
1461  //
1462  hName = recString + "FdlEmulTechDecisionMask_" + str;
1463  histName = hName.c_str();
1464 
1465  hTitle
1466  = "Emul: technical trigger decision word after mask for BxInEvent = "
1467  + str;
1468  histTitle = hTitle.c_str();
1469 
1470  m_fdlEmulTechDecisionMask[iHist][iRec] = fdlHist.make<TH1F>(histName,
1471  histTitle, numberTechTriggers, 0., numberTechTriggers);
1472 
1473  //
1474  hName = recString + "FdlDataEmulTechDecision_" + str;
1475  histName = hName.c_str();
1476 
1477  hTitle
1478  = "Data vs emul: non-matching technical trigger decision word for BxInEvent = "
1479  + str;
1480  histTitle = hTitle.c_str();
1481 
1482  m_fdlDataEmulTechDecision[iHist][iRec] = fdlHist.make<TH1F>(
1483  histName, histTitle, numberTechTriggers, 0.,
1484  numberTechTriggers);
1485 
1486  hName = recString + "FdlDataEmulTechDecisionMask_" + str;
1487  histName = hName.c_str();
1488 
1489  hTitle
1490  = "Data vs emul: non-matching technical trigger decision word after mask for BxInEvent = "
1491  + str;
1492  histTitle = hTitle.c_str();
1493 
1494  m_fdlDataEmulTechDecisionMask[iHist][iRec] = fdlHist.make<TH1F>(
1495  histName, histTitle, numberTechTriggers, 0.,
1496  numberTechTriggers);
1497 
1498  }
1499 
1500  hName = recString + "FdlDataEmul_Err";
1501  histName = hName.c_str();
1502 
1503  m_fdlDataEmul_Err[iRec] = fdlHist.make<TH1F>(histName,
1504  "FDL data vs emul: non-matching BxInEvent", 13, 0., 13.);
1505  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(1, "BoardId");
1506  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(2, "BxInEvent");
1507  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(3, "BxNr");
1508  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(4, "EventNr");
1509  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(5, "TechTrigger");
1510  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(6, "TechTriggerMask");
1511  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(7, "AlgoTrigger");
1512  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(8, "AlgoTriggerMask");
1513  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(9, "AlgoExtend");
1514  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(10, "NoAlgo");
1515  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(11, "FinalORAllParts");
1516  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(12, "FinalORPhysPart");
1517  m_fdlDataEmul_Err[iRec]->GetXaxis()->SetBinLabel(13, "LocalBxNr");
1518 
1519  hName = recString + "FdlDataAlgoDecision_Err";
1520  histName = hName.c_str();
1521 
1523  = fdlHist.make<TH1F>(
1524  histName,
1525  "Data: algorithm trigger decision word, non-matching BxInEvent",
1526  numberAlgoTriggers, 0., numberAlgoTriggers);
1527 
1528  //
1529  hName = recString + "FdlEmulAlgoDecision_Err";
1530  histName = hName.c_str();
1531 
1533  = fdlHist.make<TH1F>(
1534  histName,
1535  "Emul: algorithm trigger decision word, non-matching BxInEvent",
1536  numberAlgoTriggers, 0., numberAlgoTriggers);
1537 
1538  hName = recString + "FdlDataEmulAlgoDecision_Err";
1539  histName = hName.c_str();
1540 
1542  = fdlHist.make<TH1F>(
1543  histName,
1544  "Data vs emul: algorithm trigger decision word, non-matching BxInEvent",
1545  numberAlgoTriggers, 0., numberAlgoTriggers);
1546 
1547  //
1548  hName = recString + "FdlDataTechDecision_Err";
1549  histName = hName.c_str();
1550 
1552  = fdlHist.make<TH1F>(
1553  histName,
1554  "Data: technical trigger decision word, non-matching BxInEvent",
1555  numberTechTriggers, 0., numberTechTriggers);
1556 
1557  hName = recString + "FdlEmulTechDecision_Err";
1558  histName = hName.c_str();
1559 
1561  = fdlHist.make<TH1F>(
1562  histName,
1563  "Emul: technical trigger decision word, non-matching BxInEvent",
1564  numberTechTriggers, 0., numberTechTriggers);
1565 
1566  hName = recString + "FdlDataEmulTechDecision_Err";
1567  histName = hName.c_str();
1568 
1570  = fdlHist.make<TH1F>(
1571  histName,
1572  "Data vs emul: technical trigger decision word, non-matching BxInEvent",
1573  numberTechTriggers, 0., numberTechTriggers);
1574 
1575  }
1576 }
1577 
1578 // method called once each job just after ending the event loop
1580 
1581  // empty
1582 
1583 }
1584 
#define LogDebug(id)
T getParameter(std::string const &) const
const cms_uint16_t bData(int iB) const
get/set B_DATA_CH_IB
Definition: L1GtPsbWord.cc:323
TH1F * m_gtfeDataEmul
histograms
const cms_uint16_t bxNr() const
get/set bunch cross number of the actual bx
Definition: L1GtPsbWord.h:108
const TechnicalTriggerWord & gtTechnicalTriggerWord() const
get/set technical trigger bits
Definition: L1GtFdlWord.h:149
const cms_uint16_t boardId() const
get/set board ID
Definition: L1GtPsbWord.h:66
const cms_uint16_t noAlgo() const
get/set NoAlgo
Definition: L1GtFdlWord.h:286
TH1F * m_fdlEmulTechDecision[TotalBxInEvent][2]
virtual void compareTCS(const edm::Event &, const edm::EventSetup &, const L1TcsWord &, const L1TcsWord &)
compare the TCS board
TH1F * m_fdlDataEmul[TotalBxInEvent][2]
FDL (0 for DAQ, 1 for EVM record)
virtual void print(std::ostream &myCout) const
pretty print the content of a L1GtfeWord
Definition: L1GtfeWord.cc:321
TH1F * m_fdlEmulAlgoDecision[TotalBxInEvent][2]
std::vector< unsigned int > m_triggerMaskTechTrig
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
static const unsigned int NumberTechnicalTriggers
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
const L1GtfeWord gtfeWord() const
get / set GTFE word (record) in the GT readout record
virtual void compareDaqRecord(const edm::Event &, const edm::EventSetup &)
L1 GT DAQ record comparison.
const std::vector< L1GtPsbWord > gtPsbVector() const
get the vector of L1GtPsbWord
TH1F * m_fdlDataEmulAlgoDecisionMask[TotalBxInEvent][2]
unsigned long long m_l1GtTmTechCacheID
virtual void compareGTFE(const edm::Event &, const edm::EventSetup &, const L1GtfeWord &, const L1GtfeWord &)
compare the GTFE board
L1GtDataEmulAnalyzer(const edm::ParameterSet &)
TH1F * m_fdlEmulAlgoDecisionMask[TotalBxInEvent][2]
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
const cms_uint16_t bxNr() const
get/set BxNr - bunch cross number of the actual bx
Definition: L1GtFdlWord.h:110
const cms_uint16_t boardId() const
get/set board ID
Definition: L1GtFdlWord.h:69
void printGtDecisionWord(std::ostream &myCout) const
Definition: L1GtFdlWord.cc:345
const cms_uint16_t recordLength() const
get/set record length for alternative 0
Definition: L1GtfeWord.h:104
const cms_uint32_t eventNr() const
get/set event number since last L1 reset generated in FDL
Definition: L1GtFdlWord.h:130
std::vector< bool > DecisionWordExtended
virtual void analyze(const edm::Event &, const edm::EventSetup &)
analyze each event
int iEvent
Definition: GenABIO.cc:230
virtual void endJob()
end of job
const cms_uint16_t aData(int iA) const
get/set A_DATA_CH_IA
Definition: L1GtPsbWord.cc:228
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
std::vector< bool > DecisionWord
typedefs
TH1F * m_fdlDataEmulTechDecisionMask[TotalBxInEvent][2]
const int bxInEvent() const
get/set bunch cross in the GT event record
Definition: L1GtFdlWord.h:90
const cms_uint32_t totalTriggerNr() const
get/set total number of L1A sent since start of run
Definition: L1GtfeWord.h:211
void printGtDecisionWordExtended(std::ostream &myCout) const
Definition: L1GtFdlWord.cc:503
edm::InputTag m_l1GtEmulInputTag
input tag for the L1 GT emulator DAQ/EVM record
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
static const unsigned int NumberPhysTriggers
T * make(const Args &...args) const
make new ROOT object
void bookHistograms()
book all histograms for the module
std::ostringstream m_myCoutStream
const cms_uint16_t localBxNr() const
get/set local bunch cross number of the actual bx
Definition: L1GtPsbWord.h:178
bool isValid() const
Definition: HandleBase.h:74
TH1F * m_fdlDataAlgoDecisionMask[TotalBxInEvent][2]
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:464
const cms_uint16_t activeBoards() const
get/set boards contributing to EVM respectively DAQ record
Definition: L1GtfeWord.h:163
TH1F * m_fdlEmulTechDecisionMask[TotalBxInEvent][2]
const L1GtTriggerMenu * m_l1GtMenu
trigger menu
const cms_uint16_t bxNr() const
get/set bunch cross number as counted in the GTFE board
Definition: L1GtfeWord.h:122
std::vector< unsigned int > m_triggerMaskAlgoTrig
TH1F * m_fdlDataEmulTechDecision[TotalBxInEvent][2]
void print(std::ostream &myCout) const
pretty print the content of a L1GtFdlWord
Definition: L1GtFdlWord.cc:766
void print(std::ostream &myCout) const
pretty print
Definition: L1GtPsbWord.cc:453
const L1GtTriggerMask * m_l1GtTmAlgo
trigger masks
const cms_uint16_t boardId() const
get/set board ID
Definition: L1GtfeWord.h:65
const cms_uint32_t eventNr() const
get/set event number since last L1 reset generated in PSB
Definition: L1GtPsbWord.h:129
TH1F * m_fdlDataAlgoDecision[TotalBxInEvent][2]
static const int TotalBxInEvent
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
static const int NumberBData
Definition: L1GtPsbWord.h:35
const T & get() const
Definition: EventSetup.h:55
TH1F * m_fdlDataEmulAlgoDecision[TotalBxInEvent][2]
const int bxInEvent() const
get/set bunch cross in the GT event record
Definition: L1GtPsbWord.h:87
const DecisionWord & gtDecisionWord() const
get/set/print algorithms bits (decision word)
Definition: L1GtFdlWord.h:171
virtual void compareGt_Gct(const edm::Event &, const edm::EventSetup &)
edm::InputTag m_l1GtDataInputTag
input tag for the L1 GT hardware DAQ/EVM record
static const int NumberAData
Definition: L1GtPsbWord.h:34
unsigned long long m_l1GtMenuCacheID
TH1F * m_fdlDataTechDecisionMask[TotalBxInEvent][2]
void printGtTechnicalTriggerWord(std::ostream &myCout) const
Definition: L1GtFdlWord.cc:271
virtual void compareFDL(const edm::Event &, const edm::EventSetup &, const L1GtFdlWord &, const L1GtFdlWord &, const int)
compare the FDL board
const cms_uint32_t setupVersion() const
get/set setup version
Definition: L1GtfeWord.h:140
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
virtual void compareEvmRecord(const edm::Event &, const edm::EventSetup &)
L1 GT EVM record comparison.
const DecisionWordExtended & gtDecisionWordExtended() const
get/set extended algorithms bits (extended decision word)
Definition: L1GtFdlWord.h:203
const L1GtTriggerMask * m_l1GtTmTech
TH1F * m_fdlDataTechDecision[TotalBxInEvent][2]
T const * product() const
Definition: ESHandle.h:86
unsigned long long m_l1GtTmAlgoCacheID
edm::InputTag m_l1GctDataInputTag
input tag for the L1 GCT hardware record
virtual void comparePSB(const edm::Event &, const edm::EventSetup &, const L1GtPsbWord &, const L1GtPsbWord &)
compare the PSB board
const cms_uint16_t localBxNr() const
get/set local bunch cross number of the actual bx
Definition: L1GtFdlWord.h:372
const cms_uint16_t finalOR() const
get/set "Final OR" bits
Definition: L1GtFdlWord.h:306