コード例 #1
0
    lines.append(TLine(0, avgSF[iLine], 65, avgSF[iLine]))
    lines[iLine].SetLineColor(colour[iLine])
    all_graphs[iLine].SetMarkerColor(colour[iLine])
    all_graphs[iLine].SetLineColor(colour[iLine])
    lines[iLine].Draw('same')

if len(graphTitles) > 1:
    draw_text(graphTitles, [0.18,0.9 - 0.07 * len(graphTitles),0.4,0.95], 0.4, 0).SetTextSize(0.06)

# Draw all labels
if calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.57,0.88, 0.85,0.98], kGray+3, 0).SetTextSize(0.05)
canv.Update()

# Save canvas and root file with graph, const term and sampling term
if calo_init.output(0):
    canv.SaveAs(calo_init.output(0)+".eps")
    canv.SaveAs(calo_init.output(0)+".png")
    plots = TFile(calo_init.output(0)+".root","RECREATE")
    if calo_init.args.preview:
        cPreview.SaveAs("preview_"+calo_init.output(0)+".png")
else:
    canv.SaveAs("sampling_fraction_plots.eps")
    canv.SaveAs("sampling_fraction_plots.png")
    plots = TFile("sampling_fraction.root","RECREATE")
    if calo_init.args.preview:
        cPreview.SaveAs("preview_sampling_fraction.png")
for g in all_graphs:
    g.Write()

mean = numpy.zeros(1, dtype=float)
コード例 #2
0
    draw_hist2d(hNoFncPhi)
    canv.cd(15)
    draw_hist2d(hNoFncEta)
    canv.cd(3)
    hEnMoreClu.Draw('bar')
    canv.cd(7)
    hEtaMoreClu.Draw('bar')
    canv.cd(11)
    hPhiMoreClu.Draw('bar')
    canv.cd(4)
    hEnDiffMoreClu.Draw()
    canv.cd(8)
    hEtaDiffMoreClu.Draw()
    canv.cd(12)
    hPhiDiffMoreClu.Draw()
    canv.cd(16)
    hRDiffMoreClu.Draw()

    if calo_init.output(ifile):
        canv.Print(calo_init.output(ifile) + ".gif")
        plots = TFile(calo_init.output(ifile) + ".root", "RECREATE")
    else:
        canv.Print("Reco_monitor.gif")
        plots = TFile("Reco_monitor_plots.root", "RECREATE")

    plots.cd()
    for hset in [h1dset1, h1dset2, h2d]:
        for h in hset:
            h.Write()
    plots.Close()
コード例 #3
0
unit1 = draw_text(['(cm)'],[0.91,0.09,1,0.14] , 1, 0)
unit1.SetTextSize(0.05)
unit1.SetTextFont(42)
unit2 = draw_text(['(X_{0})'],[0.91,0.16,1,0.21] , 1, 0)
unit2.SetTextSize(0.05)
unit2.SetTextFont(42)
canv.Update()


# Draw all labels
if calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.57,0.88, 0.85,0.98], kGray+3, 0).SetTextSize(0.05)
canv.Update()

# Save canvas and root file with graph, const term and sampling term
if calo_init.output(0):
    canv.SaveAs(calo_init.output(0)+".pdf")
    canv.SaveAs(calo_init.output(0)+".png")
    plots = TFile(calo_init.output(0)+".root","RECREATE")
    if calo_init.args.preview:
        cPreview.SaveAs("preview_"+calo_init.output(0)+".png")
else:
    canv.SaveAs("sampling_fraction_plots.pdf")
    canv.SaveAs("sampling_fraction_plots.png")
    plots = TFile("sampling_fraction.root","RECREATE")
    if calo_init.args.preview:
        cPreview.SaveAs("preview_sampling_fraction.png")
for g in all_graphs:
    g.Write()

