void calc_phi_3pi_eff(){ // TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeam"); TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeamTagged"); TH2F *h2=(TH2F *)_file0->FindObjectAny("PipPimPi0Mass_vs_Ebeam"); ofstream out("phi_3pi_eff.dat"); double eff[45]; double deff[45]; double Eg[45]; for (int i=1;i<=45;i++){ double numer=h2->Integral(i,i,385,432); // 0.96-1.08 GeV double denom=h1->GetBinContent(i)+0.00001; eff[i-1]=numer/denom; deff[i-1]=eff[i-1]*sqrt(1./(numer+0.0000001)+1./denom); Eg[i-1]=h1->GetBinCenter(i); out << eff[i-1] << " " << deff[i-1] << endl; } out.close(); TCanvas *c1=new TCanvas(); TH2F *he=new TH2F("he","Efficiency for #phi#rightarrow#pi^{+}#pi^{-}#pi^{0}",10,2.8,11.8,10,0,0.2); he->SetXTitle("E_{#gamma} [GeV]"); he->SetYTitle("#varepsilon"); he->Draw(); TGraphErrors *g1=new TGraphErrors(45,Eg,eff,0,deff); g1->Draw("p"); }