CMS 3D CMS Logo

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