mean = numpy.zeros(1, dtype=float)
コード例 #4
0
    #            "RMS: "+str(round(hEn.GetRMS(),1))+" GeV"],
    #           [0.6,0.79,0.9,0.9],
    #           kBlue+3)
    draw_text(["energy: "+str(round(fitEnergy.GetParameter(1),1))+" GeV",
               "           "+str(round(fitEnergy.GetParameter(1),1)/energy*100.)+" %",
               "resolution: "+str(round(fitEnergy.GetParameter(2)/fitEnergy.GetParameter(1)*100,1))+" %"],
              [0.6,0.7,0.9,0.9],
              kBlue+3)
    canv.cd(2)
    hNo.SetStats(0)
    hNo.SetTitle('number of reconstructed clusters')
    hNo.Draw('hist')
    hNo.Draw('text0 same')
    canv.cd(3)
    hEta.SetStats(0)
    hEta.SetTitle('#eta distribution')
    hEta.Draw('bar ')
    canv.cd(4)
    hPhi.SetStats(0)
    hPhi.SetTitle('#varphi distribution')
    hPhi.Draw('bar ')
    canv.cd()
    draw_text(["0.1#times0.4 window (eta#timesphi)",
               "9 GeV energy threshold"],[0.35,0.47,0.65,0.53], kBlue+3)

    if calo_init.output(ifile):
        canv.Print(calo_init.output(ifile)+"_nofit_stat.png")
    else:
        canv.Print("Reco_monitor.png")
        canv.Print("Reco_monitor.root")
コード例 #5
0
    else:
        hEn.DrawCopy("sameep")
    fit.Draw("same")

canv.Update()

if not calo_init.args.noLinearity:
    draw_text(
        ["energy resolution", "#color[1]{#sigma_{E_{rec}}/#LTE_{rec}#GT}"] +
        resolution_list, [0.17, 0.8 - 0.05 * len(resolution_list), 0.42, 0.88],
        1, 1)
    draw_text(["linearity", "#color[1]{(#LTE_{rec}#GT-E_{beam})/E_{beam}}"] +
              mean_list, [0.7, 0.8 - 0.05 * len(resolution_list), 0.95, 0.88],
              1, 1)
else:
    draw_text(
        ["energy resolution", "#color[1]{#sigma_{E_{rec}}/#LTE_{rec}#GT}"] +
        resolution_list, [0.6, 0.7 - 0.07 * len(resolution_list), 0.95, 0.78],
        1, 0)
if calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.57, 0.88, 0.85, 0.98],
              kGray + 3, 0).SetTextSize(0.05)
canv.Update()

if calo_init.output(ifile):
    canv.Print("energyDistribution_" + calo_init.output(0) + ".png")
else:
    canv.Print("energyDistribution_" + str(energy) + "GeV.png")

input("Press ENTER to exit")
コード例 #6
0
# Prepare graphs: set colours, axis range, ...
colour = [c for c in range(1, 100)]
print(colour)
for i, g in enumerate(hPileupNoise):
    prepare_graph(g, g.GetName(), g.GetTitle(), colour[i])
    g.SetLineWidth(2)
    g.SetTitle("")
    if (i == 0):
        g.Draw()
    else:
        g.Draw("same")
    g.GetYaxis().SetRangeUser(0, yMax)

    legend.AddEntry(g, "layer " + str(i + 1), "lp")

legend.Draw()
draw_text(["FCC-hh simulation"], [0.67, 0.88, 0.95, 0.98], kGray + 3,
          0).SetTextSize(0.05)
draw_text(["Pile-up noise per cell"], [0.25, 0.88, 0.45, 0.98], 1,
          0).SetTextSize(0.05)
canv.Update()

if calo_init.output(ifile):
    canv.Print(calo_init.output(ifile) + ".gif")
    canv.Print(calo_init.output(ifile) + ".eps")
else:
    canv.Print("pileup_noise_inclined.gif")
    canv.Print("pileup_noise_inclined.eps")

raw_input("Press ENTER to exit")
コード例 #7
0
legend.SetBorderSize(0)

# Prepare graphs: set colours, axis range, ...
colour = [c for c in range(1,100)]
print(colour)
for i,g in enumerate(hPileupNoise):
    prepare_graph(g, g.GetName(), g.GetTitle(), colour[i])
    g.SetLineWidth(2)
    g.SetTitle("")
    if (i==0):
        g.Draw()
    else:
        g.Draw("same")
    g.GetYaxis().SetRangeUser(0,yMax)

    legend.AddEntry(g,"layer " + str(i+1),"lp")

