CMS 3D CMS Logo

L1TdeGCT.cc
Go to the documentation of this file.
2 #include <bitset>
3 
4 using namespace dedefs;
5 
6 const int L1TdeGCT::nGctColl_;
7 const int L1TdeGCT::nerr;
9 
11  verbose_ = iConfig.getUntrackedParameter<int>("VerboseFlag", 0);
12 
13  if (verbose())
14  std::cout << "L1TdeGCT::L1TdeGCT()...\n" << std::flush;
15 
16  DEsource_ = consumes<L1DataEmulRecord>(iConfig.getParameter<edm::InputTag>("DataEmulCompareSource"));
17  histFolder_ = iConfig.getUntrackedParameter<std::string>("HistFolder");
18 
19  histFile_ = iConfig.getUntrackedParameter<std::string>("HistFile", "");
20  if (iConfig.getUntrackedParameter<bool>("disableROOToutput", true))
21  histFile_ = "";
22 
23  if (!histFile_.empty()) {
24  edm::LogInfo("OutputRootFile") << "L1TEmulator GCT specific histograms will be saved to " << histFile_.c_str()
25  << std::endl;
26  }
27 
28  hasRecord_ = true;
29 
30  if (verbose())
31  std::cout << "L1TdeGCT::L1TdeGCT()...done.\n" << std::flush;
32  m_stage1_layer2_ = iConfig.getParameter<bool>("stage1_layer2_");
33 }
34 
36 
38  int rnkNBins = 63;
39  double rnkMinim = 0.5;
40  double rnkMaxim = 63.5;
41 
42  if (verbose())
43  std::cout << "L1TdeGCT::beginRun() start\n" << std::flush;
44 
45  ibooker.setCurrentFolder(histFolder_);
46  //for Legacy GCT
47  if (m_stage1_layer2_ == false) {
48  sysrates = ibooker.book1D("sysrates", "RATE OF COMPARISON FAILURES", nGctColl_, 0, nGctColl_);
49 
50  for (int j = 0; j < 2; j++) {
51  std::string lbl("sysncand");
52  lbl += (j == 0 ? "Data" : "Emul");
53  std::string title("GCT OBJECT MULTIPLICITY ");
54  title += (j == 0 ? "(DATA)" : "(EMULATOR)");
55  sysncand[j] = ibooker.book1D(lbl.data(), title.data(), nGctColl_, 0, nGctColl_);
56  }
57 
58  for (int j = 0; j < nGctColl_; j++) {
59  ibooker.setCurrentFolder(std::string(histFolder_ + "/" + cLabel[j]));
60 
61  std::string lbl("");
62  std::string title("");
63  lbl.clear();
64  title.clear();
65  lbl += cLabel[j];
66  lbl += "ErrorFlag";
67  title += cLabel[j];
68  title += " ErrorFlag";
69  errortype[j] = ibooker.book1D(lbl.data(), title.data(), nerr, 0, nerr);
70 
71  lbl.clear();
72  title.clear();
73  lbl += cLabel[j];
74  lbl += "Eta";
75  title += cLabel[j];
76  title += " ETA OF COMPARISON FAILURES";
77  eta[j] = ibooker.book1D(lbl.data(), title.data(), etaNBins, etaMinim, etaMaxim);
78  lbl.clear();
79  title.clear();
80  lbl += cLabel[j];
81  lbl += "Phi";
82  title += cLabel[j];
83  title += " PHI OF COMPARISON FAILURES";
84  phi[j] = ibooker.book1D(lbl.data(), title.data(), phiNBins, phiMinim, phiMaxim);
85 
86  lbl.clear();
87  title.clear();
88  lbl += cLabel[j];
89  lbl += "Etaphi";
90  title += cLabel[j];
91  title += " ETA PHI OF COMPARISON FAILURES";
92  etaphi[j] = ibooker.book2D(lbl.data(), title.data(), etaNBins, etaMinim, etaMaxim, phiNBins, phiMinim, phiMaxim);
93  lbl.clear();
94  title.clear();
95  lbl += cLabel[j];
96  lbl += "Rank";
97  title += cLabel[j];
98  title += " RANK OF COMPARISON FAILURES";
99  rnk[j] = ibooker.book1D(lbl.data(), title.data(), rnkNBins, rnkMinim, rnkMaxim);
100  //
101  lbl.clear();
102  title.clear();
103  lbl += cLabel[j];
104  lbl += "Eta";
105  lbl += "Data";
106  title += cLabel[j];
107  title += " ETA (DATA)";
108  etaData[j] = ibooker.book1D(lbl.data(), title.data(), etaNBins, etaMinim, etaMaxim);
109  lbl.clear();
110  title.clear();
111  lbl += cLabel[j];
112  lbl += "Phi";
113  lbl += "Data";
114  title += cLabel[j];
115  title += " PHI (DATA)";
116  phiData[j] = ibooker.book1D(lbl.data(), title.data(), phiNBins, phiMinim, phiMaxim);
117 
118  lbl.clear();
119  title.clear();
120  lbl += cLabel[j];
121  lbl += "Rank";
122  lbl += "Data";
123  title += cLabel[j];
124  title += " RANK (DATA)";
125  rnkData[j] = ibooker.book1D(lbl.data(), title.data(), rnkNBins, rnkMinim, rnkMaxim);
126  lbl.clear();
127  lbl += cLabel[j];
128  lbl += "Dword";
129  dword[j] = ibooker.book1D(lbl.data(), lbl.data(), nbit, 0, nbit);
130  lbl.clear();
131  lbl += cLabel[j];
132  lbl += "Eword";
133  eword[j] = ibooker.book1D(lbl.data(), lbl.data(), nbit, 0, nbit);
134  lbl.clear();
135  lbl += cLabel[j];
136  lbl += "DEword";
137  deword[j] = ibooker.book1D(lbl.data(), lbl.data(), nbit, 0, nbit);
138  //lbl.clear();
139  //lbl+=cLabel[j];lbl+="Masked";
140  //masked[j] = dbe->book1D(lbl.data(),lbl.data(),nbit,0,nbit);
141  }
142 
143  for (int i = 0; i < nGctColl_; i++) {
144  sysrates->setBinLabel(i + 1, cLabel[i]);
145  sysncand[0]->setBinLabel(i + 1, cLabel[i]);
146  sysncand[1]->setBinLabel(i + 1, cLabel[i]);
147  }
148 
149  for (int i = 0; i < nGctColl_; i++) {
150  for (int j = 0; j < nerr; j++) {
151  errortype[i]->setBinLabel(j + 1, errLabel[j]);
152  }
153  }
154 
155  for (int i = 0; i < nGctColl_; i++) {
156  etaphi[i]->setAxisTitle("GCT #eta", 1);
157  etaphi[i]->setAxisTitle("GCT #phi", 2);
158  eta[i]->setAxisTitle("GCT #eta");
159  phi[i]->setAxisTitle("GCT #phi");
160  rnk[i]->setAxisTitle("Rank");
161  etaData[i]->setAxisTitle("GCT #eta");
162  phiData[i]->setAxisTitle("GCT #phi");
163  rnkData[i]->setAxisTitle("Rank");
164  dword[i]->setAxisTitle("trigger data word bit");
165  eword[i]->setAxisTitle("trigger data word bit");
166  deword[i]->setAxisTitle("trigger data word bit");
167  }
168 
169  for (int i = 0; i < nGctColl_; i++) {
170  colCount[i] = 0;
171  nWithCol[i] = 0;
172  }
173  }
174 
175  // for stage 1 layer 2
176 
177  if (m_stage1_layer2_ == true) {
178  sysrates = ibooker.book1D("sysrates", "RATE OF COMPARISON FAILURES", nStage1Layer2Coll_, 0, nStage1Layer2Coll_);
179 
180  for (int j = 0; j < 2; j++) {
181  std::string lbl("sysncand");
182  lbl += (j == 0 ? "Data" : "Emul");
183  std::string title("Stage1Layer2 OBJECT MULTIPLICITY ");
184  title += (j == 0 ? "(DATA)" : "(EMULATOR)");
185  sysncand[j] = ibooker.book1D(lbl.data(), title.data(), nStage1Layer2Coll_, 0, nStage1Layer2Coll_);
186  }
187 
188  for (int j = 0; j < nStage1Layer2Coll_; j++) {
189  ibooker.setCurrentFolder(std::string(histFolder_ + "/" + sLabel[j]));
190 
191  if (sLabel[j] == "MHT") {
192  rnkNBins = 127;
193  rnkMinim = 0.5;
194  rnkMaxim = 127.5;
195  }
196 
197  if ((sLabel[j] == "HT") || (sLabel[j] == "ET") || (sLabel[j] == "MET")) {
198  rnkNBins = 4096;
199  rnkMinim = -0.5;
200  rnkMaxim = 4095.5;
201  }
202 
203  if (sLabel[j] == "Stage1HFSums") {
204  rnkNBins = 9;
205  rnkMinim = -0.5;
206  rnkMaxim = 8.5;
207  }
208 
209  if (sLabel[j] == "IsoTauJet") {
210  rnkNBins = 64;
211  rnkMinim = -0.5;
212  rnkMaxim = 63.5;
213  }
214 
215  std::string lbl("");
216  std::string title("");
217  lbl.clear();
218  title.clear();
219  lbl += sLabel[j];
220  lbl += "ErrorFlag";
221  title += sLabel[j];
222  title += " ErrorFlag";
223  errortype_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), nerr, 0, nerr);
224 
225  lbl.clear();
226  title.clear();
227  lbl += sLabel[j];
228  lbl += "Eta";
229  title += sLabel[j];
230  title += " ETA OF COMPARISON FAILURES";
231  eta_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), etaNBins, etaMinim, etaMaxim);
232  lbl.clear();
233  title.clear();
234  lbl += sLabel[j];
235  lbl += "Phi";
236  title += sLabel[j];
237  title += " PHI OF COMPARISON FAILURES";
238  phi_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), phiNBins, phiMinim, phiMaxim);
239 
240  lbl.clear();
241  title.clear();
242  lbl += sLabel[j];
243  lbl += "Etaphi";
244  title += sLabel[j];
245  title += " ETA PHI OF COMPARISON FAILURES";
246  etaphi_stage1layer2[j] =
247  ibooker.book2D(lbl.data(), title.data(), etaNBins, etaMinim, etaMaxim, phiNBins, phiMinim, phiMaxim);
248  lbl.clear();
249  title.clear();
250  lbl += sLabel[j];
251  lbl += "Rank";
252  title += sLabel[j];
253  title += " RANK OF COMPARISON FAILURES";
254  rnk_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), rnkNBins, rnkMinim, rnkMaxim);
255  //
256  lbl.clear();
257  title.clear();
258  lbl += sLabel[j];
259  lbl += "Eta";
260  lbl += "Data";
261  title += sLabel[j];
262  title += " ETA (DATA)";
263  etaData_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), etaNBins, etaMinim, etaMaxim);
264  lbl.clear();
265  title.clear();
266  lbl += sLabel[j];
267  lbl += "Phi";
268  lbl += "Data";
269  title += sLabel[j];
270  title += " PHI (DATA)";
271  phiData_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), phiNBins, phiMinim, phiMaxim);
272 
273  lbl.clear();
274  title.clear();
275  lbl += sLabel[j];
276  lbl += "Rank";
277  lbl += "Data";
278  title += sLabel[j];
279  title += " RANK (DATA)";
280  rnkData_stage1layer2[j] = ibooker.book1D(lbl.data(), title.data(), rnkNBins, rnkMinim, rnkMaxim);
281  lbl.clear();
282  lbl += sLabel[j];
283  lbl += "Dword";
284  dword_stage1layer2[j] = ibooker.book1D(lbl.data(), lbl.data(), nbit, 0, nbit);
285  lbl.clear();
286  lbl += sLabel[j];
287  lbl += "Eword";
288  eword_stage1layer2[j] = ibooker.book1D(lbl.data(), lbl.data(), nbit, 0, nbit);
289  lbl.clear();
290  lbl += sLabel[j];
291  lbl += "DEword";
292  deword_stage1layer2[j] = ibooker.book1D(lbl.data(), lbl.data(), nbit, 0, nbit);
293  //lbl.clear();
294  //lbl+=cLabel[j];lbl+="Masked";
295  //masked_stage1layer2[j] = dbe->book1D(lbl.data(),lbl.data(),nbit,0,nbit);
296  }
297 
298  for (int i = 0; i < nStage1Layer2Coll_; i++) {
299  sysrates->setBinLabel(i + 1, sLabel[i]);
300  sysncand[0]->setBinLabel(i + 1, sLabel[i]);
301  sysncand[1]->setBinLabel(i + 1, sLabel[i]);
302  }
303 
304  for (int i = 0; i < nStage1Layer2Coll_; i++) {
305  for (int j = 0; j < nerr; j++) {
306  errortype_stage1layer2[i]->setBinLabel(j + 1, errLabel[j]);
307  }
308  }
309 
310  for (int i = 0; i < nStage1Layer2Coll_; i++) {
311  etaphi_stage1layer2[i]->setAxisTitle("Stage1Layer2 #eta", 1);
312  etaphi_stage1layer2[i]->setAxisTitle("Stage1Layer2 #phi", 2);
313  eta_stage1layer2[i]->setAxisTitle("Stage1Layer2 #eta");
314  phi_stage1layer2[i]->setAxisTitle("Stage1Layer2 #phi");
315  rnk_stage1layer2[i]->setAxisTitle("Rank");
316  etaData_stage1layer2[i]->setAxisTitle("Stage1Layer2 #eta");
317  phiData_stage1layer2[i]->setAxisTitle("Stage1Layer2 #phi");
318  rnkData_stage1layer2[i]->setAxisTitle("Rank");
319  dword_stage1layer2[i]->setAxisTitle("trigger data word bit");
320  eword_stage1layer2[i]->setAxisTitle("trigger data word bit");
321  deword_stage1layer2[i]->setAxisTitle("trigger data word bit");
322  }
323 
324  for (int i = 0; i < nStage1Layer2Coll_; i++) {
325  colCount_stage1Layer2[i] = 0;
326  nWithCol_stage1Layer2[i] = 0;
327  }
328  }
329 
330  if (verbose())
331  std::cout << "L1TdeGCT::beginJob() end.\n" << std::flush;
332 }
333 
334 // ------------ method called to for each event ------------
335 
336 void L1TdeGCT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
337  if (!hasRecord_)
338  return;
339 
340  if (verbose())
341  std::cout << "L1TdeGCT::analyze() start\n" << std::flush;
342 
345  iEvent.getByToken(DEsource_, deRecord);
346 
347  if (!deRecord.isValid()) {
348  edm::LogInfo("DataNotFound") << "Cannot find L1DataEmulRecord"
349  << " Please verify that comparator was successfully executed."
350  << " Emulator DQM for GCT will be skipped!" << std::endl;
351  hasRecord_ = false;
352  return;
353  }
354 
355  if (m_stage1_layer2_ == false) {
356  bool isComp = deRecord->get_isComp(GCT);
357  if (!isComp) {
358  if (verbose())
359  std::cout << "[L1TdeGCT] Gct information not generated in de-record."
360  << " Skiping event!\n"
361  << std::flush;
362  return;
363  }
364 
365  int DEncand[2] = {0};
366  for (int j = 0; j < 2; j++)
367  DEncand[j] = deRecord->getNCand(GCT, j);
368 
369  if (verbose())
370  std::cout << "[L1TdeGCT] ncands"
371  << " data: " << DEncand[0] << " emul: " << DEncand[1] << std::endl;
372 
374  L1DEDigiCollection deColl;
375  deColl = deRecord->getColl();
376 
377  // extract the GCT comparison digis
378  L1DEDigiCollection gctColl;
379 
380  gctColl.reserve(20);
381  gctColl.clear();
382 
383  for (L1DEDigiCollection::const_iterator it = deColl.begin(); it != deColl.end(); it++)
384  if (!it->empty())
385  if (it->sid() == GCT)
386  gctColl.push_back(*it);
387 
388  if (verbose()) {
389  std::cout << "[L1TdeGCT] record has " << gctColl.size() << " gct de digis\n" << std::flush;
390  for (L1DEDigiCollection::const_iterator it = gctColl.begin(); it != gctColl.end(); it++)
391  std::cout << "\t" << *it << std::endl;
392  }
393 
394  const int nullVal = L1DataEmulDigi().reset();
395 
397 
398  // d|e candidate loop
399  for (L1DEDigiCollection::const_iterator it = gctColl.begin(); it != gctColl.end(); it++) {
400  // sid should be GCT
401  int sid = it->sid();
402  // cid: GCTisolaem, GCTnoisoem, GCTcenjets, GCTforjets, GCTtaujets
403  int cid = it->cid();
405 
406  if (verbose())
407  std::cout << "[L1TdeGCT] processing digi "
408  << " sys:" << sid << " type:" << cid << " \n\t" << *it << "\n"
409  << std::flush;
410 
411  //assert(cid==GCT);
412  if (sid != GCT || it->empty()) {
413  LogDebug("L1TdeGCT") << "consistency check failure, non-gct digis!";
414  continue;
415  }
416 
417  int type = it->type();
418  double phiv = it->x1();
419  double etav = it->x2();
420  float rankarr[2];
421  it->rank(rankarr);
422  float rnkv = rankarr[0];
423 
424  double wei;
425 
426  unsigned int mask = (~0x0);
427 
428  // shift coll type for starting at zero
429  int ccid = cid - dedefs::GCTisolaem;
430  if (ccid < 0 || ccid >= nGctColl_) {
431  LogDebug("L1TdeGCT") << "consistency check failure, col type outbounds:" << ccid << "\n";
432  ccid = 0;
433  }
434 
435  //type: 0:agree 1:loc.agree, 2:loc.disagree, 3:data.only, 4:emul.only
436  if (type < 4)
437  sysncand[0]->Fill(ccid);
438  if (type < 5 && type != 3)
439  sysncand[1]->Fill(ccid);
440 
441  errortype[ccid]->Fill(type);
442 
443  wei = (type == 0) ? 0. : 1.;
444  if (etav != nullVal && phiv != nullVal)
445  etaphi[ccid]->Fill(etav, phiv, wei);
446  if (etav != nullVal)
447  eta[ccid]->Fill(etav, wei);
448  if (phiv != nullVal)
449  phi[ccid]->Fill(phiv, wei);
450  rnk[ccid]->Fill(rnkv, wei);
451 
452  //exclude e-only cands (only data)
453  wei = (type == 4) ? 0. : 1.;
454  if (etav != nullVal)
455  etaData[ccid]->Fill(etav, wei);
456  if (phiv != nullVal)
457  phiData[ccid]->Fill(phiv, wei);
458  rnkData[ccid]->Fill(rnkv, wei);
459 
460  // GCT trigger bits
461  unsigned int word[2];
462  it->data(word);
463  std::bitset<32> dbits(word[0]);
464  std::bitset<32> ebits(word[1]);
465  unsigned int dexor = ((word[0]) ^ (word[1]));
466  //disagreeing bits
467  std::bitset<32> debits(dexor);
468  //disagreeing bits after masking
469  std::bitset<32> dembits(((dexor) & (mask)));
470 
471  if (verbose())
472  std::cout << "l1degct"
473  << " sid:" << sid << " cid:" << cid << "\n"
474  << " data:0x" << std::hex << word[0] << std::dec << " bitset:" << dbits << "\n"
475  << " emul:0x" << std::hex << word[1] << std::dec << " bitset:" << ebits << "\n"
476  << " xor:0x" << std::hex << dexor << std::dec << " bitset:" << debits
477  << " bitset:" << ((dbits) ^ (ebits)) << "\n"
478  << std::flush;
479 
481  for (int ibit = 0; ibit < 32; ibit++) {
482  //comparison gives no info if there's only 1 candidate
483  wei = (type == 3 || type == 4) ? 0. : 1.;
484  if (dbits[ibit])
485  dword[ccid]->Fill(ibit, wei);
486  if (ebits[ibit])
487  eword[ccid]->Fill(ibit, wei);
488  if (debits[ibit])
489  deword[ccid]->Fill(ibit, wei);
490  //if(dembits[ibit])masked[sid]->Fill(ibit,wei);
491  }
492  }
493 
494  //error rates per GCT trigger object type
495  int hasCol[nGctColl_] = {0};
496  int nagree[nGctColl_] = {0};
497  for (L1DEDigiCollection::const_iterator it = gctColl.begin(); it != gctColl.end(); it++) {
498  int ccid = it->cid() - dedefs::GCTisolaem;
499  ccid = (ccid < 0 || ccid >= nGctColl_) ? 0 : ccid;
500  hasCol[ccid]++;
501  if (!it->type())
502  nagree[ccid]++;
503  }
504  for (int i = 0; i < nGctColl_; i++) {
505  if (!hasCol[i])
506  continue;
508  //nWithCol[i]++;
509  //if(nagree[i]<hasCol[i]) colCount[i]++;
511  nWithCol[i] += hasCol[i]; //#of objects
512  colCount[i] += nagree[i]; //#of agreements
513  }
514  for (int i = 0; i < nGctColl_; i++) {
515  int ibin = i + 1;
516  double rate = nWithCol[i] ? 1. - 1. * colCount[i] / nWithCol[i] : 0.;
517  sysrates->setBinContent(ibin, rate);
518  if (verbose()) {
519  std::cout << "[L1TDEMON] analyze rate computation\t\n"
520  << " colid:" << i << "(so far)"
521  << " nWithCol: " << nWithCol[i] << " colCount: " << colCount[i] << "(this event)"
522  << "hasCol: " << hasCol[i] << " nagree: " << nagree[i] << " rate:" << sysrates->getBinContent(ibin)
523  << "\n"
524  << std::flush;
525  if (rate > 1. || rate < 0.)
526  std::cout << "problem, error rate for " << SystLabel[i] << " is " << sysrates->getBinContent(ibin) << "\n"
527  << std::flush;
528  }
529  }
530  }
531 
532  if (m_stage1_layer2_ == true) {
533  bool isComp = deRecord->get_isComp(GCT);
534  if (!isComp) {
535  if (verbose())
536  std::cout << "[L1TdeGCT] Gct information not generated in de-record."
537  << " Skiping event!\n"
538  << std::flush;
539  return;
540  }
541 
542  int DEncand[2] = {0};
543  for (int j = 0; j < 2; j++)
544  DEncand[j] = deRecord->getNCand(GCT, j);
545 
546  if (verbose())
547  std::cout << "[L1TdeGCT] ncands"
548  << " data: " << DEncand[0] << " emul: " << DEncand[1] << std::endl;
549 
551  L1DEDigiCollection deColl;
552  deColl = deRecord->getColl();
553 
554  // extract the GCT comparison digis
555  L1DEDigiCollection stage1layer2Coll;
556 
557  stage1layer2Coll.reserve(21);
558  stage1layer2Coll.clear();
559 
560  for (L1DEDigiCollection::const_iterator it = deColl.begin(); it != deColl.end(); it++)
561  if (!it->empty())
562  if (it->sid() == GCT)
563  stage1layer2Coll.push_back(*it);
564 
565  if (verbose()) {
566  std::cout << "[L1TdeSTAGE1LAYER2] record has " << stage1layer2Coll.size() << " stage1layer2 de digis\n"
567  << std::endl;
568  for (L1DEDigiCollection::const_iterator it = stage1layer2Coll.begin(); it != stage1layer2Coll.end(); it++)
569  std::cout << "\t" << *it << std::endl;
570  }
571 
572  const int nullVal = L1DataEmulDigi().reset();
573 
575 
576  // d|e candidate loop
577  for (L1DEDigiCollection::const_iterator it = stage1layer2Coll.begin(); it != stage1layer2Coll.end(); it++) {
578  // sid should be GCT
579  int sid = it->sid();
580 
581  int cid = it->cid();
583 
584  if (verbose())
585  std::cout << "[L1TdeStage1Layer2] processing digi "
586  << " sys:" << sid << " type:" << cid << " \n\t" << *it << "\n"
587  << std::endl;
588 
589  if (sid != GCT || it->empty()) {
590  LogDebug("L1TdeGCT") << "consistency check failure, non-stage1layer2 digis!";
591  continue;
592  }
593 
594  int type = it->type();
595  double phiv = it->x1();
596  double etav = it->x2();
597  float rankarr[2];
598  it->rank(rankarr);
599  float rnkv = rankarr[0];
600 
601  double wei;
602 
603  unsigned int mask = (~0x0);
604 
605  // shift coll type for starting at zero
606  int ccid = cid - dedefs::GCTisolaem;
607  if (ccid < 0 || ccid >= nStage1Layer2Coll_) {
608  LogDebug("L1TdeGCT") << "consistency check failure, col type outbounds:" << ccid << "\n";
609  ccid = 0;
610  }
611 
612  //type: 0:agree 1:loc.agree, 2:loc.disagree, 3:data.only, 4:emul.only
613  if (type < 4)
614  sysncand[0]->Fill(ccid);
615  if (type < 5 && type != 3)
616  sysncand[1]->Fill(ccid);
617  errortype_stage1layer2[ccid]->Fill(type);
618  wei = (type == 0) ? 0. : 1.;
619  if (etav != nullVal && phiv != nullVal)
620  etaphi_stage1layer2[ccid]->Fill(etav, phiv, wei);
621  if (etav != nullVal)
622  eta_stage1layer2[ccid]->Fill(etav, wei);
623  if (phiv != nullVal)
624  phi_stage1layer2[ccid]->Fill(phiv, wei);
625  rnk_stage1layer2[ccid]->Fill(rnkv, wei);
626 
627  //exclude e-only cands (only data)
628  wei = (type == 4) ? 0. : 1.;
629  if (etav != nullVal)
630  etaData_stage1layer2[ccid]->Fill(etav, wei);
631  if (phiv != nullVal)
632  phiData_stage1layer2[ccid]->Fill(phiv, wei);
633  rnkData_stage1layer2[ccid]->Fill(rnkv, wei);
634 
635  // GCT trigger bits
636  unsigned int word_stage1layer2[2];
637  it->data(word_stage1layer2);
638  std::bitset<32> dbits(word_stage1layer2[0]);
639  std::bitset<32> ebits(word_stage1layer2[1]);
640  unsigned int dexor = ((word_stage1layer2[0]) ^ (word_stage1layer2[1]));
641  //disagreeing bits
642  std::bitset<32> debits(dexor);
643  //disagreeing bits after masking
644  std::bitset<32> dembits(((dexor) & (mask)));
645 
646  if (verbose())
647  std::cout << "l1degct"
648  << " sid:" << sid << " cid:" << cid << "\n"
649  << " data:0x" << std::hex << word_stage1layer2[0] << std::dec << " bitset:" << dbits << "\n"
650  << " emul:0x" << std::hex << word_stage1layer2[1] << std::dec << " bitset:" << ebits << "\n"
651  << " xor:0x" << std::hex << dexor << std::dec << " bitset:" << debits
652  << " bitset:" << ((dbits) ^ (ebits)) << "\n"
653  << std::flush;
654 
656  for (int ibit = 0; ibit < 32; ibit++) {
657  //comparison gives no info if there's only 1 candidate
658  wei = (type == 3 || type == 4) ? 0. : 1.;
659  if (dbits[ibit])
660  dword_stage1layer2[ccid]->Fill(ibit, wei);
661  if (ebits[ibit])
662  eword_stage1layer2[ccid]->Fill(ibit, wei);
663  if (debits[ibit])
664  deword_stage1layer2[ccid]->Fill(ibit, wei);
665  //if(dembits[ibit])masked[sid]->Fill(ibit,wei);
666  }
667  }
668  //error rates per GCT trigger object type
669  int hasCol[nStage1Layer2Coll_] = {0};
670  int nagree[nStage1Layer2Coll_] = {0};
671  for (L1DEDigiCollection::const_iterator it = stage1layer2Coll.begin(); it != stage1layer2Coll.end(); it++) {
672  int ccid = it->cid() - dedefs::GCTisolaem;
673  ccid = (ccid < 0 || ccid >= nStage1Layer2Coll_) ? 0 : ccid;
674  hasCol[ccid]++;
675  if (!it->type())
676  nagree[ccid]++;
677  }
678  for (int i = 0; i < nStage1Layer2Coll_; i++) {
679  if (!hasCol[i])
680  continue;
682  //nWithCol[i]++;
683  //if(nagree[i]<hasCol[i]) colCount[i]++;
685  nWithCol_stage1Layer2[i] += hasCol[i]; //#of objects
686  colCount_stage1Layer2[i] += nagree[i]; //#of agreements
687  }
688  for (int i = 0; i < nStage1Layer2Coll_; i++) {
689  int ibin = i + 1;
690  double rate = nWithCol_stage1Layer2[i] ? 1. - 1. * colCount_stage1Layer2[i] / nWithCol_stage1Layer2[i] : 0.;
691  sysrates->setBinContent(ibin, rate);
692  if (verbose()) {
693  std::cout << "[L1TDEMON] analyze rate computation\t\n"
694  << " colid:" << i << "(so far)"
695  << " nWithCol: " << nWithCol_stage1Layer2[i] << " colCount: " << colCount_stage1Layer2[i]
696  << "(this event)"
697  << "hasCol: " << hasCol[i] << " nagree: " << nagree[i] << " rate:" << sysrates->getBinContent(ibin)
698  << "\n"
699  << std::flush;
700  if (rate > 1. || rate < 0.)
701  std::cout << "problem, error rate for " << SystLabel[i] << " is " << sysrates->getBinContent(ibin) << "\n"
702  << std::flush;
703  }
704  }
705  }
706 }
std::pair< T, T > etaphi(T x, T y, T z)
Definition: FastMath.h:162
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
bool verbose
std::vector< L1DataEmulDigi > L1DEDigiCollection
Definition: DEtrait.h:101
constexpr uint32_t mask
Definition: gpuClustering.h:26
static const int nGctColl_
Definition: L1TdeGCT.h:57
L1TdeGCT(const edm::ParameterSet &)
Definition: L1TdeGCT.cc:10
T getUntrackedParameter(std::string const &, T const &) const
uint64_t word
int iEvent
Definition: GenABIO.cc:224
L1DEDigiCollection getColl() const
bool get_isComp(int i) const
int getNCand(int i, int j) const
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
~L1TdeGCT() override
Definition: L1TdeGCT.cc:35
Log< level::Info, false > LogInfo
static const int nerr
Definition: L1TdeGCT.h:74
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
bool isValid() const
Definition: HandleBase.h:70
const std::string SystLabel[DEnsys]
Definition: DEtrait.h:42
double rate(double x)
Definition: Constants.cc:3
Definition: DEtrait.h:36
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1TdeGCT.cc:336
static const int nStage1Layer2Coll_
Definition: L1TdeGCT.h:58
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45
#define LogDebug(id)
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override
Definition: L1TdeGCT.cc:37