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+ for (int i = 0 ; i < nHists ; i ++ ) {
19+ hists [i ] = (TH1F * )file -> GetDirectory ("em-lmee-lf-cocktail" )
20+ -> Get (TString ("mee" ) + name_extra + histNames [i ]);
21+ hists [i ]-> Rebin (rebin );
22+ hists [i ]-> Scale (1. / nEvents );
23+ hists [i ]-> SetTitle (histLegends [i ]);
24+ }
25+ }
26+
27+ void plotLFCocktail (TString filename = "AnalysisResults.root" , int rebin = 1 ) {
28+
29+ TFile * file = TFile ::Open (filename .Data ());
30+
31+ TH1I * hNEvents =
32+ (TH1I * )file -> GetDirectory ("em-lmee-lf-cocktail" )-> Get ("NEvents" );
33+ int nEvents = hNEvents -> GetBinContent (1 );
34+
35+ loadHistos (file , mee , "" , rebin , nEvents );
36+ loadHistos (file , mee_orig , "_orig" , rebin , nEvents );
37+
38+ auto canvas = new TCanvas ("LF Cocktail" , "LF Cocktail" , 1500 , 500 );
39+ canvas -> Divide (2 , 1 );
40+
41+ mee [0 ]-> SetStats (0 );
42+ mee [0 ]-> GetXaxis ()-> SetRangeUser (0.0 , 1.1 );
43+ mee_orig [0 ]-> SetStats (0 );
44+ mee_orig [0 ]-> GetXaxis ()-> SetRangeUser (0.0 , 1.1 );
45+
46+ canvas -> cd (1 );
47+ gPad -> SetLogy ();
48+ for (int i = 0 ; i < nHists ; i ++ ) {
49+ mee_orig [i ]-> SetLineColor (i + 1 );
50+ mee_orig [i ]-> Draw ("same" );
51+ }
52+ gPad -> BuildLegend (0.62 , 0.9 , 0.9 , 0.6 );
53+ mee_orig [0 ]-> SetTitle ("before resolution and acceptance" );
54+ canvas -> cd (2 );
55+ gPad -> SetLogy ();
56+ for (int i = 0 ; i < nHists ; i ++ ) {
57+ mee [i ]-> SetLineColor (i + 1 );
58+ mee [i ]-> Draw ("same" );
59+ }
60+ gPad -> BuildLegend (0.62 , 0.9 , 0.9 , 0.6 );
61+ mee [0 ]-> SetTitle ("after resolution and acceptance" );
62+ }
0 commit comments