legend.Draw()
draw_text(["FCC-hh simulation"], [0.67,0.88, 0.95,0.98], kGray+3, 0).SetTextSize(0.05)
draw_text(["Pile-up noise per cell"], [0.25,0.88, 0.45,0.98], 1, 0).SetTextSize(0.05)
canv.Update()

if calo_init.output(ifile):
    canv.Print(calo_init.output(ifile)+".gif")
    canv.Print(calo_init.output(ifile)+".eps")
else:
    canv.Print("pileup_noise_inclined.gif")
    canv.Print("pileup_noise_inclined.eps")
    
raw_input("Press ENTER to exit")
コード例 #8
0
                     'upstream energy ' + energyUnit)
     hUpstremCellProfile.Fit(fitProfile, "SR")
     for ibin in reversed(
             range(0,
                   hUpstremCellProfile.GetXaxis().GetNbins())):
         if hUpstremCellProfile.GetBinContent(ibin) > 0:
             lastNonEmpty = ibin
             break
     hUpstremCellProfile.GetXaxis().SetRange(0, lastNonEmpty + 3)
     legendProfile = draw_text([str(energy) + ' GeV e^{-}, B = 4T'],
                               [0.67, 0.18, 0.85, 0.28], 9, 0)
     legendProfile.SetTextSize(0.05)
     legendProfile.SetTextFont(42)
     canvProfile.Update()
     # save canvases filled for each energy and eta
     if calo_init.output(ifile):
         canvProfile.SaveAs(
             calo_init.output(ifile) + "_previewProfile_eta" +
             str(eta) + "_e" + str(energy) + "GeV.png")
     else:
         canvProfile.SaveAs("upstremCorrection_previewProfile_eta" +
                            str(eta) + "_" + str(layer * width) +
                            "cm.png")
 if calo_init.args.previewPhi:
     canvPhi = prepare_single_canvas(
         'phi_e' + str(energy) + 'GeV__eta' + str(eta),
         'Phi distribution of first layer deposits for #eta = ' +
         str(eta))
     draw_1histogram(hCellPhi, '#varphi ' + angleUnit,
                     'E_{firstLayer} ' + energyUnit)
     # Draw all labels
コード例 #9
0
        if calo_init.args.preview:
            canvProfile = prepare_single_canvas( 'upstreamEnergy_e'+str(energy)+'GeV_eta'+str(eta), 'Upstream energy vs energy in first layer for #eta = '+str(eta))
            draw_1histogram(hUpstremCellProfile, 'E_{firstLayer} '+energyUnit,'upstream energy '+energyUnit)
            hUpstremCellProfile.Fit(fitProfile, "SR")
            for ibin in reversed(range(0,hUpstremCellProfile.GetXaxis().GetNbins())):
                if hUpstremCellProfile.GetBinContent(ibin) > 0:
                    lastNonEmpty = ibin
                    break
            hUpstremCellProfile.GetXaxis().SetRange(0, lastNonEmpty + 3)
            legendProfile = draw_text([str(energy)+' GeV e^{-}, B = 4T'], [0.67,0.18, 0.85,0.28], 9, 0)
            legendProfile.SetTextSize(0.05)
            legendProfile.SetTextFont(42)
            canvProfile.Update()
            # save canvases filled for each energy and eta
            if calo_init.output(ifile):
                canvProfile.SaveAs(calo_init.output(ifile) + "_previewProfile_eta" + str(eta) + "_e"+str(energy)+"GeV.png")
            else:
                canvProfile.SaveAs("upstremCorrection_previewProfile_eta"+str(eta)+"_"+str(layer*width)+"cm.png")
        if calo_init.args.previewPhi:
            canvPhi = prepare_single_canvas( 'phi_e'+str(energy)+'GeV__eta'+str(eta), 'Phi distribution of first layer deposits for #eta = '+str(eta))
            draw_1histogram(hCellPhi, '#varphi ' + angleUnit,'E_{firstLayer} ' + energyUnit)
            # Draw all labels
            if calo_init.args.specialLabel:
                canvProfile.cd()
                draw_text([calo_init.args.specialLabel], [0.57,0.88, 0.85,0.98], kGray+3, 0).SetTextSize(0.05)
                canvPhi.cd()
                draw_text([calo_init.args.specialLabel], [0.57,0.88, 0.85,0.98], kGray+3, 0).SetTextSize(0.05)
            legendPhi = draw_text([str(energy)+' GeV e^{-}, B = 4T'], [0.67,0.18, 0.85,0.28], 9, 0)
            legendPhi.SetTextSize(0.05)
            legendPhi.SetTextFont(42)
