17 #if !defined(__CINT__) || defined(__MAKECINT__) 20 #include <TDirectoryFile.h> 38 #include <TGraphErrors.h> 83 TString histoName =
"SMM02NoCut",
94 TString mcLeg =
"MC: #gammaJ+JJ({p^{EMCal}_{T,#gamma}>3.5 GeV/#it{c})",
95 TString titleData =
"LHC11cd_EMC7",
96 TString daLeg =
"pp@7 TeV, LHC11c+d EMC7",
103 Bool_t plotRatio = kFALSE,
104 Bool_t saveHisto = kFALSE,
111 if(histoName.Contains(
"CellModule")) pid =
"";
112 if(histoName.Contains(
"SMEMaxEClusterRat")) pid =
"";
113 if(histoName.Contains(
"TCardChannel")) pid =
"";
120 Bool_t normtomax = kFALSE;
123 if ( debug ) printf(
"Histo: %s, range [%2.2f,%2.2f], Norm %d, range [%2.2f, %2.2f], rebin %d, param range [%d,%d]\n",
124 histoName.Data(), xmin,xmax, normtomax, xNormMin,xNormMax,
rebin, firstP,lastP);
138 const Int_t nparam = lastP-firstP+1;
145 const Int_t nGroup = 4;
147 if(histoName.Contains(
"TCardChannel"))
151 TString groupSM[] = {
"0,4,5,6,8,9",
"1,2",
"3,7"};
152 TString groupTC[] = {
"Border",
"Border+1",
"Center+1",
"Center"};
169 for(
Int_t iprod = 0; iprod < firstMC; iprod++)
171 file[iprod] = TFile::Open(Form(
"%s%s.root",
prod[iprod].
Data(),clusterization.Data()));
172 if ( debug ) printf(
"Read: %s%s.root, %p\n",
prod[iprod].
Data(),clusterization.Data(),file[iprod]);
176 printf(
"Missing file %d\n",iprod);
180 h3[iprod] = (
TH3F*) file[iprod]->Get(Form(
"Shape%s_h%s%s" ,tm.Data(),histoName.Data(),pid.Data()));
181 if ( debug ) printf(
"Data, Shape%s_h%s%s %p\n",tm.Data(),histoName.Data(),pid.Data(),h3[iprod]);
182 if ( !h3[iprod] )
return;
188 if ( debug ) printf(
"Entries %e Integral %e\n",h3[iprod]->GetEntries(),h3[iprod]->Integral());
193 for(
Int_t iprod = firstMC; iprod <
nProd; iprod++)
195 if ( !
prod[iprod].Contains(
"root") )
196 file[iprod] = TFile::Open(Form(
"%s/ScaledMerged%s.root",
prod[iprod].
Data(),clusterization.Data()));
198 file[iprod] = TFile::Open(Form(
"%s",
prod[iprod].
Data()));
200 if ( debug ) printf(
"Simu %d file %s, Shape_%s_h%s%s, %p\n",
201 iprod,
prod[iprod].
Data(), tm.Data(),histoName.Data(),pid.Data(), file[iprod]);
209 h3[iprod] = (
TH3F*) file[iprod]->Get(Form(
"Shape%s_h%s%s" ,tm.Data(),histoName.Data(), pid.Data()));
210 if ( debug ) printf(
"\t histo %p\n",h3[iprod]);
212 if ( !h3[iprod] )
return;
214 if ( debug ) printf(
"Entries %e Integral %e\n",h3[iprod]->GetEntries(),h3[iprod]->Integral());
223 if ( debug ) printf(
"Project per E bin, SM/TC bin\n");
231 if ( debug ) printf(
"iprod %d\n",iprod);
235 if ( debug ) printf(
"\t ebin %d\n",iebin);
236 h3[iprod]->SetAxisRange(-1000,1000,
"Y");
238 Int_t ebinMin = h3[iprod]->GetXaxis()->FindBin(
binE[iebin ]);
239 Int_t ebinMax = h3[iprod]->GetXaxis()->FindBin(
binE[iebin+1])-1;
241 lowE[iebin] = h3[iprod]->GetXaxis()->GetBinLowEdge(ebinMin);
242 width = h3[iprod]->GetXaxis()->GetBinWidth (ebinMax);
243 higE[iebin] = h3[iprod]->GetXaxis()->GetBinLowEdge(ebinMax)+width;
245 if ( debug && iprod==0 )
247 printf(
"\t iE %d, ebinMin %d, emin %2.1f, low edge %2.1f, ebinMax %d, emax %2.1f, high edge %2.1f, width %2.2f\n",
248 iebin, ebinMin,
binE[iebin], lowE[iebin], ebinMax,
binE[iebin+1], higE[iebin], width);
251 for(
Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
253 Int_t pbinMax = h3[iprod]->GetYaxis()->FindBin(ipbin);
254 Int_t pbinMin = h3[iprod]->GetYaxis()->FindBin(ipbin);
256 if ( debug ) printf(
"\t \t ipbin %d - first %d = %d, last %d, total %d\n",ipbin,firstP,ipbin-firstP, lastP, nparam);
258 h[iprod][iebin][ipbin-firstP] =
259 (
TH1D*) h3[iprod]->ProjectionZ(Form(
"%sProd%d_BinE%d_BinP%d",histoName.Data(),iprod,iebin,ipbin),ebinMin,ebinMax, pbinMin,pbinMax);
262 (h[iprod][iebin][ipbin-firstP],histoName, iprod,
264 normtomax, xNormMin, xNormMax, lowE[iebin], higE[iebin],debug);
273 if ( debug ) printf(
"\t \t Merge all SM\n");
276 (
TH1D*) h3[iprod]->ProjectionZ(Form(
"%sProd%d_BinE%d_All",histoName.Data(),iprod,iebin),ebinMin,ebinMax, -1,10000);
279 (hA[iprod][iebin],histoName, iprod,
281 normtomax, xNormMin, xNormMax, lowE[iebin],higE[iebin],debug);
284 printf(
"Histogram with sum of all not available\n");
287 if ( debug ) printf(
"\t \t Merge groups\n");
292 Float_t colorGroup[] = {kBlue,kViolet,kRed,kBlack,6,8,3,5};
294 if ( histoName.Contains(
"SM") )
300 hGroup[iprod][iebin][0] = 0;
301 hGroup[iprod][iebin][1] = 0;
302 hGroup[iprod][iebin][2] = 0;
304 if ( h[iprod][iebin][0] ) hGroup[iprod][iebin][0] = (
TH1D*) h[iprod][iebin][0]->Clone(Form(
"SM_Group0_Ebin%d_Prod%d",iebin,iprod));
305 if ( h[iprod][iebin][1] ) hGroup[iprod][iebin][1] = (
TH1D*) h[iprod][iebin][1]->Clone(Form(
"SM_Group1_Ebin%d_Prod%d",iebin,iprod));
306 if ( h[iprod][iebin][3] ) hGroup[iprod][iebin][2] = (
TH1D*) h[iprod][iebin][3]->Clone(Form(
"SM_Group2_Ebin%d_Prod%d",iebin,iprod));
308 if( hGroup[iprod][iebin][0] )
310 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][4] );
311 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][5] );
312 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][6] );
313 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][8] );
314 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][9] );
316 hGroup[iprod][iebin][0]->Scale(1./6.);
319 if( hGroup[iprod][iebin][1] )
321 hGroup[iprod][iebin][1]->Add( h[iprod][iebin][2] );
323 hGroup[iprod][iebin][1]->Scale(1./2.);
326 if( hGroup[iprod][iebin][2] )
328 hGroup[iprod][iebin][2]->Add( h[iprod][iebin][7] );
330 hGroup[iprod][iebin][2]->Scale(1./2.);
334 if ( histoName.Contains(
"TCardChannel") )
336 hGroup[iprod][iebin][0] = 0;
337 hGroup[iprod][iebin][1] = 0;
338 hGroup[iprod][iebin][2] = 0;
339 hGroup[iprod][iebin][3] = 0;
341 if ( h[iprod][iebin][0] ) hGroup[iprod][iebin][0] = (
TH1D*) h[iprod][iebin][0]->Clone(Form(
"TC_Group0_Ebin%d_Prod%d",iebin,iprod));
342 if ( h[iprod][iebin][1] ) hGroup[iprod][iebin][1] = (
TH1D*) h[iprod][iebin][1]->Clone(Form(
"TC_Group1_Ebin%d_Prod%d",iebin,iprod));
343 if ( h[iprod][iebin][2] ) hGroup[iprod][iebin][2] = (
TH1D*) h[iprod][iebin][2]->Clone(Form(
"TC_Group2_Ebin%d_Prod%d",iebin,iprod));
344 if ( h[iprod][iebin][3] ) hGroup[iprod][iebin][3] = (
TH1D*) h[iprod][iebin][3]->Clone(Form(
"TC_Group3_Ebin%d_Prod%d",iebin,iprod));
348 printf(
"ie %d, iprod %d\n",iebin,iprod);
349 printf(
" 0-%p, 1-%p, 2-%p, 3-%p, 4-%p\n",h[iprod][iebin][ 0],h[iprod][iebin][ 1], h[iprod][iebin][ 2], h[iprod][iebin][ 3], h[iprod][iebin][ 4]);
350 printf(
" 5-%p, 6-%p, 7-%p, 8-%p, 9-%p\n",h[iprod][iebin][ 5],h[iprod][iebin][ 6], h[iprod][iebin][ 7], h[iprod][iebin][ 8], h[iprod][iebin][ 9]);
351 printf(
"10-%p, 11-%p, 12-%p, 13-%p, 14-%p\n",h[iprod][iebin][10],h[iprod][iebin][11], h[iprod][iebin][12], h[iprod][iebin][13], h[iprod][iebin][14]);
352 printf(
"15-%p, 16-%p \n" ,h[iprod][iebin][15],h[iprod][iebin][16]);
355 if( hGroup[iprod][iebin][0] )
357 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][ 7] );
358 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][ 8] );
359 hGroup[iprod][iebin][0]->Add( h[iprod][iebin][15] );
361 hGroup[iprod][iebin][0]->Scale(1./4.);
364 if( hGroup[iprod][iebin][1] )
366 hGroup[iprod][iebin][1]->Add( h[iprod][iebin][ 6] );
367 hGroup[iprod][iebin][1]->Add( h[iprod][iebin][ 9] );
368 hGroup[iprod][iebin][1]->Add( h[iprod][iebin][14] );
370 hGroup[iprod][iebin][1]->Scale(1./4.);
373 if( hGroup[iprod][iebin][2] )
375 hGroup[iprod][iebin][2]->Add( h[iprod][iebin][ 5] );
376 hGroup[iprod][iebin][2]->Add( h[iprod][iebin][10] );
377 hGroup[iprod][iebin][2]->Add( h[iprod][iebin][13] );
379 hGroup[iprod][iebin][2]->Scale(1./4.);
382 if( hGroup[iprod][iebin][3] )
384 hGroup[iprod][iebin][3]->Add( h[iprod][iebin][ 4] );
385 hGroup[iprod][iebin][3]->Add( h[iprod][iebin][11] );
386 hGroup[iprod][iebin][3]->Add( h[iprod][iebin][12] );
388 hGroup[iprod][iebin][3]->Scale(1./4.);
393 for(
Int_t igroup = 0; igroup < ngroupmax; igroup++)
395 if( !hGroup[iprod][iebin][igroup] )
continue;
396 hGroup[iprod][iebin][igroup]->SetLineColor (colorGroup[igroup]);
397 hGroup[iprod][iebin][igroup]->SetMarkerColor(colorGroup[igroup]);
409 outputFileName= Form(
"%s_%s%s%s",titleData.Data(),titleMC.Data(),outputFileName2.Data(),
opt.Data());
412 printf(
"Output string: <%s>",outputFileName.Data());
416 TFile*
fout =
new TFile(Form(
"figures/%s/Projections_%s.root",
417 histoName.Data(),outputFileName.Data()),
"recreate");
423 for(
Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
425 if( !h[iprod][iebin][ipbin-firstP] )
continue;
426 h[iprod][iebin][ipbin-firstP]->SetName(Form(
"Prod%d_Ebin%d_Param%d",iprod,iebin,ipbin));
427 h[iprod][iebin][ipbin-firstP]->Write();
430 for(
Int_t igroup = 0; igroup < ngroupmax; igroup++)
432 if( !hGroup[iprod][iebin][igroup] )
continue;
433 hGroup[iprod][iebin][igroup]->SetName(Form(
"Prod%d_Ebin%d_ParamGroup%d",iprod,iebin,igroup));
434 hGroup[iprod][iebin][igroup]->Write();
437 if ( hA[iprod][iebin] )
439 hA[iprod][iebin]->SetName(Form(
"Prod%d_Ebin%d_AllParam",iprod,iebin));
440 hA[iprod][iebin]->Write();
446 printf(
"Create: %s\n",fout->GetName());
456 titleData.ReplaceAll(
"/",
"_");
458 gStyle->SetPadRightMargin(0.01);
459 gStyle->SetPadLeftMargin(0.12);
460 gStyle->SetTitleFontSize(0.06);
462 gStyle->SetOptStat(0);
469 gStyle->SetOptTitle(1);
470 gStyle->SetPadTopMargin(0.1);
472 TCanvas *
c =
new TCanvas(Form(
"c_ebin%d_%s",
473 iebin,histoName.Data()),
474 Form(
"%2.1f < E < %2.1f, %s",
475 lowE[iebin],higE[iebin],
477 ncolPar*2000,nrowPar*2000);
478 c->Divide(ncolPar,nrowPar);
480 TLegend *l =
new TLegend(-0.04,0,1,1);
483 l =
new TLegend(-0.04,0.,1,1);
484 l->SetTextSize(0.06);
488 l =
new TLegend(0.35,0.6,0.9,0.9);
489 l->SetTextSize(0.045);
495 l->AddEntry(
"",daLeg,
"");
496 l->AddEntry(
"",mcLeg,
"");
497 if((histoName.Contains(
"MM02") || histoName.Contains(
"MM20")) && !histoName.Contains(
"NoCut") )
498 l->SetHeader(Form(
" %2.1f < #it{E} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
500 l->SetHeader(Form(
" %2.1f < #it{E} < %2.1f GeV",lowE[iebin],higE[iebin]));
502 for(
Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
506 if ( (histoName.Contains(
"ECell") && !histoName.Contains(
"Tot")) || histoName.Contains(
"NLocMax"))gPad->SetLogy();
509 if(!h[0][iebin][ipbin-firstP])
continue;
513 if(!h[iprod][iebin][ipbin-firstP])
continue;
515 h[iprod][iebin][ipbin-firstP]->SetTitle(Form(
"SM %d",ipbin));
517 if(iprod==0) h[iprod][iebin][ipbin-firstP]->Draw(
"H");
518 else h[iprod][iebin][ipbin-firstP]->Draw(
"H same");
520 if(h[iprod][iebin][ipbin-firstP]->GetMaximum() > h[0][iebin][ipbin-firstP]->GetMaximum())
521 h[0][iebin][ipbin-firstP]->SetMaximum(h[iprod][iebin][ipbin-firstP]->GetMaximum()*1.2);
524 l->AddEntry(h[iprod][iebin][ipbin-firstP],Form(
"%s",
prodLeg[iprod].
Data()),
"PL");
527 h[0][iebin][ipbin-firstP]->Draw(
"H same");
531 if(ncolPar!=nrowPar && ncolPar*nrowPar!=nparam)
535 fileName = Form(
"figures/%s/ProductionComparisonPerSM_%s_Ebin%d",
536 histoName.Data(),outputFileName.Data(),iebin);
540 if ( !plotRatio )
continue;
542 TCanvas * cR =
new TCanvas(Form(
"cRat_ebin_%d_%s",
543 iebin,histoName.Data()),
544 Form(
"%2.1f < E < %2.1f, %s",
545 lowE[iebin],higE[iebin],
547 ncolPar*2000,nrowPar*2000);
548 cR->Divide(ncolPar,nrowPar);
551 for(
Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
557 if(!h[1][iebin][ipbin-firstP])
continue;
561 if(!h[iprod][iebin][ipbin-firstP])
continue;
563 TH1F* hRat = (TH1F*) h[iprod][iebin][ipbin-firstP]->Clone(Form(
"%s_Ratio",h[iprod][iebin][ipbin-firstP]->GetName()));
564 hRat->Divide(h[0][iebin][ipbin-firstP]);
566 if(iprod==0) hRat->Draw(
"H");
567 else hRat->Draw(
"H same");
569 hRat->SetYTitle(
"Ratio MC to Data");
577 cR->cd(ncolPar*nrowPar);
580 fileName = Form(
"figures/%s/ProductionComparisonPerSM_%s_Ebin%d_Ratios",
581 histoName.Data(),outputFileName.Data(),iebin);
591 if(nEBins > 2 && ncolE!=nrowE)
593 l2 =
new TLegend(-0.04,0.,1,1);
594 l2->SetTextSize(0.06);
598 l2 =
new TLegend(0.35,0.7,0.9,0.9);
599 l2->SetTextSize(0.025);
604 l2->SetBorderSize(0);
605 l2->AddEntry(
"",daLeg,
"");
606 l2->AddEntry(
"",mcLeg,
"");
608 if(ncolE==nrowE) l2->SetTextSize(0.04);
610 TCanvas * cA =
new TCanvas(Form(
"cAllSM_%s",histoName.Data()),
611 Form(
"All SM, %s",histoName.Data()),
612 ncolE*2000,nrowE*2000);
614 cA->Divide(ncolE,nrowE);
620 if(!hA[0][iebin])
continue;
622 if((histoName.Contains(
"ECell") && !histoName.Contains(
"Tot")) || histoName.Contains(
"NLocMax"))
625 gStyle->SetOptTitle(1);
626 gStyle->SetPadTopMargin(0.1);
628 hA[0][iebin]->Draw(
"H");
632 if(!hA[iprod][iebin])
continue;
634 hA[iprod][iebin]->SetTitle(Form(
"%2.1f < #it{E}^{clus} < %2.1f GeV",lowE[iebin],higE[iebin]));
636 if((histoName.Contains(
"MM02") || histoName.Contains(
"MM20")) && !histoName.Contains(
"NoCut") )
638 hA[iprod][iebin]->SetTitle(Form(
"%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
641 hA[iprod][iebin]->Draw(
"H same");
643 if(hA[iprod][iebin]->GetMaximum() > hA[0][iebin]->GetMaximum())
644 hA[0][iebin]->SetMaximum(hA[iprod][iebin]->GetMaximum()*1.2);
646 if(hA[iprod][iebin] && iebin==0) l2->AddEntry(hA[iprod][iebin],Form(
"%s",
prodLeg[iprod].
Data()),
"L");
649 hA[0][iebin]->Draw(
"H same");
652 if ( nEBins > 1 && ncolE!=nrowE)
657 fileName = Form(
"figures/%s/ProductionComparisonPerEbin_%s_AllSM",
658 histoName.Data(),outputFileName.Data());
664 TCanvas * cAR =
new TCanvas(Form(
"cAllSM_Rat_%s",histoName.Data()),
665 Form(
"All SM, %s",histoName.Data()),
666 ncolE*2000,nrowE*2000);
668 cAR->Divide(ncolE,nrowE);
674 if(!hA[0][iebin])
continue;
678 gStyle->SetOptTitle(1);
679 gStyle->SetPadTopMargin(0.1);
681 hA[0][iebin]->Draw(
"H");
685 if(!hA[iprod][iebin])
continue;
687 TH1F* hRat = (TH1F*) hA[iprod][iebin]->Clone(Form(
"%s_Ratio",hA[iprod][iebin]->GetName()));
688 hRat->Divide(hA[0][iebin]);
690 if(iprod==1) hRat->Draw(
"H");
691 else hRat->Draw(
"H same");
693 hRat->SetYTitle(
"Ratio MC to Data");
699 if ( nEBins > 1 && ncolE!=nrowE)
700 cAR->cd(ncolE*nrowE);
704 fileName = Form(
"figures/%s/ProductionComparisonPerEbin_%s_AllSM_Ratios",
705 histoName.Data(),outputFileName.Data());
707 cAR->Print(fileName);
713 for(
Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
715 gStyle->SetOptTitle(1);
716 gStyle->SetPadTopMargin(0.1);
718 TCanvas *
c =
new TCanvas(Form(
"c_par%d_%s",
719 ipbin,histoName.Data()),
726 TLegend *l =
new TLegend(-0.04,0,1,1);
731 l->SetTextSize(0.07);
732 l->SetHeader(Form(
" SM %d",ipbin));
737 if(histoName.Contains(
"ECell") && !histoName.Contains(
"Tot"))gPad->SetLogy();
740 if(!h[0][iebin][ipbin-firstP])
continue;
744 if(!h[iprod][iebin][ipbin-firstP])
continue;
746 h[iprod][iebin][ipbin-firstP]->SetTitle(Form(
"%2.1f < #it{E}^{clus} < %2.1f GeV",lowE[iebin],higE[iebin]));
747 if((histoName.Contains(
"MM02") || histoName.Contains(
"MM20")) && !histoName.Contains(
"NoCut") )
748 h[iprod][iebin][ipbin-firstP]->SetTitle(Form(
"%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
750 if(iprod==0) h[iprod][iebin][ipbin-firstP]->Draw(
"H");
751 else h[iprod][iebin][ipbin-firstP]->Draw(
"H same");
753 if(h[iprod][iebin][ipbin-firstP]->GetMaximum() > h[0][iebin][ipbin-firstP]->GetMaximum())
754 h[0][iebin][ipbin-firstP]->SetMaximum(h[iprod][iebin][ipbin-firstP]->GetMaximum()*1.2);
757 l->AddEntry(h[iprod][iebin][ipbin-firstP],Form(
"%s",
prodLeg[iprod].
Data()),
"PL");
760 h[0][iebin][ipbin-firstP]->Draw(
"H same");
766 fileName = Form(
"figures/%s/ProductionComparisonPerEbin_%s_SM%d",
767 histoName.Data(),outputFileName.Data(),ipbin);
773 Int_t colorTC [] = {1,2,6,4,4,6,2,1,1,2,6,4,4,6,2,1};
774 Int_t lineStyleTC[] = {1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4};
776 Int_t colorSM []= { 1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 6, 6, 8, 8, kOrange, kOrange, kRose, kRose, kMagenta, kMagenta};
777 Int_t lineStyleSM[]= { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2};
787 gStyle->SetOptTitle(1);
788 gStyle->SetPadTopMargin(0.1);
790 TCanvas *
c =
new TCanvas(Form(
"c_iprod%d_%s",iprod,histoName.Data()),
791 Form(
"%s, %s" ,
prod[iprod].
Data(), histoName.Data()),
792 ncolE*2000,nrowE*2000);
793 c->Divide(ncolE,nrowE);
795 TLegend *l =
new TLegend(-0.04,0,1,1);
800 l->SetTextSize(0.07);
807 if(!h[iprod][iebin][0])
continue;
809 for(
Int_t iparam = firstP; iparam <= lastP; iparam++)
811 if(!h[iprod][iebin][iparam])
continue;
813 h[iprod][iebin][iparam]->SetTitle(Form(
"%2.1f < #it{E} < %2.1f GeV",lowE[iebin],higE[iebin]));
814 if((histoName.Contains(
"MM02") || histoName.Contains(
"MM20")) && !histoName.Contains(
"NoCut") )
815 h[iprod][iebin][iparam]->SetTitle(Form(
"%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
817 if(histoName.Contains(
"TCardChan"))
819 h[iprod][iebin][iparam]->SetLineColor(colorTC[iparam]);
820 h[iprod][iebin][iparam]->SetLineStyle(lineStyleTC[iparam]);
824 h[iprod][iebin][iparam]->SetLineColor(colorSM[iparam]);
825 h[iprod][iebin][iparam]->SetLineStyle(lineStyleSM[iparam]);
828 if(iparam==0) h[iprod][iebin][iparam]->Draw(
"H");
829 else h[iprod][iebin][iparam]->Draw(
"H same");
831 if(h[0][iebin][iparam] && h[iprod][iebin][iparam]->GetMaximum() > h[0][iebin][iparam]->GetMaximum())
832 h[0][iebin][iparam]->SetMaximum(h[iprod][iebin][iparam]->GetMaximum()*1.2);
836 if(histoName.Contains(
"SM"))
837 l->AddEntry(h[iprod][iebin][iparam],Form(
"SM = %d",iparam),
"PL");
839 l->AddEntry(h[iprod][iebin][iparam],Form(
"T-Card i = %d",iparam),
"PL");
849 if (
prod[iprod].Contains(
"data") )
850 fileName = Form(
"figures/%s/SMComparison_PerEbin_%s%s",
851 histoName.Data(),titleData.Data(),outputFileName2.Data());
854 fileName = Form(
"figures/%s/SMComparison_PerEbin_%s_%d%s",
855 histoName.Data(),titleMC.Data(),iprod,outputFileName2.Data());
865 gStyle->SetOptTitle(1);
866 gStyle->SetPadTopMargin(0.1);
867 TCanvas * cGroup =
new TCanvas(Form(
"cGroups_%s_%s",histoName.Data(),
prod[iprod].Data()),
868 Form(
"Groups, %s %s",histoName.Data(),
prod[iprod].Data()),
869 ncolE*2000,nrowE*2000);
871 cGroup->Divide(ncolE,nrowE);
873 TLegend *lG =
new TLegend(0,0,1,1);
877 lG->SetBorderSize(0);
878 lG->SetTextSize(0.07);
885 for(
Int_t igroup = 0; igroup < ngroupmax; igroup++)
887 if(!hGroup[iprod][iebin][igroup])
continue;
889 hGroup[iprod][iebin][igroup]->SetTitle(Form(
"%2.1f < #it{E} < %2.1f GeV",lowE[iebin],higE[iebin]));
890 if((histoName.Contains(
"MM02") || histoName.Contains(
"MM20")) && !histoName.Contains(
"NoCut") )
891 hGroup[iprod][iebin][igroup]->SetTitle(Form(
"%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
893 if(igroup==0) hGroup[iprod][iebin][igroup]->Draw(
"H");
894 else hGroup[iprod][iebin][igroup]->Draw(
"H same");
896 if(hGroup[0][iebin][igroup] && hGroup[iprod][iebin][igroup]->GetMaximum() > hGroup[0][iebin][igroup]->GetMaximum())
897 hGroup[0][iebin][igroup]->SetMaximum(hGroup[iprod][iebin][igroup]->GetMaximum()*1.2);
901 if(histoName.Contains(
"SM"))lG->AddEntry(hGroup[iprod][iebin][igroup],Form(
"SM = %s",groupSM[igroup].
Data()),
"PL");
902 if(histoName.Contains(
"TCardChannel"))lG->AddEntry(hGroup[iprod][iebin][igroup],Form(
"T-Card cell in %s",groupTC[igroup].
Data()),
"PL");
907 cGroup->cd(ncolE*nrowE);
913 if (
prod[iprod].Contains(
"data") )
914 fileName = Form(
"figures/%s/GroupComparison_PerEbin_%s%s",
915 histoName.Data(),titleData.Data(),outputFileName2.Data());
918 fileName = Form(
"figures/%s/GroupComparison_PerEbin_%s_%d%s",
919 histoName.Data(),titleMC.Data(),iprod,outputFileName2.Data());
922 cGroup->Print(fileName);
925 if(!plotRatio)
continue;
927 TCanvas * cR =
new TCanvas(Form(
"cRat_prod_%d_%s",iprod,histoName.Data()),
928 Form(
"%s, %s",
prod[iprod].
Data(),histoName.Data()),
929 ncolE*2000,nrowE*2000);
930 cR->Divide(ncolE,nrowE);
939 if(!h[iprod][iebin][0])
continue;
941 for(
Int_t iparam = 1; iparam < nparam; iparam++)
943 if(!h[iprod][iebin][iparam])
continue;
945 TH1F* hRat = (TH1F*) h[iprod][iebin][iparam]->Clone(Form(
"%s_Ratio_PerParam_%s",h[iprod][iebin][iparam]->GetName(),
prod[iprod].
Data()));
946 hRat->Divide(hA[iprod][iebin]);
948 if(iparam==0) hRat->Draw(
"H");
949 else hRat->Draw(
"H same");
951 hRat->SetYTitle(
"Ratio to no selection");
965 if (
prod[iprod].Contains(
"data") )
966 fileName = Form(
"figures/%s/SMComparison_PerEbin_%s%s_Ratios",
967 histoName.Data(),titleData.Data(),outputFileName2.Data());
970 fileName = Form(
"figures/%s/SMComparison_PerEbin_%s_%d%s_Ratios",
971 histoName.Data(),titleMC.Data(),iprod,outputFileName2.Data());
993 if ( histoName ==
"SMM02" )
995 xmin = 0.1; xmax = 1.10;
996 xNormMin = 0.6; xNormMax = 2;
1000 if ( histoName ==
"SMM02NoCut" )
1002 xmin = 0.1; xmax = 1.0;
1003 xNormMin = 0.1; xNormMax = 0.4;
1007 if ( histoName ==
"SMNCell" && !histoName.Contains(
"Module") )
1009 xmin = 2 ; xmax = 12 ;
1013 if ( histoName.Contains(
"SMM20Low") )
1015 xmin = 0.05; xmax = 0.25;
1020 if ( histoName.Contains(
"SMM20Hig") )
1022 xmin = 0.05; xmax = 0.30;
1027 if ( histoName.Contains(
"Module") )
1029 xmin = 0.0; xmax = 100000;
1033 if ( histoName.Contains(
"Rat") )
1037 else if ( histoName.Contains(
"Tot") )
1039 xmin = 0.0; xmax = 20;
1043 else if ( histoName.Contains(
"ECellModuleMax") ||
1044 histoName.Contains(
"ECellModuleOut") )
1046 xmin = 0.0; xmax = 10;
1051 if ( histoName.Contains(
"TCardChannelM02") )
1053 xmin = 0.1; xmax = 0.5;
1056 if( histoName.Contains(
"NoCut") ) normtomax = 1;
1059 if ( histoName.Contains (
"SMEMaxEClusterRat") )
1061 xmin = 0 ; xmax = 1 ;
1064 if ( histoName.Contains(
"LowM02") ) xmin = 0.4 ;
1065 if ( histoName.Contains(
"HighM02") ) xmax = 0.8 ;
1084 Int_t color [] = {1,4,2,kYellow-2,8,kCyan,kOrange+2,kViolet,kOrange-2,4,2,6,8,9,kYellow-6,kCyan,kOrange+2,kViolet,kOrange-2};
1085 Int_t lineStyle[] = {1,1,1,1,1,1, 1, 1, 1, 1, 1,2,2,2,2,2, 2, 2, 2, 2, 2,2,2,2,2,2,2,2,2,2,2,2};
1086 Int_t marker [] = {20,20,20,21,24,24,24,24,24,24,24};
1088 histo->SetLineColor(color[iprod]);
1090 histo->SetLineWidth(2);
1092 histo->SetLineStyle(lineStyle[iprod]);
1094 histo->SetMarkerStyle(marker[iprod]);
1096 histo->SetMarkerColor(color[iprod]);
1098 histo->SetMarkerSize(0.5);
1100 histo->SetTitleOffset(1.8,
"Y");
1102 histo->SetTitle(Form(
"%2.1f < #it{E} < %2.1f GeV",lowEBin,highEBin));
1106 histo->Rebin(rebin);
1109 histo->SetAxisRange(xmin,xmax,
"X");
1113 Int_t xNormMinBin = histo->FindBin(xNormMin);
1114 Int_t xNormMaxBin = histo->FindBin(xNormMax);
1116 Double_t integral = histo->Integral(xNormMinBin, xNormMaxBin);
1119 printf(
"\t \t Integral %e bins [%d, %d], range [%2.2f, %2.2f]\n",
1120 integral,xNormMinBin,xNormMaxBin,xNormMin,xNormMax);
1122 if ( integral < 1e-10 )
1125 histo->Scale(1./integral);
1127 if(!histoName.Contains(
"Module"))
1129 if(histoName.Contains(
"MEtaPhi"))
1130 histo->SetYTitle(
"1/ integral d #it{N} / d #sigma_{#eta#varphi}^{2}");
1131 else if(histoName.Contains(
"MEta"))
1132 histo->SetYTitle(
"1/ integral d #it{N} / d #sigma_{#eta}^{2}");
1133 else if(histoName.Contains(
"MPhi"))
1134 histo->SetYTitle(
"1/ integral d #it{N} / d #sigma_{#varphi}^{2}");
1135 else if(histoName.Contains(
"SMEMaxEClusterRat"))
1136 histo->SetYTitle(
"1/ integral d #it{N} / d (#it{E}_{cell}^{max}/#it{E}_{cluster})");
1137 else if(histoName.Contains(
"MNCell"))
1138 histo->SetYTitle(
"1/ integral d #it{N} / d #it{n}^{w}_{cell}");
1139 else if(histoName.Contains(
"MNLocMax"))
1140 histo->SetYTitle(
"1/ integral d #it{N} / d #it{n}_{LM}");
1141 else if(histoName.Contains(
"M20"))
1142 histo->SetYTitle(
"1/ integral d #it{N} / d #sigma_{short}^{2}");
1143 else if(histoName.Contains(
"M02"))
1144 histo->SetYTitle(
"1/ integral d #it{N} / d #sigma_{long}^{2}");
1146 else histo->SetYTitle(
"1/ integral d #it{N} ");
1151 Double_t scale = histo->GetBinContent(histo->FindBin(0.245));
1152 if ( debug ) printf(
"\t \t \t Norm to max scale %2.2e\n",scale);
1154 if ( scale < 1e-10 )
1157 histo->Scale(1./scale);
1158 histo->SetYTitle(
"Norm. to max at 0.25");
1162 if(!histoName.Contains(
"Module"))
1164 if(histoName.Contains(
"MEtaPhi"))
1165 histo->SetXTitle(
"#sigma_{#eta#varphi}^{2}");
1166 else if(histoName.Contains(
"MEta"))
1167 histo->SetXTitle(
"#sigma_{#eta}^{2}");
1168 else if(histoName.Contains(
"MPhi"))
1169 histo->SetXTitle(
"#sigma_{#varphi}^{2}");
1170 else if(histoName.Contains(
"MNCell"))
1171 histo->SetXTitle(
"#it{n}_{cell}^{w}");
1172 else if(histoName.Contains(
"MNLocMax"))
1173 histo->SetXTitle(
"#it{n}_{LM}");
1174 else if(histoName.Contains(
"M20"))
1175 histo->SetXTitle(
"#sigma_{#short}^{2}");
1176 else if(histoName.Contains(
"M02"))
1177 histo->SetXTitle(
"#sigma_{long}^{2}");
1179 else if(histoName.Contains(
"ECell"))
1181 histo->SetAxisRange(0,highEBin*1.05,
"X");
Int_t color[]
print message on plot with ok/not ok
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void CompareTH3DataAndMCProd(TString &outputFileName, TString histoName="SMM02NoCut", const Int_t nProd=3, TString *prod=0x0, TString *prodLeg=0x0, TString clusterization="", TString tm="_TMDep", TString pid="_Neutral", TString titleMC="JJDecLow", TString mcLeg="MC: #gammaJ+JJ({p^{EMCal}_{T,#gamma}>3.5 GeV/#it{c})", TString titleData="LHC11cd_EMC7", TString daLeg="pp@7 TeV, LHC11c+d EMC7", Int_t firstP=0, Int_t lastP=9, TArrayD binE=0, Int_t firstMC=1, Bool_t plotRatio=kFALSE, Bool_t saveHisto=kFALSE, TString opt="", Bool_t debug=kFALSE)
Bool_t SetHistogramRangesAndTitles(TH1D *histo, TString histoName, Int_t iprod, Int_t rebin, Float_t xmin, Float_t xmax, Bool_t normtomax, Float_t xNormMin, Float_t xNormMax, Float_t lowEBin, Float_t highEBin, Bool_t debug)
TFile * file
TList with histograms for a given trigger.
void GetCanvasColRowNumber(Int_t npad, Int_t &ncol, Int_t &nrow, Bool_t square=kFALSE)
TFile * fout
input train file
TString prod[]
productions to be compared, directory name
void DefineHistogramSettings(TString histoName, Float_t &xmin, Float_t &xmax, Float_t &xNormMin, Float_t &xNormMax, Bool_t &normtomax, Int_t &rebin)