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