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