コード例 #10
0
graphTitles = ['#color['+str(colour[i])+']{'+t+'}' for i,t in enumerate(graphTitles)]

# Draw all labels
if not calo_init.args.noLinearity:
    padRes.cd()
    draw_text(graphTitles, [0.4,0.85 - 0.07 * len(graphTitles),0.95,0.95], 1, 0).SetTextSize(0.04)
else:
    draw_text(graphTitles, [0.3,0.8 - 0.07 * len(graphTitles),0.95,0.86], 1, 0).SetTextSize(0.04)
if not (calo_init.args.noLinearity and calo_init.args.title):
    draw_text(["energy resolution"], [0.2,0.88, 0.4,0.98], 1, 0).SetTextSize(0.05)
else:
    cRes.SetTopMargin(0.1)
    draw_text([calo_init.args.title], [0.,0.9, 1,1], 1, 0).SetTextSize(0.05)
if calo_init.args.noLinearity and calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.67,0.88, 0.95,0.98], 1, 0).SetTextSize(0.05)
if not calo_init.args.noLinearity:
    padLin.cd()
    draw_text(["linearity"], [0.2,0.78, 0.4,0.88], 1, 0).SetTextSize(0.05*factor)
    if calo_init.args.specialLabel:
        draw_text([calo_init.args.specialLabel], [0.67,0.78, 0.95,0.88], 1, 0).SetTextSize(0.05*factor)

cRes.Update()

# Save canvas
if calo_init.output(0):
    cRes.SaveAs(calo_init.output(0)+".png")
else:
    cRes.SaveAs("energy_resolution_plots.gif")

raw_input("Press ENTER to exit")
コード例 #11
0
    draw_text(graphTitles, [0.55, 0.95 - 0.08 * len(graphTitles), 0.95, 0.95],
              1, 0).SetTextSize(0.04)
elif not calo_init.args.specialLabel:
    draw_text(graphTitles, [0.55, 0.95 - 0.08 * len(graphTitles), 0.95, 0.95],
              1, 0).SetTextSize(0.04)
else:
    draw_text(graphTitles, [0.55, 0.9 - 0.08 * len(graphTitles), 0.95, 0.85],
              1, 0).SetTextSize(0.04)
draw_text(["energy resolution"], [0.2, 0.88, 0.4, 0.98], 1,
          0).SetTextSize(0.05)
if calo_init.args.noLinearity and calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.67, 0.88, 0.95, 0.98], 1,
              0).SetTextSize(0.05)
if not calo_init.args.noLinearity:
    padLin.cd()
    draw_text(["linearity"], [0.2, 0.78, 0.4, 0.88], 1,
              0).SetTextSize(0.05 * factor)
    if calo_init.args.specialLabel:
        draw_text([calo_init.args.specialLabel], [0.67, 0.78, 0.95, 0.88], 1,
                  0).SetTextSize(0.05 * factor)

cRes.Update()

# Save canvas
if calo_init.output(0):
    cRes.SaveAs(calo_init.output(0) + ".png")
else:
    cRes.SaveAs("energy_resolution_plots.gif")

