示例#1
0
def createPlots(rootfiles, type, memory, weight=None):
    print "Processing "
    print rootfiles
    mll = utils.UOFlowTH1F(type, "", 30, 0, 30)
    utils.histoStyler(mll)
    memory.append(mll)
    sum = 0
    for f in rootfiles:
        print "***"
        filename = os.path.basename(f).split(".")[0]
        rootFile = TFile(f)
        c = rootFile.Get('tEvent')
        nentries = c.GetEntries()
        print 'Analysing', nentries, "entries"
        for ientry in range(nentries):
            if ientry % 10000 == 0:
                print "Processing " + str(ientry)
            c.GetEntry(ientry)
            if c.Met < 200:
               continue
            if c.trackBDT < 0.1:
                continue
            if c.univBDT < -0.2:
                continue
            #if c.dilepBDT < 0.1:
            #    continue
            if c.tracks[0].Pt() <5:
                continue
            #if c.tracks[0].Eta() > 2.5:
            #    continue
            
            if weight is not None:
                print "****"
                sum += c.Weight * weight
                mll.Fill(c.invMass, c.Weight * weight)
            else:
                sum += c.Weight
                mll.Fill(c.invMass, c.Weight)
    print "Filled total of sum:", sum
    return mll
示例#2
0
def main():

    print "Plotting observable"
    c2 = TCanvas("c2")
    c1 = TCanvas("c1", "c1", 800, 800)
    c1.SetBottomMargin(0.16)
    c1.SetLeftMargin(0.16)
    #c1 = utils.mkcanvas()
    #memory = []

    global method

    file = [input]
    c2.cd()
    #(testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods, names) = cut_optimisation.get_bdt_hists(file, None, None, None, None, None, None, 40)
    (testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods,
     names) = cut_optimisation.get_method_hists(file, method, None, None, None,
                                                None, None, None, 40, "",
                                                weight)
    #cut_optimisation.get_mlp_hists(file, testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods, names)
    #def get_bdt_hists(folders, testBGHists=None, trainBGHists=None, testSignalHists=None, trainSignalHists=None, methods=None, names=None, bins=10000,  condition=""):
    #    return get_method_hists(folders, "BDT", testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods, names, bins, condition)

    c1.cd()

    c1.Print(output_file + "[")

    hist = TH1F("hroc", "", 1000, 0, 1)
    hist.SetMinimum(0)
    hist.SetMaximum(1)
    hist.GetXaxis().SetTitle("#font[12]{#epsilon_{S}}")
    hist.GetYaxis().SetTitle(
        "background rejection (1 - #font[12]{#epsilon_{B}})")
    utils.histoStyler(hist)
    hist.GetYaxis().SetTitleOffset(1.20)
    hist.GetXaxis().SetLabelSize(0.055)
    hist.Draw()

    legend = TLegend(0.2, 0.2, 0.7, 0.45)
    legend.SetBorderSize(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.05)

    for inx in range(len(testBGHists)):

        testBGHist, trainBGHist, testSignalHist, trainSignalHist, method, name = testBGHists[
            inx], trainBGHists[inx], testSignalHists[inx], trainSignalHists[
                inx], methods[inx], names[inx]

        h = TGraph()
        highestZ, highestS, highestB, highestMVA, ST, BT = cut_optimisation.getHighestZ(
            trainSignalHist, trainBGHist, testSignalHist, testBGHist, h)
        h.SetTitle(name)
        h.SetLineColor(kBlack)
        h.SetMarkerSize(0.2)
        #hbdt.SetFillColor(kRed)

        h.Draw("same")
        legend.Draw("same")

    #legend.Draw("SAME")
    utils.stamp_plot()
    #utils.stampFab("35.9")
    c1.Print(output_file)
    c1.Print(output_file + "]")
    exit(0)
