CMS 3D CMS Logo

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