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