示例#3
0
def main():

    print "Plotting observable"

    c1 = TCanvas("c1", "c1", 800, 800)
    c1.SetBottomMargin(0.16)
    c1.SetLeftMargin(0.16)
    #c1 = utils.mkcanvas()
    #memory = []
    c1.Print(output_file + "[")

    legend = TLegend(.55, .75, .89, .89)
    legend.SetBorderSize(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.05)

    files = glob(signal_dir + "/*")
    signal_files_re = re.compile("(" + SIM_GROUP[input] + ")_sig*")
    bg_files_re = re.compile("(" + SIM_GROUP[input] + ")_bg*")

    signal_files = [f for f in files if signal_files_re.match(f)]
    bg_files = [f for f in files if bg_files_re.match(f)]

    print signal_files
    print bg_files

    sh = utils.UOFlowTH1F("sh", "", 100, 2, 26)
    bh = utils.UOFlowTH1F("bh", "", 100, 2, 26)
    utils.histoStyler(sh)
    utils.histoStyler(bh)

    for (fs, hs) in [(signal_files, sh), (bg_files, bh)]:
        for file in fs:
            print "Processing " + file
            f = TFile(file)
            c = f.Get('tEvent')
            nentries = c.GetEntries()
            print 'Analysing', nentries, "entries"
            for ientry in range(nentries):
                if ientry % 1000 == 0:
                    print "Processing " + str(ientry)
                c.GetEntry(ientry)
                hs.Fill(c.lepton.Pt())

    cpBlue = utils.colorPalette[2]
    cpRed = utils.colorPalette[7]

    #trainBGHist.SetTitle(name)
    bh.GetXaxis().SetTitle("Pt(l)")
    bh.GetYaxis().SetTitle("Number of tracks")
    bh.GetYaxis().SetTitleOffset(1.15)
    #bh.GetXaxis().SetLabelSize(0.04)
    #bh.GetYaxis().SetTitle("Arbitrary Units")

    fillC = TColor.GetColor(cpRed["fillColor"])
    lineC = TColor.GetColor(cpRed["lineColor"])
    #trainBGHist.SetFillStyle(cpRed["fillStyle"])
    bh.SetFillColorAlpha(fillC, 0.35)  #.35)
    bh.SetLineColor(lineC)
    bh.SetLineWidth(1)
    bh.SetMinimum(0.01)
    bh.SetOption("HIST")
    bh.Draw("HIST")

    legend.AddEntry(bh, "Non-Z tracks", 'F')

    fillC = TColor.GetColor(cpBlue["fillColor"])
    lineC = TColor.GetColor(cpBlue["lineColor"])
    #sh.SetFillStyle(cpBlue["fillStyle"])
    sh.SetFillColorAlpha(fillC, 0.35)  #.35)
    sh.SetLineColor(lineC)
    sh.SetLineWidth(1)
    sh.SetOption("HIST")
    sh.Draw("HIST SAME")

    legend.AddEntry(sh, "Z tracks", 'F')

    legend.Draw("SAME")
    gPad.SetLogy()
    utils.stamp_plot()
    #utils.stampFab("35.9")
    c1.Print(output_file)
    c1.Print(output_file + "]")
    exit(0)
