Ejemplo n.º 1
0
    def draw_nse_mean(self):
        cent_bin1 = [0, 4, 7]
        cent_bin2 = [3, 6, 8]
        p_bin1 = [
            0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5,
            3.0, 3.5, 4.0, 4.5
        ]
        p_bin2 = [
            0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0,
            3.5, 4.0, 4.5, 5.0
        ]
        gr_mean = TGraphErrors()
        gr_width = TGraphErrors()
        gr_eff = TGraphErrors()
        for i in range(0, len(p_bin1)):
            f_gaus = self.draw_nse(cent_bin1[1], cent_bin2[1], p_bin1[i],
                                   p_bin2[i], -1, 2)
            mean = f_gaus.GetParameter(1)
            mean_err = f_gaus.GetParError(1)
            width = f_gaus.GetParameter(2)
            width_err = f_gaus.GetParError(2)
            gr_mean.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, mean)
            gr_mean.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5, mean_err)
            gr_width.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, width)
            gr_width.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5, width_err)
            p = 0.5 * (p_bin1[i] + p_bin2[i])
            if p < 1:
                nse_low = 0.5 * p - 1.5
            else:
                nse_low = -1
            m = f_gaus.Integral(nse_low, 2.0)
            N = f_gaus.Integral(-10.0, 10.0)
            gr_eff.SetPoint(i, p, m / N)
            gr_eff.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5,
                                 eff_err(m, N))
        gr_mean.SetMarkerStyle(20)

        gr_mean.SetMarkerSize(1.5)
        gr_mean.SetMarkerColor(632)
        gr_width.SetMarkerStyle(20)
        gr_width.SetMarkerSize(1.5)
        gr_width.SetMarkerColor(600)
        gr_eff.SetMarkerStyle(20)
        gr_eff.SetMarkerSize(1.5)
        gr_eff.SetMarkerColor(600)
        hx = histo(0, 10, -0.2, 1.2, "p_{T}(GeV/c)", "Mean/Width")
        canvas_file = self.__canvas__
        canvas_file.cd()
        c1 = TCanvas("c1", "c1", 1000, 800)
        hx.Draw()
        gr_width.Draw("psame")
        gr_mean.Draw("psame")
        c1.Write("nse")
        c1.SaveAs("nse.png")
        c2 = TCanvas("c2", "c2", 1000, 800)
        hx.GetYaxis().SetTitle("n#sigma_{e} cut efficiency")
        hx.Draw()
        gr_eff.Draw("psame")
        c2.Write("nse_eff")
        c2.SaveAs("nse_eff.png")
Ejemplo n.º 2
0
 def draw_tof_cut_eff(self, cent_low, cent_high):
     cent_bin1 = [0, 4, 7]
     cent_bin2 = [3, 6, 8]
     p_bin1 = [
         0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5,
         3.0, 3.5, 4.0, 4.5
     ]
     p_bin2 = [
         0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0,
         3.5, 4.0, 4.5, 5.0
     ]
     gr_mean = TGraphErrors()
     gr_width = TGraphErrors()
     gr_eff = TGraphErrors()
     for i in range(0, len(p_bin1)):
         f_gaus = self.draw_tof_cut(cent_bin1[1], cent_bin2[1], p_bin1[i],
                                    p_bin2[i])
         mean = f_gaus.GetParameter(1)
         mean_err = f_gaus.GetParError(1)
         width = f_gaus.GetParameter(2)
         width_err = f_gaus.GetParError(2)
         gr_mean.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, mean)
         gr_mean.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5, mean_err)
         gr_width.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, width)
         gr_width.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5, width_err)
         m = f_gaus.Integral(0.97, 1.03)
         N = f_gaus.GetParameter(0) * math.sqrt(
             2 * math.pi) * f_gaus.GetParameter(2)
         print m, N
         gr_eff.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, m / N)
         gr_eff.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5,
                              eff_err(m, N))
     gr_mean.SetMarkerStyle(20)
     gr_mean.SetMarkerSize(1.5)
     gr_mean.SetMarkerColor(632)
     gr_width.SetMarkerStyle(20)
     gr_width.SetMarkerSize(1.5)
     gr_width.SetMarkerColor(600)
     gr_eff.SetMarkerStyle(20)
     gr_eff.SetMarkerSize(1.5)
     gr_eff.SetMarkerColor(600)
     hx = histo(0, 10, -0.2, 1.2, "p_{T}(GeV/c)", "Mean/Width")
     canvas_file = self.__canvas__
     canvas_file.cd()
     c1 = TCanvas("c1", "c1", 1000, 800)
     hx.GetYaxis().SetTitle("1/#beta cut efficency")
     hx.Draw()
     gr_width.Draw("psame")
     gr_mean.Draw("psame")
     c1.Write("tof")
     c1.SaveAs("tof.png")
     c2 = TCanvas("c2", "c2", 1000, 800)
     hx.Draw()
     gr_eff.Draw("psame")
     c2.Write("tof_cut_eff")
     c2.SaveAs("tof_cut.png")
Ejemplo n.º 3
0
def create_resolutiongraph(n, energies, sigmasmeans, energieserrors, sigmasmeanserrors, graphname):
	"""Function to perform ROOT graphs of resolutions"""
	#How many points
	n = int(n)

	TGraphresolution = TGraphErrors(n, energies, sigmasmeans, energieserrors, sigmasmeanserrors)
	
	#Draw + DrawOptions, Fit + parameter estimation
	Style = gStyle
	Style.SetOptFit()
	XAxis = TGraphresolution.GetXaxis() #TGraphresolution
	TGraphresolution.SetMarkerColor(4)
	TGraphresolution.SetMarkerStyle(20)
	TGraphresolution.SetMarkerSize(2)
	XAxis.SetTitle("Energy (GeV)")
	YAxis = TGraphresolution.GetYaxis()
	YAxis.SetTitle("Sigma/Mean")
	resolutionfit = TF1("resolutionfit", '([0]/((x)**0.5))+[1]', 0, max(energies)) #somma non quadratura
	TGraphresolution.Fit("resolutionfit")
	a = resolutionfit.GetParameter(0)
	b = resolutionfit.GetParameter(1)             
	TGraphresolution.Draw("AP")
	gPad.SaveAs(graphname)
	gPad.Close()
	return a, b
Ejemplo n.º 4
0
 def draw_neta_cut_eff(self, cent_low, cent_high):
     cent_bin1 = [0, 4, 7]
     cent_bin2 = [3, 6, 8]
     p_bin1 = [
         0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5,
         3.0, 3.5, 4.0, 4.5
     ]
     p_bin2 = [
         0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0,
         3.5, 4.0, 4.5, 5.0
     ]
     gr_eff = TGraphErrors()
     for i in range(0, len(p_bin1)):
         mn = self.draw_neta_cut(cent_low, cent_high, p_bin1[i], p_bin2[i])
         m = mn[0]
         N = mn[1]
         gr_eff.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, m / N)
         gr_eff.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5,
                              eff_err(m, N))
     gr_eff.SetMarkerStyle(20)
     gr_eff.SetMarkerSize(1.5)
     gr_eff.SetMarkerColor(600)
     hx = histo(0, 8, -0.2, 1.2, "p_{T}(GeV/c)", "n#eta cut efficiency")
     canvas_file = self.__canvas__
     canvas_file.cd()
     c2 = TCanvas("c2", "c2", 1000, 800)
     hx.Draw()
     gr_eff.Draw("psame")
     c2.Write("neta_cut_eff")
     c2.SaveAs("neta_cut.png")
Ejemplo n.º 5
0
def CompareToys(MwValuemT, MwValuemTStat):
    print(len(MwValuemT), len(MwValuemTStat))

    n = len(MwValuemT)
    x, y = array('d'), array('d')
    ex, ey = array('d'), array('d')

    for i in range(0, n):
        x.append(i + 1)
        ex.append(0)
        y.append(MwValuemT[i])
        ey.append(MwValuemTStat[i])

    gr = TGraphErrors(n, x, y, ex, ey)
    gr.Draw("P")
    gr.SetLineWidth(0)
    gr.SetMarkerStyle(20)
    gr.SetMarkerSize(1)

    xax = gr.GetXaxis()
    for i in range(0, n):
        binIndex = xax.FindBin(i)
        xax.SetBinLabel(binIndex, "toys")

    Output = ROOT.TFile.Open("Matrix.root", "RECREATE")
    gr.Write("gr")
