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 = 1.;
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 (it->type() < 4)
437  sysncand[0]->Fill(ccid);
438  if (it->type() < 5 && it->type() != 3)
439  sysncand[1]->Fill(ccid);
440 
441  errortype[ccid]->Fill(type);
442 
443  wei = 1.;
444  if (!type)
445  wei = 0.;
446  if (etav != nullVal && phiv != nullVal)
447  etaphi[ccid]->Fill(etav, phiv, wei);
448  if (etav != nullVal)
449  eta[ccid]->Fill(etav, wei);
450  if (phiv != nullVal)
451  phi[ccid]->Fill(phiv, wei);
452  rnk[ccid]->Fill(rnkv, wei);
453 
454  //exclude e-only cands (only data)
455  wei = 1.;
456  if (type == 4)
457  wei = 0.;
458  if (etav != nullVal)
459  etaData[ccid]->Fill(etav, wei);
460  if (phiv != nullVal)
461  phiData[ccid]->Fill(phiv, wei);
462  rnkData[ccid]->Fill(rnkv, wei);
463  wei = 1;
464 
465  // GCT trigger bits
466  unsigned int word[2];
467  it->data(word);
468  std::bitset<32> dbits(word[0]);
469  std::bitset<32> ebits(word[1]);
470  unsigned int dexor = ((word[0]) ^ (word[1]));
471  //disagreeing bits
472  std::bitset<32> debits(dexor);
473  //disagreeing bits after masking
474  std::bitset<32> dembits(((dexor) & (mask)));
475 
476  if (verbose())
477  std::cout << "l1degct"
478  << " sid:" << sid << " cid:" << cid << "\n"
479  << " data:0x" << std::hex << word[0] << std::dec << " bitset:" << dbits << "\n"
480  << " emul:0x" << std::hex << word[1] << std::dec << " bitset:" << ebits << "\n"
481  << " xor:0x" << std::hex << dexor << std::dec << " bitset:" << debits
482  << " bitset:" << ((dbits) ^ (ebits)) << "\n"
483  << std::flush;
484 
486  for (int ibit = 0; ibit < 32; ibit++) {
487  wei = 1.;
488  //comparison gives no info if there's only 1 candidate
489  if (type == 3 || type == 4)
490  wei = 0.;
491  if (dbits[ibit])
492  dword[ccid]->Fill(ibit, wei);
493  if (ebits[ibit])
494  eword[ccid]->Fill(ibit, wei);
495  if (debits[ibit])
496  deword[ccid]->Fill(ibit, wei);
497  //if(dembits[ibit])masked[sid]->Fill(ibit,wei);
498  }
499  wei = 1;
500  }
501 
502  //error rates per GCT trigger object type
503  int hasCol[nGctColl_] = {0};
504  int nagree[nGctColl_] = {0};
505  for (L1DEDigiCollection::const_iterator it = gctColl.begin(); it != gctColl.end(); it++) {
506  int ccid = it->cid() - dedefs::GCTisolaem;
507  ccid = (ccid < 0 || ccid >= nGctColl_) ? 0 : ccid;
508  hasCol[ccid]++;
509  if (!it->type())
510  nagree[ccid]++;
511  }
512  for (int i = 0; i < nGctColl_; i++) {
513  if (!hasCol[i])
514  continue;
516  //nWithCol[i]++;
517  //if(nagree[i]<hasCol[i]) colCount[i]++;
519  nWithCol[i] += hasCol[i]; //#of objects
520  colCount[i] += nagree[i]; //#of agreements
521  }
522  for (int i = 0; i < nGctColl_; i++) {
523  int ibin = i + 1;
524  double rate = nWithCol[i] ? 1. - 1. * colCount[i] / nWithCol[i] : 0.;
525  sysrates->setBinContent(ibin, rate);
526  if (verbose()) {
527  std::cout << "[L1TDEMON] analyze rate computation\t\n"
528  << " colid:" << i << "(so far)"
529  << " nWithCol: " << nWithCol[i] << " colCount: " << colCount[i] << "(this event)"
530  << "hasCol: " << hasCol[i] << " nagree: " << nagree[i] << " rate:" << sysrates->getBinContent(ibin)
531  << "\n"
532  << std::flush;
533  if (rate > 1. || rate < 0.)
534  std::cout << "problem, error rate for " << SystLabel[i] << " is " << sysrates->getBinContent(ibin) << "\n"
535  << std::flush;
536  }
537  }
538  }
539 
540  if (m_stage1_layer2_ == true) {
541  bool isComp = deRecord->get_isComp(GCT);
542  if (!isComp) {
543  if (verbose())
544  std::cout << "[L1TdeGCT] Gct information not generated in de-record."
545  << " Skiping event!\n"
546  << std::flush;
547  return;
548  }
549 
550  int DEncand[2] = {0};
551  for (int j = 0; j < 2; j++)
552  DEncand[j] = deRecord->getNCand(GCT, j);
553 
554  if (verbose())
555  std::cout << "[L1TdeGCT] ncands"
556  << " data: " << DEncand[0] << " emul: " << DEncand[1] << std::endl;
557 
559  L1DEDigiCollection deColl;
560  deColl = deRecord->getColl();
561 
562  // extract the GCT comparison digis
563  L1DEDigiCollection stage1layer2Coll;
564 
565  stage1layer2Coll.reserve(21);
566  stage1layer2Coll.clear();
567 
568  for (L1DEDigiCollection::const_iterator it = deColl.begin(); it != deColl.end(); it++)
569  if (!it->empty())
570  if (it->sid() == GCT)
571  stage1layer2Coll.push_back(*it);
572 
573  if (verbose()) {
574  std::cout << "[L1TdeSTAGE1LAYER2] record has " << stage1layer2Coll.size() << " stage1layer2 de digis\n"
575  << std::endl;
576  for (L1DEDigiCollection::const_iterator it = stage1layer2Coll.begin(); it != stage1layer2Coll.end(); it++)
577  std::cout << "\t" << *it << std::endl;
578  }
579 
580  const int nullVal = L1DataEmulDigi().reset();
581 
583 
584  // d|e candidate loop
585  for (L1DEDigiCollection::const_iterator it = stage1layer2Coll.begin(); it != stage1layer2Coll.end(); it++) {
586  // sid should be GCT
587  int sid = it->sid();
588 
589  int cid = it->cid();
591 
592  if (verbose())
593  std::cout << "[L1TdeStage1Layer2] processing digi "
594  << " sys:" << sid << " type:" << cid << " \n\t" << *it << "\n"
595  << std::endl;
596 
597  if (sid != GCT || it->empty()) {
598  LogDebug("L1TdeGCT") << "consistency check failure, non-stage1layer2 digis!";
599  continue;
600  }
601 
602  int type = it->type();
603  double phiv = it->x1();
604  double etav = it->x2();
605  float rankarr[2];
606  it->rank(rankarr);
607  float rnkv = rankarr[0];
608 
609  double wei = 1.;
610 
611  unsigned int mask = (~0x0);
612 
613  // shift coll type for starting at zero
614  int ccid = cid - dedefs::GCTisolaem;
615  if (ccid < 0 || ccid >= nStage1Layer2Coll_) {
616  LogDebug("L1TdeGCT") << "consistency check failure, col type outbounds:" << ccid << "\n";
617  ccid = 0;
618  }
619 
620  //type: 0:agree 1:loc.agree, 2:loc.disagree, 3:data.only, 4:emul.only
621  if (it->type() < 4)
622  sysncand[0]->Fill(ccid);
623  if (it->type() < 5 && it->type() != 3)
624  sysncand[1]->Fill(ccid);
625  errortype_stage1layer2[ccid]->Fill(type);
626  wei = 1.;
627  if (!type)
628  wei = 0.;
629  if (etav != nullVal && phiv != nullVal)
630  etaphi_stage1layer2[ccid]->Fill(etav, phiv, wei);
631  if (etav != nullVal)
632  eta_stage1layer2[ccid]->Fill(etav, wei);
633  if (phiv != nullVal)
634  phi_stage1layer2[ccid]->Fill(phiv, wei);
635  rnk_stage1layer2[ccid]->Fill(rnkv, wei);
636 
637  //exclude e-only cands (only data)
638  wei = 1.;
639  if (type == 4)
640  wei = 0.;
641  if (etav != nullVal)
642  etaData_stage1layer2[ccid]->Fill(etav, wei);
643  if (phiv != nullVal)
644  phiData_stage1layer2[ccid]->Fill(phiv, wei);
645  rnkData_stage1layer2[ccid]->Fill(rnkv, wei);
646  wei = 1;
647 
648  // GCT trigger bits
649  unsigned int word_stage1layer2[2];
650  it->data(word_stage1layer2);
651  std::bitset<32> dbits(word_stage1layer2[0]);
652  std::bitset<32> ebits(word_stage1layer2[1]);
653  unsigned int dexor = ((word_stage1layer2[0]) ^ (word_stage1layer2[1]));
654  //disagreeing bits
655  std::bitset<32> debits(dexor);
656  //disagreeing bits after masking
657  std::bitset<32> dembits(((dexor) & (mask)));
658 
659  if (verbose())
660  std::cout << "l1degct"
661  << " sid:" << sid << " cid:" << cid << "\n"
662  << " data:0x" << std::hex << word_stage1layer2[0] << std::dec << " bitset:" << dbits << "\n"
663  << " emul:0x" << std::hex << word_stage1layer2[1] << std::dec << " bitset:" << ebits << "\n"
664  << " xor:0x" << std::hex << dexor << std::dec << " bitset:" << debits
665  << " bitset:" << ((dbits) ^ (ebits)) << "\n"
666  << std::flush;
667 
669  for (int ibit = 0; ibit < 32; ibit++) {
670  wei = 1.;
671  //comparison gives no info if there's only 1 candidate
672  if (type == 3 || type == 4)
673  wei = 0.;
674  if (dbits[ibit])
675  dword_stage1layer2[ccid]->Fill(ibit, wei);
676  if (ebits[ibit])
677  eword_stage1layer2[ccid]->Fill(ibit, wei);
678  if (debits[ibit])
679  deword_stage1layer2[ccid]->Fill(ibit, wei);
680  //if(dembits[ibit])masked[sid]->Fill(ibit,wei);
681  }
682  wei = 1;
683  }
684  //error rates per GCT trigger object type
685  int hasCol[nStage1Layer2Coll_] = {0};
686  int nagree[nStage1Layer2Coll_] = {0};
687  for (L1DEDigiCollection::const_iterator it = stage1layer2Coll.begin(); it != stage1layer2Coll.end(); it++) {
688  int ccid = it->cid() - dedefs::GCTisolaem;
689  ccid = (ccid < 0 || ccid >= nStage1Layer2Coll_) ? 0 : ccid;
690  hasCol[ccid]++;
691  if (!it->type())
692  nagree[ccid]++;
693  }
694  for (int i = 0; i < nStage1Layer2Coll_; i++) {
695  if (!hasCol[i])
696  continue;
698  //nWithCol[i]++;
699  //if(nagree[i]<hasCol[i]) colCount[i]++;
701  nWithCol_stage1Layer2[i] += hasCol[i]; //#of objects
702  colCount_stage1Layer2[i] += nagree[i]; //#of agreements
703  }
704  for (int i = 0; i < nStage1Layer2Coll_; i++) {
705  int ibin = i + 1;
706  double rate = nWithCol_stage1Layer2[i] ? 1. - 1. * colCount_stage1Layer2[i] / nWithCol_stage1Layer2[i] : 0.;
707  sysrates->setBinContent(ibin, rate);
708  if (verbose()) {
709  std::cout << "[L1TDEMON] analyze rate computation\t\n"
710  << " colid:" << i << "(so far)"
711  << " nWithCol: " << nWithCol_stage1Layer2[i] << " colCount: " << colCount_stage1Layer2[i]
712  << "(this event)"
713  << "hasCol: " << hasCol[i] << " nagree: " << nagree[i] << " rate:" << sysrates->getBinContent(ibin)
714  << "\n"
715  << std::flush;
716  if (rate > 1. || rate < 0.)
717  std::cout << "problem, error rate for " << SystLabel[i] << " is " << sysrates->getBinContent(ibin) << "\n"
718  << std::flush;
719  }
720  }
721  }
722 }
dedefs::SystLabel
const std::string SystLabel[DEnsys]
Definition: DEtrait.h:42
L1DEDigiCollection
std::vector< L1DataEmulDigi > L1DEDigiCollection
Definition: DEtrait.h:101
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
edm::Run
Definition: Run.h:45
gather_cfg.cout
cout
Definition: gather_cfg.py:144
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
L1DataEmulRecord::getNCand
int getNCand(int i, int j) const
Definition: L1DataEmulRecord.h:41
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPCpg::rate
double rate(double x)
Definition: Constants.cc:3
edm::Handle
Definition: AssociativeIterator.h:50
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
L1DataEmulDigi
Definition: L1DataEmulDigi.h:17
dedefs::GCT
Definition: DEtrait.h:40
PVValHelper::eta
Definition: PVValidationHelpers.h:69
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
L1TdeGCT::~L1TdeGCT
~L1TdeGCT() override
Definition: L1TdeGCT.cc:35
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dedefs::GCTisolaem
Definition: DEtrait.h:55
metDiagnosticParameterSet_cfi.etaNBins
etaNBins
Definition: metDiagnosticParameterSet_cfi.py:12
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
L1TdeGCT::nGctColl_
static const int nGctColl_
Definition: L1TdeGCT.h:58
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
L1TdeGCT::L1TdeGCT
L1TdeGCT(const edm::ParameterSet &)
Definition: L1TdeGCT.cc:10
iEvent
int iEvent
Definition: GenABIO.cc:224
dqm::impl::MonitorElement::setBinLabel
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)
Definition: MonitorElement.cc:771
metDiagnosticParameterSet_cfi.phiNBins
phiNBins
Definition: metDiagnosticParameterSet_cfi.py:15
L1TdeGCT::bookHistograms
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override
Definition: L1TdeGCT.cc:37
L1TdeGCT::nerr
static const int nerr
Definition: L1TdeGCT.h:75
L1DataEmulDigi::reset
int reset()
Definition: L1DataEmulDigi.cc:13
edm::EventSetup
Definition: EventSetup.h:57
dedefs
Definition: DEtrait.h:36
L1DataEmulRecord::getColl
L1DEDigiCollection getColl() const
Definition: L1DataEmulRecord.h:39
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
L1TdeGCT::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1TdeGCT.cc:336
L1TdeGCT.h
L1DataEmulRecord::get_isComp
bool get_isComp(int i) const
Definition: L1DataEmulRecord.h:42
dqm::implementation::IBooker::book2D
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:177
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
L1TdeGCT::nStage1Layer2Coll_
static const int nStage1Layer2Coll_
Definition: L1TdeGCT.h:59
fastmath::etaphi
std::pair< T, T > etaphi(T x, T y, T z)
Definition: FastMath.h:162
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98