2 void plCalcZeffic(
char* iPath=
"/star/u/stevens4/wAnalysis/efficXsec/outEmb/gainUp2/"){
4 system(
"mkdir -p plots/");
11 gStyle->SetPalette(1);
14 TString fullInpName=iPath; fullInpName+=core0;
15 fullInpName+=
".wana.hist.root";
16 fd=
new TFile(fullInpName);
18 printf(
"ERROR: input histo file not found, quit\n",fullInpName.Data());
21 printf(
"Opened: %s\n",fullInpName.Data());
29 float massPlot[5]={1.0,1.0,1.0,1.0,1.0};
30 float massPlotErr[5]={1.0,1.0,1.0,1.0,1.0};
33 TH1F *hTrigMass=doEfficiency(fd,
"MCzMassAll",
"MCzMassTrig",Form(
"Z trigger efficiency"),massRebin,massPlot[0],massPlotErr[0]);
34 TH1F *hTrigZDC=doEfficiency(fd,
"MCzZdcAll",
"MCzZdcTrig",Form(
"Z trigger efficiency"),zdcRebin,0);
36 TH1F *hVertMass=doEfficiency(fd,
"MCzMassTrig",
"MCzMassVert",Form(
"Z vertex efficiency"),massRebin,massPlot[1],massPlotErr[1]);
37 TH1F *hVertZDC=doEfficiency(fd,
"MCzZdcTrig",
"MCzZdcVert",Form(
"Z vertex efficiency"),zdcRebin,0);
39 TH1F *hTrackMass=doEfficiency(fd,
"MCzMassVert",
"MCzMassTrack",Form(
"Z tracking efficiency"),massRebin,massPlot[2],massPlotErr[2]);
40 TH1F *hTrackZDC=doEfficiency(fd,
"MCzZdcVert",
"MCzZdcTrack",Form(
"Z tracking efficiency"),zdcRebin,0);
42 TH1F *hRecoMass=doEfficiency(fd,
"MCzMassTrack",
"MCzMassReco",Form(
"Z algo efficiency"),massRebin,massPlot[3],massPlotErr[3]);
43 TH1F *hRecoZDC=doEfficiency(fd,
"MCzZdcTrack",
"MCzZdcReco",Form(
"Z algo efficiency"),zdcRebin,0);
46 TH1F *hTotMass=doEfficiency(fd,
"MCzMassAll",
"MCzMassReco",Form(
"Z total efficiency"),massRebin,massPlot[4],massPlotErr[4]);
47 cout<<
"Total Efficiency = "<<massPlot[4]<<
" $\\pm$ "<<massPlotErr[4]<<endl;
48 TH1F *hTotZDC=doEfficiency(fd,
"MCzZdcAll",
"MCzZdcReco",Form(
"Z total efficiency"),zdcRebin,0);
52 cV=
new TCanvas(Form(
"Z vertex and trig effic"),
"vertex and effic",800,600);
62 cV->Print(
"plots/ZVert-TrigEffic.eps");
63 cV->Print(
"plots/ZVert-TrigEffic.png");
66 cA=
new TCanvas(Form(
"Z algo and track effic"),
"algo and track effic",800,600);
76 cA->Print(
"plots/ZAlgo-TrkEffic.eps");
77 cA->Print(
"plots/ZAlgo-TrkEffic.png");
83 TH1F* doEfficiency(TFile *fd,
char* name0,
char* name1,
char *tit,
int reb=1,
float &etplot,
float &etplotErr=0){
85 TH1F * h0=(TH1F * )fd->Get(name0); assert(h0);
86 TH1F * h1=(TH1F * )fd->Get(name1); assert(h1);
88 ha=(TH1F*) h0->Clone(); assert(ha);
89 hb=(TH1F*) h1->Clone(); assert(hb);
94 hc=(TH1F*) hb->Clone(); assert(hc);
98 float num=0;
float den=0;
99 float matchErr2=0;
float thrownErr2=0;
100 int nb=hb->GetNbinsX();
101 int startBin=hb->GetXaxis()->FindBin(70.);
102 int endBin=hb->GetXaxis()->FindBin(109.9);
105 assert(nb==ha->GetNbinsX());
106 for(
int i=1; i<=nb; i++) {
107 float n0=ha->GetBinContent(i);
108 float n1=hb->GetBinContent(i);
109 float e0=ha->GetBinError(i);
110 float e1=hb->GetBinError(i);
112 float eff=(float) n1/n0;
125 else errEff=sqrt(e1*e1*(n0-n1)*(n0-n1)+(e0-e1)*(e0-e1)*n1*n1)/n0/n0;
128 hc->SetBinContent(i,eff);
129 hc->SetBinError(i,errEff);
130 if(i>=startBin && i<=endBin){
144 cout<<name1<<
"="<< num/den <<
" $\\pm$ "<< sqrt(matchErr2*(den-num)*(den-num) + (thrownErr2-matchErr2)*num*num)/den/den <<endl;
146 etplotErr=sqrt(matchErr2*(den-num)*(den-num) + (thrownErr2-matchErr2)*num*num)/den/den;