raw_input("Press ENTER to exit")
コード例 #12
0
    hPileupAllEvents[i].GetXaxis().SetTitleSize(0.05)
    hPileupAllEvents[i].GetYaxis().SetTitleSize(0.05)
    hPileupAllEvents[i].Draw()
    hPileup[i].Draw("same")
    legend.Draw()
    canv1.cd(i+1)
    hPileupMeanEAllEvents[i].SetMarkerSize(1.1)
    hPileupMeanE[i].SetMarkerSize(1.1)
    hPileupMeanEAllEvents[i].GetXaxis().SetTitleOffset(0.95)
    hPileupMeanEAllEvents[i].GetYaxis().SetTitleOffset(0.95)
    hPileupMeanEAllEvents[i].GetXaxis().SetTitleSize(0.05)
    hPileupMeanEAllEvents[i].GetYaxis().SetTitleSize(0.05)
    hPileupMeanEAllEvents[i].Draw()
    #hPileupMeanE[i].Draw("same")

if calo_init.output(ifile):
    canv.Print(calo_init.output(ifile)+".gif")
    canv1.Print(calo_init.output(ifile)+"_meanE.gif")
    canv.Print(calo_init.output(ifile)+".eps")
    canv1.Print(calo_init.output(ifile)+"_meanE.eps")
    plots = TFile(calo_init.output(ifile)+".root","RECREATE")
else:
    canv.Print("TestPileup_mu"+str(mu)+".gif")
    canv1.Print("TestPileup_mu"+str(mu)+"_meanE.gif")
    canv.Print("TestPileup_mu"+str(mu)+".eps")
    canv1.Print("TestPileup_mu"+str(mu)+"_meanE.eps")
    plots = TFile("TestPileup_mu"+str(mu)+".root","RECREATE")

plots.cd()
for hset in [hPileup, hPileupAllEvents, hPileupMeanE, hPileupMeanEAllEvents]:
    for h in hset:
コード例 #13
0
    pad = canv.cd(2)
    pad.SetLogz()
    pad.SetGrid()
    draw_hist2d(hist[0])
    draw_text(["energy: "+str(round(enTotal,2))+" GeV"])

    pad2 = canv.cd(3)
    draw_hist2d(hist[1])
    pad2.SetGrid()
    draw_text(["energy: "+str(round(hist[1].Integral(),2))+" GeV",
               "           "+str(round(hist[1].Integral()/enTotal*100,1))+" %"])

    pad = canv.cd(4)
    pad.SetGrid()
    draw_hist2d(hist[2])
    draw_text(["energy: "+str(round(hist[2].Integral(),2))+" GeV",
               "           "+str(round(hist[2].Integral()/enTotal*100,1))+" %"])
    for ipad in range(2,5):
        canv.cd(ipad)
        draw_rectangle([meanEta-etaWindowSeed/2.*dEta, meanPhi-phiWindowSeed/2.*dPhi],
                       [meanEta+etaWindowSeed/2.*dEta, meanPhi+phiWindowSeed/2.*dPhi], kRed, 4)
        draw_rectangle([meanEta-etaWindowDupl/2.*dEta, meanPhi-phiWindowDupl/2.*dPhi],
                       [meanEta+etaWindowDupl/2.*dEta, meanPhi+phiWindowDupl/2.*dPhi], kBlue, 3)
        draw_rectangle([meanEta-etaWindowPos/2.*dEta, meanPhi-phiWindowPos/2.*dPhi],
                       [meanEta+etaWindowPos/2.*dEta, meanPhi+phiWindowPos/2.*dPhi], kGreen, 2)
    if calo_init.output(ifile):
        canv.Print(calo_init.output(ifile)+'.root')
        canv.Print(calo_init.output(ifile)+'.png')
    else:
        canv.Print('ECal_map_e'+str(energy)+'GeV.png')