Ejemplo n.º 6
0
def compareEEC( filename="sjm91_all.root", datafilename="../EECMC/share/OPAL/data.dat" ):
    f= TFile( filename )
    ao= createAnalysisObservable( f, "EEC" )
    tokens= datafilename.split( "/" )
    exp= tokens[3]
    plotoptions= { "xmin": 0.0, "xmax": 3.14159, "ymin": 0.05, "ymax": 5.0, "markerStyle": 20,
                       "markerSize": 0.5, "drawas": "3", "fillcolor": 6, "title": "EEC "+exp,
                       "xlabel": "\chi\ [rad.]", "ylabel": "1/\sigma d\Sigma/d\chi", "logy": 1 }
    tgest, tgesy= ao.plot( plotoptions )
    lines= [ line.rstrip( '\n' ) for line in open( datafilename ) ]
    n= len( lines )
    points= TVectorD( n )
    values= TVectorD( n )
    errors= TVectorD( n )
    perrs= TVectorD(n)
    grad2rad= 3.14159/180.0
    for i in range( n ):
        line= (lines[i]).split()
        points[i]= float(line[0])*grad2rad
        values[i]= float(line[3])
        errors[i]= float(line[4])
        perrs[i]= 0.0
    datatge= TGraphErrors( points, values, perrs, errors )
    datatge.SetMarkerStyle( 20 )
    datatge.SetMarkerSize( 0.5 )    
    datatge.Draw( "psame" )
    legend= TLegend( 0.2, 0.7, 0.5, 0.85 )
    datatge.SetName( "datatge" );
    tgesy.SetName( "tgesy" )
    legend.AddEntry( "datatge", exp+" data", "pe" )
    legend.AddEntry( "tgesy", "OPAL "+filename, "f" )
    legend.Draw()
    return 
Ejemplo n.º 7
0
def TGraph(x, y, yError=None, xError=None, **kwargs):

    __parseDrawOptions(kwargs)

    import sys
    #TODO: Need to check the types
    try:
        assert (len(x) == len(y))
    except AssertionError:
        print "Oops! Data points x and y aren't of the same size!"
        sys.exit()

    nPoints = len(x)

    from array import array
    if xError is None: xError = __zeros(nPoints)
    if yError is None: yError = __zeros(nPoints)

    from ROOT import TGraphErrors
    graph = TGraphErrors(nPoints, array('d', x), array('d', y),
                         array('d', xError), array('d', yError))
    graph.SetTitle(__drawOptions['title'])
    graph.SetMarkerStyle(__drawOptions['mstyle'])
    graph.SetMarkerSize(__drawOptions['msize'])
    graph.SetMarkerColor(__drawOptions['mcolour'])
    graph.SetFillStyle(0)
    graph.SetFillColor(0)
    return graph
Ejemplo n.º 8
0
def make_tgrapherrors(name,
                      title,
                      color=1,
                      marker=20,
                      marker_size=1,
                      width=1,
                      asym_err=False,
                      style=1,
                      x=None,
                      y=None):
    if (x and y) is None:
        gr = TGraphErrors() if not asym_err else TGraphAsymmErrors()
    else:
        gr = TGraphErrors(len(x), array(x, 'd'), array(
            y, 'd')) if not asym_err else TGraphAsymmErrors(
                len(x), array(x, 'd'), array(y), 'd')
    gr.SetTitle(title)
    gr.SetName(name)
    gr.SetMarkerStyle(marker)
    gr.SetMarkerColor(color)
    gr.SetLineColor(color)
    gr.SetMarkerSize(marker_size)
    gr.SetLineWidth(width)
    gr.SetLineStyle(style)
    return gr
Ejemplo n.º 9
0
def ZMultVsLumi(histo, recorded, outputDir, title):
    #gSystem.Exec("mkdir -p ZPlots")
    can1 = makeCMSCanvas(str(random.random()),"mult vs lumi ",900,700)
    lumi = []
    lumi_err = []
    mult = []
    mult_err = []
    sumLumi = 0.
    for i in range(0,len(recorded)):
        sumLumi += float(recorded[i])
        lumi.append(sumLumi - float(recorded[i])/2)
        lumi_err.append(float(recorded[i])/2)
        mult.append(histo[i].GetEntries()/float(recorded[i]))
        mult_err.append(math.sqrt(histo[i].GetEntries()/float(recorded[i])))
    graph1 = TGraphErrors(len(lumi),array('d',lumi),array('d',mult),array('d',lumi_err),array('d',mult_err))
    can1.cd()
    graph1.SetTitle("")
    graph1.GetXaxis().SetTitle("Lumi [fb^{-1}]")
    graph1.GetYaxis().SetTitle("#Z / fb^{-1}")
    graph1.SetMarkerStyle(20)
    graph1.SetMarkerSize(1)
    graph1.Draw("AP")
    printLumiPrelOut(can1)
    can1.SaveAs(str(outputDir) + "/Z_multiplicity_"+title+".pdf")
    can1.SaveAs(str(outputDir) + "/Z_multiplicity_"+title+".png")
    return graph1;
Ejemplo n.º 10
0
def Ratio(histo1,histo2, recorded, title):
    #gSystem.Exec("mkdir -p ZPlots")
    can1 = makeCMSCanvas(str(random.random()),"mult vs lumi ",900,700)
    lumi = []
    lumi_err = []
    ratio = []
    ratio_err = []
    sumLumi = 0.
    for i in range(0,len(recorded)):
        sumLumi += float(recorded[i])
        lumi.append(sumLumi - float(recorded[i])/2)
        lumi_err.append(float(recorded[i])/2)
        ratio.append(histo1[i].GetEntries()/histo2[i].GetEntries())
        ratio_err.append(0)
    graph1 = TGraphErrors(len(recorded),array('d',lumi),array('d',ratio),array('d',lumi_err),array('d',ratio_err))
    can1.cd()
    graph1.SetTitle("")
    graph1.GetXaxis().SetTitle("Lumi [fb^{-1}]")
    graph1.GetYaxis().SetTitle("e^{+}e^{-}/#mu^{+}#mu^{-}")
    graph1.SetMarkerStyle(20)
    graph1.SetMarkerSize(1)
    graph1.Draw("AP")
    printLumiPrelOut(can1)
    can1.SaveAs("ZPlots/Z_ratio_"+title+".pdf")
    can1.SaveAs("ZPlots/Z_ratio_"+title+".png")
    return;
Ejemplo n.º 11
0
def GraphVsLumi(result, outputDir, title):
    #gSystem.Exec("mkdir -p ZPlots")
    can1 = makeCMSCanvas(str(random.random()), "mean vs lumi ", 900, 700)
    can2 = makeCMSCanvas(str(random.random()), "width vs lumi ", 900, 700)
    lumi = []
    lumi_err = []
    mean = []
    mean_err = []
    width = []
    width_err = []
    sumLumi = 0.
    for i in range(0, len(result)):
        sumLumi += float(result[i].lumi)
        lumi.append(sumLumi - float(result[i].lumi) / 2)
        lumi_err.append(float(result[i].lumi) / 2)
        mean.append(result[i].mean)
        mean_err.append(result[i].mean_err)
        width.append(result[i].width)
        width_err.append(result[i].width_err)
    graph1 = TGraphErrors(len(result), array('d', lumi), array('d', mean),
                          array('d', lumi_err), array('d', mean_err))
    graph2 = TGraphErrors(len(result), array('d', lumi), array('d', width),
                          array('d', lumi_err), array('d', width_err))
    can1.cd()
    graph1.SetTitle("")
    graph1.GetXaxis().SetTitle("Lumi [fb^{-1}]")
    graph1.GetYaxis().SetTitle("Mass [GeV]")
    graph1.SetMarkerStyle(20)
    graph1.SetMarkerSize(1)
    graph1.Draw("AP")
    printLumiPrelOut(can1)
    can1.SaveAs(str(outputDir) + "/" + title + "_mean.pdf")
    can1.SaveAs(str(outputDir) + "/" + title + "_mean.png")
    can2.cd()
    graph2.SetTitle("")
    graph2.GetXaxis().SetTitle("Lumi [fb^{-1}]")
    graph2.GetYaxis().SetTitle("Width [GeV]")
    graph2.SetMarkerStyle(20)
    graph2.SetMarkerSize(1)
    graph2.Draw("AP")
    printLumiPrelOut(can2)
    can2.SaveAs(str(outputDir) + "/" + title + "_width.pdf")
    can2.SaveAs(str(outputDir) + "/" + title + "_width.png")
    return graph1, graph2
Ejemplo n.º 12
0
def MeanRMSVsLumi(histo, recorded, outputDir, title):
    can1 = makeCMSCanvas(str(random.random()), "mean vs lumi ", 900, 700)
    can2 = makeCMSCanvas(str(random.random()), "RMS vs lumi ", 900, 700)
    lumi = []
    lumi_err = []
    mean = []
    mean_err = []
    RMS = []
    RMS_err = []
    sumLumi = 0.
    for i in range(0, len(recorded)):
        sumLumi += float(recorded[i])
        lumi.append(sumLumi - float(recorded[i]) / 2)
        lumi_err.append(float(recorded[i]) / 2)
        mean.append(histo[i].GetMean())
        mean_err.append(0.)  #dont put error on ISO and SIP histo[i].GetRMS()
        RMS.append(histo[i].GetRMS())
        RMS_err.append(0.)
    graph1 = TGraphErrors(len(recorded), array('d', lumi), array('d', mean),
                          array('d', lumi_err), array('d', mean_err))
    graph2 = TGraphErrors(len(recorded), array('d', lumi), array('d', RMS),
                          array('d', lumi_err), array('d', RMS_err))
    can1.cd()
    graph1.SetTitle("")
    graph1.GetXaxis().SetTitle("Lumi [fb^{-1}]")
    graph1.GetYaxis().SetTitle(" ")
    graph1.SetMarkerStyle(20)
    graph1.SetMarkerSize(1)
    graph1.Draw("AP")
    printLumiPrelOut(can1)
    can1.SaveAs(str(outputDir) + "/" + title + "_mean.pdf")
    can1.SaveAs(str(outputDir) + "/" + title + "_mean.png")
    can2.cd()
    graph2.SetTitle("")
    graph2.GetXaxis().SetTitle(" ")
    graph2.GetYaxis().SetTitle("Width [GeV]")
    graph2.SetMarkerStyle(20)
    graph2.SetMarkerSize(1)
    graph2.Draw("AP")
    printLumiPrelOut(can2)
    can2.SaveAs(str(outputDir) + "/" + title + "_width.pdf")
    can2.SaveAs(str(outputDir) + "/" + title + "_width.png")

    return graph1, graph2
