1+ const int nHists = 7 ;
2+ TH1F * mee [nHists ];
3+ TH1F * mee_orig [nHists ];
4+ TString histNames [nHists ] = {"" , "_Pi0" , "_Eta" , "_EtaP" ,
5+ "_Rho" , "_Omega" , "_Phi" };
6+ TString histLegends [nHists ] = {
7+ "Cocktail sum" ,
8+ "#pi^{0}#rightarrow#gammae^{+}e^{-}" ,
9+ "#eta#rightarrow#gammae^{+}e^{-}" ,
10+ "#eta'#rightarrow#gammae^{+}e^{-}, #eta'#rightarrow#omegae^{+}e^{-}" ,
11+ "#rho#rightarrowe^{+}e^{-}" ,
12+ "#omega#rightarrow#pi^{0}e^{+}e^{-}, #omega#rightarrowe^{+}e^{-}" ,
13+ "#phi#rightarrow#etae^{+}e^{-}, #phi#rightarrow#pi^{0}e^{+}e^{-}, "
14+ "#phi#rightarrowe^{+}e^{-}" };
15+
16+ void loadHistos (TFile * file , TH1F * hists [], TString name_extra , int rebin ,
17+ int nEvents )
18+ {
19+ for (int i = 0 ; i < nHists ; i ++ ) {
20+ hists [i ] = (TH1F * )file -> GetDirectory ("em-lmee-lf-cocktail" )
21+ -> Get (TString ("mee" ) + name_extra + histNames [i ]);
22+ hists [i ]-> Rebin (rebin );
23+ hists [i ]-> Scale (1. / nEvents );
24+ hists [i ]-> SetTitle (histLegends [i ]);
25+ }
26+ }
27+
28+ void plotLFCocktail (TString filename = "AnalysisResults.root" , int rebin = 1 )
29+ {
30+
31+ TFile * file = TFile ::Open (filename .Data ());
32+
33+ TH1I * hNEvents =
34+ (TH1I * )file -> GetDirectory ("em-lmee-lf-cocktail" )-> Get ("NEvents" );
35+ int nEvents = hNEvents -> GetBinContent (1 );
36+
37+ loadHistos (file , mee , "" , rebin , nEvents );
38+ loadHistos (file , mee_orig , "_orig" , rebin , nEvents );
39+
40+ auto canvas = new TCanvas ("LF Cocktail" , "LF Cocktail" , 1500 , 500 );
41+ canvas -> Divide (2 , 1 );
42+
43+ mee [0 ]-> SetStats (0 );
44+ mee [0 ]-> GetXaxis ()-> SetRangeUser (0.0 , 1.1 );
45+ mee_orig [0 ]-> SetStats (0 );
46+ mee_orig [0 ]-> GetXaxis ()-> SetRangeUser (0.0 , 1.1 );
47+
48+ canvas -> cd (1 );
49+ gPad -> SetLogy ();
50+ for (int i = 0 ; i < nHists ; i ++ ) {
51+ mee_orig [i ]-> SetLineColor (i + 1 );
52+ mee_orig [i ]-> Draw ("same" );
53+ }
54+ gPad -> BuildLegend (0.62 , 0.9 , 0.9 , 0.6 );
55+ mee_orig [0 ]-> SetTitle ("before resolution and acceptance" );
56+ canvas -> cd (2 );
57+ gPad -> SetLogy ();
58+ for (int i = 0 ; i < nHists ; i ++ ) {
59+ mee [i ]-> SetLineColor (i + 1 );
60+ mee [i ]-> Draw ("same" );
61+ }
62+ gPad -> BuildLegend (0.62 , 0.9 , 0.9 , 0.6 );
63+ mee [0 ]-> SetTitle ("after resolution and acceptance" );
64+ }
0 commit comments