コード例 #14
0
    draw_hist2d(hNoFncPhi)
    canv.cd(15)
    draw_hist2d(hNoFncEta)
    canv.cd(3)
    hEnMoreClu.Draw('bar')
    canv.cd(7)
    hEtaMoreClu.Draw('bar')
    canv.cd(11)
    hPhiMoreClu.Draw('bar')
    canv.cd(4)
    hEnDiffMoreClu.Draw()
    canv.cd(8)
    hEtaDiffMoreClu.Draw()
    canv.cd(12)
    hPhiDiffMoreClu.Draw()
    canv.cd(16)
    hRDiffMoreClu.Draw()

    if calo_init.output(ifile):
        canv.Print(calo_init.output(ifile)+".gif")
        plots = TFile(calo_init.output(ifile)+".root","RECREATE")
    else:
        canv.Print("Reco_monitor.gif")
        plots = TFile("Reco_monitor_plots.root","RECREATE")

    plots.cd()
    for hset in [h1dset1, h1dset2, h2d]:
        for h in hset:
            h.Write()
    plots.Close()
コード例 #15
0
        " %"
    ])
    for ipad in range(2, 5):
        canv.cd(ipad)
        draw_rectangle([
            meanEta - etaWindowSeed / 2. * dEta,
            meanPhi - phiWindowSeed / 2. * dPhi
        ], [
            meanEta + etaWindowSeed / 2. * dEta,
            meanPhi + phiWindowSeed / 2. * dPhi
        ], kRed, 4)
        draw_rectangle([
            meanEta - etaWindowDupl / 2. * dEta,
            meanPhi - phiWindowDupl / 2. * dPhi
        ], [
            meanEta + etaWindowDupl / 2. * dEta,
            meanPhi + phiWindowDupl / 2. * dPhi
        ], kBlue, 3)
        draw_rectangle([
            meanEta - etaWindowPos / 2. * dEta,
            meanPhi - phiWindowPos / 2. * dPhi
        ], [
            meanEta + etaWindowPos / 2. * dEta,
            meanPhi + phiWindowPos / 2. * dPhi
        ], kGreen, 2)
    if calo_init.output(ifile):
        canv.Print(calo_init.output(ifile) + '.root')
        canv.Print(calo_init.output(ifile) + '.png')
    else:
        canv.Print('ECal_map_e' + str(energy) + 'GeV.png')
コード例 #16
0
gSystem.Load("libCaloAnalysis")
from ROOT import SimpleAnalysis, TCanvas, TFile, TF1, gPad
from draw_functions import draw_1histogram, draw_2histograms

# use this script for multiple files

for ifile, filename in enumerate(calo_init.filenamesIn):
    energy = calo_init.energy(ifile)
    analysis = SimpleAnalysis(energy, SF)
    analysis.loop(filename, calo_init.verbose)
    print "Energy of the initial particle: ", energy
    print "Mean hit energy: ", analysis.hHitEnergy.GetMean()
    print "1/SF calculated: ", energy / (analysis.hHitEnergy.GetMean())

    c1 = TCanvas("c1" + str(energy), "c1_" + str(energy) + "_GeV", 1000, 1000)
    c1.Divide(2, 2)
    c1.cd(1)
    draw_1histogram(analysis.hHitEnergy, "hit level energy [GeV]", "")
    c1.cd(2)
    draw_1histogram(analysis.hCellEnergy, "cell level energy [GeV]", "")
    analysis.hCellEnergy.Rebin(2)
    analysis.hCellEnergy.Fit("gaus")
    c1.cd(3)
    draw_1histogram(analysis.hGenPt, "Generated pt [GeV]", "")
    if calo_init.output(ifile):
        c1.SaveAs(calo_init.output(ifile) + ".png")
    else:
        c1.SaveAs("plots_electron_" + str(energy) + "GeV.png")

raw_input("Press ENTER to exit")
コード例 #17
0
    if ifile == 0:
        hEn.DrawCopy()
    else:
        hEn.DrawCopy("sameep")
    fit.Draw("same")

canv.Update()

if not calo_init.args.noLinearity:
    draw_text(["energy resolution", "#color[1]{#sigma_{E_{rec}}/#LTE_{rec}#GT}"]
              + resolution_list,
              [0.17,0.8-0.05*len(resolution_list),0.42,0.88], 1, 1)
    draw_text(["linearity", "#color[1]{(#LTE_{rec}#GT-E_{beam})/E_{beam}}"]
              + mean_list,
              [0.7,0.8-0.05*len(resolution_list),0.95,0.88], 1, 1)