Ejemplo n.º 13
0
def getGraph(data, name='graph', offset=0):
    from ROOT import TGraphErrors
    g = TGraphErrors(len(data))
    for n, (_, throughput, throughputE) in enumerate(data):
        g.SetPoint(n, offset + n, throughput)
        g.SetPointError(n, 0., throughputE)
    g.SetName(name)
    g.SetLineWidth(2)
    g.SetMarkerSize(1.7)
    return g
def draw_limits_per_category(nchannels, xmin, xmax, obs, expect, upper1sig,
                             lower1sig, upper2sig, lower2sig):

    channel = np.array(
        [3. * nchannels - 1.5 - 3. * i for i in range(0, nchannels)])
    ey = np.array([0.8 for i in range(0, nchannels)])
    zero = np.zeros(nchannels)

    gexpect1sig = TGraphAsymmErrors(nchannels, expect, channel, lower1sig,
                                    upper1sig, ey, ey)
    gexpect1sig.SetFillColor(kGreen)
    gexpect1sig.SetLineWidth(2)
    gexpect1sig.SetLineStyle(2)

    gexpect2sig = TGraphAsymmErrors(nchannels, expect, channel, lower2sig,
                                    upper2sig, ey, ey)
    gexpect2sig.SetFillColor(kYellow)
    gexpect2sig.SetLineWidth(2)
    gexpect2sig.SetLineStyle(2)

    gexpect2sig.Draw("2")
    gexpect1sig.Draw("2")

    gobs = TGraphErrors(nchannels, obs, channel, zero, ey)
    gobs.SetMarkerStyle(21)
    gobs.SetMarkerSize(1.5)
    gobs.SetLineWidth(2)
    gobs.Draw("pz")

    # dashed line at median expected limits
    l = TLine()
    l.SetLineStyle(2)
    l.SetLineWidth(2)
    for bin in range(nchannels):
        l.DrawLine(expect[bin], channel[bin] - ey[bin], expect[bin],
                   channel[bin] + ey[bin])

    # line to separate individual and combined limits
    l.SetLineStyle(1)
    l.SetLineWidth(1)
    l.DrawLine(xmin, 0, xmax, 0)

    # legend
    x1 = gStyle.GetPadLeftMargin() + 0.01
    y2 = 1 - gStyle.GetPadTopMargin() - 0.01
    leg = TLegend(x1, y2 - 0.17, x1 + 0.25, y2)
    leg.SetFillColor(4000)
    leg.AddEntry(gexpect1sig, "Expected #pm1#sigma", "FL")
    leg.AddEntry(gexpect2sig, "Expected #pm2#sigma", "FL")
    leg.AddEntry(gobs, "Observed", "pl")
    leg.Draw()

    return gobs, gexpect1sig, gexpect2sig, leg
Ejemplo n.º 15
0
def draw_limits_per_category(nchannels, xmin, xmax, obs, expect, upper1sig,
                             lower1sig, upper2sig, lower2sig):

    channel = np.array(
        [nchannels - 1.5 - float(i) for i in range(0, nchannels)])
    ey = np.full(nchannels, 0.494)
    zero = np.zeros(nchannels)

    gexpect1sig = TGraphAsymmErrors(nchannels, expect, channel, lower1sig,
                                    upper1sig, ey, ey)
    gexpect1sig.SetFillColor(kGreen)
    gexpect1sig.SetLineWidth(2)
    gexpect1sig.SetLineStyle(2)

    gexpect2sig = TGraphAsymmErrors(nchannels, expect, channel, lower2sig,
                                    upper2sig, ey, ey)
    gexpect2sig.SetFillColor(kYellow)
    gexpect2sig.SetLineWidth(2)
    gexpect2sig.SetLineStyle(2)

    gexpect2sig.Draw("2")
    gexpect1sig.Draw("2")

    gobs = TGraphErrors(nchannels, obs, channel, zero, ey)
    gobs.SetMarkerStyle(21)
    gobs.SetMarkerSize(1.5)
    gobs.SetLineWidth(2)
    #gobs.Draw("pz")

    # dashed line at median expected limits
    l = TLine()
    l.SetLineStyle(2)
    l.SetLineWidth(2)
    for bin in range(nchannels):
        l.DrawLine(expect[bin], channel[bin] - ey[bin], expect[bin],
                   channel[bin] + ey[bin])

    # line to separate individual and combined limits
    l.SetLineStyle(1)
    l.SetLineWidth(1)
    l.DrawLine(xmin, 0, xmax, 0)

    # legend
    leg = TLegend(0.75, 0.75, 0.95, 0.9)
    leg.SetFillColor(4000)
    leg.AddEntry(gexpect1sig, "Expected #pm1#sigma", "FL")
    leg.AddEntry(gexpect2sig, "Expected #pm2#sigma", "FL")
    #leg.AddEntry( gobs,        "Observed", "pl" )
    leg.Draw()

    return gobs, gexpect1sig, gexpect2sig, leg
Ejemplo n.º 16
0
def plot_correction( h2, slope, offset, x_points, y_points, error_points, outname, 
                     xlabel='',
                     etBinIdx=None, 
                     etaBinIdx=None, 
                     etBins=None,
                     etaBins=None, 
                     label='Internal',
                     ref_value=None, 
                     pd_value=None,
                     palette=kBlackBody):

    def toStrBin(etlist = None, etalist = None, etidx = None, etaidx = None):
        if etlist and etidx is not None:
            etlist=copy(etlist)
            if etlist[-1]>9999:  etlist[-1]='#infty'
            binEt = (str(etlist[etidx]) + ' < E_{T} [GeV] < ' + str(etlist[etidx+1]) if etidx+1 < len(etlist) else
                                     'E_{T} > ' + str(etlist[etidx]) + ' GeV')
            return binEt
        if etalist and etaidx is not None:
            binEta = (str(etalist[etaidx]) + ' < |#eta| < ' + str(etalist[etaidx+1]) if etaidx+1 < len(etalist) else
                                        str(etalist[etaidx]) + ' <|#eta| < 2.47')
            return binEta

    canvas = TCanvas("canvas","canvas",500,500)
    rpl.set_figure(canvas)
    gStyle.SetPalette(palette)
    canvas.SetRightMargin(0.15)
    canvas.SetTopMargin(0.15)
    canvas.SetLogz()
    h2.GetXaxis().SetTitle('Neural Network output (Discriminant)')
    h2.GetYaxis().SetTitle(xlabel)
    h2.GetZaxis().SetTitle('Count')
    h2.Draw('colz')
    g = TGraphErrors(len(x_points), array.array('d',x_points), array.array('d',y_points), array.array('d',error_points), array.array('d',[0]*len(x_points)))
    g.SetMarkerColor(kBlue)
    g.SetMarkerStyle(8)
    g.SetMarkerSize(1)
    g.Draw("P same")
    line = TLine(slope*h2.GetYaxis().GetXmin()+offset,h2.GetYaxis().GetXmin(), slope*h2.GetYaxis().GetXmax()+offset, h2.GetYaxis().GetXmax())
    line.SetLineColor(kBlack)
    line.SetLineWidth(2)
    line.Draw()
    # Add text labels into the canvas
    text = toStrBin(etlist=etBins, etidx=etBinIdx)
    text+= ', '+toStrBin(etalist=etaBins, etaidx=etaBinIdx)
    if ref_value and pd_value:
        text+=', P_{D} = %1.2f (%1.2f) [%%]'%(pd_value*100, ref_value*100)
    rpl.add_text(0.15, 0.885, text, textsize=.03)
    rpl.set_atlas_label(0.15, 0.94, label)
    rpl.format_canvas_axes(XLabelSize=16, YLabelSize=16, XTitleOffset=0.87, ZLabelSize=16,ZTitleSize=16, YTitleOffset=0.87, ZTitleOffset=1.1)
    canvas.SaveAs(outname)
