def make_effplots(): hitcut = "abs(({0})-({1}))<2".format(bar_var,barexp_var) # require hit in the extrapolated bar or the adjacent bar events.Draw("{0}:{1}>>hexp2d({2},{3})".format(y_var,x_var,x_binning,y_binning),"","colz"); c.Print(outfilename+".pdf"); events.Draw("{0}:{1}>>hexp2d_withhit({2},{3})".format(y_var,x_var,x_binning,y_binning),hitcut,"colz"); c.Print(outfilename+".pdf"); numerator = gDirectory.Get("hexp2d_withhit") denominator = gDirectory.Get("hexp2d") #numerator.Sumw2(); numerator.Divide(denominator) numerator.GetZaxis().SetRangeUser(0,1) numerator.SetTitle("efficiency vs. position, {0}, no quad cut;extrapolated x [cm];extrapolated y [cm]".format(station)) numerator.Draw("colz"); c.Print(outfilename+".pdf"); for quad in range(0,4): quadcut = "quad=={0}".format(quad) flipped_x = x_var+"*({0})".format(1 if quad%2==0 else -1) # extrapolated X flipped such that the fiducial area is on the positive side flipped_y = y_var+"*({0})".format(1 if quad<2 else -1) # extrapolated Y flipped such that the fiducial area is on the positive side fiducialcut_x = "{0}>{1}".format(flipped_x,xedge[quad]) fiducialcuts = "{0} && {1}>{2}".format(fiducialcut_x,flipped_y,yedge[quad]) ''' events.Draw("fElementID_exp-1>>hhits_exp(40,-0.5,39.5)",quadcut,""); events.Draw("fElementID_exp-1>>hhits(40,-0.5,39.5)",quadcut+" && "+hitcut,""); gDirectory.Get("hhits").Sumw2(); gDirectory.Get("hhits").Divide(gDirectory.Get("hhits_exp")); gDirectory.Get("hhits").Draw(); c.Print(outfilename+".pdf"); ''' events.Draw(barexp_var+">>hhits_exp_{0}_quad{1}({2})".format(station,quad,bar_binning)," && ".join([quadcut,fiducialcuts]),""); events.Draw(barexp_var+">>hhits_{0}_quad{1}({2})".format(station,quad,bar_binning)," && ".join([quadcut,fiducialcuts,hitcut]),""); numerator = gDirectory.Get("hhits_{0}_quad{1}".format(station,quad)) denominator = gDirectory.Get("hhits_exp_{0}_quad{1}".format(station,quad)) eff = TEfficiency(numerator,denominator) eff.SetName("eff_{0}_quad{1}".format(station,quad)) #eff.GetYaxis().SetRangeUser(0,1.1) eff.SetTitle("efficiency vs. bar, {0}, quad {1} ({2});extrapolated bar ID;efficiency".format(station,quad,quadnames[quad])) eff.Write() eff.Draw() gPad.Update() eff.GetPaintedGraph().SetMinimum(0) eff.GetPaintedGraph().SetMaximum(1.1) #numerator.Sumw2(); #numerator.Divide(denominator) #numerator.GetYaxis().SetRangeUser(0,1.1) #numerator.SetTitle("efficiency vs. bar, {0}, quad {1};extrapolated bar ID;efficiency".format(station,quad)) #numerator.Draw(); c.Print(outfilename+".pdf"); events.Draw(bar_var+">>hhits2_{0}_quad{1}({2})".format(station,quad,bar_binning)," && ".join([quadcut,fiducialcuts,hitcut]),""); numerator = gDirectory.Get("hhits2_{0}_quad{1}".format(station,quad)) denominator = gDirectory.Get("hhits_exp_{0}_quad{1}".format(station,quad)) numerator.Sumw2(); numerator.Divide(denominator) numerator.GetYaxis().SetRangeUser(0,1.1) numerator.SetTitle("efficiency vs. bar, {0}, quad {1} ({2});hit bar ID;efficiency".format(station,quad,quadnames[quad])) numerator.Draw(); c.Print(outfilename+".pdf"); ''' leg = TLegend(0.0,0.75,0.2,0.9) for xslice in range(0,10): expslicehistname = "hhits_exp_{0}".format(xslice) events.Draw("fElementID_exp>>{0}(40,-0.5,39.5)".format(expslicehistname),"quad=={0}&&abs(tx*797+x0-{1})<5".format(quad,xslice*10-45),""); slicehistname = "hhits_{0}".format(xslice) #print(slicehistname) events.Draw("fElementID>>{0}(40,-0.5,39.5)".format(slicehistname),"quad=={0} && abs(fElementID-fElementID_exp+1)<2&&abs(tx*797+x0-{1})<5".format(quad,xslice*10-45),""); #print("fElementID>>hhits(40,-0.5,39.5)","quad=={0} && abs(fElementID-fElementID_exp+1)<2&&abs(tx*797+x0-{1})<5".format(quad,xslice*10-45,slicehistname)) #print("fElementID>>{0}(40,-0.5,39.5)","quad=={0} && abs(fElementID-fElementID_exp+1)<2&&abs(tx*797+x0-{1})<5".format(quad,xslice*10-45,slicehistname)) #events.Draw("fElementID>>{2}(40,-0.5,39.5)","quad=={0} && abs(fElementID-fElementID_exp+1)<2&&abs(tx*797+x0-{1})<5".format(quad,xslice*10-45,slicehistname),""); #gDirectory.ls() hist = gDirectory.Get(slicehistname) gDirectory.Get(slicehistname).Sumw2(); gDirectory.Get(slicehistname).Divide(gDirectory.Get(expslicehistname)); gDirectory.Get(slicehistname).Draw(); hist.SetLineColor(xslice+1) leg.AddEntry(hist,"abs(tx*797+x0-{1})<5".format(quad,xslice*10-45)) if (xslice==0): gDirectory.Get(slicehistname).GetYaxis().SetRangeUser(0,1); hs = THStack("hs",gDirectory.Get(slicehistname).GetTitle()); gDirectory.Get(slicehistname).DrawClone(); else: gDirectory.Get(slicehistname).DrawClone("same"); hs.Add(gDirectory.Get(slicehistname)) #c.Print(outfilename+".pdf"); hs.Draw("nostack") leg.Draw() c.Print(outfilename+".pdf"); ''' events.Draw(flipped_y+">>hy_exp({0})".format(flipped_y_binning)," && ".join([quadcut,fiducialcut_x]),""); #c.Print(outfilename+".pdf"); events.Draw(flipped_y+">>hy({0})".format(flipped_y_binning)," && ".join([quadcut,fiducialcut_x,hitcut]),""); #c.Print(outfilename+".pdf"); numerator = gDirectory.Get("hy") denominator = gDirectory.Get("hy_exp") eff = TEfficiency(numerator,denominator) #eff.GetYaxis().SetRangeUser(0,1.1) eff.SetTitle("efficiency vs. position, {0}, quad {1};extrapolated y [cm];efficiency".format(station,quad)) eff.Draw("APZ") #eff.Draw("A3") gPad.Update() #eff.GetPaintedGraph().SetFillColor(12) #eff.GetPaintedGraph().SetFillStyle(1001) eff.GetPaintedGraph().SetMinimum(0) eff.GetPaintedGraph().SetMaximum(1.1) #numerator.Sumw2(); #numerator.Divide(denominator) #numerator.GetYaxis().SetRangeUser(0,1.1) #numerator.SetTitle("efficiency vs. position, {0}, quad {1};extrapolated y [cm];efficiency".format(station,quad)) #numerator.Draw(); c.Print(outfilename+".pdf"); #events.Draw("ty*797+y0:tx*797+x0>>hexp2d_fid(200,-50,50,200,-50,50)",fiducialcuts,"colz"); #c.Print(outfilename+".pdf"); events.Draw("{0}:{1}>>hexp2d({2},{3})".format(y_var,x_var,x_binning,y_binning),quadcut,"colz"); c.Print(outfilename+".pdf"); events.Draw("{0}:{1}>>hexp2d_withhit({2},{3})".format(y_var,x_var,x_binning,y_binning)," && ".join([quadcut,hitcut]),"colz"); c.Print(outfilename+".pdf"); numerator = gDirectory.Get("hexp2d_withhit") denominator = gDirectory.Get("hexp2d") eff = TEfficiency(numerator,denominator) #eff.GetZaxis().SetRangeUser(0,1) eff.SetTitle("efficiency vs. position, {0}, quad {1};extrapolated x [cm];extrapolated y [cm]".format(station,quad)) eff.Draw("colz") gPad.Update() eff.GetPaintedHistogram().GetZaxis().SetRangeUser(0,1) #eff.GetPaintedGraph().SetMaximum(1.1) #numerator.Sumw2(); #numerator.Divide(denominator) #numerator.GetZaxis().SetRangeUser(0,1) #numerator.SetTitle("efficiency vs. position, {0}, quad {1};extrapolated x [cm];extrapolated y [cm]".format(station,quad)) #numerator.Draw("colz"); c.Print(outfilename+".pdf"); '''
eff_e_more = TEfficiency(h_correct_more_showers, h_total) print "1+ showers, 1 track", h_correct_more_showers.Integral( ) / h_total.Integral() eff_e_shower_only = TEfficiency(h_correct_shower_only, h_total) print "1 shower", h_correct_shower_only.Integral() / h_total.Integral() eff_e_more_showers_only = TEfficiency(h_correct_more_showers_only, h_total) print "1+ showers", h_correct_more_showers_only.Integral() / h_total.Integral() eff_e.Draw("apl") eff_e_more.Draw("pl same") eff_e_shower_only.Draw("pl same") eff_e_more_showers_only.Draw("pl same") gPad.Update() eff_e.GetPaintedGraph().SetMinimum(0.001) eff_e.GetPaintedGraph().SetMaximum(1.3) eff_e.GetPaintedGraph().GetXaxis().SetRangeUser(0, 3) eff_e.SetLineColor(kBlue + 1) eff_e.SetMarkerStyle(20) eff_e_more.SetLineColor(kRed + 1) eff_e_more.SetMarkerStyle(21) eff_e_shower_only.SetLineColor(kBlue + 1) eff_e_shower_only.SetLineStyle(2) eff_e_shower_only.SetMarkerStyle(24) eff_e_more_showers_only.SetLineColor(kRed + 1) eff_e_more_showers_only.SetLineStyle(2) eff_e_more_showers_only.SetMarkerStyle(25) eff_e.SaveAs("plots/pandoraNu_eff.root") eff_e_more.SaveAs("plots/pandoraNu_more_eff.root") eff_e_shower_only.SaveAs("plots/pandoraNu_s_eff.root")