示例#4
0
def main():

    print "Plotting observable"

    c1 = TCanvas("c1", "c1", 800, 800)
    c1.SetBottomMargin(0.16)
    c1.SetLeftMargin(0.16)
    #c1 = utils.mkcanvas()
    #memory = []
    c1.Print(output_file + "[")

    #legend = TLegend(.55,.75,.89,.89)
    legend = TLegend(.2, .75, .89, .89)
    legend.SetBorderSize(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.05)

    files = [input]

    print files

    sh = utils.UOFlowTH1F("sh", "", 30, 0, 8)
    bh = utils.UOFlowTH1F("bh", "", 30, 0, 8)
    utils.histoStyler(sh)
    utils.histoStyler(bh)

    for file in files:
        f = TFile(file)
        c = f.Get('tEvent')
        nentries = c.GetEntries()
        print 'Analysing', nentries, "entries"
        for ientry in range(nentries):
            c.GetEntry(ientry)
            if ientry % 1000 == 0:
                print "Processing " + str(ientry) + " weight=" + str(c.Weight)
            if analysis_ntuples.isX1X2X1Process(c):
                genZL, genNonZL = analysis_ntuples.classifyGenZLeptons(c)
                if genZL is None:
                    print "WHAT?!"
                    continue
                nL = c.Electrons.size() + c.Muons.size()
                l1 = None
                l2 = None
                if c.Electrons.size(
                ) == 2 and c.Electrons_charge[0] * c.Electrons_charge[1] < 0:
                    l1 = c.Electrons[0]
                    l2 = c.Electrons[1]
                elif c.Muons.size(
                ) == 2 and c.Muons_charge[0] * c.Muons_charge[1] < 0:
                    l1 = c.Muons[0]
                    l2 = c.Muons[1]
                if l1 is not None:
                    if l1.Pt() < 5 or l2.Pt() < 5:
                        continue
                    #print l1, genZL, c
                    minZ, minCanZ = analysis_ntuples.minDeltaRGenParticles(
                        l1, genZL, c.GenParticles)
                    if minZ > 0.1:
                        #print "NO"
                        continue
                    minZ, minCanZ = analysis_ntuples.minDeltaRGenParticles(
                        l2, genZL, c.GenParticles)
                    if minZ > 0.1:
                        #print "NO"
                        continue
                    sh.Fill((l1 + l2).M(), c.Weight)
                else:
                    ch1 = None
                    if c.Electrons.size() == 1:
                        l1 = c.Electrons[0]
                        ch1 = c.Electrons_charge[0]
                    elif c.Muons.size() == 1:
                        l1 = c.Muons[0]
                        ch1 = c.Muons_charge[0]
                    if not l1:
                        continue
                    if l1.Pt() < 5:
                        continue
                    if not genZL:
                        continue
                    for ti in range(c.tracks.size()):
                        if c.tracks_trkRelIso[ti] > 0.1:
                            continue

                        t = c.tracks[ti]
                        elecMin = analysis_tools.minDeltaR(t, c.Electrons)
                        muonMin = analysis_tools.minDeltaR(t, c.Muons)
                        if (elecMin is not None
                                and elecMin < 0.1) or (muonMin is not None
                                                       and muonMin < 0.1):
                            continue

                        minZ, minCanZ = analysis_ntuples.minDeltaRGenParticles(
                            t, genZL, c.GenParticles)
                        minNZ, minCanNZ = analysis_ntuples.minDeltaRGenParticles(
                            t, genNonZL, c.GenParticles)

                        min = None
                        if minNZ is None or minZ < minNZ:
                            min = minZ
                        else:
                            min = minNZ

                        result = ""

                        if min > 0.1:
                            result = "MM"
                        elif minNZ is None or minZ < minNZ:
                            if c.tracks_charge[ti] * c.GenParticles_PdgId[
                                    minCanZ] < 0:
                                result = "Zl"
                                #print "Found!"
                            else:
                                result = "MM"
                        else:
                            result = "MM"

                        if result == "Zl" and c.tracks_charge[ti] * ch1 < 0:
                            bh.Fill((t + l1).M(), c.Weight)
                            break

    cpBlue = utils.colorPalette[2]
    cpRed = utils.colorPalette[7]

    #trainBGHist.SetTitle(name)
    bh.GetXaxis().SetTitle("M_{ll} [GeV]")
    bh.GetYaxis().SetTitle("Number of events")
    bh.GetYaxis().SetTitleOffset(1.15)
    #bh.GetXaxis().SetLabelSize(0.04)
    #bh.GetYaxis().SetTitle("Arbitrary Units")

    fillC = TColor.GetColor(cpRed["fillColor"])
    lineC = TColor.GetColor(cpRed["lineColor"])
    #trainBGHist.SetFillStyle(cpRed["fillStyle"])
    bh.SetFillColorAlpha(fillC, 0.35)  #.35)
    bh.SetLineColor(lineC)
    bh.SetLineWidth(1)
    bh.SetOption("HIST")
    bh.SetMaximum(900)
    bh.Draw("HIST")

    legend.AddEntry(bh, "One reco one track", 'F')

    fillC = TColor.GetColor(cpBlue["fillColor"])
    lineC = TColor.GetColor(cpBlue["lineColor"])
    #sh.SetFillStyle(cpBlue["fillStyle"])
    sh.SetFillColorAlpha(fillC, 0.35)  #.35)
    sh.SetLineColor(lineC)
    sh.SetLineWidth(1)
    sh.SetOption("HIST")
    sh.Draw("HIST SAME")

    legend.AddEntry(sh, "Two reconstructed", 'F')

    legend.Draw("SAME")
    gPad.SetLogy()
    utils.stamp_plot()
    #utils.stampFab("35.9")
    c1.Print(output_file)
    c1.Print(output_file + "]")
    exit(0)
