void calc_eta_2g_eff(){ //TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeam"); TH1F *h1=(TH1F *)_file0->FindObjectAny("MCBeamTagged"); TH2F *h2=(TH2F *)_file0->FindObjectAny("TwoGammaMass_vs_Ebeam"); ofstream out("eta_2g_eff.dat"); double eff[45]; double deff[45]; double Eg[45]; for (int i=1;i<=45;i++){ double numer=h2->Integral(i,i,201,240); // 0.5-0.6 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 << " " << eff[i-1] << " " << deff[i-1] << endl; } out.close(); TCanvas *c1=new TCanvas(); TH2F *he=new TH2F("he","Efficiency for #eta#rightarrow2#gamma",10,2.8,11.8,10,0,0.5); he->SetXTitle("E_{#gamma} [GeV]"); he->SetYTitle("#varepsilon"); he->Draw(); TGraphErrors *g1=new TGraphErrors(45,Eg,eff,0,deff); g1->Draw("p"); }