4 using namespace dedefs;
11 std::cout <<
"L1TdeGCT::L1TdeGCT()...\n" << std::flush;
26 if (histFile_.size()!=0) {
28 <<
"L1TEmulator GCT specific histograms will be saved to "
34 dbe->setCurrentFolder(histFolder_);
39 std::cout <<
"L1TdeGCT::L1TdeGCT()...done.\n" << std::flush;
48 std::cout <<
"L1TdeGCT::beginJob() start\n" << std::flush;
54 dbe->
rmdir(histFolder_);
58 std::string cLabel[nGctColl_]=
59 {
"IsoEM",
"NoisoEM",
"CenJet",
"ForJet",
"TauJet",
"HT",
"MET",
"ET",
"MHT",
"HFSums",
"HFCnts"};
68 const int phiNBins = 18 ;
69 const double phiMinim = -0.5;
70 const double phiMaxim = 17.5;
71 const int etaNBins = 22 ;
72 const double etaMinim = -0.5;
73 const double etaMaxim = 21.5;
74 const int rnkNBins = 63;
75 const double rnkMinim = 0.5;
76 const double rnkMaxim = 63.5;
78 sysrates = dbe->
book1D(
"sysrates",
"RATE OF COMPARISON FAILURES",nGctColl_, 0, nGctColl_ );
80 for(
int j=0;
j<2;
j++) {
81 std::string lbl(
"sysncand");
82 lbl += (
j==0?
"Data":
"Emul");
83 std::string
title(
"GCT OBJECT MULTIPLICITY ");
84 title += (
j==0?
"(DATA)":
"(EMULATOR)");
85 sysncand[
j] = dbe->
book1D(lbl.data(),title.data(),nGctColl_, 0, nGctColl_ );
88 for(
int j=0;
j<nGctColl_;
j++) {
93 std::string
title(
"");
96 lbl+=cLabel[
j];lbl+=
"ErrorFlag";
97 title+=cLabel[
j];title+=
" ErrorFlag";
98 errortype[
j] = dbe->
book1D(lbl.data(),title.data(), nerr, 0, nerr);
102 lbl+=cLabel[
j];lbl+=
"Eta";
103 title+=cLabel[
j];title+=
" ETA OF COMPARISON FAILURES";
105 etaNBins, etaMinim, etaMaxim);
108 lbl+=cLabel[
j];lbl+=
"Phi";
109 title+=cLabel[
j];title+=
" PHI OF COMPARISON FAILURES";
111 phiNBins, phiMinim, phiMaxim);
115 lbl+=cLabel[
j];lbl+=
"Etaphi";
116 title+=cLabel[
j];title+=
" ETA PHI OF COMPARISON FAILURES";
118 etaNBins, etaMinim, etaMaxim,
119 phiNBins, phiMinim, phiMaxim
123 lbl+=cLabel[
j];lbl+=
"Rank";
124 title+=cLabel[
j];title+=
" RANK OF COMPARISON FAILURES";
125 rnk[
j] = dbe->
book1D(lbl.data(),title.data(),
126 rnkNBins, rnkMinim, rnkMaxim);
130 lbl+=cLabel[
j];lbl+=
"Eta"; lbl+=
"Data";
131 title+=cLabel[
j];title+=
" ETA (DATA)";
132 etaData[
j] = dbe->
book1D(lbl.data(),title.data(),
133 etaNBins, etaMinim, etaMaxim);
136 lbl+=cLabel[
j];lbl+=
"Phi"; lbl+=
"Data";
137 title+=cLabel[
j];title+=
" PHI (DATA)";
138 phiData[
j] = dbe->
book1D(lbl.data(),title.data(),
139 phiNBins, phiMinim, phiMaxim);
143 lbl+=cLabel[
j];lbl+=
"Rank"; lbl+=
"Data";
144 title+=cLabel[
j];title+=
" RANK (DATA)";
145 rnkData[
j] = dbe->
book1D(lbl.data(),title.data(),
146 rnkNBins, rnkMinim, rnkMaxim);
148 lbl+=cLabel[
j];lbl+=
"Dword";
149 dword[
j] = dbe->
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
151 lbl+=cLabel[
j];lbl+=
"Eword";
152 eword[
j] = dbe->
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
154 lbl+=cLabel[
j];lbl+=
"DEword";
155 deword[
j] = dbe->
book1D(lbl.data(),lbl.data(),nbit,0,nbit);
164 std::string errLabel[nerr]= {
165 "Agree",
"Loc. Agree",
"L.Disagree",
"Data only",
"Emul only"
168 for(
int i=0;
i<nGctColl_;
i++) {
170 sysncand[0]->setBinLabel(i+1,cLabel[i]);
171 sysncand[1]->setBinLabel(i+1,cLabel[i]);
174 for(
int i=0;
i<nGctColl_;
i++) {
175 for(
int j=0;
j<nerr;
j++) {
176 errortype[
i]->setBinLabel(
j+1,errLabel[
j]);
180 for(
int i=0;
i<nGctColl_;
i++) {
181 etaphi [
i]->setAxisTitle(
"GCT #eta",1);
182 etaphi [
i]->setAxisTitle(
"GCT #phi",2);
183 eta [
i]->setAxisTitle(
"GCT #eta");
184 phi [
i]->setAxisTitle(
"GCT #phi");
185 rnk [
i]->setAxisTitle(
"Rank");
186 etaData[
i]->setAxisTitle(
"GCT #eta");
187 phiData[
i]->setAxisTitle(
"GCT #phi");
188 rnkData[
i]->setAxisTitle(
"Rank");
189 dword [
i]->setAxisTitle(
"trigger data word bit");
190 eword [
i]->setAxisTitle(
"trigger data word bit");
191 deword [
i]->setAxisTitle(
"trigger data word bit");
195 for(
int i=0;
i<nGctColl_;
i++) {
201 std::cout <<
"L1TdeGCT::beginJob() end.\n" << std::flush;
207 std::cout <<
"L1TdeGCT::endJob()...\n" << std::flush;
209 if(histFile_.size()!=0 && dbe)
210 dbe->save(histFile_);
213 std::cout <<
"L1TdeGCT::endJob() end.\n" << std::flush;
225 std::cout <<
"L1TdeGCT::analyze() start\n" << std::flush;
233 <<
"Cannot find L1DataEmulRecord with label "
235 <<
" Please verify that comparator was successfully executed."
236 <<
" Emulator DQM for GCT will be skipped!"
242 bool isComp = deRecord->get_isComp(
GCT);
245 std::cout <<
"[L1TdeGCT] Gct information not generated in de-record."
246 <<
" Skiping event!\n" << std::flush;
251 for(
int j=0;
j<2;
j++)
252 DEncand[
j] = deRecord->getNCand(
GCT,
j);
256 <<
" data: " << DEncand[0]
257 <<
" emul: " << DEncand[1]
263 deColl = deRecord->getColl();
272 for(L1DEDigiCollection::const_iterator it=deColl.begin();
273 it!=deColl.end(); it++)
276 gctColl.push_back(*it);
279 std::cout <<
"[L1TdeGCT] record has " << gctColl.size()
280 <<
" gct de digis\n" << std::flush;
281 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
282 it!=gctColl.end(); it++)
291 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
292 it!=gctColl.end(); it++) {
301 std::cout <<
"[L1TdeGCT] processing digi "
309 if(sid!=
GCT || it->empty()) {
310 LogDebug(
"L1TdeGCT") <<
"consistency check failure, non-gct digis!";
314 int type = it->type();
315 double phiv = it->x1();
316 double etav = it->x2();
319 float rnkv = rankarr[0];
323 unsigned int mask = (~0x0);
327 if(ccid<0 || ccid >= nGctColl_) {
328 LogDebug(
"L1TdeGCT") <<
"consistency check failure, col type outbounds:"
335 sysncand[0]->Fill(ccid);
336 if(it->type()<5&&it->type()!=3)
337 sysncand[1]->Fill(ccid);
339 errortype[ccid]->Fill(type);
341 wei=1.;
if(!type) wei=0.;
342 if(etav!=nullVal && phiv!=nullVal)
343 etaphi[ccid]->Fill(etav,phiv,wei);
345 eta [ccid]->Fill(etav,wei);
347 phi [ccid]->Fill(phiv,wei);
348 rnk[ccid]->Fill(rnkv,wei);
351 wei=1.;
if(type==4) wei=0.;
353 etaData[ccid]->Fill(etav,wei);
355 phiData[ccid]->Fill(phiv,wei);
356 rnkData[ccid]->Fill(rnkv,wei);
360 unsigned int word[2];
362 std::bitset<32> dbits(word[0]);
363 std::bitset<32> ebits(word[1]);
364 unsigned int dexor = ( (word[0]) ^ (word[1]) );
366 std::bitset<32> debits(dexor);
368 std::bitset<32> dembits( ( (dexor) & (mask) ) );
372 <<
" sid:" << sid <<
" cid:" << cid <<
"\n"
373 <<
" data:0x" << std::hex << word[0] << std::dec
374 <<
" bitset:" << dbits
376 <<
" emul:0x" << std::hex << word[1] << std::dec
377 <<
" bitset:" << ebits
379 <<
" xor:0x" << std::hex << dexor << std::dec
380 <<
" bitset:" << debits
381 <<
" bitset:" << ( (dbits) ^ (ebits) )
382 <<
"\n" << std::flush;
385 for(
int ibit=0; ibit<32; ibit++) {
388 if(type==3 || type==4) wei=0.;
389 if(dbits [ibit]) dword[
sid]->Fill(ibit,wei);
390 if(ebits [ibit]) eword[
sid]->Fill(ibit,wei);
391 if(debits [ibit])deword[
sid]->Fill(ibit,wei);
399 int hasCol[nGctColl_]={0};
400 int nagree[nGctColl_]={0};
401 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
402 it!=gctColl.end(); it++) {
404 ccid = (ccid<0 || ccid >= nGctColl_) ? 0:ccid;
409 for(
int i=0;
i<nGctColl_;
i++) {
410 if(!hasCol[
i])
continue;
415 nWithCol[
i]+=hasCol[
i];
416 colCount[
i]+=nagree[
i];
418 for(
int i=0;
i<nGctColl_;
i++) {
420 double rate = nWithCol[
i] ? 1.-1.*colCount[
i]/nWithCol[
i]: 0.;
421 sysrates->setBinContent(ibin,rate);
423 std::cout <<
"[L1TDEMON] analyze rate computation\t\n"
426 <<
" nWithCol: " << nWithCol[
i]
427 <<
" colCount: " << colCount[
i]
429 <<
"hasCol: " << hasCol[
i]
430 <<
" nagree: " << nagree[
i]
431 <<
" rate:" << sysrates->getBinContent(ibin)
432 <<
"\n" << std::flush;
433 if(rate>1. || rate<0.)
435 <<
" is "<<sysrates->getBinContent(ibin)
436 <<
"\n" << std::flush;
442 std::cout <<
"L1TdeGCT::analyze() end.\n" << std::flush;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
void rmdir(const std::string &fullpath)
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
L1TdeGCT(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::pair< T, T > etaphi(T x, T y, T z)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const std::string SystLabel[DEnsys]
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
void setCurrentFolder(const std::string &fullpath)
virtual void beginJob(void)