6 #include <TPaveStats.h>
11 #include <TObjArray.h>
14 #include <StMessMgr.h>
16 #include "EemcTwMask.h"
17 #include "EEqaPresenter.h"
19 static TObjArray *hCleanUp =
new TObjArray();
25 defStyle=gROOT->GetStyle(
"Default");
26 ee1Style=
new TStyle(
"ee1STyle",
"ee1Style (general, minimal Stat)");
28 ee1Style->SetOptStat(11);
29 ee1Style->SetPalette(1);
30 ee1Style->SetTextSize(0.09);
36 TH1 *GetHisto(
FileType &fd,
const Char_t *name) {
37 TH1 *h = (TH1*)fd.Get(name, 0);
40 if (hCleanUp) hCleanUp->Add(h);
42 LOG_ERROR <<
"Histogram not found: " << name << endm;
48 void eePlot(
int page,
int panel,
FileType fd, TPad *cc,
const Char_t *eemcTwMaskFilename){
49 static bool first =
true;
54 bool twMaskFound = useTwMask(eemcTwMaskFilename, twMask);
62 if (ee1Style) ee1Style->cd();
63 if (hCleanUp) hCleanUp->Delete();
68 case 1: eeJpQa(fd, cc, twMask);
break;
69 case 2: eeDaqCorr(fd, cc,1);
break;
72 case 3: eeDaqTwHot(fd, cc, twMask);
break;
73 case 4: eeDaqTwHit(fd, cc);
break;
74 default: plNone(cc);
break;
76 }
else if (page==12) {
78 case 1: eeDaqCorr(fd, cc,2);
break;
79 case 2: eeDaqMapmtStat(fd, cc);
break;
86 case 3: eeDaqSmdA(fd, cc,
"SmdA",
'U');
break;
87 case 4: eeDaqSmdA(fd, cc,
"SmdA",
'V');
break;
88 case 5: eeDaqSmdA(fd, cc,
"HSmd",
'U');
break;
89 case 6: eeDaqSmdA(fd, cc,
"HSmd",
'V');
break;
90 default: plNone(cc);
break;
92 }
else if (page==13) {
95 case 1: eeTrigDsm0(fd, cc,
"HT");
break;
96 case 2: eeTrigDsm0(fd, cc,
"TP");
break;
97 case 3: eeTrigDsm1(fd, cc,
"HT");
break;
98 case 4: eeTrigDsm1(fd, cc,
"TP");
break;
99 case 5: eeTrigDsm2HT(fd, cc);
break;
100 case 6: eeTrigJPsum(fd, cc,
"_sum");
break;
101 case 7: eeTrigJPfreq(fd, cc);
break;
102 case 8: eeTrigAdjJPsum(fd, cc,
"_sum");
break;
103 case 9: eeTrigAdjJPcor(fd, cc,
"_cor");
break;
104 case 10: eeTrigEtot(fd, cc);
break;
105 default: plNone(cc);
break;
107 }
else if (page==14) {
109 case 1: eeDaqTwCr(fd, cc, twMask);
break;
110 case 2: eeFreq(fd, cc, twMask);
break;
111 case 3: eeDaqMapmtCr(fd, cc,64);
break;
112 case 4: eeDaqMapmtCr(fd, cc,72);
break;
113 case 5: eeDaqMapmtCr(fd, cc,80);
break;
114 case 6: eeDaqMapmtCr(fd, cc,88);
break;
115 case 7: eeDaqMapmtCr(fd, cc,96);
break;
116 case 8: eeDaqMapmtCr(fd, cc,104);
break;
117 case 9: eeTrigHanks(fd, cc);
break;
118 case 10:eeEmuVsSimu(fd, cc);
break;
120 default: plNone(cc);
break;
125 LOG_DEBUG <<
"JB panel=" << panel <<
" page=" << page <<
" done" << endm;
130 void plNone(TPad *c) {
132 TText *txt =
new TText(0.05,.5,
"tempo disabled, Jan");
134 if (hCleanUp) hCleanUp->Add(txt);
144 TPad* c =
new TPad(
"pad2",
"apd2",0.0,0.1,1.,1.);
147 const Char_t *name1[]={
"JPpedZoom",
"JPtotCor",
"JPtotFreq",
"JPpedHot"};
148 const Char_t *name2[]={
"JPpedZoom",
"JPsumTh3",
"JPtotFreq",
"xx"};
149 const Char_t **name = (m == 0) ? name2 : name1;
152 for (
int i = 0;i < 4;i++) {
153 TH1 *h = GetHisto(fd,name[i]);
160 if(i==0) gPad->SetLogz();
161 if ((i == 1) || (i == 2)) {
164 if (i == 3) H4jpHot = h;
170 for(
int cr=1;cr<6;cr++) {
171 TH1 *hx = GetHisto(fd, Form(
"cr%dHot",cr));
173 if(hx->Integral()<=50 )
continue;
174 if(hx->GetRMS()<=2.)
continue;
175 hx->Fit(
"pol0",
"0Q");
176 TF1 *ff=hx->GetFunction(
"pol0");
177 float yM=ff->GetParameter(0);
179 int nb=hx->GetNbinsX();
182 if(hx->GetBinContent(k)<10*yM)
continue;
183 if(m && m->crCh[cr-1][k-1])
continue;
184 LOG_DEBUG <<
" hot cr=" << cr <<
" ch=" << (k - 1) <<
" val=" << hx->GetBinContent(k) << endm;
191 TPad *c3 =
new TPad(
"pad3",
"apd3",0.,0.,1.,.1);
194 if (m && m->txtH) m->txtH->Draw();
199 void eeDaqCorr(
FileType fd, TPad *c,
int es) {
204 const Char_t *nameT[]={
"ETowHealth",
"ETowHeadCorr",
"ETowOFF",
"ETowN256",
"ETowOFFid",
"ETowGhost",
"ETowCorrBit"};
205 const Char_t *nameE[]={
"ESmdHealth",
"ESmdHeadCorr",
"ESmdOFF",
"ESmdN256",
"ESmdOFFid",
"ESmdGhost",
"ESmdCorrBit"};
207 const Char_t **name=nameT;
217 c2 =
new TPad(
"pad2",
"apd2",0.0,y1+0.01,1.,1.);
218 c2->Draw(); c2->cd();
221 for(
int i=0;i<n1;i++) {
222 TH1 *h = GetHisto(fd,name[i]);
234 c2 =
new TPad(
"pad2",
"apd2",0.0,y2,1.,y1);
239 TH1 *h = GetHisto(fd,name[i]);
242 if(h->Integral() > 0) gPad->SetLogy();
250 c3 =
new TPad(
"pad3",
"apd3",0.0,0.,1.,y1);
254 TH1 *h = GetHisto(fd,name[i]);
262 void eeEmuVsSimu(
FileType fd, TPad *c ) {
263 const Char_t *name[2]={
"HighTowerTriggerCorruption",
"PatchSumTriggerCorruption"};
265 for (
int i = 0;i < 2;i++) {
266 TH1 *h = GetHisto(fd, name[i]);
272 if (h->Integral() > 0) gPad->SetLogz();
282 for (
int i = 0;i < 6;i++) {
283 TH1 *h = GetHisto(fd, Form(
"cr%d",i+1));
288 h->SetAxisRange(0, 500);
289 if (h->Integral() > 0) gPad->SetLogz();
291 TGraphErrors &gr = m->crG2[i];
292 if(gr.GetN() > 0) gr.Draw(
"P");
301 const Char_t *name[nh]={
"TowHits",
"Pre1Hits",
"Pre2Hits",
"PostHits"};
303 for (
int i = 0;i < nh;i++) {
304 TH1 *h = GetHisto(fd, name[i]);
310 if (h->Integral() > 0 ) gPad->SetLogz();
311 if((i == 0) && m && (m->phiG.GetN() > 0)){
314 if (i == 0) addJPphiLimits(h);
319 void eeDaqTwHit(
FileType fd, TPad *c) {
321 const Char_t *name[nh]={
"HTow",
"HPre1",
"HPre2",
"HPost"};
323 for (
int i = 0;i < nh;i++) {
324 TH1 *h = GetHisto(fd, name[i]);
329 if (h->Integral() > 0) gPad->SetLogy();
335 void eeMany1D(
FileType fd, TPad *c,
const Char_t *core,
int nh,
int nx,
int ny) {
338 for (
int i = 0;i < nh;i++) {
339 TH1 *h = GetHisto(fd, Form(
"%s%d",core,i+1));
344 if ((h->Integral() > 0) && (linLog == 1)) gPad->SetLogy();
355 for (
int i = 0;i < ncr;i++) {
356 TH1 *h = GetHisto(fd, Form(
"cr%dHot",i+1));
363 if (h->Integral() <= 10)
continue;
364 if (h->GetRMS() <= 2.0)
continue;
365 if (h->Integral() > 1) gPad->SetLogy();
367 TF1 *ff = h->GetFunction(
"pol0");
368 float yM = ff->GetParameter(0);
369 if (ymax < yM) ymax = yM;
371 TGraph &gr = m->crG[i];
372 if (gr.GetN() > 0) gr.Draw(
"P");
376 for (
int i = 0;i < ncr;i++)
if (hh[i]) hh[i]->SetMaximum(ymax * 20.);
380 void eeDaqMapmtCr(
FileType fd, TPad *c,
int cr1) {
383 for (
int cr = cr1;cr <= cr1 + 7;cr++) {
384 TH1 *h = GetHisto(fd, Form(
"cr%d", cr));
389 h->SetAxisRange(0, 1000);
390 if(h->Integral() > 0) gPad->SetLogz();
396 void eeDaqSmdA(
FileType fd, TPad *c,
const Char_t *core, Char_t uv){
397 if(strstr(core,
"SmdA")) {
402 for (
int sec = 1;sec <= 12;sec++) {
403 TH1 *h = GetHisto(fd, Form(
"%s%d%c",core,sec,uv));
408 if (h->Integral() > 0) gPad->SetLogy();
414 void eeDaqMapmtStat(
FileType fd, TPad *c) {
416 TH1 *h = GetHisto(fd,
"MAPMHits");
417 TH1 *hcopy = GetHisto(fd,
"MAPMHits");
420 h->SetAxisRange(63, 87);
421 h->SetXTitle(
"Crate ID 12S1=64, 1S1=68, 2S1=72, 3S1=76, 4S1=80, 5S1=84");
425 if (h->Integral()>0) gPad->SetLogz();
429 hcopy->SetAxisRange(88, 120);
430 hcopy->SetXTitle(
"Crate ID 6S1=88, 7S1=92, 8S1=96, 9S1=100, 10S1=104, 11S1=108");
434 if (hcopy->Integral()>0) gPad->SetLogz();
439 void eeTrigHanks(
FileType fd, TPad *c ) {
440 const Char_t *name[2]={
"dsm0inJPall_HT",
"dsm0inJPall_TP"};
442 for (
int i = 0;i < 2;i++) {
443 TH1 *h = GetHisto(fd, name[i]);
448 if (h->Integral() > 0) gPad->SetLogz();
454 void eeTrigDsm0(
FileType fd, TPad *c,
const Char_t *mode ) {
459 for (
int j = 0;j < ncr;j++) {
461 TH1 *h = GetHisto(fd, Form(
"dsm0inJP%d_%s", j+1, mode));
466 if (ymax < h->GetMaximum()) ymax = h->GetMaximum();
467 if (h->Integral() > 0) gPad->SetLogz();
470 for (
int j = 0;j < ncr;j++)
if (hh[j]) hh[j]->SetMaximum(ymax);
474 void eeTrigDsm1(
FileType fd, TPad *c,
const Char_t *mode ) {
475 const Char_t *core=
"dsm1HJP";
476 if (mode[0] ==
'H') {
484 for (
int j = 0;j < n;j++) {
485 TH1 *h = GetHisto(fd, Form(
"%s%d_%s",core,j+1,mode));
491 if (ymax < h->GetMaximum()) ymax = h->GetMaximum();
492 if (h->Integral() > 0) gPad->SetLogz();
493 if(mode[0] ==
'H') gPad->SetGridx();
496 for (
int j = 0;j < n;j++)
if (hh[j]) hh[j]->SetMaximum(ymax);
500 void eeTrigDsm2HT(
FileType fd, TPad *c ) {
501 const Char_t *name[3]={
"dsm2Half1_HTTP",
"dsm2Half2_HTTP",
"dsm3_HTTP"};
503 for (
int i = 0;i < 3;i++) {
504 TH1 *h = GetHisto(fd,name[i]);
509 if (h->Integral() > 0) gPad->SetLogz();
515 void eeTrigJPsum(
FileType fd, TPad *c,
const Char_t *mode) {
517 const Char_t *core=
"JP";
518 for (
int j = 0;j < 6;j++) {
519 TH1 *h = GetHisto(fd, Form(
"%s%d%s", core, j + 1, mode));
522 int maxbin = h->GetMaximumBin() - 1;
523 const Char_t *title = h->GetTitle();
524 h->SetTitle(Form(
"%s ped= %d\n", title, maxbin));
526 h->GetXaxis()->SetRange(1, 200);
528 if (h->Integral() > 0) gPad->SetLogy();
534 void eeTrigJPfreq(
FileType fd, TPad *c) {
536 const Char_t *core=
"JPsumTh";
537 for (
int j = 0;j < 4;j++) {
538 TH1 *h = GetHisto(fd, Form(
"%s%d",core,j));
545 for (
int j = 0;j < 2;j++) {
546 TH1 *h = GetHisto(fd, Form(
"dsm2Half%d_Etot",j+1));
554 TH1 *h = GetHisto(fd,
"JPadjTh");
561 void eeTrigAdjJPsum(
FileType fd, TPad *c,
const Char_t *mode) {
563 const Char_t *core=
"JP";
564 for (
int j = 0;j < 6;j++) {
565 TH1 *h = GetHisto(fd, Form(
"%s%d%d%s",core,j+1,((j+1)%6)+1,mode));
571 if (h->Integral() > 0) gPad->SetLogy();
577 void eeTrigEtot(
FileType fd, TPad *c) {
578 const Char_t *nameA[3]={
"dsm2E_etot",
"dsm2B_etot",
"dsm2BE_etot"};
583 for (
int i = 0;i < 3;i++) {
586 for (
int ii = 0;ii <= 1;ii++) {
587 TH1 *h = GetHisto(fd, Form(
"%s%d",nameA[i],ii));
589 hh[i + (ii * 3)] = h;
592 TString tt = h->GetTitle();
593 tt +=
" COLORS: bit=0 BLUE , bit=1 RED";
598 if ((ii == 0) && (h->Integral() > 0)) gPad->SetLogy();
599 if (ymax < h->GetMaximum()) ymax = h->GetMaximum();
603 for (
int j = 0;j < n;j++)
if (hh[j]) hh[j]->SetMaximum(ymax * 1.1);
607 void eeTrigAdjJPcor(
FileType fd, TPad *c,
const Char_t *mode) {
609 const Char_t *core=
"JP";
610 for (
int j = 0;j < 6;j++) {
611 TH1 *h = GetHisto(fd, Form(
"%s%d%d%s",core,j+1,((j+1)%6)+1,mode));
616 if (h->Integral() > 0) gPad->SetLogz();
622 void addJPphiLimits(TH1 *h) {
623 TList *Lx = h ? h->GetListOfFunctions() : 0;
624 if (!Lx || (Lx->GetSize() > 0))
return;
625 for (
int i = 0;i <= 5;i++) {
626 float x1 = 2.5 + (i * 10);
627 TLine *ln =
new TLine(x1, -0.2, x1, 12.5);
634 if (jpid == 7) jpid = 1;
635 TString aa =
"Jet Patch "; aa += jpid;
636 TText *tt =
new TText(x1 + 1, 12.6, aa);
639 tt->SetTextSize(0.08);
646 void eeJpQaMinMax(TH1 *hh) {
648 hh->SetAxisRange(0.5, 6.4);
650 int ib = hh->GetMaximumBin();
651 float yMax = hh->GetBinContent(ib);
652 ib = hh->GetMinimumBin();
653 float yMin = hh->GetBinContent(ib);
654 float r = 0, er = 999;
655 if (yMin <= 0) yMin = 1;
656 if (yMax <= 0) yMax = 1;
657 if ((yMin > 0) && (yMax > 0)) {
659 er = r * TMath::Sqrt((1 / yMax) + (1 / yMin));
660 LOG_DEBUG << Form(
"JP min/max=%.2f +/- %.2f (min=%.0f max=%.0f) \"%s\"", r, er, yMin, yMax, hh->GetTitle()) << endm;
661 LOG_DEBUG << Form(
"#JP %.2f %.2f %.0f %.0f :%s", r, er, yMin, yMax, hh->GetTitle()) << endm;