// WARNING: This script seems to only work the first // time it is run. Subsequent invocations cause empty // histos. Restart ROOT before re-running! #include "chain_fine.h" #include "chain_course.h" #include "StandardLabels.C" void theta_rms_vs_E(void) { gROOT->Reset(); int max_events = 1000000; TChain *fine = chain_fine("event"); TChain *course = chain_course("event"); TCanvas *c1 = new TCanvas(); c1->SetTicks(); TH2D *thetares_fine = new TH2D("thetares_fine", "", 50, 0.0, 2.0, 80, -20.0, 20.0); TH2D *thetares_course = new TH2D("thetares_course", "", 50, 0.0, 2.0, 80, -20.0, 20.0); TCut cut1(""); fine->Project("thetares_fine","(E.recon.p.Theta()-E.thrown.Theta())*57.3:E.thrown.E()",cut1,"",max_events); course->Project("thetares_course","(E.recon.p.Theta()-E.thrown.Theta())*57.3:E.thrown.E()",cut1,"",max_events); TH1D *thetares_fine_2 = MakeRMSHisto(thetares_fine); TH1D *thetares_course_2 = MakeRMSHisto(thetares_course); thetares_fine_2->SetLineColor(kRed); thetares_fine_2->SetLineWidth(2); thetares_course_2->SetLineColor(kBlue); thetares_course_2->SetLineWidth(2); TH2D *axes = new TH2D("axes","BCAL Reconstruction Efficiency", 100, 0.0, 2.0, 100, 0.0, 6.0); axes->SetStats(0); axes->SetYTitle("RMS(#theta_{rec}-#theta_{gen}) (deg.)"); axes->SetXTitle("E_{#gamma} (GeV)"); axes->Draw(); thetares_fine_2->Draw("same"); thetares_course_2->Draw("same"); TLegend *leg = new TLegend(0.564,0.680, 0.883, 0.872); leg->SetFillColor(kWhite); leg->AddEntry(thetares_fine_2,"Fine Segmentation"); leg->AddEntry(thetares_course_2,"Course Segmentation"); leg->Draw(); char str[256]; sprintf(str,"%d events No cuts on primary conversion point.", fine->GetEntries(cut1)); StandardLabels(axes, "100MeV #leq E #leq 150MeV 10^{o}#leq#theta#leq110^{o}", "Single #gamma", str, "RMS from projections"); c1->SaveAs("theta_rms_vs_E.png"); c1->SaveAs("theta_rms_vs_E.pdf"); } TH1D* MakeRMSHisto(TH2D *h) { char hname[256]; sprintf(hname, "%s_2", h->GetName()); TAxis *xaxis = h->GetXaxis(); TAxis *yaxis = h->GetYaxis(); Int_t Nbins = xaxis->GetNbins(); TH1D *h_2 = new TH1D(hname, "", Nbins, xaxis->GetXmin(), xaxis->GetXmax()); TH1D *tmp_py = new TH1D("tmp_py", "", yaxis->GetNbins(), yaxis->GetXmin(), yaxis->GetXmax()); for(int bin=1; bin<=Nbins; bin++){ tmp_py->Reset(); h->ProjectionY("tmp_py", bin, bin); h_2->SetBinContent(bin, tmp_py->GetRMS()); h_2->SetBinError(bin, tmp_py->GetRMSError()); } return h_2; }