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;
47 std::cout <<
"L1TdeGCT::beginRun() start\n" << std::flush;
50 dbe->setCurrentFolder(histFolder_);
51 dbe->rmdir(histFolder_);
55 dbe->setCurrentFolder(histFolder_);
58 sysrates = dbe->book1D(
"sysrates",
"RATE OF COMPARISON FAILURES",nGctColl_, 0, nGctColl_ );
60 for(
int j=0;
j<2;
j++) {
62 lbl += (
j==0?
"Data":
"Emul");
64 title += (
j==0?
"(DATA)":
"(EMULATOR)");
65 sysncand[
j] = dbe->book1D(lbl.data(),title.data(),nGctColl_, 0, nGctColl_ );
68 for(
int j=0;
j<nGctColl_;
j++) {
70 dbe->setCurrentFolder(
std::string(histFolder_+
"/"+cLabel[
j]));
76 lbl+=cLabel[
j];lbl+=
"ErrorFlag";
77 title+=cLabel[
j];title+=
" ErrorFlag";
78 errortype[
j] = dbe->book1D(lbl.data(),title.data(), nerr, 0, nerr);
82 lbl+=cLabel[
j];lbl+=
"Eta";
83 title+=cLabel[
j];title+=
" ETA OF COMPARISON FAILURES";
84 eta[
j] = dbe->book1D(lbl.data(),title.data(),
85 etaNBins, etaMinim, etaMaxim);
88 lbl+=cLabel[
j];lbl+=
"Phi";
89 title+=cLabel[
j];title+=
" PHI OF COMPARISON FAILURES";
90 phi[
j] = dbe->book1D(lbl.data(),title.data(),
91 phiNBins, phiMinim, phiMaxim);
95 lbl+=cLabel[
j];lbl+=
"Etaphi";
96 title+=cLabel[
j];title+=
" ETA PHI OF COMPARISON FAILURES";
97 etaphi[
j] = dbe->book2D(lbl.data(),title.data(),
98 etaNBins, etaMinim, etaMaxim,
99 phiNBins, phiMinim, phiMaxim
103 lbl+=cLabel[
j];lbl+=
"Rank";
104 title+=cLabel[
j];title+=
" RANK OF COMPARISON FAILURES";
105 rnk[
j] = dbe->book1D(lbl.data(),title.data(),
106 rnkNBins, rnkMinim, rnkMaxim);
110 lbl+=cLabel[
j];lbl+=
"Eta"; lbl+=
"Data";
111 title+=cLabel[
j];title+=
" ETA (DATA)";
112 etaData[
j] = dbe->book1D(lbl.data(),title.data(),
113 etaNBins, etaMinim, etaMaxim);
116 lbl+=cLabel[
j];lbl+=
"Phi"; lbl+=
"Data";
117 title+=cLabel[
j];title+=
" PHI (DATA)";
118 phiData[
j] = dbe->book1D(lbl.data(),title.data(),
119 phiNBins, phiMinim, phiMaxim);
123 lbl+=cLabel[
j];lbl+=
"Rank"; lbl+=
"Data";
124 title+=cLabel[
j];title+=
" RANK (DATA)";
125 rnkData[
j] = dbe->book1D(lbl.data(),title.data(),
126 rnkNBins, rnkMinim, rnkMaxim);
128 lbl+=cLabel[
j];lbl+=
"Dword";
129 dword[
j] = dbe->book1D(lbl.data(),lbl.data(),nbit,0,nbit);
131 lbl+=cLabel[
j];lbl+=
"Eword";
132 eword[
j] = dbe->book1D(lbl.data(),lbl.data(),nbit,0,nbit);
134 lbl+=cLabel[
j];lbl+=
"DEword";
135 deword[
j] = dbe->book1D(lbl.data(),lbl.data(),nbit,0,nbit);
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]);
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");
170 for(
int i=0;
i<nGctColl_;
i++) {
176 std::cout <<
"L1TdeGCT::beginJob() end.\n" << std::flush;
186 std::cout <<
"L1TdeGCT::endJob()...\n" << std::flush;
188 if(histFile_.size()!=0 && dbe)
189 dbe->save(histFile_);
192 std::cout <<
"L1TdeGCT::endJob() end.\n" << std::flush;
204 std::cout <<
"L1TdeGCT::analyze() start\n" << std::flush;
212 <<
"Cannot find L1DataEmulRecord"
213 <<
" Please verify that comparator was successfully executed."
214 <<
" Emulator DQM for GCT will be skipped!"
220 bool isComp = deRecord->get_isComp(
GCT);
223 std::cout <<
"[L1TdeGCT] Gct information not generated in de-record."
224 <<
" Skiping event!\n" << std::flush;
229 for(
int j=0;
j<2;
j++)
230 DEncand[
j] = deRecord->getNCand(
GCT,
j);
234 <<
" data: " << DEncand[0]
235 <<
" emul: " << DEncand[1]
241 deColl = deRecord->getColl();
250 for(L1DEDigiCollection::const_iterator it=deColl.begin();
251 it!=deColl.end(); it++)
254 gctColl.push_back(*it);
257 std::cout <<
"[L1TdeGCT] record has " << gctColl.size()
258 <<
" gct de digis\n" << std::flush;
259 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
260 it!=gctColl.end(); it++)
269 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
270 it!=gctColl.end(); it++) {
279 std::cout <<
"[L1TdeGCT] processing digi "
287 if(sid!=
GCT || it->empty()) {
288 LogDebug(
"L1TdeGCT") <<
"consistency check failure, non-gct digis!";
292 int type = it->type();
293 double phiv = it->x1();
294 double etav = it->x2();
297 float rnkv = rankarr[0];
301 unsigned int mask = (~0x0);
305 if(ccid<0 || ccid >= nGctColl_) {
306 LogDebug(
"L1TdeGCT") <<
"consistency check failure, col type outbounds:"
313 sysncand[0]->
Fill(ccid);
314 if(it->type()<5&&it->type()!=3)
315 sysncand[1]->
Fill(ccid);
317 errortype[ccid]->Fill(type);
319 wei=1.;
if(!type) wei=0.;
320 if(etav!=nullVal && phiv!=nullVal)
321 etaphi[ccid]->Fill(etav,phiv,wei);
323 eta [ccid]->Fill(etav,wei);
325 phi [ccid]->Fill(phiv,wei);
326 rnk[ccid]->Fill(rnkv,wei);
329 wei=1.;
if(type==4) wei=0.;
331 etaData[ccid]->Fill(etav,wei);
333 phiData[ccid]->Fill(phiv,wei);
334 rnkData[ccid]->Fill(rnkv,wei);
338 unsigned int word[2];
340 std::bitset<32> dbits(word[0]);
341 std::bitset<32> ebits(word[1]);
342 unsigned int dexor = ( (word[0]) ^ (word[1]) );
344 std::bitset<32> debits(dexor);
346 std::bitset<32> dembits( ( (dexor) & (mask) ) );
350 <<
" sid:" << sid <<
" cid:" << cid <<
"\n"
351 <<
" data:0x" << std::hex << word[0] << std::dec
352 <<
" bitset:" << dbits
354 <<
" emul:0x" << std::hex << word[1] << std::dec
355 <<
" bitset:" << ebits
357 <<
" xor:0x" << std::hex << dexor << std::dec
358 <<
" bitset:" << debits
359 <<
" bitset:" << ( (dbits) ^ (ebits) )
360 <<
"\n" << std::flush;
363 for(
int ibit=0; ibit<32; ibit++) {
366 if(type==3 || type==4) wei=0.;
367 if(dbits [ibit]) dword[sid]->Fill(ibit,wei);
368 if(ebits [ibit]) eword[sid]->Fill(ibit,wei);
369 if(debits [ibit])deword[sid]->Fill(ibit,wei);
377 int hasCol[nGctColl_]={0};
378 int nagree[nGctColl_]={0};
379 for(L1DEDigiCollection::const_iterator it=gctColl.begin();
380 it!=gctColl.end(); it++) {
382 ccid = (ccid<0 || ccid >= nGctColl_) ? 0:ccid;
387 for(
int i=0;
i<nGctColl_;
i++) {
388 if(!hasCol[
i])
continue;
393 nWithCol[
i]+=hasCol[
i];
394 colCount[
i]+=nagree[
i];
396 for(
int i=0;
i<nGctColl_;
i++) {
398 double rate = nWithCol[
i] ? 1.-1.*colCount[
i]/nWithCol[
i]: 0.;
399 sysrates->setBinContent(ibin,rate);
401 std::cout <<
"[L1TDEMON] analyze rate computation\t\n"
404 <<
" nWithCol: " << nWithCol[
i]
405 <<
" colCount: " << colCount[
i]
407 <<
"hasCol: " << hasCol[
i]
408 <<
" nagree: " << nagree[
i]
409 <<
" rate:" << sysrates->getBinContent(ibin)
410 <<
"\n" << std::flush;
411 if(rate>1. || rate<0.)
413 <<
" is "<<sysrates->getBinContent(ibin)
414 <<
"\n" << std::flush;
420 std::cout <<
"L1TdeGCT::analyze() end.\n" << std::flush;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup)
std::vector< L1DataEmulDigi > L1DEDigiCollection
L1TdeGCT(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::pair< T, T > etaphi(T x, T y, T z)
const std::string SystLabel[DEnsys]
virtual void beginJob(void)