Ejemplo n.º 1
0
def main():
    # Set the ATLAS Style
    astyle.SetAtlasStyle()

    # Construct the canvas
    c1 = root.TCanvas("c1", "The FillRandom example", 0, 0, 800, 600)

    # Define a distribution
    form1 = root.TFormula("form1", "abs(sin(x)/x)")
    sqroot = root.TF1("sqroot", "x*gaus(0) + [3]*form1", 0, 10)
    sqroot.SetParameters(10, 4, 1, 20)

    # Randomly fill the histrogram according to the above distribution
    hist = root.TH1F("hist", "Test random numbers", 100, 0, 10)
    hist.FillRandom("sqroot", 10000)
    hist.Draw()

    # Set axis titles
    hist.GetXaxis().SetTitle("x axis")
    hist.GetYaxis().SetTitle("y axis")

    # Add the ATLAS Label
    astyle.ATLASLabel(0.2, 0.87, "Internal")

    # Save the plot as a PDF
    c1.Update()
    c1.Print("random_hist.pdf")
Ejemplo n.º 2
0
import logging, coloredlogs

logging.basicConfig()
log = logging.getLogger(__name__)
coloredlogs.install(level="INFO", logger=log)

from .runMatch import runlist_from_root, runMatch
from copy import deepcopy
import os
import numpy
import math

try:
    from atlasplots import atlas_style

    atlas_style.SetAtlasStyle()
except:
    pass
import ROOT
from array import array


class PlotSensor(object):
    def __init__(self, sensor_name):
        self.sensor_name = sensor_name
        self.plot_data = {}

    def add_plot_data(self, name, plot_data):
        self.plot_data[name] = plot_data

Ejemplo n.º 3
0
# Create output directory
outdir = make_outdir(params)

# Need to keep track of open files to read from TTree
open_files = []

# Load TTrees
for file in params['file']:
    # Replace the tree name with the tree itself
    # You can always get the name back with tree.GetName()
    tmp_file, file['tree'] = utils.GetTTree(file['name'], file['tree'])
    open_files.append(tmp_file)

# ---------- Loop over the set of kinematic variables and plot ---------- #

astyle.SetAtlasStyle()

for plot in params['plot']:
    if args.verbose:
        print("Creating plot {}".format(plot['name']))

    # Create canvas
    canv = root.TCanvas("canv_" + plot['name'], "", params['canvas']['w'],
                        params['canvas']['h'])

    # List of histograms in plot
    hists = []

    # ----- Loop over the files and get trees ----- #
    for file in params['file']:
        if args.verbose: