// This macro is to be used on a root file produced with the // event.C selector. #include "chain_fine.h" #include "chain_course.h" #include "StandardLabels.C" void Eres_vs_E(const char *who="fine") { gROOT->Reset(); //gStyle->SetPadRightMargin(0.15); char fname[256]; sprintf(fname,"event_%s.root", who); TFile *f = new TFile(fname); TH3D *E_diff = (TH3D*)gROOT->FindObject("E_diff"); TCanvas *c1 = new TCanvas(); c1->SetTicks(); c1->SetGrid(); char title[256]; sprintf(title, "BCAL Energy Res. (%s)", who); TH2D *axes = new TH2D("axes",title, 100, 0.0, 3.0, 100, 0.0, 45.0); axes->SetStats(0); axes->SetXTitle("Energy (GeV)"); axes->SetYTitle("Energy Resolution(%)"); axes->Draw(); // Legend TLegend *leg = new TLegend(0.526, 0.119+0.40, 0.879, 0.462+0.40); leg->SetFillColor(kWhite); // Make plot for several different energy bins double thetas[]={12.0, 16.0, 20.0, 45.0, 90.0}; int colors[] = {kRed,kBlue,kGreen,kMagenta,kBlack}; int styles[] = {20, 21, 22, 23, 29}; int Nthetas = 5; for(int i=0; iGetXaxis()->FindBin(thetas[i]); int xbinstart = xbin - (Nbins-1)/2; int xbinend = xbinstart + Nbins-1; double ystart = E_diff->GetXaxis()->GetBinLowEdge(xbinstart); double yend = E_diff->GetXaxis()->GetBinLowEdge(xbinend+1); E_diff->GetXaxis()->SetRange(xbinstart, xbinend); TH2D *E_diff_zy = E_diff->Project3D("zy"); E_diff_zy->FitSlicesY(); TH1D *E_diff_zy_2 = (TH1D*)gROOT->FindObject("E_diff_zy_2"); char hname[256]; sprintf(hname, "theta%05d_px", thetas[i]*100.0); TH1D *Eres = (TH1D*)E_diff_zy_2->Clone(hname); Eres->Scale(100.0); // convert to percent Eres->SetLineColor(colors[i]); Eres->SetMarkerColor(colors[i]); Eres->SetMarkerStyle(styles[i]); Eres->Draw("PCLsame"); char lab[256]; double theta = thetas[i]; double Lfrac = (65.0-17.0+65.0/tan(theta/57.3))/390.0; sprintf(lab,"%2.0f^{o}- %2.0f^{o} (z=%4.02fL)", ystart, yend, Lfrac); leg->AddEntry(Eres, lab); } leg->Draw(); StandardLabels(axes, "20M events No cuts on primary conversion point.", "Single #gamma"); sprintf(fname,"Eres_vs_E_%s.png", who); c1->SaveAs(fname); sprintf(fname,"Eres_vs_E_%s.pdf", who); c1->SaveAs(fname); }