26 #include "L1Trigger/L1TMuonEndCap/interface/SubsystemCollectorFactory.h"
32 #include <TLorentzVector.h>
45 #include "L1Trigger/L1TMuonEndCap/interface/GeometryTranslator.h"
47 #include "L1Trigger/L1TMuonEndCap/interface/MuonTriggerPrimitive.h"
48 #include "L1Trigger/L1TMuonEndCap/interface/MuonTriggerPrimitiveFwd.h"
66 #include "TGraphErrors.h"
69 using namespace L1TMuon;
80 WordHist(
string theVarName,
int theNBits,
double theXCornerVal,
double theYCornerVal);
82 bool fillWord(
int,
int);
83 void formatWordHist();
102 void setFormatValues();
139 void formatHist(TH2F*
hist,
string histTitle,
int nXBins,
int xLow,
int xHigh,
string xTitle,
140 int nYBins,
int yLow,
int yHigh,
string yTitle);
141 void pad2png(TH2F *
h,
string imgName);
155 cout<<
"Begin DiagMaker Analyzer:::::::::::::::::::::::::::::::::::::\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n\n";
157 cout <<
"Reached analyze part of DiagMaker.\n";
163 ev.
getByLabel(
"L1TMuonTrkFinder" ,
"DataITC" , dataITC );
165 int trknmbData, validData, qualityData, keywireData, stripData, patternData;
166 int bendData, bxData, mpclinkData, bx0Data, syncErrData, cscIDData;
167 int trknmbEmu, validEmu, qualityEmu, keywireEmu, stripEmu, patternEmu;
168 int bendEmu, bxEmu, mpclinkEmu, bx0Emu, syncErrEmu, cscIDEmu;
170 auto itEmu = emuITC->cbegin();
171 auto itendEmu = emuITC->cend();
173 auto itData = dataITC->cbegin();
174 auto itendData = dataITC->cend();
177 for( ; (itEmu != itendEmu) && (itData != itendData) ; ++itEmu, ++itData)
180 cout <<
"TRACK(Emu) " << trkCntr <<
" Phi: " << itEmu->phi <<
", Theta: " << itEmu ->theta << endl;
181 cout <<
"TRACK(Data) " << trkCntr <<
" Phi: " << itData->phi <<
", Theta: " << itData->theta << endl;
182 cout <<
"Track(Emu) " << trkCntr <<
" Rank: " << itEmu->rank << endl;
183 cout <<
"Track(Data) " << trkCntr <<
" Rank: " << itData->rank<< endl;
184 cout <<
"Emu:\n dp1- "<<itEmu->deltas[0][0]<<
" dp2- "<<itEmu->deltas[0][1]<<
" dt1- "<<itEmu->deltas[1][0]<<
" dt2- "<<itEmu->deltas[1][1]<<endl;
185 cout <<
"Data:\n dp1- "<<itData->deltas[0][0]<<
" dp2- "<<itData->deltas[0][1]<<
" dt1- "<<itData->deltas[1][0]<<
" dt2- "<<itData->deltas[1][1]<<endl;
187 wordTrkPhi -> fillWord( itData->phi , itEmu->phi );
188 wordTrkTheta -> fillWord( itData->theta , itEmu->theta );
189 wordRank -> fillWord( itData->rank , itEmu->rank );
190 wordPHD1 -> fillWord( fabs(itData->deltas[0][0]) , fabs(itEmu->deltas[0][0]));
191 wordPHD2 -> fillWord( fabs(itData->deltas[0][1]) , fabs(itEmu->deltas[0][1]));
192 wordTHD1 -> fillWord( fabs(itData->deltas[1][0]) , fabs(itEmu->deltas[1][0]));
193 wordTHD2 -> fillWord( fabs(itData->deltas[1][1]) , fabs(itEmu->deltas[1][1]));
195 if(itData->phi != itEmu->phi){
std::cout<<
"Track Phi Mismatch\n\n";}
196 if(itData->theta != itEmu->theta){
std::cout<<
"Track Theta Mismatch\n\n";}
197 if(itData->rank != itEmu->rank){
std::cout<<
"Track Rank Mismatch\n\n";}
198 if(fabs(itData->deltas[0][0]) != fabs(itEmu->deltas[0][0])){
std::cout<<
"00 D Mismatch\n";}
199 if(fabs(itData->deltas[0][1]) != fabs(itEmu->deltas[0][1])){
std::cout<<
"01 D Mismatch\n";}
200 if(fabs(itData->deltas[1][0]) != fabs(itEmu->deltas[1][0])){
std::cout<<
"10 D Mismatch\n";}
201 if(fabs(itData->deltas[1][1]) != fabs(itEmu->deltas[1][1])){
std::cout<<
"11 D Mismatch\n";}
215 for(
unsigned meNum=
id; meNum<(
id+4); meNum++)
220 std::vector<TriggerPrimitive> tplData = tpsmData[meNum];
221 std::vector<TriggerPrimitive> tplEmu = tpsmEmu[meNum];
223 cout <<
"ME " << meNum-
id+1 <<
" - # Trig Prims = " << tplData.size() << endl;
226 for(
unsigned tpNum = 0; (tpNum < tplData.size()) && (tpNum < tplEmu.size()) ; tpNum++)
228 cout <<
" ----- tp #" << tpNum << endl;
233 trknmbData = (tprData).getCSCData().trknmb;
234 validData = (tprData).getCSCData().valid;
235 qualityData = (tprData).getCSCData().quality;
236 keywireData = (tprData).getCSCData().keywire;
237 stripData = (tprData).getCSCData().strip;
238 patternData = (tprData).getCSCData().pattern;
239 bendData = (tprData).getCSCData().bend;
240 bxData = (tprData).getCSCData().bx;
241 mpclinkData = (tprData).getCSCData().mpclink;
242 bx0Data = (tprData).getCSCData().bx0;
243 syncErrData = (tprData).getCSCData().syncErr;
244 cscIDData = (tprData).getCSCData().cscID;
246 trknmbEmu = (tprEmu).getCSCData().trknmb;
247 validEmu = (tprEmu).getCSCData().valid;
248 qualityEmu = (tprEmu).getCSCData().quality;
249 keywireEmu = (tprEmu).getCSCData().keywire;
250 stripEmu = (tprEmu).getCSCData().strip;
251 patternEmu = (tprEmu).getCSCData().pattern;
252 bendEmu = (tprEmu).getCSCData().bend;
253 bxEmu = (tprEmu).getCSCData().bx;
254 mpclinkEmu = (tprEmu).getCSCData().mpclink;
255 bx0Emu = (tprEmu).getCSCData().bx0;
256 syncErrEmu = (tprEmu).getCSCData().syncErr;
257 cscIDEmu = (tprEmu).getCSCData().cscID;
259 cout <<
"trknmb: " <<
"data=" << trknmbData <<
", emu=" << trknmbEmu << endl;
260 cout <<
"valid: " <<
"data=" << validData <<
", emu=" << validEmu << endl;
261 cout <<
"quality: " <<
"data=" << qualityData <<
", emu=" << qualityEmu << endl;
262 cout <<
"keywire: " <<
"data=" << keywireData <<
", emu=" << keywireEmu << endl;
263 cout <<
"strip: " <<
"data=" << stripData <<
", emu=" << stripEmu << endl;
264 cout <<
"pattern: " <<
"data=" << patternData <<
", emu=" << patternEmu << endl;
265 cout <<
"bend: " <<
"data=" << bendData <<
", emu=" << bendEmu << endl;
266 cout <<
"bx: " <<
"data=" << bxData <<
", emu=" << bxEmu << endl;
267 cout <<
"mpclink: " <<
"data=" << mpclinkData <<
", emu=" << mpclinkEmu << endl;
268 cout <<
"bx0: " <<
"data=" << bx0Data <<
", emu=" << bx0Emu << endl;
269 cout <<
"syncErr: " <<
"data=" << syncErrData <<
", emu=" << syncErrEmu << endl;
270 cout <<
"cscID: " <<
"data=" << cscIDData <<
", emu=" << cscIDEmu << endl;
271 cout <<
"--------------------------------\n";
274 wordTrknmb -> fillWord( trknmbData , trknmbEmu );
275 wordValid -> fillWord( validData , validEmu );
276 wordQuality -> fillWord( qualityData , qualityEmu );
277 wordKeywire -> fillWord( keywireData , keywireEmu );
278 wordStrip -> fillWord( stripData , stripEmu );
279 wordPattern -> fillWord( patternData , patternEmu );
280 wordBend -> fillWord( bendData , bendEmu );
281 wordBx -> fillWord( bxData , bxEmu );
282 wordMpclink -> fillWord( mpclinkData , mpclinkEmu );
283 wordBx0 -> fillWord( bx0Data , bx0Emu );
284 wordSyncErr -> fillWord( syncErrData , syncErrEmu );
285 wordCscID -> fillWord( cscIDData , cscIDEmu );
287 if(keywireData != keywireEmu){
std::cout<<
"Wire Mismatch\n\n";}
288 if(stripData != stripEmu){
std::cout<<
"Strip Mismatch\n\n";}
295 cout<<
"End DiagMaker Analyzer:::::::::::::::::::::::::::::::::::::\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n\n";
310 wordTrkPhi =
new WordHist(
"Phi" , 12 , 0 , 0 );
312 wordTrkTheta =
new WordHist(
"Theta" , 6 , 0 , 0.2 );
314 wordTrknmb =
new WordHist(
"Phhit" , 6 , 0 , 0.4 );
316 wordValid =
new WordHist(
"Valid" , 12 , 0 , 0.6 );
318 wordQuality =
new WordHist(
"Quality" , 7 , 0 , 0.8 );
320 wordKeywire =
new WordHist(
"Keywire" , 12 , 0.5 , 0 );
322 wordStrip =
new WordHist(
"Strip" , 7 , 0.5 , 0.2 );
324 wordPattern =
new WordHist(
"Pattern" , 12 , 0.5 , 0.4 );
326 wordBend =
new WordHist(
"Bend" , 12 , 0.5 , 0.6 );
328 wordBx =
new WordHist(
"Bx" , 12 , 0.5 , 0.8 );
332 wordMpclink =
new WordHist(
"Mpclink" , 12 , 0 , 0 );
334 wordBx0 =
new WordHist(
"Bx" , 12 , 0 , 0.2 );
336 wordSyncErr =
new WordHist(
"SyncErr" , 12 , 0 , 0.4 );
338 wordCscID =
new WordHist(
"CscID" , 12 , 0 , 0.6 );
340 wordRank =
new WordHist(
"Rank" , 12 , 0.5 , 0 );
342 wordPHD1 =
new WordHist(
"PHD1" , 12 , 0.5 , 0.2 );
344 wordPHD2 =
new WordHist(
"PHD2" , 12 , 0.5 , 0.4 );
346 wordTHD1 =
new WordHist(
"THD1" , 12 , 0.5 , 0.6 );
348 wordTHD2 =
new WordHist(
"THD2" , 12 , 0.5 , 0.8 );
357 wordTrkPhi -> pad -> cd();
358 wordTrkPhi -> formatWordHist();
359 wordTrkTheta -> pad -> cd();
360 wordTrkTheta -> formatWordHist();
361 wordTrknmb -> pad -> cd();
362 wordTrknmb -> formatWordHist();
363 wordValid -> pad -> cd();
364 wordValid -> formatWordHist();
365 wordQuality -> pad -> cd();
366 wordQuality -> formatWordHist();
367 wordKeywire -> pad -> cd();
368 wordKeywire -> formatWordHist();
369 wordStrip -> pad -> cd();
370 wordStrip -> formatWordHist();
371 wordPattern -> pad -> cd();
372 wordPattern -> formatWordHist();
373 wordBend -> pad -> cd();
374 wordBend -> formatWordHist();
375 wordBx -> pad -> cd();
376 wordBx -> formatWordHist();
378 gSystem->ProcessEvents();
379 TImage *img1 = TImage::Create();
381 img1 -> WriteImage(
"wordHist1.png");
387 wordMpclink -> pad -> cd();
388 wordMpclink -> formatWordHist();
389 wordBx0 -> pad -> cd();
390 wordBx0 -> formatWordHist();
391 wordSyncErr -> pad -> cd();
392 wordSyncErr -> formatWordHist();
393 wordCscID -> pad -> cd();
394 wordCscID -> formatWordHist();
395 wordRank -> pad -> cd();
396 wordRank -> formatWordHist();
397 wordPHD1 -> pad -> cd();
398 wordPHD1 -> formatWordHist();
399 wordPHD2 -> pad -> cd();
400 wordPHD2 -> formatWordHist();
401 wordTHD1 -> pad -> cd();
402 wordTHD1 -> formatWordHist();
403 wordTHD2 -> pad -> cd();
404 wordTHD2 -> formatWordHist();
406 gSystem->ProcessEvents();
407 TImage *img2 = TImage::Create();
409 img2->WriteImage(
"wordHist2.png");
417 void formatHist(TH2F*
hist,
string histTitle,
int nXBins,
int xLow,
int xHigh,
string xTitle,
418 int nYBins,
int yLow,
int yHigh,
string yTitle)
420 TAxis *xaxis = hist->GetXaxis();
421 xaxis -> SetTitle(xTitle.c_str());
422 xaxis -> CenterTitle();
423 xaxis -> SetNdivisions(nXBins,kFALSE);
424 xaxis -> SetTickLength(1.0);
425 xaxis -> CenterLabels();
427 TAxis *yaxis = hist->GetYaxis();
428 yaxis -> SetTitle(yTitle.c_str());
429 yaxis -> CenterTitle();
430 yaxis -> SetNdivisions(nYBins,kFALSE);
431 yaxis -> SetTickLength(1.0);
432 yaxis -> CenterLabels();
434 hist -> SetTitle(histTitle.c_str());
441 TCanvas *
c =
new TCanvas;
443 gSystem->ProcessEvents();
444 TImage *img = TImage::Create();
446 img->WriteImage(imgName.c_str());
457 lowBit =
hist -> GetBinError(0);
460 numBits =
hist -> GetNbinsX();
462 wordData = wordData >> lowBit;
463 wordEmu = wordEmu >> lowBit;
467 bool matchFlag =
true;
469 for (
int i = 0;
i < numBits;
i++)
472 yFill = (wordData & 0x1) - (wordEmu & 0x1);
474 matchFlag |= (yFill == 0);
478 wordData = wordData >> 1;
479 wordEmu = wordEmu >> 1;
489 WordHist::WordHist(
string theVarName,
int theNBits,
double theXCornerVal,
double theYCornerVal) : nBits(theNBits)
501 cout <<
"Error: pad length is too long for x corner value.\n";
510 pad -> SetBottomMargin(0.4);
521 TF1 *
f1 =
new TF1(
"f1",
"12-x",1,
nBits+1);
522 TF1 *
f2 =
new TF1(
"f2",
"x",-1,2);
526 hist -> SetStats(kFALSE);
527 hist -> Draw(
"ah col");
530 TGaxis *xtick =
new TGaxis(0, -1.5,
nBits,-1.5,
533 xtick -> SetLineWidth(2.5);
534 xtick -> SetTickSize(0.12);
535 xtick -> Draw(
"same");
538 TGaxis *xaxis =
new TGaxis(-1, -1.5,
nBits-1,-1.5,
539 "f1",
nBits+1,
"MNIBS");
541 xaxis -> SetTickSize(0);
542 xaxis -> SetLabelSize(0.14);
545 if(
nBits > 3) xaxis -> SetTitle((
varName +
" word bit").c_str());
546 if(
nBits == 3) xaxis -> SetTitle((
" " +
varName +
" word bit").c_str());
547 if(
nBits == 2) xaxis -> SetTitle((
" " +
varName +
" word bit").c_str());
548 if(
nBits == 1) xaxis -> SetTitle((
" " +
varName +
" word bit").c_str());
551 xaxis -> SetTitleSize(0.16);
552 xaxis -> CenterTitle();
554 xaxis -> Draw(
"same");
557 TGaxis *yaxis =
new TGaxis(0, -1.5,0,1.5,
560 yaxis -> SetTickSize(-1);
563 yaxis -> SetLineWidth(2.5);
564 yaxis -> SetLabelSize(0.14);
567 yaxis -> SetTitle(
"data - emul");
569 yaxis -> SetTitleSize(0.15);
572 yaxis -> Draw(
"same");
575 TGaxis *xtop =
new TGaxis(0,1.5,
nBits,1.5,
"f1",
nBits+1,
"US-");
577 xtop -> SetTickSize(0.12);
578 xtop -> SetLineWidth(2.5);
579 xtop -> Draw(
"same");
582 TGaxis *yright =
new TGaxis(
nBits,-1.5,
nBits,1.5,
"f2",4,
"+US");
584 yright -> SetLineWidth(2.5);
585 yright -> Draw(
"same");
588 double xPoints[(
nBits-1)*2];
589 double yPoints[(
nBits-1)*2];
590 double ex[(
nBits-1)*2];
591 double ey[(
nBits-1)*2];
596 xPoints[2*
i+1] =
i+1;
599 yPoints[2*
i+1] = 0.5;
603 for (
int i = 0;
i < (nBits-1)*2;
i++){
609 TGraphErrors *gridGraph;
611 gridGraph =
new TGraphErrors((nBits-1)*2, xPoints, yPoints, ex, ey);
614 gridGraph -> SetLineWidth(0.4);
616 gridGraph -> Draw(
"pz same");
void formatHist(TH2F *hist, string histTitle, int nXBins, int xLow, int xHigh, string xTitle, int nYBins, int yLow, int yHigh, string yTitle)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define DEFINE_FWK_MODULE(type)
void analyze(const edm::Event &, const edm::EventSetup &)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void pad2png(TH2F *h, string imgName)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
WordHist(string theVarName, int theNBits, double theXCornerVal, double theYCornerVal)
std::map< unsigned, TriggerPrimitiveCollection > TriggerPrimitiveStationMap