示例#5
0
def main():

    print "Plotting observable"

    c1 = TCanvas("c1", "c1", 800, 800)
    c1.SetBottomMargin(0.16)
    c1.SetLeftMargin(0.18)

    c1.Print(output_file+"[");

    bg_files = glob(bg_dir + "/*")
    sumTypes = {}
    memory = []

    for f in bg_files: 
        filename = os.path.basename(f).split(".")[0]
        types = filename.split("_")
        if types[0] not in sumTypes:
            sumTypes[types[0]] = {}
        sumTypes[types[0]][types[1]] = True
    histograms = {}
    print sumTypes
    for type in sumTypes:
        if utils.existsInCoumpoundType(type):
            continue
        print "Summing type", type
        rootfiles = glob(bg_dir + "/*" + type + "*.root")
        #rootfiles.append(signal_file)
        #rootfiles = [signal_file] + rootfiles
        mll = createPlots(rootfiles, type, memory)
        print type
        histograms[type] = mll
    
    for cType in utils.compoundTypes:
        print "Creating compound type", cType
        rootFiles = []
        for type in utils.compoundTypes[cType]:
            rootFiles.extend(glob(bg_dir + "/*" + type + "*.root"))
        if len(rootFiles):
            mll = createPlots(rootFiles, cType, memory)
            histograms[type] = mll
        else:
            print "**Couldn't find file for " + cType

    sigHist = createPlots([signal_dir], "signal", memory)

    utils.formatHist(sigHist, utils.signalCp[0], 0.8)

    hs = THStack("invMass","")
    memory.append(hs)
    types = [k for k in utils.bgOrder]
    types = sorted(types, key=lambda a: utils.bgOrder[a])
    typesInx = []

    i = 0
    foundBg = False
    for type in types:
        if histograms.get(type) is not None:
            hs.Add(histograms[type])
            typesInx.append(i)
            foundBg = True
        i += 1
    #hs.Add(sigHist)
    #typesInx.append(i)

    sigMax = sigHist.GetMaximum()
    maximum = sigMax
    if foundBg:
        bgMax = hs.GetMaximum()
        maximum = max(bgMax, sigMax)

    #legend = TLegend(.69,.55,.89,.89)
    legend = TLegend(.20,.60,.89,.89)
    legend.SetNColumns(2)
    legend.SetBorderSize(0)
    legend.SetFillStyle(0)
    memory.append(legend)
    if foundBg:
        newBgHist = utils.styledStackFromStack(hs, memory, legend, "", typesInx, True)
        #newBgHist.SetFillColorAlpha(fillC, 0.35)
        newBgHist.SetMaximum(maximum*1000)
        newBgHist.SetMinimum(0.01)
        newBgHist.Draw("hist")
        utils.histoStyler(newBgHist)
        newBgHist.GetXaxis().SetTitle("M_{ll}")
        newBgHist.GetYaxis().SetTitle("Number of events")
        newBgHist.GetYaxis().SetTitleOffset(1.15)
        #newBgHist.GetXaxis().SetLabelSize(0.055)
        c1.Modified()
        #newBgHist.SetTitle(signal_name)

    #sigHist.SetTitle(signal_name)
    legend.AddEntry(sigHist, "signal", 'l')
    if foundBg:
        sigHist.SetMaximum(maximum)
    sigHist.SetMinimum(0.01)
    sigHist.SetLineWidth(2)
    sigHist.GetXaxis().SetTitle("GeV")
    if foundBg:
        sigHist.Draw("HIST SAME")
    else:
        sigHist.Draw("HIST")
    legend.Draw("SAME")
    gPad.SetLogy();
    utils.stamp_plot()
    c1.Update()
    c1.Print(output_file);

    c1.Print(output_file+"]");