Ejemplo n.º 17
0
 def plot( self, plotoptions, opt="?" ):
     vx= array( "d", self.aostand.getPointsCenter() )
     values= self.values
     sterrs= self.sterrs
     if "m" in opt:
         print "AnalysisObservable::plot: use errors from error matrix"
         sterrs= array( "d", self.aostand.getErrors( "m" ) )
     syerrs= self.syerrs
     npoints= len(vx)
     if "xshift" in plotoptions:
         for i in range(npoints):
             vx[i]+= plotoptions["xshift"]
     vex= array( "d", npoints*[0.0] )
     tgest= TGraphErrors( npoints, vx, values, vex, sterrs )
     toterrs= np.sqrt( np.add( np.square( sterrs ),  np.square( syerrs ) ) )
     tgesy= TGraphErrors( npoints, vx, values, vex, toterrs )
     tgesy.SetMarkerStyle( plotoptions["markerStyle"] )
     tgesy.SetMarkerSize( plotoptions["markerSize"] )
     drawas= plotoptions["drawas"] if "drawas" in plotoptions else "p"
     tgesy.SetName( self.obs )
     if "fillcolor" in plotoptions:
         tgesy.SetFillColor(plotoptions["fillcolor"])
         tgest.SetFillColor(plotoptions["fillcolor"])
     if "s" in opt:
         tgesy.Draw( "psame" )
     else:
         if "title" in plotoptions:
             tgesy.SetTitle( plotoptions["title"] )
         else:
             tgesy.SetTitle( self.obs )
         tgesy.SetMinimum( plotoptions["ymin"] )
         tgesy.SetMaximum( plotoptions["ymax"] )
         xaxis= tgesy.GetXaxis()
         xaxis.SetLimits( plotoptions["xmin"], plotoptions["xmax"] )
         if "xlabel" in plotoptions:
             xaxis.SetTitle( plotoptions["xlabel"] )
         if "ylabel" in plotoptions:
             tgesy.GetYaxis().SetTitle( plotoptions["ylabel"] )
         tgesy.Draw( "a"+drawas )
     optlogx= plotoptions["logx"] if "logx" in plotoptions else 0
     gPad.SetLogx( optlogx )
     optlogy= plotoptions["logy"] if "logy" in plotoptions else 0
     gPad.SetLogy( optlogy )
     tgest.Draw( "same"+drawas )
     return tgest, tgesy
Ejemplo n.º 18
0
	def getGraph(self, filename):
		data = self.getData(filename)

		from ROOT import TFile, TTree, gDirectory, TGraphErrors, TCanvas
		from array import array

		nsteps = len(data)
		g = TGraphErrors(nsteps)

		## Loop on the data
		for	n,(fragsize,tp,tpE) in enumerate(data):
			g.SetPoint(      n, fragsize, tp)
			g.SetPointError( n,       0., tpE)

		g.SetLineWidth(2)
		g.SetMarkerSize(1.7)

		return g
Ejemplo n.º 19
0
def create_linearitygraph(n, energies, energieserrors, means, sigmameans, graphname):
	"""Function to perform ROOT graphs of resolutions"""
	#How many points
	n = int(n)

	TGraphlinearity = TGraphErrors(n, energies, means, energieserrors, sigmameans)
	
	#Draw + DrawOptions, Fit + parameter estimation
	Style = gStyle
	Style.SetOptFit()
	XAxis = TGraphlinearity.GetXaxis() #TGraphresolution
	TGraphlinearity.SetMarkerColor(4)
	TGraphlinearity.SetMarkerStyle(20)
	TGraphlinearity.SetMarkerSize(2)
	XAxis.SetTitle("Energy (GeV)")
	YAxis = TGraphlinearity.GetYaxis()
	YAxis.SetTitle("Mean/TrueEnergy")
	TGraphlinearity.Draw("AP")
	gPad.SaveAs(graphname)
	gPad.Close()
Ejemplo n.º 20
0
def getResponseGraph(file):
    print "Read=", file
    i = 0
    g1 = TGraphErrors()
    for line in open(file, "r"):
        columns = line.split(',')
        pt = float(columns[0])
        pt_err = float(columns[1])
        sigma = float(columns[2])
        err = float(columns[3])
        g1.SetPoint(i, pt, sigma)
        ex = pt_err
        ey = err
        g1.SetPointError(i, ex, ey)
        i = i + 1

    g1.SetMarkerColor(1)
    g1.SetMarkerStyle(20)
    g1.SetMarkerSize(0.5)

    # g1->Print();
    return g1
Ejemplo n.º 21
0
def compareY23d( filename="sjm91_all.root", mtffilename=None, opt="m" ):
    if mtffilename == None:
        ecm= ecmFromFilename( filename )
        mtffilename= "mtford-y23d"+ecm+".txt" 
    arrays= ascii2arrays( mtffilename )
    mtfordpointsl= arrays[0]
    mtfordpointsr= arrays[1]
    mtfordpoints= np.divide( np.add( arrays[0], arrays[1] ), 2.0 )
    mtfordvalues= arrays[2]
    mtfordsterrs= arrays[3]
    mtfordsyerrs= arrays[4]
    mtforderrs= np.sqrt( np.add( np.square( mtfordsterrs ),  np.square( mtfordsyerrs ) ) )
    if filename=="sjm133.root":
        f1= TFile( "sjm130.root" )
        ao1= createAnalysisObservable( f1, "durhamymerge23" )
        f2= TFile( "sjm136.root" )
        ao2= createAnalysisObservable( f2, "durhamymerge23" )
        ao= combineAnalysisObservables( [ ao1, ao2 ] )
    else:
        f= TFile( filename )
        ao= createAnalysisObservable( f, "durhamymerge23" )
    npoints= len( mtfordpoints )
    vex= array( "d", npoints*[0.0] )
    tgest= TGraphErrors( npoints, mtfordpoints, mtfordvalues, vex, mtfordsterrs )
    tgetot= TGraphErrors( npoints, mtfordpoints, mtfordvalues, vex, mtforderrs )
    plotoptions= { "xmin": 0.0003, "xmax": 0.5, "ymin": 0.5, "ymax": 500.0, "markerStyle": 20,
                       "markerSize": 0.75, "title": "Durham y23 "+filename, "xlabel": "y_{23}",
                       "ylabel": "1/\sigma d\sigma/dy_{23}", "logx":1, "logy":1 }
    ao.plot( plotoptions, opt )
    tgetot.SetMarkerStyle( 24 )
    tgetot.SetMarkerSize( 1.25 )
    tgetot.SetName( "mtford" )
    tgetot.Draw( "psame" )
    tgest.Draw( "psame" )
    tl= TLegend( 0.7, 0.9, 0.7, 0.9 )
    tl.AddEntry( "mtford", "M.T. Ford thesis", "ep" )
    tl.AddEntry( "durhamymerge23", "sjmanalysis", "ep" )
    tl.Draw()
    return
Ejemplo n.º 22
0
def compareThrust( filename="sjm91_all.root", mtffilename=None ):
    if mtffilename == None:
        ecm= ecmFromFilename( filename )
        mtffilename= "mtford-thrust"+ecm+".txt" 
    arrays= ascii2arrays( mtffilename )
    mtfordvalues= arrays[2]
    mtfordsterrs= arrays[3]
    mtfordsyerrs= arrays[4]
    mtforderrs= np.sqrt( np.add( np.square( mtfordsterrs ),  np.square( mtfordsyerrs ) ) )
    if filename=="sjm133.root":
        # f1= TFile( "sjm130.root" )
        # aothrust1= createAnalysisObservable( f1, "thrust" )
        # f2= TFile( "sjm136.root" )
        # aothrust2= createAnalysisObservable( f2, "thrust" )
        # aothrust= combineAnalysisObservables( [ aothrust1, aothrust2 ] )
        aothrust= createCombineAnalysisObservables( ( "sjm130.root", "sjm136.root" ), "lepthrust" )
    else:
        f= TFile( filename )
        aothrust= createAnalysisObservable( f, "lepthrust" )    
    vx= array( "d", aothrust.aostand.getPointsCenter() )
    npoints= len(vx)-1
    vex= array( "d", npoints*[0.0] )
    tgethrustst= TGraphErrors( npoints, vx, mtfordvalues, vex, mtfordsterrs )
    tgethrusttot= TGraphErrors( npoints, vx, mtfordvalues, vex, mtforderrs )
    plotoptions= { "xmin": 0.0, "xmax": 0.5, "ymin": 0.2, "ymax": 30, "markerStyle": 20,
                       "markerSize": 0.8, "title": "Thrust "+filename, "logy": 1,
                       "xlabel": "1-T", "ylabel": "1/\sigma d\sigma/d(1-T)" }
    aothrust.plot( plotoptions )
    tgethrusttot.SetMarkerStyle( 24 )
    tgethrusttot.SetMarkerSize( 1.25 )
    tgethrusttot.SetName( "mtford" )
    tgethrusttot.Draw( "psame" )
    tgethrustst.Draw( "psame" )
    tl= TLegend( 0.6, 0.75, 0.85, 0.9 )
    tl.AddEntry( "mtford", "M.T. Ford thesis", "ep" )
    tl.AddEntry( "thrust", "sjmanalysis", "ep" )
    tl.Draw()
    return
