예제 #1
0
    def savePie(self, legend, lumi, labelx):

        cpie = TCanvas("cpie", "TPie test", 700, 700)

        pad1 = TPad("pad1", "pad1", 0.1, 0.1, 0.75, 0.75)
        pad1.SetBottomMargin(0.12)
        pad1.Draw()

        pad1.cd()

        colors = []
        names = []
        vals = []

        for i in range(0, len(self.histos)):
            vals.append(self.histos[i].Integral())
            colors.append(self.histos[i].GetLineColor())
            names.append(self.histos[i].GetName())
        v = array('d', vals)
        c = array('i', colors)
        pie4 = TPie("p4", "", len(v), v, c)

        pie4.SetRadius(.45)
        pie4.SetLabelsOffset(.01)
        pie4.SetLabelsOffset(100)
        pie4.SetEntryLineWidth(1, 2)
        pie4.SetEntryLineWidth(2, 2)
        pie4.SetEntryLineWidth(3, 2)
        pie4.SetEntryLineWidth(4, 2)
        pie4.SetEntryLineWidth(5, 2)
        pie4.SetEntryLineWidth(6, 2)
        pie4.SetEntryLineWidth(7, 2)
        pie4.Draw()

        self.makeLegend()
        self.myLegend.Draw()

        lat = TLatex()
        lat.SetNDC()
        lat.SetTextSize(0.06)
        lat.SetTextFont(42)
        lat.DrawLatex(0.12, -0.1, "Slepton signal region, " + labelx)

        self.banner3(True, lumi)
        for plotName in self.plotNames:
            path = 'plots/' + plotName
            #self.ensurePath(path)
            cpie.SaveAs(path)

        self.myLegend.IsA().Destructor(self.myLegend)
예제 #2
0
def PlotExitCodes(dir, res):
    if res == []:
        return False
    name = dir.split('/')[-1]
    if name == '':
        name = dir.split('/')[-2]
    ls = array("d")
    out = []
    codes = []
    codesArr = []
    for it in res:
        if it[1] not in codes:
            codes.append(it[1])
            codesArr.append(array('c',
                                  str(it[1]) + '\0'))  # ugly! thx to pyROOT!
            ls.append(1)
            out.append([it[1], 1])
        else:
            ls[codes.index(it[1])] += 1
            for i in range(0, len(out)):
                if out[i][0] == it[1]:
                    out[i][1] += 1

    canv = TCanvas("canv", "", 400, 400)
    pie = TPie("pie" + dir, "Jobs exit codes for " + name, len(ls), ls)
    pie.SetLabels(array('l', map(lambda x: x.buffer_info()[0], codesArr)))
    if 0 in codes:
        pie.SetEntryFillColor(codes.index(0), 8)
    #pie.SetLabelFormat("%txt (%frac)")
    pie.SetLabelsOffset(-.1)
    pie.Draw("r")
    canv.SaveAs('exitcodes_' + name + ".png")
    return out
예제 #3
0
def piePlot():
    gStyle.SetTitleSize(0.1, 't')
    darknames = {
        'df1en0': 'Dark Factor = 1E0',
        'df1en1': 'Dark Factor = 1E-1',
        'df1en2': 'Dark Factor = 1E-2',
        'df1en3': 'Dark Factor = 1E-3'
    }
    recocolors = [2, 4, 6]
    labels = ['Photon', 'Jet', 'MET']
    #	can.Divide(2,2)
    iter = 1
    pie = {}
    for tre in darkFactors:
        can = TCanvas('can', 'can', 1000, 500)
        can.SetLeftMargin(1)
        can.SetRightMargin(1)
        GenDarkPhoisPho = 0
        GenDarkPhoisJet = 0
        GenDarkPhoisMet = 0
        for event in treefin[tre]:
            GenDarkPhoisPho += event.GenDarkPho_isPho
            GenDarkPhoisJet += event.GenDarkPho_isJet
            GenDarkPhoisMet += event.GenDarkPho_isMet
        vals = [GenDarkPhoisPho, GenDarkPhoisJet, GenDarkPhoisMet]
        #		print scipy.array(vals)
        #		print scipy.array(recocolors)
        pie[tre] = TPie('pie', darknames[tre], 3, array('d', vals),
                        array('i', recocolors))
        #		pie[tre] = TPie('pie',darknames[tre],3,scipy.array(vals),scipy.array(colors))
        #		pie[tre].SetLabels(labels)
        pie[tre].SetEntryLabel(0, "Photon")
        pie[tre].SetEntryLabel(1, "Jet")
        pie[tre].SetEntryLabel(2, "MET")
        pie[tre].Draw("3d")
        can.SaveAs('plots/pieChart_' + tre + '.pdf')
        can.Close()
        iter += 1