示例#6
0
def main():
    print("Start: " + datetime.now().strftime('%d-%m-%Y %H:%M:%S'))

    print("Opening histograms file " + histograms_file)
    histograms = TFile(histograms_file, 'read')

    for lepNum in [1, 2]:
        for lep in ["Muons", "Electrons"]:

            orthOpt = [True, False] if (lepNum == 2
                                        and lep == "Muons") else [False]
            for orth in orthOpt:
                histname = "bg_" + ("1t" if lepNum == 1 else "2l") + "_" + (
                    "orth_" if orth else "") + lep
                print("Getting", histname)
                bg_hist = histograms.Get(histname)

                maximum = bg_hist.GetMaximum()

                signal_histograms = []
                for signal in signals:

                    #"bg_2l_" + ("orth_" if orth else "") + lep + "_" + jetiso

                    histname = signal + "_" + ("1t" if lepNum == 1 else
                                               "2l") + "_" + ("orth_" if orth
                                                              else "") + lep
                    print("Getting", histname)
                    hist = histograms.Get(histname)
                    maximum = max(maximum, hist.GetMaximum())
                    signal_histograms.append(hist)

                bg_hist.SetMaximum(maximum)

                c1 = TCanvas("c1", "c1", 800, 800)
                c1.cd()

                legend = TLegend(0.65, 0.70, 0.87, 0.875)
                legend.SetBorderSize(0)
                legend.SetTextFont(42)
                legend.SetTextSize(0.02)

                cpRed = utils.colorPalette[7]
                utils.histoStyler(bg_hist)
                bg_hist.SetTitle("")
                bg_hist.GetXaxis().SetTitle("BDT Output")
                bg_hist.GetYaxis().SetTitle("Number of events")
                #bg_hist.GetYaxis().SetTitleOffset(1.4)
                #bg_hist.GetXaxis().SetLabelSize(0.055)
                #trainBGHist.SetMaximum(maxY + 0.02)
                utils.formatHist(bg_hist, cpRed, 0.35, True)
                # fillC = TColor.GetColor(cpRed["fillColor"])
                #             lineC = TColor.GetColor(cpRed["lineColor"])
                #             bg_hist.SetFillStyle(0)
                #             bg_hist.SetFillColorAlpha(fillC, 0.35)
                #             bg_hist.SetLineColor(lineC)
                #             bg_hist.SetLineWidth(1)
                #             bg_hist.SetOption("HIST")

                bg_hist.Draw("HIST")

                #print "BinWidth", bg_hist.GetBinWidth()
                # print("*********GetNbinsX", bg_hist.GetNbinsX())
                #                 for ibin in range(1, bg_hist.GetNbinsX()):
                #                     print("BinWidth", bg_hist.GetBinWidth(ibin))
                #                     print("GetBinLowEdge", bg_hist.GetBinLowEdge(ibin))

                legend.AddEntry(bg_hist, "Background", 'F')

                for i in range(len(signals)):
                    utils.formatHist(signal_histograms[i], utils.signalCp[i],
                                     0.8)
                    legend.AddEntry(signal_histograms[i], signals[i], 'l')
                    signal_histograms[i].Draw("hist same")

                legend.Draw("SAME")

                c1.Print(output_dir + "/signal_background_" +
                         ("1t" if lepNum == 1 else "2l") + "_" +
                         ("orth_" if orth else "") + lep + ".pdf")

                ############# DRAW SIGNIFICANCES ##############

                categories = 10
                cut_values = []
                binMax = -1

                for category in range(categories):

                    significance_histograms = []

                    for i in range(len(signals)):
                        significance_histogram = signal_histograms[i].Clone()
                        significance_histogram.Reset()

                        endPoint = signal_histograms[i].GetNbinsX(
                        ) if binMax == -1 else binMax
                        print("endPoint", endPoint)
                        for ibin in range(1, endPoint):
                            print("calculating for bin", ibin)
                            sig = utils.calcSignificanceCutCount(
                                signal_histograms[i], bg_hist, ibin,
                                binMax - 1 if binMax > 0 else -1)
                            print("sig", sig)
                            significance_histogram.SetBinContent(ibin, sig)
                        significance_histograms.append(significance_histogram)

                    c1 = TCanvas("c1", "c1", 800, 800)
                    c1.cd()

                    legend = TLegend(0.15, 0.70, 0.55, 0.875)
                    legend.SetBorderSize(0)
                    legend.SetTextFont(42)
                    legend.SetTextSize(0.02)

                    maximum = 0
                    for i in range(len(signals)):
                        maximum = max(significance_histograms[i].GetMaximum(),
                                      maximum)
                    significance_histograms[0].SetMaximum(maximum + 1)
                    utils.histoStyler(significance_histograms[0])
                    significance_histograms[0].SetTitle("")
                    significance_histograms[0].GetXaxis().SetTitle(
                        "BDT Output")
                    significance_histograms[0].GetYaxis().SetTitle(
                        "Significance")

                    for i in range(len(signals)):
                        utils.formatHist(significance_histograms[i],
                                         utils.signalCp[i], 0.8)
                        legend.AddEntry(significance_histograms[i], signals[i],
                                        'l')
                        if i == 0:
                            significance_histograms[i].Draw("hist")
                        else:
                            significance_histograms[i].Draw("hist same")

                    binMax = significance_histograms[1].GetMaximumBin()
                    maxValue = significance_histograms[1].GetXaxis(
                    ).GetBinCenter(binMax)

                    print("binMax", binMax, "maxValue",
                          "{:0.2f}".format(maxValue))

                    cut_values.append("{:0.2f}".format(maxValue))

                    sigLine = TLine(maxValue, 0, maxValue, maximum + 1)
                    sigLine.Draw("SAME")
                    sigLine.SetLineColor(kRed)
                    sigLine.SetLineWidth(2)

                    tl = TLatex()
                    tl.SetTextFont(42)
                    tl.SetTextSize(0.04)
                    tl.DrawLatex(maxValue + 0.05, maximum + 0.5,
                                 "{:0.2f}".format(maxValue))

                    legend.Draw("SAME")

                    c1.Print(output_dir + "/sr" + str(category + 1) +
                             "_significance_" +
                             ("1t" if lepNum == 1 else "2l") + "_" +
                             ("orth_" if orth else "") + lep + ".pdf")

                print("===========")
                print(("1t" if lepNum == 1 else "2l") + "_" +
                      ("orth_" if orth else "") + lep)
                print(cut_values)
    exit(0)
