def efficiencytracking(): hadron_list = ["pion", "proton", "electron", "muon"] color_list = [1, 2, 4, 6] fileo2 = TFile("../codeHF/AnalysisResults_O2.root") c1 = TCanvas("c1", "A Simple Graph Example") c1.SetCanvasSize(1500, 1500) c1.cd() gPad.SetLogx() gPad.SetLogy() eff_list = [] hempty = TH1F("hempty", ";p_{T};efficiency", 100, 0.001, 5.0) hempty.Draw() leg = TLegend(0.1, 0.7, 0.3, 0.9, "") leg.SetFillColor(0) for i, had in enumerate(hadron_list): hnum = fileo2.Get("qa-tracking-efficiency-%s/num" % had) hden = fileo2.Get("qa-tracking-efficiency-%s/den" % had) hnum.Rebin(4) hden.Rebin(4) eff = TEfficiency(hnum, hden) eff.SetLineColor(color_list[i]) eff_list.append(eff) eff.Draw("same") leg.AddEntry(eff_list[i], had) leg.Draw() c1.SaveAs("efficiency_tracking.pdf")
def efficiencyhadron(had, var): fileo2 = TFile("../codeHF/AnalysisResults_O2.root") ceffhf = TCanvas("ceffhf", "A Simple Graph Example") ceffhf.SetCanvasSize(1500, 700) ceffhf.Divide(2, 1) gPad.SetLogy() hnum = fileo2.Get("hf-task-%s-mc/h%sRecSig" % (had, var)) hden = fileo2.Get("hf-task-%s-mc/h%sGen" % (had, var)) hnum.Rebin(4) hden.Rebin(4) eff = TEfficiency(hnum, hden) eff.Draw() ceffhf.SaveAs("efficiency_hfcand%s%s.pdf" % (had, var))
def draw_geff(t, title, h_bins, to_draw, den_cut, extra_num_cut, opt = "", color = kBlue, marker_st = 1, marker_sz = 1.): """Make an efficiency plot""" ## total numerator selection cut num_cut = AND(den_cut,extra_num_cut) ## PyROOT works a little different than ROOT when you are plotting ## histograms directly from tree. Hence, this work-around nBins = int(h_bins[1:-1].split(',')[0]) minBin = float(h_bins[1:-1].split(',')[1]) maxBin = float(h_bins[1:-1].split(',')[2]) num = TH1F("num", "", nBins, minBin, maxBin) den = TH1F("den", "", nBins, minBin, maxBin) t.Draw(to_draw + ">>num", num_cut, "goff") t.Draw(to_draw + ">>den", den_cut, "goff") debug = False if debug: print("Denominator cut", den_cut, den.GetEntries()) print("Numerator cut", num_cut, num.GetEntries()) ## check if the number of passed entries larger than total entries doConsistencyCheck = False if doConsistencyCheck: for i in range(0,nBins): print(i, num.GetBinContent(i), den.GetBinContent(i)) if num.GetBinContent(i) > den.GetBinContent(i): print(">>>Error: passed entries > total entries") eff = TEfficiency(num, den) ## plotting options if not "same" in opt: num.Reset() num.GetYaxis().SetRangeUser(0.0,1.1) num.SetStats(0) num.SetTitle(title) num.Draw() eff.SetLineWidth(2) eff.SetLineColor(color) eff.SetMarkerStyle(marker_st) eff.SetMarkerColor(color) eff.SetMarkerSize(marker_sz) eff.Draw(opt + " same") SetOwnership(eff, False) return eff
def efficiencyhadron(had, var): # extract the efficiency vs pT for single species(D0, Lc, Jpsi) fileo2 = TFile("../codeHF/AnalysisResults_O2.root") ceffhf = TCanvas("ceffhf", "A Simple Graph Example") ceffhf.SetCanvasSize(1500, 700) ceffhf.Divide(2, 1) gPad.SetLogy() # hnum = fileo2.Get("qa-tracking-efficiency-%s/%s/num" % (had, var)) hnum = fileo2.Get("hf-task-%s-mc/h%sRecSig" % (had, var)) # hden = fileo2.Get("qa-tracking-efficiency-%s/%s/den" % (had, var)) hden = fileo2.Get("hf-task-%s-mc/h%sGen" % (had, var)) hnum.Rebin(4) hden.Rebin(4) eff = TEfficiency(hnum, hden) eff.Draw() saveCanvas(ceffhf, "efficiency_hfcand%s%s" % (had, var))
effhist.Draw("surf") c.Print(outfilename + ".pdf") effhist.Draw("colz") c.Print(outfilename + ".pdf") effhistnopickup.Draw("surf") c.Print(outfilename + ".pdf") effhistnopickup.Draw("colz") c.Print(outfilename + ".pdf") effhistnopickup.Draw("e") c.Print(outfilename + ".pdf") eff.Draw("colz") c.Print(outfilename + ".pdf") efffunc = TF1("efffunc", "TMath::Max(0.0,([0] - x/[1]))", 0, 1500) #efffunc.SetParameter(0,1.0) #efffunc.SetParameter(1,500) massArr = array.array('d') zeroArr = array.array('d') xintArr = array.array('d') yintArr = array.array('d') xintErrArr = array.array('d') yintErrArr = array.array('d') for iy in range(1, cleanhist.GetNbinsY() + 1): cleanslice = cleanhist.ProjectionX("cleanslice", iy, iy) messyslice = messycleanhist.ProjectionX("messyslice", iy, iy)
h1b_eff.SetLineColor(600) # kBlue h1b_eff.SetLineWidth(2) gr = h1a_eff.CreateGraph() gr.Draw("ap") frame = gr.GetHistogram() frame = frame.Clone(hname + "_frame") frame.GetYaxis().SetTitle("#varepsilon") frame.SetMinimum(0.0) frame.SetMaximum(1.2) frame.SetStats(0) frame.Draw() xmin, xmax = frame.GetXaxis().GetXmin(), frame.GetXaxis().GetXmax() tline.DrawLine(xmin, 1.0, xmax, 1.0) #h1a_eff.Draw("same") h1b_eff.Draw("same") draw_cms_lumi() gPad.Print("figures_perf/" + hname + "_omtf" + ".png") gPad.Print("figures_perf/" + hname + "_omtf" + ".pdf") donotdelete.append([frame, h1a_eff, h1b_eff]) if False: outfile = TFile.Open("figures_perf/" + hname + ".root", "RECREATE") for obj in [frame, h1a_eff, h1b_eff]: obj.Write() outfile.Close() # ____________________________________________________________________________ # emtf_eff_vs_genphi_l1pt20 hname = "emtf_eff_vs_genphi_l1pt20"
def trackmatch(): garanainit.init() #ROOT.gROOT.SetBatch(True) # run in batch mode (don't display plots) tm = ROOT.TreeManager("./test.root") #structuredtree.root") # truth matching utility bt = ROOT.Backtracker(tm) print("constructed treemanager") #tree accessors #gen = tm.GetGenTree() g4 = tm.GetG4Tree() rec = tm.GetRecoTree() nmatch = 0 # number of reco tracks matched to a G4Particle ntrack = 0 # number of reco tracks nprimary = 0 # true number of primaries nprimary_match = 0 #number of primaries matched to at least one track hg4_nmatch = TH1F('hg4_nmatch', 'G4Particle -> Track matching;N^{0} matches', 10, 0, 10) hfrac = TH1F("hfrac", "particle contributing most energy;fraction of total", 50, 0, 1.1) hncont = TH1F("hncont", "particles contributing energy;N^{0} particles", 10, 0, 10) hncontfrac = TH2F( 'hncontfrac', 'particles contributing energy;N^{0} particles;max fraction of total', 10, 0, 25, 0, 1.1) eff_g4match = TEfficiency( 'eff_g4match', 'G4Particle -> Track matching; initial energy [GeV]; efficiency', 10, 0, 5) # loop over events for ientry in range(rec.NEntries()): if ientry % 100 == 0: print('processing event ' + str(ientry)) tm.GetEntry(ientry) bt.FillMaps() #load associations for this entry #nprimary += g4.NPrimary() for ig4 in range(g4.NSim()): if not g4.IsPrimary(ig4): continue # only consider primaries if not abs(g4.PDG(ig4)) == 2212: continue # muons only nprimary += 1 if bt.G4ParticleToTracks(ig4).size() > 0: nprimary_match += 1 # matched to something? hg4_nmatch.Fill(bt.G4ParticleToTracks(ig4).size()) eff_g4match.Fill( bt.G4ParticleToTracks(ig4).size() > 0, g4.SimMomEnter(ig4, 0).E()) ntrack += rec.NTrack() for itrack in range(rec.NTrack()): imatch = bt.TrackToG4Particle(itrack) if imatch < g4.NSim(): nmatch += 1 #imatches = bt.TrackToG4Particles(itrack) hncont.Fill(rec.TrackNTrueTrack(itrack)) #len(imatches)) for ip in range(rec.TrackNTrueTrack(itrack)): hfrac.Fill(rec.TrackMaxDepositFrac(itrack)) hncontfrac.Fill(rec.TrackNTrueTrack(itrack), rec.TrackMaxDepositFrac(itrack)) if nprimary != 0: print('number of primaries found: ', nprimary) print('number of matched primaries: ', nprimary_match) print('g4particle -> track matching efficiency: ', 1.0 * nprimary_match / nprimary) else: print('no G4particles found!') if ntrack != 0: print('track -> g4particle matching efficiency: ', 1.0 * nmatch / ntrack) else: print('no tracks found!') print('hncont size is ', hncont.Integral()) print('hfrac size is ', hfrac.Integral()) cg4_nmatch = TCanvas() hg4_nmatch.Draw() cg4_nmatch.SaveAs('g4_nmatch.png') cncont = TCanvas() hncont.Draw() cncont.SaveAs('ncont.png') cfrac = TCanvas() hfrac.Draw() cfrac.SaveAs('frac.png') cncontfrac = TCanvas() hncontfrac.Draw() cncontfrac.SaveAs('ncont_v_frac.png') ceff_g4match = TCanvas() eff_g4match.Draw() ceff_g4match.SaveAs('g4match_eff.png') # ask for user input as a way to keep the program from ending so we can # see the histogram. # python doesn't like empty input strings so I abuse exception handling try: null = input("press <Enter> to close canvas and exit program.") except: null = 'null'
eff = TEfficiency(hpass, hall) eff.SetLineWidth(2) kinvar = name[1:].replace('Pass', '') hframe = hpass.Clone('hframe') hframe.Reset() hframe.GetYaxis().SetRangeUser(0, 1.3) hframe.GetXaxis().SetTitle(kinvar + ' [' + units[kinvar] + ']') hframe.GetYaxis().SetTitle('#epsilon') hframe.SetTitle('') hframe.Draw() # hall.Scale(1.0/hall.Integral(),'width') hall.Scale(1 / hall.GetMaximum()) hall.Draw('hist same') eff.Draw('same') hframe.Draw('axis same') stamp() leg = mklegend(x1=.17, y1=.62, x2=.43, y2=.81) leg.AddEntry(eff, 'efficiency', 'l') leg.AddEntry(hall, 'spectrum', 'lfp') leg.Draw() canv.Update() canv.Print('pdfs/eff_' + kinvar + '.pdf') # pause() canv = mkcanvas()
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.SetMarkerStyle(20) fit = TF1('fit', '(1-[2])+[2]*TMath::Erf((x-[0])/[1])', xmin, xmax) fit.SetParameters(800, 100, 0.3) fit.SetLineColor(ROOT.kBlue) eff.Fit(fit, 'RQ') line = TF1('line', '1', xmin, xmax) line.GetXaxis().SetTitle('m_{jj} (GeV)') line.GetYaxis().SetTitle('Trigger Efficiency') line.SetLineColor(ROOT.kBlack) line.SetLineStyle(2) line.SetMinimum(0.3) line.SetMaximum(1.1) line.Draw() eff.Draw('samePE1') gPad.Update() x0 = fit.GetX(0.99) cut = TLine(x0, gPad.GetFrame().GetY1(), x0, gPad.GetFrame().GetY2()) cut.SetLineColor(ROOT.kRed) cut.SetLineStyle(2) cut.Draw() print '99% efficiency point: ' + str(round(x0, 1)) + ' GeV' #----- keep the GUI alive ------------ if __name__ == '__main__': rep = '' while not rep in ['q', 'Q']: rep = raw_input('enter "q" to quit: ')
def makeCombinedEtaPlot(self, tight=False): hist = self.makeL1TimeVsEtaPlot(('tight_' if tight else '') + 'dtOnly_bxidVsEta')[2] countsInL1 = [] for x in np.arange(-.95, 1.05, 0.1): totalCounter = 0 zeroCount = 0 for y in range(-2, 3): totalCounter += hist.GetBinContent(hist.FindBin(x, y)) if y == 0: zeroCount = hist.GetBinContent(hist.FindBin(x, y)) countsInL1.append({ 'total': totalCounter, 'zero': zeroCount, 'eta': x }) #Graph for results graph1 = TEfficiency(hist.GetName(), "", 8, -9.195, -.5) graph2 = TEfficiency(hist.GetName(), "", 8, .5, 9.195) for item in countsInL1: if item['total'] == 0: continue print item['total'], item['zero'], item['eta'] if item['eta'] < 0: graph1.SetTotalEvents( graph1.FindFixBin(-0.5 + item['eta'] / 0.087), int(item['total'])) graph1.SetPassedEvents( graph1.FindFixBin(-0.5 + item['eta'] / 0.087), int(item['zero'])) else: graph2.SetTotalEvents( graph2.FindFixBin(0.5 + item['eta'] / 0.087), int(item['total'])) graph2.SetPassedEvents( graph2.FindFixBin(0.5 + item['eta'] / 0.087), int(item['zero'])) histHo = None if tight: histHo = self.plotTightHoTimeVsEta()[3][1] else: histHo = self.plotHoTimeVsEta()[3][1] histHo.SetTitle(('Tight ' if tight else '') + 'Unmatched DT + HO') canvas = TCanvas( 'combinedPlot' + ('Tight ' if tight else '') + hist.GetName(), 'combinedPlot') canvas.cd().SetTopMargin(.15) histHo.Draw('ap') canvas.Update() canvas.cd().SetTicks(0, 0) histHo.SetMarkerStyle(2) histHo.SetLineColor(colorRwthDarkBlue) histHo.SetMarkerColor(colorRwthDarkBlue) histHo.GetPaintedGraph().GetXaxis().SetRangeUser(-12, 12) histHo.GetPaintedGraph().GetXaxis().SetLabelColor(colorRwthDarkBlue) histHo.GetPaintedGraph().GetXaxis().SetTitleColor(colorRwthDarkBlue) histHo.GetPaintedGraph().GetXaxis().SetAxisColor(colorRwthDarkBlue) yMax = gPad.GetFrame().GetY2() yMin = gPad.GetFrame().GetY1() #Print average Fraction excluding iEta +/-2 x = Double(0) y = Double(0) mean = 0 var = 0 for i in range(0, histHo.GetPaintedGraph().GetN()): histHo.GetPaintedGraph().GetPoint(i, x, y) if abs(x) == 2: continue mean += y var += histHo.GetPaintedGraph().GetErrorY( i) * histHo.GetPaintedGraph().GetErrorY(i) mean /= histHo.GetPaintedGraph().GetN() - 2 sigma = sqrt(var / (histHo.GetPaintedGraph().GetN() - 2)) self.debug( "Average fraction excluding iEta +/- 2 %s: %5.2f%% +/- %5.2f%%" % ('[Tight]' if tight else '', mean * 100, sigma * 100)) nTotal = 0 nPassed = 0 for item in countsInL1: if fabs(item['eta']) == 2 or fabs(item['eta'] == 0): continue nTotal += item['total'] nPassed += item['zero'] #Print again with ClopperPearson uncertainty, the counts are for L1!!! mean = nPassed / nTotal * 100 sigmaPlus = TEfficiency.ClopperPearson(int(nTotal), int(nPassed), .68, 1) * 100 - mean sigmaMinus = mean - TEfficiency.ClopperPearson( int(nTotal), int(nPassed), .68, 0) * 100 #self.debug("Average fraction excluding iEta +/- 2 %s with Clop.Pear.: %5.2f%% +%5.2f%% -%5.2f%%" # % ('[Tight]' if tight else '',mean,sigmaPlus,sigmaMinus)) #Left axis part f1 = TF1("f1", "x", -0.87, 0) A1 = TGaxis(-10, yMax, -0.5, yMax, "f1", 010, "-") A1.SetLineColor(colorRwthRot) A1.SetLabelColor(colorRwthRot) A1.Draw() #Right axis part f2 = TF1("f2", "x", 0, 0.87) A2 = TGaxis(0.5, yMax, 10, yMax, "f2", 010, "-") A2.SetLineColor(colorRwthRot) A2.SetLabelColor(colorRwthRot) A2.Draw() #Box for shading out 0 box = TBox(-.5, yMin, 0.5, yMax) box.SetLineColor(colorRwthDarkGray) box.SetFillColor(colorRwthDarkGray) box.SetFillStyle(3013) box.Draw('same') #Left L1 eta graph1.SetMarkerColor(colorRwthRot) graph1.SetLineColor(colorRwthRot) graph1.SetMarkerStyle(20) graph1.Draw('same,p') #Right L1Eta graph2.SetMarkerColor(colorRwthRot) graph2.SetLineColor(colorRwthRot) graph2.SetMarkerStyle(20) graph2.Draw('same,p') #Label for extra axis axisLabel = TPaveText(0.83, 0.85, 0.89, 0.9, "NDC") axisLabel.AddText('#eta_{L1}') axisLabel.SetBorderSize(0) axisLabel.SetFillStyle(0) axisLabel.SetTextColor(colorRwthRot) axisLabel.SetTextSize(0.05) axisLabel.Draw() #Legend legend = getLegend(x1=0.1, y1=0.1, x2=0.4, y2=.35) legend.AddEntry(histHo, 'HO #in #pm12.5 ns', 'pe') legend.AddEntry(graph1, ('Tight ' if tight else '') + 'L1 BXID = 0', 'pe') legend.Draw() canvas.Update() self.storeCanvas(canvas, "combinedFractionL1AndHo" + ('Tight' if tight else ''), drawMark=False) return histHo, graph1, canvas, A1, f1, A2, f2, box, graph2, axisLabel, legend
c_eff = TCanvas("c_eff") eff_e = TEfficiency(h_correct, h_total) print "1 shower, 1 track", h_correct.Integral() / h_total.Integral() 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)