def plot(values, suffix=None): canvas = ROOT.TCanvas("canvas", "canvas", 800, 600) axes = canvas.DrawFrame(-1.55, -0.6, 1.15, 2.6) axes.GetXaxis().SetTitle("#eta#alpha") axes.GetYaxis().SetTitle("response") axes.GetYaxis().SetTitleOffset(1.2) PyROOTUtils.DrawText(0.2, 0.87, "InterpCode = " + str(options.interpcode), textSize=0.03) leg = PyROOTUtils.Legend(0.2, 0.83, textSize=0.03) for etaData in values: eta = etaData['eta'] data = etaData['data'] g = PyROOTUtils.Graph(data) container.append(g) gDerivative = PyROOTUtils.Graph(g.derivativeData(), lineStyle=ROOT.kDashed) container.append(gDerivative) gDerivative2 = PyROOTUtils.Graph(g.derivative2Data(), lineStyle=ROOT.kDotted) if 'secondDerivative' in etaData: gDerivative2 = PyROOTUtils.Graph(etaData['secondDerivative'], lineStyle=ROOT.kDotted) gDerivative2.transformY(lambda y: y / 10.0) container.append(gDerivative2) infoStr = "#eta = " + str(eta) + " " if 'slopeAtZero' in etaData: infoStr += "\nslope(0) = %.2f " % (etaData['slopeAtZero']) t = PyROOTUtils.DrawText(data[0][0], data[0][1], infoStr, textSize=0.025, halign="right", valign="center", NDC=False) container.append(t) g.Draw("L") gDerivative.Draw("L") gDerivative2.Draw("L") leg.AddEntry(g, "f(#eta#alpha)", "L") leg.AddEntry(gDerivative, "f'(#eta#alpha)", "L") leg.AddEntry(gDerivative2, "1/10 f''(#eta#alpha)", "L") leg.Draw() outFileName = options.output if suffix: outFileName = outFileName.replace(".eps", suffix + ".eps") canvas.SaveAs(outFileName)
def content(mHBestFit=130.0, height1SigmaLabel=10.0, color=ROOT.kBlue): # make mock curve linSpace = [100 + i * 60.0 / 300.0 for i in range(300)] likelihood = [(x, (x - mHBestFit) * (x - mHBestFit) / 25.0) for x in linSpace] likelihood_statOnly = [(x, (x - mHBestFit) * (x - mHBestFit) / 20.0) for x in linSpace] # draw curve g = PyROOTUtils.Graph(likelihood, lineColor=color, lineWidth=2) g.Draw() g_statOnly = PyROOTUtils.Graph(likelihood_statOnly, lineColor=color, lineWidth=2, lineStyle=ROOT.kDashed) g_statOnly.Draw() # find 68% CL interval from likelihood low, high = g.getFirstIntersectionsWithValue(1.0) vLineM1Sigma = PyROOTUtils.DrawVLine(low, lineStyle=ROOT.kDashed, lineWidth=1, lineColor=color) vLineP1Sigma = PyROOTUtils.DrawVLine(high, lineStyle=ROOT.kDashed, lineWidth=1, lineColor=color) hLine1Sigma = PyROOTUtils.DrawLine(low, height1SigmaLabel, high, height1SigmaLabel, lineWidth=5, lineColor=color) label1Sigma = PyROOTUtils.DrawText( mHBestFit, height1SigmaLabel, ("#lower[-0.5]{%.1f^{%+.1f}_{%+.1f} GeV}" % (mHBestFit, high - mHBestFit, low - mHBestFit)), NDC=False, textSize=0.025, halign="center", valign="bottom", textColor=color) container.append( (g, g_statOnly, vLineM1Sigma, vLineP1Sigma, hLine1Sigma, label1Sigma)) return (g, g_statOnly)
outputtexfile.write(line + "\n") tail = ''' \\hline \\hline \end{tabular} \end{center} \end{table} ''' outputtexfile.write(tail) outputtexfile.close() #gr_med = PyROOTUtils.Graph(masses, medians) gr_obs = PyROOTUtils.Graph(masses, lim_obs) gr_obs.SetMarkerStyle(20) gr_med = PyROOTUtils.Graph(masses, lim_med) #gr_med.SetMarkerStyle(7) gr_med.SetLineStyle(R.kDashed) gr_med.SetLineWidth(2) #band_1sigma = PyROOTUtils.Band(masses, minus1sigmas, plus1sigmas, fillColor=R.kGreen) #band_2sigma = PyROOTUtils.Band(masses, minus2sigmas, plus2sigmas, fillColor=R.kYellow) band_1sigma = PyROOTUtils.Band(masses, minus1sig, plus1sig, fillColor=R.kGreen) band_2sigma = PyROOTUtils.Band(masses, minus2sig, plus2sig, fillColor=R.kYellow) # Prepare frame hframe = R.TH1I("frame", "frame", 1, min(masses), max(masses))