示例#7
0
                      isoBarrelHist.GetMinimum(),
                      isoBarrelHistFactor.GetMinimum(),
                      isoDataBarrelHistFactor.GetMinimum())
        maximum = max(barrelHist.GetMaximum(), dataBarrelHist.GetMaximum(),
                      isoDataBarrelHist.GetMaximum(),
                      isoBarrelHist.GetMaximum(),
                      isoBarrelHistFactor.GetMaximum(),
                      isoDataBarrelHistFactor.GetMaximum())

    barrelHist.SetMinimum(minimum - 0.1)
    barrelHist.SetMaximum(maximum + 0.1)

    #Originally it was here isoBarrelHist formatted

    utils.formatHist(barrelHist, utils.colorPalette[14], 0, True, True)
    utils.histoStyler(barrelHist)
    #barrelHist.GetYaxis().SetTitleOffset(1.5)

    #isoBarrelHist.SetLineColor(kBlack)
    #isoBarrelHist.SetMarkerColor(kBlack)
    #isoBarrelHist.SetMarkerStyle(kOpenSquare)

    # isoBarrelHistFactor.SetLineColor(kBlue)
    #     isoBarrelHistFactor.SetMarkerColor(kBlue)
    #     isoBarrelHistFactor.SetMarkerStyle(kOpenSquare)

    barrelHist.SetLineColor(kRed)
    barrelHist.SetMarkerColor(kRed)
    barrelHist.SetMarkerStyle(kFullSquare)

    #isoDataBarrelHist.SetMarkerStyle(kFullCircle)
