4 using namespace dedefs;
14 std::cout <<
"L1TdeGCT::L1TdeGCT()...\n" << std::flush;
23 if (histFile_.size()!=0) {
25 <<
"L1TEmulator GCT specific histograms will be saved to "
33 std::cout <<
"L1TdeGCT::L1TdeGCT()...done.\n" << std::flush;
34 m_stage1_layer2_ = iConfig.
getParameter<
bool>(
"stage1_layer2_");
49 double rnkMinim = 0.5;
50 double rnkMaxim = 63.5;
54 std::cout <<
"L1TdeGCT::beginRun() start\n" << std::flush;
58 if (m_stage1_layer2_ ==
false) {
60 sysrates = ibooker.
book1D(
"sysrates",
"RATE OF COMPARISON FAILURES",nGctColl_, 0, nGctColl_ );
62 for(
int j=0;
j<2;
j++) {
64 lbl += (
j==0?
"Data":
"Emul");
66 title += (
j==0?
"(DATA)":
"(EMULATOR)");
67 sysncand[
j] = ibooker.
book1D(lbl.data(),title.data(),nGctColl_, 0, nGctColl_ );
70 for(
int j=0;
j<nGctColl_;
j++) {
78 lbl+=cLabel[
j];lbl+=
"ErrorFlag";
79 title+=cLabel[
j];title+=
" ErrorFlag";
80 errortype[
j] = ibooker.
book1D(lbl.data(),title.data(), nerr, 0, nerr);
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);
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);
97 lbl+=cLabel[
j];lbl+=
"Etaphi";
98 title+=cLabel[
j];title+=
" ETA PHI OF COMPARISON FAILURES";
100 etaNBins, etaMinim, etaMaxim,
101 phiNBins, phiMinim, phiMaxim
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);
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);
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);
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);
130 lbl+=cLabel[
j];lbl+=
"Dword";
131 dword[
j] = ibooker.
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
133 lbl+=cLabel[
j];lbl+=
"Eword";
134 eword[
j] = ibooker.
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
136 lbl+=cLabel[
j];lbl+=
"DEword";
137 deword[
j] = ibooker.
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
143 for(
int i=0;
i<nGctColl_;
i++) {
145 sysncand[0]->setBinLabel(i+1,cLabel[i]);
146 sysncand[1]->setBinLabel(i+1,cLabel[i]);
149 for(
int i=0;
i<nGctColl_;
i++) {
150 for(
int j=0;
j<nerr;
j++) {
151 errortype[
i]->setBinLabel(
j+1,errLabel[
j]);
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");
169 for(
int i=0;
i<nGctColl_;
i++) {
177 if (m_stage1_layer2_ ==
true) {
179 sysrates = ibooker.
book1D(
"sysrates",
"RATE OF COMPARISON FAILURES",nStage1Layer2Coll_, 0, nStage1Layer2Coll_ );
181 for(
int j=0;
j<2;
j++) {
183 lbl += (
j==0?
"Data":
"Emul");
185 title += (
j==0?
"(DATA)":
"(EMULATOR)");
186 sysncand[
j] = ibooker.
book1D(lbl.data(),title.data(),nStage1Layer2Coll_, 0, nStage1Layer2Coll_ );
189 for(
int j=0;
j<nStage1Layer2Coll_;
j++) {
193 if(sLabel[j]==
"MHT"){
199 if((sLabel[j]==
"HT")||(sLabel[j]==
"ET")||(sLabel[j]==
"MET")){
205 if(sLabel[j]==
"Stage1HFSums"){
211 if(sLabel[j]==
"IsoTauJet"){
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);
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);
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);
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);
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);
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);
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);
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);
272 lbl+=sLabel[
j];lbl+=
"Dword";
273 dword_stage1layer2[
j] = ibooker.
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
275 lbl+=sLabel[
j];lbl+=
"Eword";
276 eword_stage1layer2[
j] = ibooker.
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
278 lbl+=sLabel[
j];lbl+=
"DEword";
279 deword_stage1layer2[
j] = ibooker.
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
285 for(
int i=0;
i<nStage1Layer2Coll_;
i++) {
287 sysncand[0]->setBinLabel(i+1,sLabel[i]);
288 sysncand[1]->setBinLabel(i+1,sLabel[i]);
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]);
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");
311 for(
int i=0;
i<nStage1Layer2Coll_;
i++) {
312 colCount_stage1Layer2[
i]=0;
313 nWithCol_stage1Layer2[
i]=0;
318 std::cout <<
"L1TdeGCT::beginJob() end.\n" << std::flush;
330 std::cout <<
"L1TdeGCT::analyze() start\n" << std::flush;
338 <<
"Cannot find L1DataEmulRecord"
339 <<
" Please verify that comparator was successfully executed."
340 <<
" Emulator DQM for GCT will be skipped!"
346 if (m_stage1_layer2_ ==
false) {
347 bool isComp = deRecord->get_isComp(
GCT);
350 std::cout <<
"[L1TdeGCT] Gct information not generated in de-record."
351 <<
" Skiping event!\n" << std::flush;
356 for(
int j=0;
j<2;
j++)
357 DEncand[
j] = deRecord->getNCand(
GCT,
j);
361 <<
" data: " << DEncand[0]
362 <<
" emul: " << DEncand[1]
367 deColl = deRecord->getColl();
376 for(L1DEDigiCollection::const_iterator it=deColl.begin();
377 it!=deColl.end(); it++)
380 gctColl.push_back(*it);
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++)
395 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
396 it!=gctColl.end(); it++) {
405 std::cout <<
"[L1TdeGCT] processing digi "
413 if(sid!=
GCT || it->empty()) {
414 LogDebug(
"L1TdeGCT") <<
"consistency check failure, non-gct digis!";
418 int type = it->type();
419 double phiv = it->x1();
420 double etav = it->x2();
423 float rnkv = rankarr[0];
427 unsigned int mask = (~0x0);
431 if(ccid<0 || ccid >= nGctColl_) {
432 LogDebug(
"L1TdeGCT") <<
"consistency check failure, col type outbounds:"
439 sysncand[0]->
Fill(ccid);
440 if(it->type()<5&&it->type()!=3)
441 sysncand[1]->
Fill(ccid);
443 errortype[ccid]->Fill(type);
445 wei=1.;
if(!type) wei=0.;
446 if(etav!=nullVal && phiv!=nullVal)
447 etaphi[ccid]->Fill(etav,phiv,wei);
449 eta [ccid]->Fill(etav,wei);
451 phi [ccid]->Fill(phiv,wei);
452 rnk[ccid]->Fill(rnkv,wei);
455 wei=1.;
if(type==4) wei=0.;
457 etaData[ccid]->Fill(etav,wei);
459 phiData[ccid]->Fill(phiv,wei);
460 rnkData[ccid]->Fill(rnkv,wei);
464 unsigned int word[2];
466 std::bitset<32> dbits(word[0]);
467 std::bitset<32> ebits(word[1]);
468 unsigned int dexor = ( (word[0]) ^ (word[1]) );
470 std::bitset<32> debits(dexor);
472 std::bitset<32> dembits( ( (dexor) & (mask) ) );
476 <<
" sid:" << sid <<
" cid:" << cid <<
"\n"
477 <<
" data:0x" << std::hex << word[0] <<
std::dec
478 <<
" bitset:" << dbits
480 <<
" emul:0x" << std::hex << word[1] <<
std::dec
481 <<
" bitset:" << ebits
483 <<
" xor:0x" << std::hex << dexor <<
std::dec
484 <<
" bitset:" << debits
485 <<
" bitset:" << ( (dbits) ^ (ebits) )
486 <<
"\n" << std::flush;
489 for(
int ibit=0; ibit<32; ibit++) {
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);
503 int hasCol[nGctColl_]={0};
504 int nagree[nGctColl_]={0};
505 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
506 it!=gctColl.end(); it++) {
508 ccid = (ccid<0 || ccid >= nGctColl_) ? 0:ccid;
513 for(
int i=0;
i<nGctColl_;
i++) {
514 if(!hasCol[
i])
continue;
519 nWithCol[
i]+=hasCol[
i];
520 colCount[
i]+=nagree[
i];
522 for(
int i=0;
i<nGctColl_;
i++) {
524 double rate = nWithCol[
i] ? 1.-1.*colCount[
i]/nWithCol[
i]: 0.;
525 sysrates->setBinContent(ibin,rate);
527 std::cout <<
"[L1TDEMON] analyze rate computation\t\n"
530 <<
" nWithCol: " << nWithCol[
i]
531 <<
" colCount: " << colCount[
i]
533 <<
"hasCol: " << hasCol[
i]
534 <<
" nagree: " << nagree[
i]
535 <<
" rate:" << sysrates->getBinContent(ibin)
536 <<
"\n" << std::flush;
537 if(rate>1. || rate<0.)
539 <<
" is "<<sysrates->getBinContent(ibin)
540 <<
"\n" << std::flush;
545 if (m_stage1_layer2_ ==
true) {
546 bool isComp = deRecord->get_isComp(
GCT);
549 std::cout <<
"[L1TdeGCT] Gct information not generated in de-record."
550 <<
" Skiping event!\n" << std::flush;
555 for(
int j=0;
j<2;
j++)
556 DEncand[
j] = deRecord->getNCand(
GCT,
j);
560 <<
" data: " << DEncand[0]
561 <<
" emul: " << DEncand[1]
566 deColl = deRecord->getColl();
571 stage1layer2Coll.reserve(21);
572 stage1layer2Coll.
clear();
575 for(L1DEDigiCollection::const_iterator it=deColl.begin();
576 it!=deColl.end(); it++)
579 stage1layer2Coll.push_back(*it);
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++)
594 for(L1DEDigiCollection::const_iterator it=stage1layer2Coll.begin();
595 it!=stage1layer2Coll.end(); it++) {
604 std::cout <<
"[L1TdeStage1Layer2] processing digi "
611 if(sid!=
GCT || it->empty()) {
612 LogDebug(
"L1TdeGCT") <<
"consistency check failure, non-stage1layer2 digis!";
616 int type = it->type();
617 double phiv = it->x1();
618 double etav = it->x2();
621 float rnkv = rankarr[0];
625 unsigned int mask = (~0x0);
629 if(ccid<0 || ccid >= nStage1Layer2Coll_) {
630 LogDebug(
"L1TdeGCT") <<
"consistency check failure, col type outbounds:"
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);
645 eta_stage1layer2 [ccid]->Fill(etav,wei);
647 phi_stage1layer2 [ccid]->Fill(phiv,wei);
648 rnk_stage1layer2[ccid]->Fill(rnkv,wei);
651 wei=1.;
if(type==4) wei=0.;
653 etaData_stage1layer2[ccid]->Fill(etav,wei);
655 phiData_stage1layer2[ccid]->Fill(phiv,wei);
656 rnkData_stage1layer2[ccid]->Fill(rnkv,wei);
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]) );
666 std::bitset<32> debits(dexor);
668 std::bitset<32> dembits( ( (dexor) & (mask) ) );
672 <<
" sid:" << sid <<
" cid:" << cid <<
"\n"
673 <<
" data:0x" << std::hex << word_stage1layer2[0] <<
std::dec
674 <<
" bitset:" << dbits
676 <<
" emul:0x" << std::hex << word_stage1layer2[1] <<
std::dec
677 <<
" bitset:" << ebits
679 <<
" xor:0x" << std::hex << dexor <<
std::dec
680 <<
" bitset:" << debits
681 <<
" bitset:" << ( (dbits) ^ (ebits) )
682 <<
"\n" << std::flush;
685 for(
int ibit=0; ibit<32; ibit++) {
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);
698 int hasCol[nStage1Layer2Coll_]={0};
699 int nagree[nStage1Layer2Coll_]={0};
700 for(L1DEDigiCollection::const_iterator it=stage1layer2Coll.begin();
701 it!=stage1layer2Coll.end(); it++) {
703 ccid = (ccid<0 || ccid >= nStage1Layer2Coll_) ? 0:ccid;
708 for(
int i=0;
i<nStage1Layer2Coll_;
i++) {
709 if(!hasCol[
i])
continue;
714 nWithCol_stage1Layer2[
i]+=hasCol[
i];
715 colCount_stage1Layer2[
i]+=nagree[
i];
717 for(
int i=0;
i<nStage1Layer2Coll_;
i++) {
719 double rate = nWithCol_stage1Layer2[
i] ? 1.-1.*colCount_stage1Layer2[
i]/nWithCol_stage1Layer2[
i]: 0.;
720 sysrates->setBinContent(ibin,rate);
722 std::cout <<
"[L1TDEMON] analyze rate computation\t\n"
725 <<
" nWithCol: " << nWithCol_stage1Layer2[
i]
726 <<
" colCount: " << colCount_stage1Layer2[
i]
728 <<
"hasCol: " << hasCol[
i]
729 <<
" nagree: " << nagree[
i]
730 <<
" rate:" << sysrates->getBinContent(ibin)
731 <<
"\n" << std::flush;
732 if(rate>1. || rate<0.)
734 <<
" is "<<sysrates->getBinContent(ibin)
735 <<
"\n" << std::flush;
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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
static const int nGctColl_
L1TdeGCT(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
std::pair< T, T > etaphi(T x, T y, T z)
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
const std::string SystLabel[DEnsys]
virtual void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override