#include using namespace std; #include "StandardLabels.C" int GetIntegral(const char *fname, double &integral); void eff_vs_z(void) { vector integral_Mpipi; vector z_vals; for(int z=1; z<=79 ; z+=2){ char fname[256]; sprintf(fname, "../OUTPUT.2/z%d.root", z); double integral; if(GetIntegral(fname, integral) != 0)continue; integral/=100000; // normalize to number of events integral_Mpipi.push_back(integral); z_vals.push_back((double)z); } TGraphErrors *g = new TGraphErrors(z_vals.size(), &z_vals[0], &integral_Mpipi[0]); g->SetMarkerStyle(20); TCanvas *c1 = new TCanvas("c1"); c1->SetTicks(); c1->SetGridy(); TH2D *axes = new TH2D("axes", "Rough efficiency vs. target position", 100, 0.0, 80.0, 100, 0.0, 1.1); axes->SetStats(0); axes->SetXTitle("Target Position (cm)"); axes->SetYTitle("Num. #pi^{+}#pi^{-} pairs/Num. generated events"); axes->Draw(); g->Draw("P"); StandardLabels(axes, "100k #pi^{+}#pi^{-} events generated" , "0.2 #leq m_{#pi#pi recon} #leq 0.5" , "vertex constraint fixed at z=65cm (i.e. not at actual vertex location)" , ""); c1->SaveAs("eff_vs_z.png"); c1->SaveAs("eff_vs_z.pdf"); } int GetIntegral(const char *fname, double &integral) { TFile f(fname); if(!f.IsOpen())return -1; TH1D *h = (TH1D*)gROOT->FindObject("mass_pip_pim"); integral = h->Integral(h->FindBin(0.2), h->FindBin(0.5)); f.Close(); }