Beispiel #1
0
    #=================== SIGNAL SAMPLES ==================================#
#   for (signalfilename,xs,k,efilter,nMC,legend_latex,plotbool) in zip(signal_list,xs_list,k_list,efilter_list,nMC_list,signal_legend_list,bool_list):
#        if plotbool == "Plot" :
#            signal=root_open(signalMC_location + "/" +signalfilename)
#
#            treesSR = signal.trees_SR_
#            signalcut = Cut(xs+"*" + efilter + "*" + k + "*" + str(lumifb) + "*mcEventWeight/" + nMC) * cut
#            histname = "hist" + signalfilename
#            histogram = histname + "(" + nbins + "," + xmin + "," + xmax + ")"
#            hist = treesSR.Draw(variable + ">>" + histogram,selection = signalcut, drawstyle="hist")

#            objects.append(hist)

#=================== DRAW STACK ====================================#
    stack.Draw()

    stack.xaxis.SetTitle(xtitle)
    stack.yaxis.SetTitle(ytitle)

    #=================== DRAW DATA ====================================#
    for (dataobject, data_legend_latex) in zip(dataobjects, data_legend_list):
        legend.AddEntry(dataobject, label=data_legend_latex)
        dataobject.Draw("same X0")
#
#=================== DRAW SIGNALS ====================================#
#    for (object,legend_latex,linestyle) in zip(objects,signal_legend_list,linestyle_list):
#        object.SetLineColor("black")
#        object.SetLineWidth(3)
#        object.SetLineStyle(linestyle)
#        legend.AddEntry(object,label = legend_latex,style='L')
Beispiel #2
0
            for hist in hstack:
              mcScale += hist.integral()
            if mcScale != 0.:
              normalizeFactor = dataScale/mcScale
            else:
              normalizeFactor = 1.
            for hist in hstack:
              hist.scale(normalizeFactor)

        # cycle through all draw options and make sure we don't overwrite
        drawOptions = ["same"]*len(soloHists)
        drawOptions = cycle([''] + drawOptions)

        # draw it so we have access to the xaxis and yaxis
        if hstack:
          hstack.Draw(next(drawOptions))
          # set up axes
          set_minmax(hstack, plots_path)
          set_label(hstack, plots_path, canvasConfigs)
          get_axis(hstack, 'x').SetNdivisions(canvasConfigs.get('ndivisions', 5), canvasConfigs.get('ndivisions opt', True))
          # set label/title sizes
          get_axis(hstack, 'x').set_label_size(canvasConfigs.get('xlabel size', 30))
          get_axis(hstack, 'x').set_title_size(canvasConfigs.get('xtitle size', 30))
          get_axis(hstack, 'y').set_label_size(canvasConfigs.get('ylabel size', 30))
          get_axis(hstack, 'y').set_title_size(canvasConfigs.get('ytitle size', 30))
          # set label/title fonts
          get_axis(hstack, 'x').set_label_font(canvasConfigs.get('label font', 43))
          get_axis(hstack, 'x').set_title_font(canvasConfigs.get('title font', 43))
          get_axis(hstack, 'y').set_label_font(canvasConfigs.get('label font', 43))
          get_axis(hstack, 'y').set_title_font(canvasConfigs.get('title font', 43))
Beispiel #3
0
h2.linewidth = 0

stack = HistStack()
stack.Add(h1)
stack.Add(h2)

# plot with ROOT
canvas = Canvas(width=700, height=500)

# try setting logy=True and uncommenting the two lines below
xmin, xmax, ymin, ymax = get_limits([stack, h3], logy=False)
stack.SetMaximum(ymax)
#stack.SetMinimum(ymin)
#canvas.SetLogy()

stack.Draw('HIST E1 X0')
h3.Draw('SAME E1 X0')
stack.xaxis.SetTitle('Mass')
stack.yaxis.SetTitle('Events')
# set the number of expected legend entries
legend = Legend(3, leftmargin=0.45, margin=0.3)
legend.AddEntry(h1, style='F')
legend.AddEntry(h2, style='F')
legend.AddEntry(h3, style='LEP')
legend.Draw()
label = ROOT.TText(0.3, 0.8, 'ROOT')
label.SetTextFont(43)
label.SetTextSize(25)
label.SetNDC()
label.Draw()
canvas.Modified()
Beispiel #4
0
                    for hist in hstack:
                        mcScale += hist.integral()
                    if mcScale != 0.:
                        normalizeFactor = dataScale / mcScale
                    else:
                        normalizeFactor = 1.
                    for hist in hstack:
                        hist.scale(normalizeFactor)

                # cycle through all draw options and make sure we don't overwrite
                drawOptions = ["same"] * len(soloHists)
                drawOptions = cycle([''] + drawOptions)

                # draw it so we have access to the xaxis and yaxis
                if hstack:
                    hstack.Draw(next(drawOptions))
                    # set up axes
                    set_minmax(hstack, plots_path)
                    set_label(hstack, plots_path, canvasConfigs)
                    get_axis(hstack, 'x').SetNdivisions(
                        canvasConfigs.get('ndivisions', 5))
                    # set label/title sizes
                    get_axis(hstack, 'x').set_label_size(
                        canvasConfigs.get('xlabel size', 30))
                    get_axis(hstack, 'x').set_title_size(
                        canvasConfigs.get('xtitle size', 30))
                    get_axis(hstack, 'y').set_label_size(
                        canvasConfigs.get('ylabel size', 30))
                    get_axis(hstack, 'y').set_title_size(
                        canvasConfigs.get('ytitle size', 30))
                    # set label/title fonts