void calc_rho_eff(){ //TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeam"); TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeamTagged"); TH2F *h2=(TH2F *)_file0->FindObjectAny("PipPimMass_vs_Ebeam"); ofstream out("rho_eff.dat"); double eff[45]; double deff[45]; double Eg[45]; for (int i=1;i<=45;i++){ double numer=h2->Integral(i,i,113,480); // 0.28-1.2 GeV //double numer=h2->Integral(i,i,201,400); // 0.5-1. GeV double denom=h1->GetBinContent(i)+0.00001; eff[i-1]=numer/denom; deff[i-1]=eff[i-1]*sqrt(1./numer+1./denom); Eg[i-1]=h1->GetBinCenter(i); out << Eg[i-1] << " " << eff[i-1] << " " << deff[i-1] << endl; } out.close(); TCanvas *c1=new TCanvas(); TH2F *he=new TH2F("he","Efficiency for #rho#rightarrow#pi^{+}#pi^{-}",10,3,12,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"); }