Ejemplo n.º 23
0
    def draw_bemc_match(self, cent_low, cent_high):
        h_tpc_e = self.get_subtract(self.hist_sige, cent_low, cent_high)
        h_tpc_e.SetName("h_tpc_e")
        h_bemcmatch = self.get_subtract(self.hist_bemcmatch, cent_low,
                                        cent_high)
        h_bemcmatch.SetName("h_bemcmatch")
        ymax = h_tpc_e.GetMaximum()
        haxis = histo(0, 10, 1, ymax * 3.5, "p_{T}(GeV/c)", "Counts")
        haxis.SetNdivisions(510)

        h_tpc_e.SetLineColor(600)
        h_tpc_e.SetFillColor(600)
        h_tpc_e.SetFillStyle(1001)
        h_tpc_e.SetMarkerStyle(1)
        h_tpc_e.SetMarkerColor(600)
        h_bemcmatch.SetLineColor(632)
        h_bemcmatch.SetFillColorAlpha(632, 1)
        h_bemcmatch.SetFillStyle(1001)
        h_bemcmatch.SetMarkerStyle(1)
        h_bemcmatch.SetMarkerColor(632)
        leg = TLegend(0.55, 0.5, 0.8, 0.65)
        leg.SetBorderSize(0)
        leg.SetTextSize(0.035)
        leg.SetTextFont(132)
        leg.AddEntry(h_tpc_e, "TPC electron", "f")
        leg.AddEntry(h_bemcmatch, "BEMC match electon", "f")
        data_set = "Run10 Au+Au@200GeV MinBias"
        cent_range = "{}-{}% centrality".format(self.cent_list1[cent_high],
                                                self.cent_list2[cent_low])
        c = TCanvas("c", "c", 1000, 800)
        haxis.SetStats(0)
        haxis.Draw()
        gPad.SetLogy()
        h_tpc_e.Draw("histsamelfbar2")
        h_bemcmatch.Draw("histsamelfbar2")
        leg.Draw("same")
        drawLatex(0.55, 0.72, data_set, 0.035, 132, 1)
        drawLatex(0.55, 0.67, cent_range, 0.035, 132, 1)
        c.SaveAs("tpc_e.png")
        self.__canvas__.cd()
        c.Write("tpc_e")
        c1 = TCanvas("c1", "c1", 1000, 800)
        gr = TGraphErrors()
        p_bin1 = [
            0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5,
            3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0
        ]
        p_bin2 = [
            0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.5, 2.0, 2.5, 3.0,
            3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0
        ]
        for i in range(0, len(p_bin1)):
            xlow = h_tpc_e.GetXaxis().FindBin(p_bin1[i] + 1E-3)
            xup = h_tpc_e.GetXaxis().FindBin(p_bin2[i] + 1E-3)
            N = h_tpc_e.Integral(xlow, xup)
            xlow = h_bemcmatch.GetXaxis().FindBin(p_bin1[i] + 1E-3)
            xup = h_bemcmatch.GetXaxis().FindBin(p_bin2[i] + 1E-3)
            m = h_bemcmatch.Integral(xlow, xup)
            gr.SetPoint(i, (p_bin1[i] + p_bin2[i]) * 0.5, m / N)
            gr.SetPointError(i, (p_bin2[i] - p_bin1[i]) * 0.5, eff_err(m, N))
        hx = histo(0, 10, 0, 1.5, "p_{T}(GeV/c)", "TOF match efficiency")
        hx.Draw()
        gr.Draw("psame")
        gr.SetMarkerStyle(20)
        gr.SetMarkerSize(1.5)
        gr.SetMarkerColor(632)
        canvas_file = self.__canvas__
        canvas_file.cd()
        c1.Write("bemc_match_eff")
        c1.SaveAs("bemc_match_eff.png")
g_eff.SetMarkerStyle(20)
g_eff.SetLineColor(kRed + 1)
g_eff.SetLineWidth(2)
g_purity.Draw("PL")
g_purity.SetMarkerStyle(21)
g_purity.SetLineColor(kBlue + 1)
g_purity.SetLineWidth(2)
g_acceptance.Draw("PL")
g_acceptance.SetMarkerStyle(23)
g_acceptance.SetLineColor(kGreen + 2)
g_acceptance.SetLineWidth(2)
g_reco_eff.Draw("PL")
g_reco_eff.SetLineColor(kGray + 2)
g_reco_eff.SetLineWidth(2)
g_reco_eff.SetMarkerStyle(29)
g_reco_eff.SetMarkerSize(1.5)
g_reco_eff_data.Draw("PL")
g_data_eff.Draw("PL")
g_data_eff.SetLineColor(kRed + 1)
g_data_eff.SetLineWidth(2)
g_data_eff.SetMarkerStyle(4)
g_data_eff.SetLineStyle(2)
g_reco_eff_data.SetLineColor(kGray + 2)
g_reco_eff_data.SetLineWidth(2)
g_reco_eff_data.SetMarkerStyle(30)
g_reco_eff_data.SetMarkerSize(1.5)
g_reco_eff_data.SetLineStyle(2)

l = TLegend(0.46, 0.16, 0.85, 0.425)
l.SetBorderSize(0)
l.SetShadowColor(0)
Ejemplo n.º 25
0
gPad.SetPad(small, 0.3, 1.-small, 1.-small)
gPad.SetBottomMargin(small)

labelSize=10
makerSize = 0.3

gStyle.SetEndErrorSize(0)

gr = TGraphErrors( n, energyVec, recoEnergyVec, energyErrorVec, recoEnergyErrorVec )
gr.SetName('gr')
gr.SetLineColor( 1 )
gr.SetLineWidth( 1 )
gr.SetLineStyle( 2 )
gr.SetMarkerColor( 2 )
gr.SetMarkerStyle( 20 )
gr.SetMarkerSize( makerSize )
textsize = labelSize/(gPad.GetWh()*gPad.GetAbsHNDC())
gr.SetTitle( '' )
gr.GetXaxis().SetTitle( 'E_{particle} (GeV)' )
gr.GetYaxis().SetTitle( 'E_{reco} (GeV)' )
gr.GetYaxis().SetTitleSize(textsize)
gr.GetYaxis().SetLabelSize(textsize)
gr.GetYaxis().SetTitleOffset(1.4)
gr.GetYaxis().SetRangeUser(2, 100)
gPad.SetLeftMargin(0.15)
gr.Draw( 'AP' )