else:
    draw_text(["energy resolution", "#color[1]{#sigma_{E_{rec}}/#LTE_{rec}#GT}"]
              + resolution_list,
              [0.6,0.7-0.07*len(resolution_list),0.95,0.78], 1, 0)
if calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.57,0.88, 0.85,0.98], kGray+3, 0).SetTextSize(0.05)
canv.Update()

if calo_init.output(ifile):
    canv.Print("energyDistribution_"+calo_init.output(0)+".png")
else:
    canv.Print("energyDistribution_"+str(energy)+"GeV.png")


input("Press ENTER to exit")
コード例 #18
0
    constString = "const: "+str(round(fitResult.Get().Parameter(0),4))+" #pm "+str(round(fitResult.Get().Error(0),4))
    samplingString = "sampl: "+str(round(fitResult.Get().Parameter(1),4))+" #pm "+str(round(fitResult.Get().Error(1),4))
    draw_text([constString, samplingString], [0.55,0.68,0.88,0.76], colour+1, 0).SetTextSize(0.05)
draw_text(["energy resolution"], [0.2,0.88, 0.45,0.98], 1, 0).SetTextSize(0.05)
if calo_init.args.noLinearity and calo_init.args.specialLabel:
    draw_text([calo_init.args.specialLabel], [0.67,0.88, 0.95,0.98], kGray+3, 0).SetTextSize(0.05)
cRes.Update()
if not calo_init.args.noLinearity:
    padLin.cd()
    gLin.Draw("ape")
    draw_text(["linearity"], [0.2,0.78, 0.4,0.88], 1, 0).SetTextSize(0.05*factor)
    if calo_init.args.specialLabel:
        draw_text([calo_init.args.specialLabel], [0.67,0.78, 0.95,0.88], kGray+3, 0).SetTextSize(0.05*factor)

# Save canvas and root file with graph, const term and sampling term
if calo_init.output(0):
    cRes.SaveAs(calo_init.output(0)+".png")
    plots = TFile(calo_init.output(0)+".root","RECREATE")
else:
    cRes.SaveAs("energy_resolution_plots.gif")
    plots = TFile("energy_resolution_plots.root","RECREATE")
gRes.Write()
gLin.Write()
const = numpy.zeros(1, dtype=float)
sampl = numpy.zeros(1, dtype=float)
constErr = numpy.zeros(1, dtype=float)
samplErr = numpy.zeros(1, dtype=float)
t = TTree("params", "Fit parameters")
t.Branch("const", const, "const/D");
t.Branch("sampl", sampl, "sampl/D");
t.Branch("constErr", constErr, "constErr/D");
コード例 #19
0
gSystem.Load("libCaloAnalysis")
from ROOT import SimpleAnalysis, TCanvas, TFile, TF1, gPad
from draw_functions import draw_1histogram, draw_2histograms

# use this script for multiple files

for ifile, filename in enumerate(calo_init.filenamesIn):
    energy = calo_init.energy(ifile)
    analysis = SimpleAnalysis(energy, SF)
    analysis.loop(filename, calo_init.verbose)
    print "Energy of the initial particle: ", energy
    print "Mean hit energy: ", analysis.hHitEnergy.GetMean()
    print "1/SF calculated: ", energy/(analysis.hHitEnergy.GetMean())

    c1 = TCanvas("c1"+str(energy),"c1_"+str(energy)+"_GeV",1000,1000)
    c1.Divide(2,2)
    c1.cd(1)
    draw_1histogram(analysis.hHitEnergy,"hit level energy [GeV]","")
    c1.cd(2)
    draw_1histogram(analysis.hCellEnergy,"cell level energy [GeV]","")
    analysis.hCellEnergy.Rebin(2)
    analysis.hCellEnergy.Fit("gaus")
    c1.cd(3)
    draw_1histogram(analysis.hGenPt,"Generated pt [GeV]","")
    if calo_init.output(ifile):
        c1.SaveAs(calo_init.output(ifile)+".png")
    else:
        c1.SaveAs("plots_electron_"+str(energy)+"GeV.png")

raw_input("Press ENTER to exit")