File indexing completed on 2023-10-25 09:54:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 bool save_histos = 1;
0024 int save_single = 0;
0025
0026 const int run = 0;
0027
0028 const int DEnsys = 12;
0029
0030 enum syslist {
0031 ETP, HTP, RCT, GCT, DTP, DTF,
0032 CTP, CTF, RPC, LTC, GMT, GLT
0033 };
0034
0035 const std::string SystLabelExt[DEnsys] = {
0036 "ECAL", "HCAL", "RCT", "GCT", "DTTPG", "DTTF",
0037 "CSCTPG", "CSCTF", "RPC", "LTC", "GMT", "GT"
0038 };
0039
0040 const std::string SystLabel[DEnsys] = {
0041 "ETP", "HTP", "RCT", "GCT", "DTP", "DTF",
0042 "CTP", "CTF", "RPC", "LTC", "GMT", "GLT"
0043 };
0044
0045
0046 TH1F* rates;
0047 TH1F* ncand [DEnsys];
0048
0049 TH1F* eta [DEnsys];
0050 TH1F* phi [DEnsys];
0051 TH1F* x3 [DEnsys];
0052 TH2F* etaphi[DEnsys];
0053
0054 TH1F* etaData[DEnsys];
0055 TH1F* phiData[DEnsys];
0056 TH1F* x3Data[DEnsys];
0057 TH1F* rnkData[DEnsys];
0058
0059 TH1F* dword [DEnsys];
0060 TH1F* eword [DEnsys];
0061 TH1F* deword[DEnsys];
0062 TH1F* masked[DEnsys];
0063
0064 TH1F* error;
0065 TH1F* errors[DEnsys];
0066
0067 const int ncorr = 3;
0068 TH2F* CORR[DEnsys][DEnsys][ncorr];
0069
0070 const int nhist = 8+4;
0071 TAxis *xaxis[nhist][DEnsys], *yaxis[nhist][DEnsys];
0072
0073
0074
0075 void plotDE(TString finput = "l1demon.root") {
0076
0077 TString dir("figures/");
0078 dir += "run-";
0079 dir += run;
0080
0081 TFile *infile = new TFile(finput);
0082 TDirectory* tdir = infile->GetDirectory("DQMData/L1TEMU/");
0083
0084 gInterpreter->ExecuteMacro("/afs/cern.ch/user/n/nuno/style/ScanStyle.C");
0085
0086
0087 TDirectory* tdircom = tdir->GetDirectory("common/");
0088 rates = (TH1F*) tdircom->Get("sysrates");
0089 error = (TH1F*) tdircom->Get("errorflag");
0090
0091
0092
0093
0094
0095
0096 for(int j=0; j<2; j++) {
0097 std::string lbl("");
0098 lbl += "sysncand";
0099 lbl += (j==0?"Data":"Emul");
0100 ncand [j] = (TH1F*) tdircom->Get(lbl.data());
0101 }
0102
0103
0104 cout << "getting histos\t";
0105 for(int j=0; j<DEnsys; j++) {
0106
0107 cout << " ." << flush;
0108
0109 TDirectory* tdirsys = tdir->GetDirectory(SystLabelExt[j].data());
0110
0111 std::string lbl("");
0112
0113 lbl.clear();
0114 lbl+=SystLabel[j];lbl+="eta";
0115 eta [j] = (TH1F*) tdirsys->Get(lbl.data());
0116
0117 lbl.clear();
0118 lbl+=SystLabel[j];lbl+="phi";
0119 phi [j] = (TH1F*) tdirsys->Get(lbl.data());
0120 lbl.clear();
0121 lbl+=SystLabel[j];lbl+="x3";
0122 x3 [j] = (TH1F*) tdirsys->Get(lbl.data());
0123
0124 lbl.clear();
0125 lbl+=SystLabel[j];lbl+="etaphi";
0126 etaphi[j] = (TH2F*) tdirsys->Get(lbl.data());
0127
0128 lbl.clear();
0129 lbl+=SystLabel[j];lbl+="dword";
0130 dword [j] = (TH1F*) tdirsys->Get(lbl.data());
0131
0132 lbl.clear();
0133 lbl+=SystLabel[j];lbl+="eta"; lbl+="Data";
0134 etaData[j] = (TH1F*) tdirsys->Get(lbl.data());
0135 lbl.clear();
0136 lbl+=SystLabel[j];lbl+="phi"; lbl+="Data";
0137 phiData[j] = (TH1F*) tdirsys->Get(lbl.data());
0138 lbl.clear();
0139 lbl+=SystLabel[j];lbl+="x3"; lbl+="Data";
0140 x3Data [j] = (TH1F*) tdirsys->Get(lbl.data());
0141 lbl.clear();
0142 lbl+=SystLabel[j];lbl+="rank"; lbl+="Data";
0143 rnkData[j] = (TH1F*) tdirsys->Get(lbl.data());
0144
0145
0146 lbl.clear();
0147 lbl+=SystLabel[j];lbl+="eword";
0148 eword [j] = (TH1F*) tdirsys->Get(lbl.data());
0149 lbl.clear();
0150 lbl+=SystLabel[j];lbl+="deword";
0151 deword[j] = (TH1F*) tdirsys->Get(lbl.data());
0152 lbl.clear();
0153 lbl+=SystLabel[j];lbl+="masked";
0154 masked[j] = (TH1F*) tdirsys->Get(lbl.data());
0155 lbl.clear();
0156 lbl+=SystLabel[j];lbl+="ErrorFlag";
0157 errors[j] = (TH1F*) tdirsys->Get(lbl.data());
0158
0159 }
0160 cout << "\tdone.\n";
0161
0162 TString corrl[ncorr] = {"phi","eta","rank"};
0163
0164 TDirectory* tdirsys = tdir->GetDirectory("xcorr");
0165
0166 for(int i=0; i<DEnsys; i++) {
0167 for(int j=0; j<DEnsys; j++) {
0168 if(i>j) continue;
0169 for(int k=0; k<ncorr; k++) {
0170 std::string lbl("");
0171 lbl.clear(); lbl+=SystLabel[i]; lbl+=SystLabel[j]; lbl+=corrl[k];
0172 CORR[i][j][k] = (TH2F*) tdirsys->Get(lbl.data());
0173 }
0174 }
0175 }
0176
0177 TAxis *xcorr[DEnsys][DEnsys][ncorr], *ycorr[DEnsys][DEnsys][ncorr];
0178 for(int i=0; i<DEnsys; i++) {
0179 for(int j=0; j<DEnsys; j++) {
0180 if(i>j) continue;
0181 for(int k=0; k<ncorr; k++) {
0182 std::string xlbl("");xlbl+=SystLabel[i];xlbl+=corrl[k];
0183 std::string ylbl("");ylbl+=SystLabel[j];ylbl+=corrl[k];
0184 axis2F(CORR[i][j][k], xcorr[i][j][k],ycorr[i][j][k],xlbl,ylbl);
0185 }
0186 }
0187 }
0188
0189 const int nglobal = 4;
0190 TAxis *xglb[nglobal], *yglb[nglobal];
0191
0192 axis1F(rates, xglb[0],yglb[0],"L1 trigger subsystem","error rate");
0193 axis1F(ncand[0], xglb[1],yglb[1],"L1 trigger subsystem","");
0194 axis1F(ncand[1], xglb[2],yglb[2],"L1 trigger subsystem","");
0195 axis1F(error , xglb[3],yglb[3],"error flag", "");
0196 for(int j=0; j<3; j++)
0197 for(int i=0; i<DEnsys+1; i++)
0198 xglb[j]->SetBinLabel(i+1,SystLabel[i].c_str());
0199
0200 const int nerr=5;
0201 TString errLabel[nerr]= {
0202 "Agree", "Loc. Agree", "L.Disagree", "Data only", "Emul only"
0203 }
0204 TString errLabelB[nerr]= {
0205 "Agree", "Loc. Agree", "Loc. Disagree", "D only", "E only"
0206 }
0207 for(int i=0; i<nerr; i++)
0208 xglb[3]->SetBinLabel(i+1,errLabel[i].Data());
0209
0210
0211 TAxis *xerr[DEnsys], *yerr[DEnsys];
0212 axis1F(errors[ 0], xerr[ 0],yerr[ 0],"","");
0213 axis1F(errors[ 1], xerr[ 1],yerr[ 1],"","");
0214 axis1F(errors[ 2], xerr[ 2],yerr[ 2],"","");
0215 axis1F(errors[ 3], xerr[ 3],yerr[ 3],"","");
0216 axis1F(errors[ 4], xerr[ 4],yerr[ 4],"","");
0217 axis1F(errors[ 5], xerr[ 5],yerr[ 5],"","");
0218 axis1F(errors[ 6], xerr[ 6],yerr[ 6],"","");
0219 axis1F(errors[ 7], xerr[ 7],yerr[ 7],"","");
0220 axis1F(errors[ 8], xerr[ 8],yerr[ 8],"","");
0221 axis1F(errors[ 9], xerr[ 9],yerr[ 9],"","");
0222 axis1F(errors[10], xerr[10],yerr[10],"","");
0223 for(int j=0; j<10; j++)
0224 for(int i=0; i<nerr; i++)
0225 xerr[j]->SetBinLabel(i+1,errLabelB[i].Data());
0226
0227 TString xlabel[nhist] = {
0228 "eta",
0229 "phi",
0230 "x3",
0231 "eta",
0232 "eta",
0233 "phi",
0234 "x3",
0235 "rank",
0236 "trigger data word bit",
0237 "trigger data word bit",
0238 "trigger data word bit",
0239 "trigger data word bit"
0240 };
0241
0242 TString ylabel[nhist] = {
0243 "",
0244 "",
0245 "",
0246 "phi",
0247 "",
0248 "",
0249 "",
0250 "",
0251 "",
0252 "",
0253 "",
0254 ""
0255 };
0256
0257
0258 cout << "setting axis\t" << flush;
0259 for(int j=0; j<DEnsys; j++) {
0260 cout << " ." << flush;
0261 axis1F(eta [j] , xaxis[ 0][j],yaxis[ 0][j],xlabel[ 0].Data(),ylabel[ 0].Data());
0262 axis1F(phi [j] , xaxis[ 1][j],yaxis[ 1][j],xlabel[ 1].Data(),ylabel[ 1].Data());
0263 axis1F(x3 [j] , xaxis[ 2][j],yaxis[ 2][j],xlabel[ 2].Data(),ylabel[ 2].Data());
0264 axis2F(etaphi [j] , xaxis[ 3][j],yaxis[ 3][j],xlabel[ 3].Data(),ylabel[ 3].Data());
0265 axis1F(etaData[j] , xaxis[ 4][j],yaxis[ 4][j],xlabel[ 4].Data(),ylabel[ 4].Data());
0266 axis1F(phiData[j] , xaxis[ 5][j],yaxis[ 5][j],xlabel[ 5].Data(),ylabel[ 5].Data());
0267 axis1F( x3Data[j] , xaxis[ 6][j],yaxis[ 6][j],xlabel[ 6].Data(),ylabel[ 6].Data());
0268 axis1F(rnkData[j] , xaxis[ 7][j],yaxis[ 7][j],xlabel[ 7].Data(),ylabel[ 7].Data());
0269 axis1F(dword [j] , xaxis[ 8][j],yaxis[ 8][j],xlabel[ 8].Data(),ylabel[ 8].Data());
0270 axis1F(eword [j] , xaxis[ 9][j],yaxis[ 9][j],xlabel[ 9].Data(),ylabel[ 9].Data());
0271 axis1F(deword [j] , xaxis[10][j],yaxis[10][j],xlabel[10].Data(),ylabel[10].Data());
0272 axis1F(masked [j] , xaxis[11][j],yaxis[11][j],xlabel[11].Data(),ylabel[11].Data());
0273 }
0274 cout << "\tdone.\n";
0275
0276 if(!save_histos)
0277 return;
0278
0279 cout << "printing histos...\n" << flush;
0280
0281 TString ofile(dir); ofile += ".ps";
0282
0283
0284
0285 TCanvas *cvs = new TCanvas("teste","teste",0,0,500,450);
0286
0287 cvs->Print(TString(ofile+"["));
0288 Print (rates ,cvs,ofile);
0289 Print (ncand[0],cvs,ofile);
0290 Print (ncand[1],cvs,ofile);
0291
0292 Print (error ,cvs,ofile);
0293
0294 Print2(rates ,cvs,dir);
0295
0296 Print2(ncand[0],cvs,dir);
0297 Print2(ncand[1],cvs,dir);
0298 Print2(error ,cvs,dir);
0299 for(int j=0; j<DEnsys; j++) {
0300
0301 Print(eta [j],cvs,ofile);
0302 Print(phi [j],cvs,ofile);
0303 Print(x3 [j],cvs,ofile);
0304 Print(etaphi [j],cvs,ofile);
0305 Print(etaData [j],cvs,ofile);
0306 Print(phiData [j],cvs,ofile);
0307 Print( x3Data [j],cvs,ofile);
0308 Print(rnkData [j],cvs,ofile);
0309 Print(dword [j],cvs,ofile);
0310 Print(eword [j],cvs,ofile);
0311 Print(deword [j],cvs,ofile);
0312 Print(masked [j],cvs,ofile);
0313 TString name(dir); name += "/"; name += SystLabel[j];
0314 Print2(errors [j],cvs,name);
0315 Print2(eta [j],cvs,name);
0316 Print2(phi [j],cvs,name);
0317 Print2(x3 [j],cvs,name);
0318 Print2(etaphi [j],cvs,name);
0319 Print2(etaData[j],cvs,name);
0320 Print2(phiData[j],cvs,name);
0321 Print2( x3Data[j],cvs,name);
0322 Print2(rnkData[j],cvs,name);
0323 Print2(dword [j],cvs,name);
0324 Print2(eword [j],cvs,name);
0325 Print2(deword [j],cvs,name);
0326 Print2(masked [j],cvs,name);
0327 }
0328 cvs->Print(TString(ofile+"]"));
0329
0330 TCanvas *cor = new TCanvas("correlations","correlations",0,0,500,450);
0331 TString cfile(dir); cfile+= "-corr"; cfile += ".ps";
0332 cor->Print(TString(cfile+"["));
0333 for(int i=0; i<DEnsys; i++) {
0334 for(int j=0; j<DEnsys; j++) {
0335 if(i>j) continue;
0336 if(i==LTC || j==LTC) continue;
0337 for(int k=0; k<ncorr; k++) {
0338 Print(CORR[i][j][k],cor,cfile);
0339 TString name(dir); name += "/CORR";
0340 Print2(CORR[i][j][k],cor,name);
0341 }
0342 }
0343 }
0344 cor->Print(TString(cfile+"]"));
0345
0346 return;
0347 }
0348
0349
0350
0351
0352 bool empty(TH1* h) {return h->GetEntries()==0;}
0353 bool empty(TH2* h) {return h->GetEntries()==0;}
0354
0355 void axis1F(TH1F *histo,
0356 TAxis *&xaxis,
0357 TAxis *&yaxis,
0358 char *xtitle,
0359 char *ytitle) {
0360
0361 histo->SetMarkerSize(0.5);
0362 histo->SetMarkerStyle(kFullCircle);
0363 xaxis = histo->GetXaxis();
0364 yaxis = histo->GetYaxis();
0365 xaxis->SetLabelFont(42);
0366 yaxis->SetLabelFont(42);
0367 xaxis->SetLabelOffset(0.015);
0368 yaxis->SetLabelOffset(0.020);
0369 xaxis->SetNdivisions(505);
0370 yaxis->SetNdivisions(505);
0371 xaxis->SetTitle(xtitle);
0372 yaxis->SetTitle(ytitle);
0373 xaxis->SetTitleColor(kBlack);
0374 yaxis->SetTitleColor(kBlack);
0375 xaxis->SetTitleFont(42);
0376 yaxis->SetTitleFont(42);
0377 xaxis->SetTitleOffset(2);
0378 yaxis->SetTitleOffset(1.80);
0379 xaxis->SetLabelSize(0.055);
0380 yaxis->SetLabelSize(0.040);
0381 xaxis->SetTitleSize(0.055);
0382 yaxis->SetTitleSize(0.045);
0383 xaxis->SetTitleSize(0.05);
0384 yaxis->SetTitleSize(0.05);
0385 }
0386
0387 void axis2F(TH2F *histo,
0388 TAxis *&xaxis,
0389 TAxis *&yaxis,
0390 TString xtitle,
0391 TString ytitle)
0392 {
0393 xaxis = histo->GetXaxis();
0394 yaxis = histo->GetYaxis();
0395 xaxis->SetLabelFont(42);
0396 yaxis->SetLabelFont(42);
0397 xaxis->SetLabelOffset(0.01);
0398 yaxis->SetLabelOffset(0.02);
0399 xaxis->SetNdivisions(505);
0400 yaxis->SetNdivisions(505);
0401 xaxis->SetTitleFont(42);
0402 yaxis->SetTitleFont(42);
0403 xaxis->SetTitleOffset(1.3);
0404 yaxis->SetTitleOffset(1.3);
0405 xaxis->SetTitle(xtitle.Data());
0406 yaxis->SetTitle(ytitle.Data());
0407 }
0408
0409 void Draw(TH1F *histo, int fColor, int fStyle,
0410 char *drawOpt, int lColor, int lWidth,
0411 int mColor, double mSize, int mStyle)
0412 {
0413 histo->SetDirectory(0 );
0414 histo->SetFillColor(fColor);
0415 histo->SetFillStyle(fStyle);
0416 histo->SetLineColor (lColor);
0417 histo->SetLineWidth (lWidth);
0418 histo->SetMarkerColor(mColor);
0419 histo->SetMarkerSize (mSize );
0420 histo->SetMarkerStyle(mStyle);
0421 if (histo != NULL) histo->Draw(drawOpt);
0422 }
0423
0424 void Draw(TH2F *histo, int fColor, int fStyle,
0425 char *drawOpt, int lColor, int lWidth,
0426 int mColor, double mSize, int mStyle)
0427 {
0428 histo->SetDirectory(0 );
0429 histo->SetFillColor(fColor);
0430 histo->SetFillStyle(fStyle);
0431 histo->SetLineColor (lColor);
0432 histo->SetLineWidth (lWidth);
0433 histo->SetMarkerColor(mColor);
0434 histo->SetMarkerSize (mSize );
0435 histo->SetMarkerStyle(mStyle);
0436 if (histo != NULL) histo->Draw(drawOpt);
0437 }
0438
0439
0440 void Print(TH1F* h, TCanvas *cvs, TString of) {
0441 if(empty(h)) return;
0442 Draw(h, 19, 1001, "", 28, 1, 1, 0.8, 20);
0443 sign(); cvs->Print(of);
0444 }
0445 void Print2(TH1F* h, TCanvas *cvs, TString dir) {
0446 if(empty(h)) return;
0447 Draw(h, 19, 1001, "", 28, 1, 1, 0.8, 20);
0448 sign();
0449 TString name(dir); name += "/"; name += h->GetName();
0450 switch (save_single) {
0451 case 0:
0452 return; break;
0453 case 1:
0454 name+=".eps"; break;
0455 case 2:
0456 name+=".gif"; break;
0457 case 3:
0458 name+=".jpg"; break;
0459 }
0460 cvs->Print(name);
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474 }
0475
0476 void Print(TH2F* h, TCanvas *cvs, TString of) {
0477 if(empty(h)) return;
0478 Draw(h, 38, 1001, "col", 2, 1, 2, 0.8, 20);
0479
0480 sign(); cvs->Print(of);
0481 }
0482 void Print2(TH2F* h, TCanvas *cvs, TString dir) {
0483 if(empty(h)) return;
0484 Draw(h, 38, 1001, "col", 2, 1, 2, 0.8, 20);
0485 sign();
0486 TString name(dir); name += "/"; name += h->GetName();
0487 switch (save_single) {
0488 case 0:
0489 return; break;
0490 case 1:
0491 name+=".eps"; break;
0492 case 2:
0493 name+=".gif"; break;
0494 case 3:
0495 name+=".jpg"; break;
0496 }
0497 cvs->Print(name);
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508 }
0509
0510 void sign() {
0511 TLatex l;
0512 l.SetTextAlign(23);
0513 l.SetTextSize(0.03);
0514 TString ss("L1Comparator");
0515 ss += " | Run:"; ss += run;
0516 if(run>20500 && run < 21010) ss += " GRES";
0517 if(run>29320 && run < 30635) ss += " GREN";
0518 if(run>37842-1 && run < 38483+1) ss += " GRUMM";
0519 l.DrawTextNDC(0.25,0.04,ss);
0520 }