#include int xft_fake(Char_t* filename="119632.hbk") { //Clear out variables on the stack (avoids much grief) gROOT->Reset(); gStyle->SetHistLineWidth(1); gStyle->SetPadGridX(true); gStyle->SetPadGridY(true); gStyle->SetLabelSize(0.04,"XY"); gStyle->SetTitleSize(0.05, "XY"); gStyle->SetTitleOffset(0.8, "XY"); //Open histogram file cout << "filename is "<< filename << endl; TFile* f= new TFile(filename); //Open file in which to store pictures TPostScript *ps = new TPostScript("XFT_fake.ps",111); //Open Canvas TCanvas *myc = new TCanvas("MyC","Test Canvas",700,700); // //Now look at fakes TH1F *xftFake = (TH1F*)xftPtBin->Clone(); xftFake->SetName("xftFake"); Float_t x=0., xf=0., x10=0., xf10=0.; Int_t nx = xftPtBin->GetNbinsX(); for (Int_t i=1;i<=nx;i++){ Float_t xbin = xftPtBin->GetBinContent(i); Float_t xfbin = xftFakePtBin->GetBinContent(i); Float_t efficiency = 0.; Float_t error = 0.; if(xbin>0.5){ efficiency = xfbin/xbin; error = sqrt(efficiency*(1.-efficiency)/xbin); } xftFake->SetBinContent(i,100.*efficiency); xftFake->SetBinError(i,100.*error); x += xbin; xf += xfbin; if(i>35 && i< 60){ x10 += xbin; xf10 += xfbin; } } printf("\n XFT = %8.0f Fakes = %8.0f",x,xf); printf("\n XFT = %8.0f Fakes = %8.0f in top 24 bins ",x10,xf10); Float_t fake=0., fake10=0., error = 0.; if(x>1.){ fake = xf/x; error = sqrt(fake*(1.-fake)/x); } printf("\n Fake = %6.2f +- %6.2f percent",100.*fake,100.*error); if(x10>1.){ fake10 = xf10/x10; error = sqrt(fake10*(1.-fake10)/x10); } printf("\n Fake = %6.2f +- %6.2f percent in top 24 bins ",100.*fake10,100.*error); ps->NewPage(); myc->Clear(); myc->Divide(1,2); myc->cd(1); xftPtBin->SetTitle("XFT tracks (fakes are shaded in red)"); xftPtBin->SetXTitle("pT Bin"); xftPtBin->SetYTitle("XFT Tracks"); xftPtBin->GetXaxis()->SetRange(0,100); xftPtBin->Draw("eh"); xftFakePtBin->SetFillColor(2); xftFakePtBin->Draw("ehsame"); l = new TLine(36.,0,36,350); l->SetLineColor(2); l->SetLineStyle(2); l->SetLineWidth(2); l->Draw(); l = new TLine(59.,0,59,350); l->SetLineColor(2); l->SetLineStyle(2); l->SetLineWidth(2); l->Draw(); a = new TArrow(36.,350,59,350,0.05,"<|>"); a->SetFillColor(2); a->SetLineColor(2); a->SetLineWidth(2); a->Draw(); TLatex *e = new TLatex(); e->SetTextSize(0.06); e->SetTextColor(2); e->DrawLatex(30,375,"XFT Tracks above 8 GeV"); myc->cd(2); xftFake->SetXTitle("pT Bin"); xftFake->SetYTitle("% Fakes"); xftFake->SetTitle("fake XFT/total XFT in each bin"); xftFake->GetXaxis()->SetRange(0,100); xftFake->Draw("e0"); l = new TLine(36.,0,36,25); l->SetLineColor(2); l->SetLineStyle(2); l->SetLineWidth(2); l->Draw(); l = new TLine(59.,0,59,25); l->SetLineColor(2); l->SetLineStyle(2); l->SetLineWidth(2); l->Draw(); a = new TArrow(36.,25,59,25,0.05,"<|>"); a->SetFillColor(2); a->SetLineColor(2); a->SetLineWidth(2); a->Draw(); TLatex *e = new TLatex(); e->SetTextSize(0.06); e->SetTextColor(2); e->DrawLatex(30,27,"XFT Tracks above 8 GeV"); myc->Update(); ps->Close(); char *ch = new char[1]; printf(" Hit Enter to continue \n"); gets(ch); myc->Print("XFT_fake.eps"); return 0; }