func1 = TF1('fun1', 'x', 0., 100.)
func1.SetLineColor(4)
func1.SetLineStyle(2)
func1.Draw('same')
Ejemplo n.º 26
0
def main(argv):
    #Usage controls from OptionParser
    parser_usage = ""
    parser = OptionParser(usage=parser_usage)
    (options, args) = parser.parse_args(argv)
    if (len(args) != 2 and len(args) != 3):
        parser.print_help()
        return

    c1 = TCanvas("c1", "c1", 1200, 800)

    f_18deg = TFile.Open(argv[0])
    f_10deg = TFile.Open(argv[1])
    if (len(args) == 3): f_5deg = TFile.Open(argv[2])

    size = 1.3

    gr_L1_US_18deg = f_18deg.Get("gr_layer1_US_RMS")
    gr_L2_US_18deg = f_18deg.Get("gr_layer2_US_RMS")
    gr_L3_US_18deg = f_18deg.Get("gr_layer3_US_RMS")
    gr_L4_US_18deg = f_18deg.Get("gr_layer4_US_RMS")
    gr_global_US_18deg = f_18deg.Get("gr_global_US_RMS")
    gr_L1_US_10deg = f_10deg.Get("gr_layer1_US_RMS")
    gr_L2_US_10deg = f_10deg.Get("gr_layer2_US_RMS")
    gr_L3_US_10deg = f_10deg.Get("gr_layer3_US_RMS")
    gr_L4_US_10deg = f_10deg.Get("gr_layer4_US_RMS")
    gr_global_US_10deg = f_10deg.Get("gr_global_US_RMS")
    if (len(args) == 3): gr_L1_US_5deg = f_5deg.Get("gr_layer1_US_RMS")
    if (len(args) == 3): gr_L2_US_5deg = f_5deg.Get("gr_layer2_US_RMS")
    if (len(args) == 3): gr_L3_US_5deg = f_5deg.Get("gr_layer3_US_RMS")
    if (len(args) == 3): gr_L4_US_5deg = f_5deg.Get("gr_layer4_US_RMS")
    if (len(args) == 3): gr_global_US_5deg = f_5deg.Get("gr_global_US_RMS")

    color = kRed
    gr_L1_US_18deg.SetLineColor(color)
    gr_L1_US_18deg.SetMarkerColor(color)
    gr_L1_US_18deg.SetMarkerSize(size)
    gr_L1_US_18deg.SetMarkerStyle(kOpenCircle)
    gr_L1_US_10deg.SetLineColor(color)
    gr_L1_US_10deg.SetMarkerColor(color)
    gr_L1_US_10deg.SetMarkerSize(size)
    gr_L1_US_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L1_US_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L1_US_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L1_US_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L1_US_5deg.SetMarkerStyle(kRad)
    color = kGreen + 3
    gr_L2_US_18deg.SetLineColor(color)
    gr_L2_US_18deg.SetMarkerColor(color)
    gr_L2_US_18deg.SetMarkerSize(size)
    gr_L2_US_18deg.SetMarkerStyle(kOpenCircle)
    gr_L2_US_10deg.SetLineColor(color)
    gr_L2_US_10deg.SetMarkerColor(color)
    gr_L2_US_10deg.SetMarkerSize(size)
    gr_L2_US_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L2_US_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L2_US_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L2_US_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L2_US_5deg.SetMarkerStyle(kRad)
    color = kBlue
    gr_L3_US_18deg.SetLineColor(color)
    gr_L3_US_18deg.SetMarkerColor(color)
    gr_L3_US_18deg.SetMarkerSize(size)
    gr_L3_US_18deg.SetMarkerStyle(kOpenCircle)
    gr_L3_US_10deg.SetLineColor(color)
    gr_L3_US_10deg.SetMarkerColor(color)
    gr_L3_US_10deg.SetMarkerSize(size)
    gr_L3_US_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L3_US_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L3_US_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L3_US_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L3_US_5deg.SetMarkerStyle(kRad)
    color = kMagenta
    gr_L4_US_18deg.SetLineColor(color)
    gr_L4_US_18deg.SetMarkerColor(color)
    gr_L4_US_18deg.SetMarkerSize(size)
    gr_L4_US_18deg.SetMarkerStyle(kOpenCircle)
    gr_L4_US_10deg.SetLineColor(color)
    gr_L4_US_10deg.SetMarkerColor(color)
    gr_L4_US_10deg.SetMarkerSize(size)
    gr_L4_US_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L4_US_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L4_US_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L4_US_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L4_US_5deg.SetMarkerStyle(kRad)
    color = kBlack
    gr_global_US_18deg.SetLineColor(color)
    gr_global_US_18deg.SetMarkerColor(color)
    gr_global_US_18deg.SetMarkerSize(size)
    gr_global_US_18deg.SetMarkerStyle(kOpenCircle)
    gr_global_US_10deg.SetLineColor(color)
    gr_global_US_10deg.SetMarkerColor(color)
    gr_global_US_10deg.SetMarkerSize(size)
    gr_global_US_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_global_US_5deg.SetLineColor(color)
    if (len(args) == 3): gr_global_US_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_global_US_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_global_US_5deg.SetMarkerStyle(kRad)

    gr_L1_US_18deg.SetTitle("Upstream Pedestal Width " + year)
    gr_L1_US_18deg.GetXaxis().SetTitle("SiPM bias voltage (V)")
    gr_L1_US_18deg.GetYaxis().SetTitle("Pedestal RMS (ADC units)")
    gr_L1_US_18deg.GetYaxis().SetRangeUser(1, 2.5)
    gr_L1_US_18deg.Draw("APx")
    gr_L2_US_18deg.Draw("Pxsame")
    gr_L3_US_18deg.Draw("Pxsame")
    gr_L4_US_18deg.Draw("Pxsame")
    gr_global_US_18deg.Draw("Pxsame")
    gr_L1_US_10deg.Draw("Pxsame")
    gr_L2_US_10deg.Draw("Pxsame")
    gr_L3_US_10deg.Draw("Pxsame")
    gr_L4_US_10deg.Draw("Pxsame")
    gr_global_US_10deg.Draw("Pxsame")
    if (len(args) == 3): gr_L1_US_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_L2_US_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_L3_US_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_L4_US_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_global_US_5deg.Draw("Pxsame")

    legend = TLegend(
        0.13, 0.45, 0.7, 0.85
    )  #0.1 is lower limit of plot, 0.9 is upper limit (beyond on either side is labeling+whitespace)
    legend.AddEntry(gr_L1_US_18deg, "Layer 1 (18 Celcius)", "pl")
    legend.AddEntry(gr_L1_US_10deg, "Layer 1 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L1_US_5deg, "Layer 1 (5 Celcius)", "pl")
    legend.AddEntry(gr_L2_US_18deg, "Layer 2 (18 Celcius)", "pl")
    legend.AddEntry(gr_L2_US_10deg, "Layer 2 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L2_US_5deg, "Layer 2 (5 Celcius)", "pl")
    legend.AddEntry(gr_L3_US_18deg, "Layer 3 (18 Celcius)", "pl")
    legend.AddEntry(gr_L3_US_10deg, "Layer 3 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L3_US_5deg, "Layer 3 (5 Celcius)", "pl")
    legend.AddEntry(gr_L4_US_18deg, "Layer 4 (18 Celcius)", "pl")
    legend.AddEntry(gr_L4_US_10deg, "Layer 4 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L4_US_5deg, "Layer 4 (5 Celcius)", "pl")
    legend.AddEntry(gr_global_US_18deg, "ALL upstream (18 Celcius)", "pl")
    legend.AddEntry(gr_global_US_10deg, "ALL upstream (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_global_US_5deg, "ALL upstream (5 Celcius)", "pl")
    legend.Draw()
    c1.SaveAs("plots/upstream" + year + ".png")

    gr_L1_DS_18deg = f_18deg.Get("gr_layer1_DS_RMS")
    gr_L2_DS_18deg = f_18deg.Get("gr_layer2_DS_RMS")
    gr_L3_DS_18deg = f_18deg.Get("gr_layer3_DS_RMS")
    gr_L4_DS_18deg = f_18deg.Get("gr_layer4_DS_RMS")
    gr_global_DS_18deg = f_18deg.Get("gr_global_DS_RMS")
    gr_L1_DS_10deg = f_10deg.Get("gr_layer1_DS_RMS")
    gr_L2_DS_10deg = f_10deg.Get("gr_layer2_DS_RMS")
    gr_L3_DS_10deg = f_10deg.Get("gr_layer3_DS_RMS")
    gr_L4_DS_10deg = f_10deg.Get("gr_layer4_DS_RMS")
    gr_global_DS_10deg = f_10deg.Get("gr_global_DS_RMS")
    if (len(args) == 3): gr_L1_DS_5deg = f_5deg.Get("gr_layer1_DS_RMS")
    if (len(args) == 3): gr_L2_DS_5deg = f_5deg.Get("gr_layer2_DS_RMS")
    if (len(args) == 3): gr_L3_DS_5deg = f_5deg.Get("gr_layer3_DS_RMS")
    if (len(args) == 3): gr_L4_DS_5deg = f_5deg.Get("gr_layer4_DS_RMS")
    if (len(args) == 3): gr_global_DS_5deg = f_5deg.Get("gr_global_DS_RMS")

    color = kRed
    gr_L1_DS_18deg.SetLineColor(color)
    gr_L1_DS_18deg.SetMarkerColor(color)
    gr_L1_DS_18deg.SetMarkerSize(size)
    gr_L1_DS_18deg.SetMarkerStyle(kOpenCircle)
    gr_L1_DS_10deg.SetLineColor(color)
    gr_L1_DS_10deg.SetMarkerColor(color)
    gr_L1_DS_10deg.SetMarkerSize(size)
    gr_L1_DS_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L1_DS_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L1_DS_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L1_DS_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L1_DS_5deg.SetMarkerStyle(kRad)
    color = kGreen + 3
    gr_L2_DS_18deg.SetLineColor(color)
    gr_L2_DS_18deg.SetMarkerColor(color)
    gr_L2_DS_18deg.SetMarkerSize(size)
    gr_L2_DS_18deg.SetMarkerStyle(kOpenCircle)
    gr_L2_DS_10deg.SetLineColor(color)
    gr_L2_DS_10deg.SetMarkerColor(color)
    gr_L2_DS_10deg.SetMarkerSize(size)
    gr_L2_DS_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L2_DS_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L2_DS_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L2_DS_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L2_DS_5deg.SetMarkerStyle(kRad)
    color = kBlue
    gr_L3_DS_18deg.SetLineColor(color)
    gr_L3_DS_18deg.SetMarkerColor(color)
    gr_L3_DS_18deg.SetMarkerSize(size)
    gr_L3_DS_18deg.SetMarkerStyle(kOpenCircle)
    gr_L3_DS_10deg.SetLineColor(color)
    gr_L3_DS_10deg.SetMarkerColor(color)
    gr_L3_DS_10deg.SetMarkerSize(size)
    gr_L3_DS_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L3_DS_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L3_DS_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L3_DS_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L3_DS_5deg.SetMarkerStyle(kRad)
    color = kMagenta
    gr_L4_DS_18deg.SetLineColor(color)
    gr_L4_DS_18deg.SetMarkerColor(color)
    gr_L4_DS_18deg.SetMarkerSize(size)
    gr_L4_DS_18deg.SetMarkerStyle(kOpenCircle)
    gr_L4_DS_10deg.SetLineColor(color)
    gr_L4_DS_10deg.SetMarkerColor(color)
    gr_L4_DS_10deg.SetMarkerSize(size)
    gr_L4_DS_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_L4_DS_5deg.SetLineColor(color)
    if (len(args) == 3): gr_L4_DS_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_L4_DS_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_L4_DS_5deg.SetMarkerStyle(kRad)
    color = kBlack
    gr_global_DS_18deg.SetLineColor(color)
    gr_global_DS_18deg.SetMarkerColor(color)
    gr_global_DS_18deg.SetMarkerSize(size)
    gr_global_DS_18deg.SetMarkerStyle(kOpenCircle)
    gr_global_DS_10deg.SetLineColor(color)
    gr_global_DS_10deg.SetMarkerColor(color)
    gr_global_DS_10deg.SetMarkerSize(size)
    gr_global_DS_10deg.SetMarkerStyle(kSquare)
    if (len(args) == 3): gr_global_DS_5deg.SetLineColor(color)
    if (len(args) == 3): gr_global_DS_5deg.SetMarkerColor(color)
    if (len(args) == 3): gr_global_DS_5deg.SetMarkerSize(size)
    if (len(args) == 3): gr_global_DS_5deg.SetMarkerStyle(kRad)

    gr_L1_DS_18deg.SetTitle("Downstream Pedestal Width " + year)
    gr_L1_DS_18deg.GetXaxis().SetTitle("SiPM bias voltage (V)")
    gr_L1_DS_18deg.GetYaxis().SetTitle("Pedestal RMS (ADC units)")
    gr_L1_DS_18deg.GetYaxis().SetRangeUser(1, 2.5)
    gr_L1_DS_18deg.Draw("APx")
    gr_L2_DS_18deg.Draw("Pxsame")
    gr_L3_DS_18deg.Draw("Pxsame")
    gr_L4_DS_18deg.Draw("Pxsame")
    gr_global_DS_18deg.Draw("Pxsame")
    gr_L1_DS_10deg.Draw("Pxsame")
    gr_L2_DS_10deg.Draw("Pxsame")
    gr_L3_DS_10deg.Draw("Pxsame")
    gr_L4_DS_10deg.Draw("Pxsame")
    gr_global_DS_10deg.Draw("Pxsame")
    if (len(args) == 3): gr_L1_DS_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_L2_DS_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_L3_DS_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_L4_DS_5deg.Draw("Pxsame")
    if (len(args) == 3): gr_global_DS_5deg.Draw("Pxsame")

    legend = TLegend(
        0.13, 0.45, 0.7, 0.85
    )  #0.1 is lower limit of plot, 0.9 is upper limit (beyond on either side is labeling+whitespace)
    legend.AddEntry(gr_L1_DS_18deg, "Layer 1 (18 Celcius)", "pl")
    legend.AddEntry(gr_L1_DS_10deg, "Layer 1 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L1_DS_5deg, "Layer 1 (5 Celcius)", "pl")
    legend.AddEntry(gr_L2_DS_18deg, "Layer 2 (18 Celcius)", "pl")
    legend.AddEntry(gr_L2_DS_10deg, "Layer 2 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L2_DS_5deg, "Layer 2 (5 Celcius)", "pl")
    legend.AddEntry(gr_L3_DS_18deg, "Layer 3 (18 Celcius)", "pl")
    legend.AddEntry(gr_L3_DS_10deg, "Layer 3 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L3_DS_5deg, "Layer 3 (5 Celcius)", "pl")
    legend.AddEntry(gr_L4_DS_18deg, "Layer 4 (18 Celcius)", "pl")
    legend.AddEntry(gr_L4_DS_10deg, "Layer 4 (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_L4_DS_5deg, "Layer 4 (5 Celcius)", "pl")
    legend.AddEntry(gr_global_DS_18deg, "ALL downstream (18 Celcius)", "pl")
    legend.AddEntry(gr_global_DS_10deg, "ALL downstream (10 Celcius)", "pl")
    if (len(args) == 3):
        legend.AddEntry(gr_global_DS_5deg, "ALL downstream (5 Celcius)", "pl")
    legend.Draw()
    c1.SaveAs("plots/downstream" + year + ".png")

    #Difference plots
    size = 0.8
    gr_diff_L1 = TGraphErrors()
    gr_diff_L2 = TGraphErrors()
    gr_diff_L3 = TGraphErrors()
    gr_diff_L4 = TGraphErrors()
    gr_diff_G = TGraphErrors()
    if temp_4PlottingDiff == "5":
        gr_diff_L1 = f_5deg.Get("gr_layer1_diff_RMS")
        gr_diff_L2 = f_5deg.Get("gr_layer2_diff_RMS")
        gr_diff_L3 = f_5deg.Get("gr_layer3_diff_RMS")
        gr_diff_L4 = f_5deg.Get("gr_layer4_diff_RMS")
        gr_diff_G = f_5deg.Get("gr_global_diff_RMS")
    if temp_4PlottingDiff == "10":
        gr_diff_L1 = f_10deg.Get("gr_layer1_diff_RMS")
        gr_diff_L2 = f_10deg.Get("gr_layer2_diff_RMS")
        gr_diff_L3 = f_10deg.Get("gr_layer3_diff_RMS")
        gr_diff_L4 = f_10deg.Get("gr_layer4_diff_RMS")
        gr_diff_G = f_10deg.Get("gr_global_diff_RMS")
    if temp_4PlottingDiff == "18":
        gr_diff_L1 = f_18deg.Get("gr_layer1_diff_RMS")
        gr_diff_L2 = f_18deg.Get("gr_layer2_diff_RMS")
        gr_diff_L3 = f_18deg.Get("gr_layer3_diff_RMS")
        gr_diff_L4 = f_18deg.Get("gr_layer4_diff_RMS")
        gr_diff_G = f_18deg.Get("gr_global_diff_RMS")
    gr_diff_L1.SetMarkerColor(kBlack)
    gr_diff_L2.SetMarkerColor(kRed)
    gr_diff_L3.SetMarkerColor(kBlue)
    gr_diff_L4.SetMarkerColor(kMagenta)
    gr_diff_G.SetMarkerColor(kBlack)
    gr_diff_L1.SetMarkerStyle(20)
    gr_diff_L2.SetMarkerStyle(20)
    gr_diff_L3.SetMarkerStyle(20)
    gr_diff_L4.SetMarkerStyle(20)
    gr_diff_G.SetMarkerStyle(kOpenCircle)
    gr_diff_L1.SetMarkerSize(size)
    gr_diff_L2.SetMarkerSize(size)
    gr_diff_L3.SetMarkerSize(size)
    gr_diff_L4.SetMarkerSize(size)
    gr_diff_G.SetMarkerSize(size)

    gr_diff_L1.Draw("APx")
    c1.SaveAs("plots/diff_L1_" + year + "_" + temp_4PlottingDiff + "C.png")
    gr_diff_L2.Draw("APx")
    c1.SaveAs("plots/diff_L2_" + year + "_" + temp_4PlottingDiff + "C.png")
    gr_diff_L3.Draw("APx")
    c1.SaveAs("plots/diff_L3_" + year + "_" + temp_4PlottingDiff + "C.png")
    gr_diff_L4.Draw("APx")
    c1.SaveAs("plots/diff_L4_" + year + "_" + temp_4PlottingDiff + "C.png")
    gr_diff_G.Draw("APx")
    c1.SaveAs("plots/diff_global_" + year + "_" + temp_4PlottingDiff + "C.png")

    legend = TLegend(
        0.13 + 0.15, 0.65, 0.5 + 0.15, 0.85
    )  #0.1 is lower limit of plot, 0.9 is upper limit (beyond on either side is labeling+whitespace)
    legend.AddEntry(gr_diff_L1, "Layer 1", "pl")
    legend.AddEntry(gr_diff_L2, "Layer 2 / #sqrt{2}", "pl")
    legend.AddEntry(gr_diff_L3, "Layer 3 / #sqrt{3}", "pl")
    legend.AddEntry(gr_diff_L4, "Layer 4 / #sqrt{4}", "pl")
    gr_diff_L1.SetTitle("")
    gr_diff_L1.Draw("APx")
    gr_diff_L2.Draw("pxsame")
    gr_diff_L3.Draw("pxsame")
    gr_diff_L4.Draw("pxsame")
    legend.Draw()
    c1.SaveAs("plots/diff" + year + "_" + temp_4PlottingDiff + "C.png")

    print("Done ")
Ejemplo n.º 27
0
def Plot2DCorrection(hist2D,
                     graph,
                     f1,
                     etBin=None,
                     etaBin=None,
                     outname=None,
                     xlabel='N_{vtx}',
                     runLabel=None,
                     legends=None,
                     extraText1=None,
                     legendX1=.5,
                     etidx=None,
                     etaidx=None,
                     etlist=None,
                     etalist=None):

    import array as ar
    from ROOT import TCanvas, gStyle, TLegend, kRed, kBlue, kBlack, TLine, kBird, kOrange
    from ROOT import TGraphErrors, TF1, TColor
    pileup_max = hist2D.GetYaxis().GetXmax()
    pileup_min = hist2D.GetYaxis().GetXmin()
    # Retrieve some usefull information
    gStyle.SetPalette(kBird)
    canvas = TCanvas('canvas', 'canvas', 500, 500)
    #FormatCanvasAxes(canvas, XLabelSize=18, YLabelSize=18, XTitleOffset=0.87, YTitleOffset=1.5)
    canvas.SetRightMargin(0.12)
    canvas.SetLeftMargin(0.10)
    hist2D.Draw('colz')
    hist2D.GetZaxis().SetTitle("Entries")
    canvas.SetLogz()
    AddTopLabels(canvas,
                 legends,
                 runLabel=runLabel,
                 legOpt='p',
                 etlist=etlist,
                 etalist=etalist,
                 etidx=etidx,
                 etaidx=etaidx)
    FormatCanvasAxes(canvas,
                     XLabelSize=12,
                     YLabelSize=12,
                     XTitleOffset=0.87,
                     ZLabelSize=12,
                     ZTitleSize=14,
                     YTitleOffset=0.87,
                     ZTitleOffset=0.67)
    SetAxisLabels(canvas, 'Neural Network output (Discriminant)', xlabel)
    # Invert graph
    import array
    x = graph.GetX()
    x.SetSize(graph.GetN())
    ex = graph.GetEX()
    ex.SetSize(graph.GetN())
    y = graph.GetY()
    y.SetSize(graph.GetN())
    ey = graph.GetEY()
    ey.SetSize(graph.GetN())
    nvtx_points = array.array('d', x)
    nvtx_error_points = array.array('d', ex)
    discr_points = array.array('d', y)
    discr_error_points = array.array('d', ey)
    g1 = TGraphErrors(len(discr_points), discr_points, nvtx_points,
                      discr_error_points, nvtx_error_points)
    g1.SetLineWidth(1)
    #g1.SetLineColor(kBlack)
    g1.SetMarkerColor(kBlue + 1)
    g1.SetMarkerSize(.6)
    g1.Draw("P same")
    tobject_collector.append(g1)
    #l2 = TLine(eff_uncorr.thres,miny,eff_uncorr.thres,maxy)
    #l2.SetLineColor(kRed)
    #l2.SetLineWidth(2)
    #l2.Draw("l,same")
    #tobject_collector.append(l2)
    #f1 = eff.f1
    if type(f1) is not list: f1 = [f1]

    for idx, f in enumerate(f1):
        l3 = TLine(f.Eval(pileup_min), pileup_min, f.Eval(pileup_max),
                   pileup_max)
        if idx > 0: l3.SetLineColor(GetTransparent(kRed))
        else:
            l3.SetLineColor(kBlack)
        l3.SetLineWidth(2)
        l3.Draw("l,same")
        tobject_collector.append(l3)

    if outname: canvas.SaveAs(outname)
Ejemplo n.º 28
0
def plot_2(var,cuts):
    for s in attr:
        c1 = TCanvas("c1", "Signals", 1200, 800)

        if log_y == 1: 
            c1.SetLogy()

        c1.SetTopMargin(0.08)#0.12
        c1.SetBottomMargin(0.11)#0.12
        c1.SetLeftMargin(0.14)
        c1.SetRightMargin(0.14)#0.24
        c1.cd()
        #c1.SetGrid()
        gStyle.SetTitleFontSize(0.04)
        if ct_dep == 0:
            if s in ('elf','muf','cm','nm','chm'): 
                c1.SetLogx()
            for cc in channel:
                #hist[cc][s].SetMaximum(0.44)
                if   'combind' in cc:     
                    fc = 30
                    #hist[cc][s].SetFillStyle()#3005)
                elif 'VBF'      in cc:   
                    fc = 38    
                    hist[cc][s].SetFillStyle(3444)
                elif 'HT50'     in cc:  
                    fc = 7
                    hist[cc][s].SetFillStyle(3001)                  
                elif 'HT100'    in cc: 
                    fc = 4
                    hist[cc][s].SetFillStyle(3002) 
                elif 'HT200'    in cc: 
                    fc = 6
                    hist[cc][s].SetFillStyle(3003) 
                elif 'HT300'    in cc: 
                    fc = 9
                    hist[cc][s].SetFillStyle(3004) 
                
                if histFillColOn == 1:
                    pass
                    #hist[cc][s].SetFillColor(fc) 
                
                hist[cc][s].Draw(histStyl) 
            #legend = TLegend(0.76, 0.56, 0.99, 0.88)
            legend = TLegend(0.60, 0.9-0.04*2, 0.85, 0.9) #x_left y_bottom x_right y_top
            legend.SetBorderSize(0)
            legend.SetFillStyle(0)#1001
            legend.SetFillColor(0)
            #legend.SetHeader( entry['entries'] )
            for cc in channel:
                legend.AddEntry(hist[cc][s],cc)
            legend.Draw()
            for ct in cut_text:
                cut_text[ct].Draw()
            
            #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Line for critical value
            if   s == 'chm':
                l = TLine(11.4,0.0,11.4,0.084) 
            elif s == 'cHadEFrac':
                l = TLine(0.38,0.0,0.38,0.027)
            elif s == 'FracCal':
                l = TLine(30,0.0,30,0.44)
            #l.SetLineColor(2)
            #l.SetLineWidth(3)
            if critical_line == 1: 
                l.SetLineColor(46)#4,2
                l.SetLineWidth(3)
                l.Draw('same')

            c1.Print(path1 + s + var + cuts.replace('(','_').replace(')','_').replace('&&','_').replace('>','LG').replace('<','LS').replace('=','EQ').replace('.','P').replace('-','N').replace('Jet','J').replace('GenBquark','GBQ') + ".pdf")
            
        elif ct_dep == 1:
            eac0 = str( entries_after_cut['ct0'][s] )
            c1.SetLogx()
            #gr = TGraph( len_of_lt , x , yy['sgn'][s] )
            gr = TGraphErrors( len_of_lt , x , yy['sgn'][s] , ex , ey['sgn'][s] )
            gr.SetMarkerSize(1.5)
            gr.SetMarkerStyle(1)
            gr.GetYaxis().SetTitleOffset(1.6)
            gr.SetLineColor(4)
            gr.SetLineWidth(4)
            gr.SetTitle('mean ' + s )
            gr.GetXaxis().SetTitle('decaying length (mm)')
            gr.GetYaxis().SetTitle('mean normalized number of events')
            gr.GetXaxis().SetTitleOffset(1.4)
            gr.SetMaximum( plotrange[s] * 1.12 )
            gr.SetName('sgn')
            gr.Draw('ACP')  # '' sets up the scattering style
            gr1 = TGraphErrors( len_of_lt , x , yy['QCD'][s] , ex , ey['QCD'][s] )
            gr1.SetMarkerSize(1.0)
            gr1.SetMarkerStyle(1)
            gr.GetYaxis().SetTitleOffset(1.6)
            gr1.SetLineColor(2)
            gr1.SetLineWidth(2)
            gr1.SetName('QCD')
            #gr1.SetTitle('averaged ' + s)
            #gr1.GetXaxis().SetTitle('decaying length (mm)')
            #gr1.GetYaxis().SetTitle('mean frequency')
            gr1.Draw('CP')  # '' sets up the scattering style
            legend = TLegend(0.76, 0.56, 0.99, 0.88)
            legend.SetHeader( 'Entries: ' + eac0 )
            legend.AddEntry('QCD', legendb, 'l')
            legend.AddEntry('sgn', legends, 'l')
            legend.Draw()
            for ct in cut_text:
                cut_text[ct].Draw()
            c1.Print(path1 + 'mean_' + s + var + cuts.replace('(','_').replace(')','_').replace('&&','_').replace('>','LG').replace('<','LS').replace('=','EQ').replace('.','P').replace('-','N').replace('Jet','J').replace('GenBquark','GBQ') + ".pdf")
        c1.Update()
        c1.Close() 
        print('|||||||||||||||||||||||||||||||||||||||||||||||||||')        
Ejemplo n.º 29
0
            CombinedcorrectedTrackAmbiguity) / math.sqrt(NLoops), "%\n"

    _Efficiency.append(np.mean(CombinedtrackEfficiency))
    _Purity.append(100 - np.mean(CombinedcorrectedTrackAmbiguity))
    _NumberOfProtons.append(nMeanProton)
    _EfficiencyErr.append(np.std(CombinedtrackEfficiency) / math.sqrt(NLoops))
    _PurityErr.append(
        np.std(CombinedcorrectedTrackAmbiguity) / math.sqrt(NLoops))
    _NumberOfProtonsErr.append(0.0)

canvas1 = TCanvas('c1', "mycanvas", 200, 10, 700, 500)

effGraph = TGraphErrors(len(_NumberOfProtons), _NumberOfProtons, _Efficiency,
                        _NumberOfProtonsErr, _EfficiencyErr)
effGraph.SetMarkerStyle(2)
effGraph.SetMarkerSize(2)
effGraph.GetXaxis().SetTitle("Mean N Proton")
effGraph.GetYaxis().SetTitle("Efficiency/Purity (%)")
effGraph.SetTitle("Efficiency")

purGraph = TGraphErrors(len(_NumberOfProtons), _NumberOfProtons, _Purity,
                        _NumberOfProtonsErr, _PurityErr)
purGraph.SetMarkerStyle(5)
purGraph.SetLineColor(2)
purGraph.SetMarkerColor(2)
purGraph.SetMarkerSize(2)
purGraph.GetXaxis().SetTitle("Mean N Proton")
purGraph.GetYaxis().SetTitle("Purity")
purGraph.SetTitle("Purity")
MyFile = TFile(
    "effVsPurity_bs" + (str)(beamSpread) + "mrad_geo" + geoName +
Ejemplo n.º 30
0
    y.append(1.08)
    y.append(1.1)
    y.append(1.15)
    y.append(1.2)
    y.append(1.2)
    y.append(1.22)
    y.append(1.22)

    n = len(x)
    gr0 = TGraphErrors(n, x, y, ex, ey)

    gr0.SetMarkerColor(ROOT.kBlue)
    gr0.SetMarkerStyle(20)
    gr0.SetLineColor(ROOT.kBlue)
    gr0.SetMarkerSize(1.5)

    gr0.Draw()
    p1 = TF1("pol1", "pol1", 200, 900.)
    # p1 = TF1("pol2","pol2",200,2000.);

    p1.SetLineColor(ROOT.kMagenta)

    f1 = TF1("f1", "[0] +[1]*x", 200, 2000)
    f1.SetParameters(0.99601, 0.00241919)

    f1.SetLineColor(ROOT.kBlue)

    gr0.Fit(p1, "0R")
    p1.Draw("sames")
    f1.Draw("same")