Exemple #1
0
def correctedCrossSectionsPlot(crossings, shapes, overDiff):
    uncorrected = {41: (3.2575816286, 0.00514858611944), \
                   281: (3.26316215713, 0.00468789412223), \
                   872: (3.27340775031, 0.00484925398906), \
                   1783: (3.24986926821, 0.00460908436455), \
                   2063: (3.26363843728, 0.0044071069983)}
    multi = TMultiGraph('sigmavis', '')
    graphs = []
    n = len(shapes) + 1
    for i, shape in enumerate([''] + list(shapes)):
        xval = array('d',
                     [a + 0.08 * (i - 0.5 * n) for a in range(len(crossings))])
        xerr = array('d', len(crossings) * [0])
        yval = array('d', [uncorrected[int(bx)][0] for bx in crossings])
        yerr = array('d', [uncorrected[int(bx)][1] for bx in crossings])
        if shape:
            for j, bx in enumerate(crossings):
                yval[j] *= 1 + overDiff[shape][bx]
                yerr[j] *= 1 + overDiff[shape][bx]
        graph = TGraphErrors(len(crossings), xval, yval, xerr, yerr)
        graph.SetName('ge' + shape)
        graph.SetMarkerStyle(20)
        graph.SetMarkerColor(1 + i)
        multi.Add(graph)
        graphs.append(graph)
    gStyle.SetOptStat(0)
    hist = TH2F('hist', '', len(crossings), -0.5,
                len(crossings) - 0.5, 100, 3.23, 3.33)
    for i, bx in enumerate(crossings):
        hist.GetXaxis().SetBinLabel(i + 1, bx)
    canvas = TCanvas('c_' + multi.GetName(), '', 600, 600)
    hist.Draw('AXIS')
    multi.Draw('P')
    canvas.Update()
    hist.GetXaxis().SetLabelSize(0.035)
    hist.GetXaxis().SetNdivisions(len(crossings), False)
    hist.GetYaxis().SetTitle('#sigma_{vis} [b]')
    hist.GetYaxis().SetLabelSize(0.025)
    hist.GetYaxis().SetTitleOffset(1.3)
    leg = TLegend(0.15, 0.82, 0.85, 0.85)
    leg.SetNColumns(len(shapes) + 1)
    leg.SetBorderSize(0)
    for i, shape in enumerate([''] + list(shapes)):
        entry = leg.AddEntry('ge' + shape, shapeNames[shape], 'P')
        entry.SetMarkerStyle(20)
        entry.SetMarkerColor(1 + i)
    leg.Draw()
    drawCMS()
    canvas.Modified()
    canvas.Update()
    canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.pdf')
    canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.C')
Exemple #2
0
def combinedDraw(frescoGraph, goodPID, badPID, goodCORR, badCORR):
    #print "combinedDraw start"
    canvas = TCanvas('canvas', 'shouldnotseethis', 0, 0, 1280, 720)

    MG = TMultiGraph()
    legend = ROOT.TLegend(0.55, .55, .9, .9)
    ##legend.SetBorderSize(0)
    #underHisto.SetLineColor(ROOT.kBlack)
    #underHisto.SetMinimum(0)
    ##underHisto.SetMaximum(underHisto.GetMaximum() * 1.5)
    #underHisto.GetXaxis().SetRangeUser(0,180)
    #underHisto.SetTitle(title)
    #underHisto.SetLineColor(ROOT.kBlack)
    #underHisto.SetTitle(title)
    #underHisto.GetYaxis().SetTitle("Counts in Arb. Units")
    #legend.AddEntry(underHisto,"Simulated Angular Distribution")
    #underHisto.SetStats(ROOT.kFALSE)
    #underHisto.Draw()

    if frescoGraph:
        #print "frescoGraph"
        frescoGraph.SetMarkerColor(ROOT.kBlack)
        frescoGraph.SetLineColor(ROOT.kBlack)
        frescoGraph.SetFillColor(ROOT.kBlack)
        #frescoGraph.SetMarkerStyle(33)
        MG.Add(frescoGraph, "L")
        legend.AddEntry(frescoGraph, "Fresco Output")
    else:
        print "No FrescoGraph!!!"
        return

    if goodPID:
        #print "goodPID"
        goodPID.SetMarkerColor(ROOT.kGreen)
        goodPID.SetLineColor(ROOT.kGreen)
        goodPID.SetFillColor(ROOT.kGreen)
        #goodPID.SetMarkerStyle(33)
        MG.Add(goodPID, "P")
        legend.AddEntry(goodPID, "ScaledPID")
    else:
        print "No goodPID in Draw()"

    if goodCORR:
        #print "goodCORR"
        goodCORR.SetMarkerColor(TColor.GetColorDark(ROOT.kGreen))
        goodCORR.SetLineColor(TColor.GetColorDark(ROOT.kGreen))
        goodCORR.SetFillColor(TColor.GetColorDark(ROOT.kGreen))
        goodCORR.SetMarkerStyle(21)
        #afterHisto.Draw("PLsame")
        MG.Add(goodCORR, "P")
        legend.AddEntry(goodCORR, "Good Dual Det")
    else:
        print "No goodCORR in Draw()"

    if badPID:
        #print "badPID"
        badPID.SetMarkerColor(ROOT.kRed)
        badPID.SetLineColor(ROOT.kRed)
        badPID.SetFillColor(ROOT.kRed)
        badPID.SetMarkerStyle(33)
        MG.Add(badPID, "P")
        legend.AddEntry(badPID, "Discard PID")
    else:
        print "No badPID in Draw()"

    if badCORR:
        #print "badCORR"
        badCORR.SetMarkerColor(TColor.GetColorDark(ROOT.kRed))
        badCORR.SetLineColor(TColor.GetColorDark(ROOT.kRed))
        badCORR.SetFillColor(TColor.GetColorDark(ROOT.kRed))
        badCORR.SetMarkerStyle(21)
        MG.Add(badCORR, "P")
        legend.AddEntry(badCORR, "Discard Dual Det")
    else:
        print "No badCORR in Draw()"

    MG.SetTitle(
        "Scaled Elastic Distribution for detector {};Center of Mass Angle in Degrees;Cross section in mb/sr"
        .format(det))
    MG.SetName("MG_d{}".format(det))
    MG.Draw("AP")
    legend.Draw()
    MG.Write()
    MG.SetMaximum(500)
    MG.SetMinimum(0)

    canvas.SetLogy()
    #MG.GetYaxis().SetRangeUser(0,500)

    MG.Draw()
    canvas.SaveAs(MG.GetName() + '.png')