Esempio n. 1
0
sample_labels = hpl.sample_labels()
metadata = util.loadMetadata(
    "config/sampleMetaData.txt")  # dictionary of metadata; key=primary dataset

#numberOfHists = 0
# Access data -- assumes you are plotting histograms from multiple sources in one figure

for hi, histogram in enumerate(histograms):

    histogramName = histogram[2:].replace(
        "_" + selection, "")  # turn "h_jet_pt_events" into "jet_pt"

    print "  :: Plotting " + histogram + "\n"

    ## setup histogram
    hist = HepPlotter("histogram", 1)

    hist.ratio_plot = False  # plot a ratio of things [Data/MC]
    hist.ratio_type = "ratio"  # "ratio"
    hist.stacked = False  # stack plots
    hist.rebin = variables[histogramName].binning
    hist.logplot = False  # plot on log scale
    hist.x_label = variables[histogramName].label
    hist.y_label = "Events"
    hist.y_ratio_label = ""
    hist.lumi = 'XY.Z'  # in /fb
    hist.format = 'pdf'  # file format for saving image
    hist.saveAs = "{0}/hist_{1}".format(outpath,
                                        histogramName)  # save figure with name
    hist.CMSlabel = 'top left'  # 'top left', 'top right'; hack code for something else
    hist.CMSlabelStatus = 'Internal'  # ('Simulation')+'Internal' || 'Preliminary'
Esempio n. 2
0
## Make histograms
for histogram in histograms:

    selection = 'ejets' if histogram.endswith('ejets') else 'mujets'
    if histogram.startswith("h_mu_") and selection == "ejets": continue
    if histogram.startswith("h_el_") and selection == "mujets": continue

    # CyMiniAna saves histograms with extra text in the name, remove that here
    histogramName = histogram.replace("h_", "").replace("_" + selection, "")

    print "  :: Plotting " + histogram

    ## setup histogram
    #hist = HepPlotterDataMC()
    hist = HepPlotter("histogram", 1)

    hist.drawStatUncertainty = True  # draw stat uncertainty separately
    hist.drawSystUncertainty = False  # draw syst uncertainty separately
    hist.drawStatSystUncertainty = False  # draw stat+syst uncertainty
    hist.legendLoc = 1
    hist.stackSignal = False
    hist.blind = False
    hist.xlim = None
    hist.ratio_plot = True  # plot a ratio of things [Data/MC]
    hist.ratio_type = "ratio"  # "ratio"
    hist.stacked = True  # stack backgrounds
    hist.rebin = variables[histogramName].binning  # rebin per histogram
    hist.logplot = False
    hist.x_label = variables[histogramName].label
    hist.y_label = "Events"
Esempio n. 3
0
wprime2_label_short = r"W$^\prime$(2.5)"

# Access data -- assumes you are plotting histograms from multiple sources in one figure
for hi, histogram in enumerate(histograms):

    selection = "ejets" if histogram.endswith("ejets") else "mujets"

    if histogram.startswith("h_mu_") and selection == "ejets": continue
    if histogram.startswith("h_el_") and selection == "mujets": continue

    histogram = histogram.strip('\n')
    histogramname = gethistname(histogram)
    print "  :: Plotting " + histogram

    ## setup histogram
    hist = HepPlotter("histogram", 1)

    hist.ratio_plot = True  # plot a ratio of things [e.g., Data/MC]
    hist.ratio_type = "significance"
    hist.ymaxScale = 1.6
    hist.stacked = False  # stack plots
    hist.normed = True
    hist.rebin = x_labels[histogramname].binning
    hist.xlim = None
    hist.logplot = False  # plot on log scale
    hist.x_label = x_labels[histogramname].label
    hist.y_label = "Arbitrary Units"
    hist.y_ratio_label = r"S/$\sqrt{\text{B}}$"
    hist.lumi = ''  # in /fb
    hist.format = 'pdf'  # file format for saving image
    hist.saveAs = outpath + "/{0}_multiSignal".format(
Esempio n. 4
0
## Add the data from each file
## Assume the data is structured such that you want to plot
## multiple efficiencies from the same file in one plot
## -> change to your desired structure / plot
##    e.g., to plot efficiencies from two sources (files) on 1 plot:
##          switch order of file & hist loops
##          To plot multiple kinds of variables on different plots,
##          you'll need another loop
for file in files:
    f = ROOT.TFile.Open(file)
    filename = file.split("/")[-1].split(".")[0]

    print "  > Opening data from ", filename

    ## setup histogram
    hist = HepPlotter("efficiency", 1)

    hist.drawEffDist = True  # draw the physics distribution for efficiency (jet_pt for jet trigger)
    hist.rebin = 1
    hist.x_label = labels[variable].label
    hist.y_label = "Efficiency"
    hist.format = 'png'  # file format for saving image
    hist.saveAs = outpath + "eff_" + filename  # save figure with name
    hist.CMSlabel = 'top left'  # 'top left', 'top right'; hack code for something else
    hist.CMSlabelStatus = 'Simulation Internal'  # ('Simulation')+'Internal' || 'Preliminary'

    #hist.extra_text.Add(text,coords[0,0])

    hist.initialize()

    # loop over variables to put on one plot