def plot_histo_and_fit(h): c = TCanvas("c", "c", 600, 300) h.SetXTitle("mbb [GeV]") h.SetYTitle("Number of events") h.Fit("bukin", "RQ", "HIST", xmin, xmax) f = h.GetFunction("bukin") result = (f.GetParameter(0), f.GetParameter(1), f.GetParameter(2), f.GetParameter(3), f.GetParameter(4), f.GetParameter(5)) f.SetLineColor(color) f.Draw("same") # https://root.cern.ch/doc/master/classTLegend.html legend = TLegend(0.15, 0.60, 0.50, 0.80) legend.AddEntry(None, "#bf{mean[GeV] / sigma[GeV] / ratio}", "") legend.AddEntry(h, h.GetName(), "f") result = (height, mean, rms) legend_text = "#bf{%-.3f/%-.3f/%-.3f}" % (result[1], result[2], ratio(result[2], result[1])) legend.AddEntry(None, legend_text, "") legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetTextColor(color) legend.Draw("SAME") # https://root.cern.ch/doc/master/classTLatex.html#L3 t = TLatex() t.SetNDC() t.SetTextSize(10) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.15, 0.40, "#it{#bf{ATLAS} Simulation Internal}") t.Draw("same") # save the canvas to file c.Print("plot_histo_and_fit.pdf")
def plot_histo(hs): l = 0 c = TCanvas("c", "c", 1000, 600) hs.Draw("nostack") hs.GetXaxis().SetTitle("mbb [GeV]") hs.GetYaxis().SetTitle("Number of events") legend = TLegend(0.13, 0.41, 0.25, 0.88) legend.AddEntry(None, "#bf{mean[GeV] / sigma[GeV] / ratio}", "") while l < 7: legend.AddEntry(h[l], h[l].GetName(), "f[l]") result[l] = (height[l], mean[l], rms[l]) legend_text[l] = "#bf{%-.3f/%-.3f/%-.3f}" % ( result[l][1], result[l][2], ratio(result[l][2], result[l][1])) legend.AddEntry(None, legend_text[l], "") l = l + 1 legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetTextColor(1) legend.Draw("SAME") t = TLatex() t.SetNDC() t.SetTextSize(14) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.73, 0.85, "#it{#bf{ATLAS} Simulation Internal}") t.Draw() c.Print("plot_histo.pdf")
def plot_histo_and_fit(hs, f): n = 0 r = 0 c2 = TCanvas("c2", "c2", 1000, 600) hs.Draw("nostack") hs.GetXaxis().SetTitle("mbb [GeV]") hs.GetYaxis().SetTitle("Number of events") while n < 7: h[n].SetXTitle("mbb [GeV]") h[n].SetYTitle("Number of events") f[n].SetLineColor(n + 1) f[n].Draw("SAME") n = n + 1 legend = TLegend(0.13, 0.41, 0.25, 0.88) legend.AddEntry(None, "#bf{mean[GeV] / sigma[GeV] / ratio}", "") while r < 7: legend.AddEntry(h[r], h[r].GetName(), "f[r]") result[r] = (height[r], mean[r], rms[r]) legend_text[r] = "#bf{%-.3f/%-.3f/%-.3f}" % ( result[r][1], result[r][2], ratio(result[r][2], result[r][1])) legend.AddEntry(None, legend_text[r], "") r = r + 1 legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetTextColor(1) legend.Draw("SAME") t = TLatex() t.SetNDC() t.SetTextSize(14) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.73, 0.85, "#it{#bf{ATLAS} Simulation Internal}") t.Draw() c2.Print("plot_histo_and_fit.pdf")
def plot(h, option, histoName): entries = h.GetEntries() height = h.GetMaximum() mean = h.GetMean() rms = h.GetRMS() color = h.GetLineColor() xmin = mean - 3 * rms xmax = mean + 3 * rms #Getting Bukin Function f = setBukin(mean=mean, rms=rms, height=height, xmin=xmin, xmax=xmax) c = TCanvas("c", "c", 600, 300) h.SetXTitle("mbb [GeV]") h.SetYTitle("Number of events") ########### start code specific to the histo and/or fit choice ################## if option == "histo": h.Draw("HIST") elif option == "histo+fit": h.Fit("bukin", "RQ", "HIST", xmin, xmax) f = h.GetFunction("bukin") result = (f.GetParameter(0), f.GetParameter(1), f.GetParameter(2), f.GetParameter(3), f.GetParameter(4), f.GetParameter(5)) f.SetLineColor(color) f.Draw("same") elif option == "fit": h.Fit("bukin", "RQ", "RO", xmin, xmax) f = h.GetFunction("bukin") result = (f.GetParameter(0), f.GetParameter(1), f.GetParameter(2), f.GetParameter(3), f.GetParameter(4), f.GetParameter(5)) f.SetLineColor(color) else: print "option", option, "not known" assert (False) ########## end code specific to the histo and/or fit choice ################## # https://root.cern.ch/doc/master/classTLegend.html legend = TLegend(0.15, 0.60, 0.50, 0.80) legend.AddEntry(None, "#bf{mean[GeV] / sigma[GeV] / ratio}", "") legend.AddEntry(h, h.GetName(), "f") result = (height, mean, rms) legend_text = "#bf{%-.3f/%-.3f/%-.3f}" % (result[1], result[2], ratio(result[2], result[1])) legend.AddEntry(None, legend_text, "") legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetTextColor(color) legend.Draw("SAME") # https://root.cern.ch/doc/master/classTLatex.html#L3 t = TLatex() t.SetNDC() t.SetTextSize(10) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.15, 0.40, "#it{#bf{ATLAS} Simulation Internal}") t.Draw("same") # save the canvas to file c.Print(histoName + "_" + option + ".pdf")
def checkForOutliers(hist, qaContainer): """ Checks for outliers in selected histograms. Outliers are calculated by looking at the standard deviation. See: :func:`hasSignalOutlier()`. This function is mainly a proof of concept, but could become more viable with a bit more work. Note: This function will add a large TLegend to the histogram noting the mean and the number of outliers. It will also display the recalculated mean excluding the outlier(s). Args: hist (TH1): The histogram to be processed. qaContainer (:class:`~processRuns.qa.qaFunctionContainer`): Contains information about the QA function and histograms, as well as the run being processed. Returns: None """ # If outlier data point, print warning banner if hist.GetName() == "": tempList = hasSignalOutlier( hist ) # array of info from hasSignalOutlier function, to print on legend numOutliers = tempList[0] mean = tempList[1] stdev = tempList[2] newMean = tempList[3] newStdev = tempList[4] if (numOutliers): # Create TLegend and fill with information if there is an outlier. leg = TLegend(0.15, 0.5, 0.7, 0.8) SetOwnership(leg, False) leg.SetBorderSize(4) leg.SetShadowColor(2) leg.SetHeader("#splitline{OUTLIER SIGNAL DETECTED}{IN %s BINS!}" % numOutliers) leg.AddEntry( None, "Mean: %s, Stdev: %s" % ('%.2f' % mean, '%.2f' % stdev), "") leg.AddEntry( None, "New mean: %s, New Stdev: %s" % ('%.2f' % newMean, '%.2f' % newStdev), "") leg.SetTextSize(0.04) leg.SetTextColor(2) leg.Draw()
def plot_fit(h, xmin, xmax, height, mean, rms): k = 0 m = 0 s = 0 c1 = TCanvas("c1", "c1", 1000, 600) while k < 7: function = TF1("bukin", Bukin(), xmin[k], xmax[k], 6) function.SetParName(0, "height") function.SetParName(1, "mean") function.SetParName(2, "width") function.SetParName(3, "asymmetry") function.SetParName(4, "size of lower tail") function.SetParName(5, "size of higher tail") function.SetParameter(0, height[k]) function.SetParameter(1, mean[k]) function.SetParameter(2, rms[k]) h[k].Fit("bukin", "RQ", "RO", xmin[k], xmax[k]) f[k] = h[k].GetFunction("bukin") k = k + 1 while m < 7: h[m].SetXTitle("mbb [GeV]") h[m].SetYTitle("Number of events") f[m].SetLineColor(m + 1) f[m].Draw("SAME") m = m + 1 legend = TLegend(0.13, 0.41, 0.25, 0.88) legend.AddEntry(None, "#bf{mean[GeV] / sigma[GeV] / ratio}", "") while s < 7: legend.AddEntry(h[s], h[s].GetName(), "f[s]") result[s] = (height[s], mean[s], rms[s]) legend_text[s] = "#bf{%-.3f/%-.3f/%-.3f}" % ( result[s][1], result[s][2], ratio(result[s][2], result[s][1])) legend.AddEntry(None, legend_text[s], "") s = s + 1 legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.03) legend.SetTextColor(1) legend.Draw("SAME") t = TLatex() t.SetNDC() t.SetTextSize(14) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.73, 0.85, "#it{#bf{ATLAS} Simulation Internal}") t.Draw() c1.Print("plot_fit.pdf")
def plotUpperLimits(): # for example, see CMS plot guidelines: https://ghm.web.cern.ch/ghm/plots/ lumi = 150 limits = getLimits( "mwp_upper_limit_L{}.root".format(lumi)) # array of limits N = len(limits) yellow = TGraph(2 * N) # yellow band green = TGraph(2 * N) # green band median = TGraph(N) # median line up2s = [] for i in range(N): values = limits[i] # if i == 1 and lumi == 150: # values = [200, 0.8591836, 1.3878179, 1.9979995, 0.5129849, 0.3124208] # if i == 5 and lumi == 150: # values = [600, 0.108226, 0.152326, 0.207678, 0.076572, 0.0558201] up2s.append(values[3]) yellow.SetPoint(i, values[0], values[3]) # + 2 sigma green.SetPoint(i, values[0], values[2]) # + 1 sigma median.SetPoint(i, values[0], values[1]) # median green.SetPoint(2 * N - 1 - i, values[0], values[4]) # - 1 sigma yellow.SetPoint(2 * N - 1 - i, values[0], values[5]) # - 2 sigma ROOT.gStyle.SetLineScalePS(1) W = 809 H = 530 T = 0.08 * H B = 0.12 * H L = 0.12 * W R = 0.04 * W c = TCanvas("c", "c", 100, 100, W, H) c.SetLogy() c.SetFillColor(0) c.SetBorderMode(0) c.SetFrameFillStyle(0) c.SetFrameBorderMode(0) c.SetLeftMargin(L / W) c.SetRightMargin(R / W) c.SetTopMargin(T / H) c.SetBottomMargin(B / H) c.SetTickx(0) c.SetTicky(0) c.SetGrid() c.cd() frame = c.DrawFrame(1.4, 0.001, 4.1, 10) frame.SetLineColor(ROOT.kBlue + 4) frame.GetYaxis().SetTitleSize(0.045) frame.GetXaxis().SetTitleSize(0.045) frame.GetXaxis().SetLabelSize(0.04) frame.GetYaxis().SetLabelSize(0.04) frame.GetXaxis().SetLabelColor(ROOT.kBlue + 4) frame.GetYaxis().SetLabelColor(ROOT.kBlue + 4) frame.GetXaxis().SetTitleColor(ROOT.kBlue + 4) frame.GetYaxis().SetTitleColor(ROOT.kBlue + 4) frame.GetXaxis().SetTitleOffset(1.28) frame.GetYaxis().SetTitleOffset(1.4) frame.GetXaxis().SetNdivisions(508) frame.GetYaxis().SetNdivisions(10) frame.GetXaxis().SetTickLength(0.0237) frame.GetYaxis().SetTickLength(0.0237) frame.GetXaxis().CenterTitle(True) frame.GetYaxis().CenterTitle(True) frame.GetYaxis().SetTitle("95% CLs upper limit #sigma [pb]") # frame.GetYaxis().SetTitle("95% upper limit on #sigma #times BR / (#sigma #times BR)_{SM}") frame.GetXaxis().SetTitle("m_{W'} [GeV]") frame.SetMinimum(0.001) frame.SetMaximum(max(up2s) * 1.4) frame.GetXaxis().SetLimits(min(values) + 50, max(values) + 50) yellow.SetFillColorAlpha(ROOT.kOrange - 4, 0.6) yellow.SetLineColorAlpha(ROOT.kOrange - 4, 0.6) yellow.SetFillStyle(1001) yellow.Draw('F') green.SetFillColorAlpha(ROOT.kSpring - 5, 0.3) green.SetLineColorAlpha(ROOT.kSpring - 5, 0.3) green.SetFillStyle(1001) green.Draw('Fsame') median.SetLineColorAlpha(ROOT.kGreen + 4, 0.5) median.SetLineWidth(1) median.SetLineStyle(2) median.Draw('Lsame') # CMS_lumi.CMS_lumi(c,14,11) ROOT.gPad.SetTicks(1, 1) frame.Draw('sameaxis') x1 = 0.625 x2 = x1 + 0.31 y2 = 0.885 y1 = 0.75 legend = TLegend(x1, y1, x2, y2) legend.SetFillStyle(1001) legend.SetFillColor(ROOT.kWhite) legend.SetBorderSize(0) legend.SetTextColor(ROOT.kBlue + 4) legend.SetTextSize(0.035) legend.SetTextFont(42) legend.AddEntry(median, "Asymptotic CL_{s} expected", 'L') legend.AddEntry(green, "#pm 1 std. deviation", 'f') # legend.AddEntry(green, "Asymptotic CL_{s} #pm 1 std. deviation",'f') legend.AddEntry(yellow, "#pm 2 std. deviation", 'f') # legend.AddEntry(green, "Asymptotic CL_{s} #pm 2 std. deviation",'f') legend.Draw() tx = ROOT.TLatex() tx.SetNDC() tx.SetTextAngle(0) tx.SetTextColor(ROOT.kBlue + 4) tx.SetTextFont(42) tx.SetTextAlign(11) tx.SetTextSize(0.037) tx.DrawLatex(0.76, 0.95, "#sqrt{{s}} = 14 TeV, {} fb^{{-1}}".format(lumi)) c.Update() print " " c.SaveAs("UpperLimit_L{}.eps".format(lumi)) c.Close()
def plot(dictHist,option,fitFunction): c=TCanvas("c","c",600,300) legend=TLegend(0.12,0.18,0.35,0.85) fNamePart = "" #Determines name of the output file legend.AddEntry(None,"#bf{mean[GeV] / sigma[GeV] / ratio}","") color = 1 hs = THStack("hs","corrections;mbb [GeV];Number of events;") drawOption = "" #Draw Option for THStack for key in dictHist: hist = dictHist[key].Clone() hist.SetLineColor(color) # Setting color for the histogram # print 'Current Hist Title: ',hist.GetTitle() # print 'Color Option: ',color entries=hist.GetEntries() height=hist.GetMaximum() mean=hist.GetMean() rms=hist.GetRMS() xmin=mean-3*rms xmax=mean+3*rms #Getting Function of Choice if (fitFunction == 'gauss'): f = setGauss(mean=mean, rms=rms, height=height, xmin=xmin, xmax=xmax) elif (fitFunction == 'bukin'): f = setBukin(mean=mean, rms=rms, height=height, xmin=xmin, xmax=xmax) else: print "Name of the function was not recognized! Selection can be either 'gauss' or 'bukin'." assert(False) ########### start code specific to the histo and/or fit choice ################## if option=="histo": hs.Add(hist) result=(height,mean,rms) drawOption = "nostack" fNamePart = option elif option=="histo+fit": hist.Fit(fitFunction,"RQ","HISTS",xmin,xmax) f=hist.GetFunction(fitFunction) if (fitFunction == 'gauss'): result=(f.GetParameter(0),f.GetParameter(1),f.GetParameter(2)) else: result=(f.GetParameter(0),f.GetParameter(1),f.GetParameter(2),f.GetParameter(3),f.GetParameter(4),f.GetParameter(5)) f.SetLineColor(color) hs.Add(hist) drawOption = "nostack" fNamePart = "histo+" + fitFunction elif option=="fit": hist.Fit(fitFunction,"RQ","RO",xmin,xmax) f=hist.GetFunction(fitFunction) if (fitFunction == 'gauss'): result=(f.GetParameter(0),f.GetParameter(1),f.GetParameter(2)) else: result=(f.GetParameter(0),f.GetParameter(1),f.GetParameter(2),f.GetParameter(3),f.GetParameter(4),f.GetParameter(5)) f.SetLineColor(color) hs.Add(hist) drawOption = "nostackRO" fNamePart = fitFunction else: print "option",option,"not known" assert(False) ########## end code specific to the histo and/or fit choice ################## # https://root.cern.ch/doc/master/classTLegend.html legend.AddEntry(hist,hist.GetName(),"f") legend_text="#bf{%-.3f/%-.3f/%-.3f}" % (result[1],result[2],ratio(result[2],result[1])) legend.AddEntry(None,legend_text,"") c.Update() color += 1 if (color == 10): #10 would not be visible color = 11 hs.Draw(drawOption) legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.025) legend.SetTextColor(1) legend.Draw('Same') # https://root.cern.ch/doc/master/classTLatex.html#L3 t = TLatex() t.SetNDC() t.SetTextSize(10) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.7,0.85,"#it{#bf{ATLAS} Simulation Internal}") t.Draw("Same") c.Print("Higgs_"+fNamePart+".pdf")
def plot_fit(h): c = TCanvas("c", "c", 600 * 10, 300 * 10) legend = TLegend(0.15, 0.35, 0.20, 0.85) legend.AddEntry(None, "#bf{mean[GeV] / sigma[GeV] / ratio}", "") function.SetParameter(0, height[0]) function.SetParameter(1, mean[0]) function.SetParameter(2, rms[0]) h[0].SetXTitle("mbb [GeV]") h[0].SetYTitle("Number of events") h[0].Fit("bukin", "RQ", "RO", xmin[0], xmax[0]) function.SetParameter(0, height[1]) function.SetParameter(1, mean[1]) function.SetParameter(2, rms[1]) h[1].SetXTitle("mbb [GeV]") h[1].SetYTitle("Number of events") h[1].Fit("bukin", "RQ", "RO", xmin[1], xmax[1]) function.SetParameter(0, height[2]) function.SetParameter(1, mean[2]) function.SetParameter(2, rms[2]) h[2].SetXTitle("mbb [GeV]") h[2].SetYTitle("Number of events") h[2].Fit("bukin", "RQ", "RO", xmin[2], xmax[2]) function.SetParameter(0, height[3]) function.SetParameter(1, mean[3]) function.SetParameter(2, rms[3]) h[3].SetXTitle("mbb [GeV]") h[3].SetYTitle("Number of events") h[3].Fit("bukin", "RQ", "RO", xmin[3], xmax[3]) function.SetParameter(0, height[5]) function.SetParameter(1, mean[5]) function.SetParameter(2, rms[5]) h[5].SetXTitle("mbb [GeV]") h[5].SetYTitle("Number of events") h[5].Fit("bukin", "RQ", "RO", xmin[5], xmax[5]) function.SetParameter(0, height[7]) function.SetParameter(1, mean[7]) function.SetParameter(2, rms[7]) h[7].SetXTitle("mbb [GeV]") h[7].SetYTitle("Number of events") h[7].Fit("bukin", "RQ", "RO", xmin[7], xmax[7]) function.SetParameter(0, height[8]) function.SetParameter(1, mean[8]) function.SetParameter(2, rms[8]) h[8].SetXTitle("mbb [GeV]") h[8].SetYTitle("Number of events") h[8].Fit("bukin", "RQ", "RO", xmin[8], xmax[8]) f = h[0].GetFunction("bukin") result = (f.GetParameter(0), f.GetParameter(1), f.GetParameter(2), f.GetParameter(3), f.GetParameter(4), f.GetParameter(5)) h[0].GetFunction("bukin").SetLineColor(1) h[1].GetFunction("bukin").SetLineColor(2) h[2].GetFunction("bukin").SetLineColor(3) h[3].GetFunction("bukin").SetLineColor(4) h[5].GetFunction("bukin").SetLineColor(5) h[7].GetFunction("bukin").SetLineColor(6) h[8].GetFunction("bukin").SetLineColor(7) h[8].GetFunction("bukin").Draw() h[0].GetFunction("bukin").Draw("SAME") h[1].GetFunction("bukin").Draw("SAME") h[2].GetFunction("bukin").Draw("SAME") h[3].GetFunction("bukin").Draw("SAME") h[5].GetFunction("bukin").Draw("SAME") h[7].GetFunction("bukin").Draw("SAME") for i in range(0, 9): if i == 4 or i == 6: continue f = h[i].GetFunction("bukin") result = (f.GetParameter(0), f.GetParameter(1), f.GetParameter(2), f.GetParameter(3), f.GetParameter(4), f.GetParameter(5)) legend.AddEntry(f, h[i].GetName(), "f") result = (height[i], mean[i], rms[i]) legend_text = "#bf{%-.3f/%-.3f/%-.3f}" % (result[1], result[2], ratio(result[2], result[1])) legend.AddEntry(None, legend_text, "") legend.SetBorderSize(0) legend.SetTextFont(42) legend.SetTextSize(0.02) legend.SetTextColor(color[0]) legend.Draw("SAME") t = TLatex() t.SetNDC() t.SetTextSize(100) t.SetTextFont(43) t.SetTextAlign(13) t.DrawLatex(0.15, 0.30, "#it{#bf{ATLAS} Simulation Internal}") t.Draw("SAME") # save the canvas to file c.Print("plot_fit.pdf")
graphA.SetPoint(i_g, mA, wA) print i_g, wA, wH i_g += 1 graphs.append((graphA, graphH)) # The drawing and cosmetics part c = TCanvas() legendA = TLegend(0.3, 0.4, 0.53, 0.65) legendA.AddEntry(None, 'B(A#rightarrow t#bar{t})', '') legendH = TLegend(0.55, 0.4, 0.78, 0.65) legendH.SetTextColor(2) legendH.AddEntry(None, 'B(H#rightarrow t#bar{t})', '') for i_g, (graphA, graphH) in enumerate(graphs): graphA.SetLineColor(ROOT.kBlack) graphH.SetLineColor(ROOT.kRed) graphA.SetLineStyle(i_g + 1) graphH.SetLineStyle(i_g + 1) if i_g == 0: graphA.Draw('AC') graphA.GetXaxis().SetTitle('m_{A} (GeV)') # #prop coupling^{2} graphA.GetYaxis().SetTitle('B(#Phi#rightarrow t#bar{t})') graphA.GetYaxis().SetTitleSize(0.05) graphA.GetYaxis().SetLabelSize(0.05) graphA.GetYaxis().SetTitleOffset(0.85) graphA.GetXaxis().SetTitleSize(0.05)
############################################################################### c21 = TCanvas('2d_eta10to0p7_eta20to0p7', '2d_eta10to0p7_eta20to0p7', 100, 20, 600, 600) gStyle.SetPalette(53) gStyle.SetNumberContours(99) gPad.SetLeftMargin(0.16) gPad.SetRightMargin(0.14) h2Ele1DrMatched_eta10to0p7_eta20to0p7.Draw('COLZ') gEle1DrMatched_eta10to0p7_eta20to0p7_mean.Draw('PZ') legend21 = TLegend(0.19, 0.69, 0.60, 0.74) legend21.SetTextFont(font) legend21.SetTextSize(0.04) legend21.SetTextColor(ROOT.kWhite) legend21.SetBorderSize(0) legend21.SetFillColor(19) legend21.SetFillStyle(0) legend21.AddEntry(gEle1DrMatched_eta10to0p7_eta20to0p7_mean, '#LTH / E#GT of m(ee) slice', 'lp') legend21.Draw('same') tex21 = TLatex() tex21.SetNDC() tex21.SetTextFont(font) tex21.SetTextSize(0.04) tex21.DrawLatex(0.16, 0.91, 'CMS Simulation, 8 TeV') tex21.SetTextColor(ROOT.kWhite) tex21.DrawLatex(0.19, 0.84, 'two e with |#eta| < 0.7')
def plotInputComparison(files, runs, processes, path): #clear memory gROOT.Reset() #make canvas to save plots to c1 = TCanvas('c1', 'c1', 10, 10, 5000, 3000) c1.SetLogy() c1.SetGridx() c1.SetGridy() i = 0 Tfiles = [] while i < len(files): print "Adding file: %s to list of files to run with Run Number: %s and Process Name: %s" % ( files[i], runs[i], processes[i]) Tfiles.append(TFile(files[i])) i += 1 j = 0 Thists = [] while j < len(Tfiles): # dirname="DQMData/Run %s/HLT/Run summary/TimerService/Running 1 processes/process %s/Paths/%s_module_total" % (runs[j],processes[j],path) dirname = "DQMData/Run %s/HLT/Run summary/TimerService/process %s paths/path %s/module_time_real_total" % ( runs[j], processes[j], path) print dirname hist = Tfiles[j].Get(dirname) Thists.append(hist) j += 1 k = 0 leg = TLegend(0.35, 0.7, 0.9, 1, "") leg.SetFillStyle(0) leg.SetBorderSize(0) leg.SetTextFont(62) leg.SetTextSize(0.028) leg.SetTextColor(2) while k < len(Thists): if k == 0: #Thists[k].Scale( 1.0 / Thists[k].Integral() ) Thists[k].GetYaxis().SetRangeUser(0.15, 1000) print "lower bound of bin 100: %i" % Thists[k].GetBinCenter(100) print "percentage of events running particle flow: %i " % Thists[ k].Integral(100, 500) Thists[k].SetLineWidth(2) Thists[k].SetLineColor(k + 4) if args.ext: Thists[k].GetXaxis().SetRangeUser(0, 2000) else: Thists[k].GetXaxis().SetRangeUser(0, 400) Thists[k].Draw('hist') else: Thists[k].Scale(1.0 / Thists[k].Integral()) Thists[k].SetLineWidth(2) Thists[k].SetLineColor(k + 1) Thists[k].Draw("hist same") #write name in full # name = "Mean: %f" % Thists[k].GetMean() name = path print "name is = " + name if args.ext: Thists[k].GetXaxis().SetRangeUser(0, 2000) else: Thists[k].GetXaxis().SetRangeUser(312, 400) leg.AddEntry(Thists[k], name, "l") k += 1 leg.Draw() filename = 'ModuleTotal_%s.pdf' % path c1.Print(filename)