void calc_phi_kpkm_eff(){ // TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeam"); TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeamTagged"); TH2F *h2=(TH2F *)_file0->FindObjectAny("KpKmMass_vs_Ebeam"); ofstream out("phi_kpkm_eff.dat"); double eff[45]; double deff[45]; double Eg[45]; for (int i=1;i<=45;i++){ double numer=h2->Integral(i,i,41,110); // 0.99-1.06 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#rightarrowK^{+}K^{-}",45,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"); }