def main():

    print "Plotting observable"
    c2 = TCanvas("c2")
    c1 = TCanvas("c1", "c1", 800, 800)
    c1.SetBottomMargin(0.16)
    c1.SetLeftMargin(0.18)
    #c1 = utils.mkcanvas()
    #memory = []
    
    global method
    global normalise
    
    file = [input]
    c2.cd()
    #(testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods, names) = cut_optimisation.get_bdt_hists(file, None, None, None, None, None, None, 40)
    (testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods, names) = cut_optimisation.get_method_hists(file, method, None, None, None, None, None, None, 40, "", weight)
    #cut_optimisation.get_mlp_hists(file, testBGHists, trainBGHists, testSignalHists, trainSignalHists, methods, names)
    c1.cd()
    
    c1.Print(output_file+"[");
    
    c1.SetLogy()
    
    legend = TLegend(0.65, 0.70, 0.87, 0.875)
    legend.SetBorderSize(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.05)
    
    for inx in range(len(testBGHists)):
    
        testBGHist, trainBGHist, testSignalHist, trainSignalHist, method, name = testBGHists[inx], trainBGHists[inx], testSignalHists[inx], trainSignalHists[inx], methods[inx], names[inx]
        
        ST = trainSignalHist.Integral() + testSignalHist.Integral()
        BT = trainBGHist.Integral() + testBGHist.Integral()

        if normalise:
            trainSignalHist.Scale(1./ST)
            testSignalHist.Scale(1./ST)
            testBGHist.Scale(1./BT)
            trainBGHist.Scale(1./BT)
            
        maxY = max(trainSignalHist.GetMaximum(), testSignalHist.GetMaximum(), testBGHist.GetMaximum(), trainBGHist.GetMaximum())
        
        cpBlue = utils.colorPalette[2]
        cpRed = utils.colorPalette[7]
        utils.histoStyler(trainBGHist)
        trainBGHist.SetTitle("")
        trainBGHist.GetXaxis().SetTitle("BDT Output")
        trainBGHist.GetYaxis().SetTitle("Number of events")
        trainBGHist.GetYaxis().SetTitleOffset(1.4)
        trainBGHist.GetXaxis().SetLabelSize(0.055)
        #trainBGHist.SetMaximum(maxY + 0.02)

        fillC = TColor.GetColor(cpRed["fillColor"])
        lineC = TColor.GetColor(cpRed["lineColor"])
        trainBGHist.SetFillStyle(cpRed["fillStyle"])
        trainBGHist.SetFillColorAlpha(fillC, 0.35)
        trainBGHist.SetLineColor(lineC)
        trainBGHist.SetLineWidth(1)
        trainBGHist.SetOption("HIST")
        
        trainBGHist.Draw("HIST")

        legend.AddEntry(trainBGHist, "B (train)", 'F')

        fillC = TColor.GetColor(cpBlue["fillColor"])
        lineC = TColor.GetColor(cpBlue["lineColor"])
        trainSignalHist.SetFillStyle(cpBlue["fillStyle"])
        trainSignalHist.SetFillColorAlpha(fillC, 0.35)
        trainSignalHist.SetLineColor(lineC)
        trainSignalHist.SetLineWidth(1)
        trainSignalHist.SetOption("HIST")
        trainSignalHist.Draw("HIST SAME")
        
        legend.AddEntry(trainSignalHist, "S (train)", 'F')
        
        testBGHist.SetMarkerColor(kRed)
        testBGHist.SetMarkerSize(0.5)
        testBGHist.SetMarkerStyle(20)
        testBGHist.SetOption("p E1")
        testBGHist.SetLineColor(kRed)
        testBGHist.Draw("SAME p E1")
        
        legend.AddEntry(testBGHist, "B (test)", "p e2")
        
        testSignalHist.SetMarkerColor(kBlue)
        testSignalHist.SetMarkerSize(0.5)
        testSignalHist.SetMarkerStyle(20)
        testSignalHist.SetOption("p E1")
        testSignalHist.SetLineColor(kBlue)
        testSignalHist.Draw("SAME p E1")
        
        legend.AddEntry(testSignalHist, "S (test)", "p e2")
    
        legend.Draw("SAME")

    utils.stamp_plot()
    #gPad.SetLogy();
    #utils.stampFab("35.9")
    c1.Print(output_file);
    c1.Print(output_file+"]");
    exit(0)