Example #1
0
                              help="Plot preview of fits",
                              action='store_true')
calo_init.parser.add_argument("--previewPhi",
                              help="Plot preview of phi distribution",
                              action='store_true')
calo_init.parser.add_argument("--specialLabel",
                              help="Additional label to be plotted",
                              type=str,
                              default="FCC-hh simulation")
calo_init.parse_args()
calo_init.print_config()

layer = calo_init.args.numLayers
if calo_init.args.simulation:
    ifActive = True
    activeNames, check = calo_init.substitute(calo_init.args.activeFile)
    print(activeNames)
else:
    ifActive = False
width = calo_init.args.layerWidth  # cm
if calo_init.args.roundBrackets:
    energyUnit = '(GeV)'
    angleUnit = '(rad)'
else:
    energyUnit = '[GeV]'
    angleUnit = '[rad]'

if len(calo_init.args.rebin) > 1:
    if len(calo_init.args.rebin) != len(calo_init.filenamesIn):
        print("Length of 'rebin' argument (", len(calo_init.args.rebin),
              ") is not equal to the number of input files(",
if calo_init.args.roundBrackets:
    energyUnit = '(GeV)'
else:
    energyUnit = '[GeV]'
if len(calo_init.args.histogramName) == 1:
    histogramNames = [calo_init.args.histogramName[0] for i in range (0, len(calo_init.filenamesIn))]
else:
    histogramNames = calo_init.args.histogramName
if len(histogramNames) > 1 and len(histogramNames) != len(calo_init.filenamesIn):
    print("If names of the histograms differ in each input file, the same amount of filenames and histogram names needs to be given.")
    exit()

if len(calo_init.args.legend) == 0:
    legend = ["" for i in range (0, len(calo_init.filenamesIn))]
elif len(calo_init.args.legend) == 1:
    legend, check = calo_init.substitute(calo_init.args.legend[0])
    legend = [leg + ": " for leg in legend]
else:
    legend = calo_init.args.legend
    legend = [leg + ": " for leg in legend]
print (legend)

from ROOT import gSystem, gROOT, TCanvas, TGraphErrors, TF1, gStyle, kRed, kBlue, kGray, TFile, TTree, TPad, TGaxis, gPad, TLine, kOrange, kGreen, SetOwnership
from draw_functions import prepare_histogram, prepare_divided_canvas,  prepare_single_canvas, draw_text, draw_1histogram
import numpy
gStyle.SetOptFit(0)
gStyle.SetOptStat(0)

colours = [ kRed + 2, 8, kGray + 3 , kOrange + 1 , 8, 9]
coloursFit = [kRed, kGreen+2, kGray+3, kOrange + 2 , kGreen + 2, kBlue + 2]
    "--bitfield",
    help=
    "Bitfield used to encode the IDs (from DD4hep xml, e.g. \"system:4,x:4,y:4\"",
    type=str)
calo_init.parse_args()

from math import pi, floor
# set of default parameters
maxEta = 1.79
nPhi = 629  # artificially increase by 1 (odd number) - to make plots look OK
dEta = 0.01
nEta = int(2 * maxEta / dEta + 1)
dPhi = 2 * pi / nPhi
nameClusterCollection = "caloClusters"
nameParticlesCollection = "GenParticles"
filenamesSim, checkRegexInSimInput = calo_init.substitute(
    calo_init.args.inputSim)

# get parameters if passed from command line
if calo_init.args.maxEta:
    maxEta = calo_init.args.maxEta
if calo_init.args.numPhi:
    nPhi = calo_init.args.numPhi
    dPhi = 2 * pi / nPhi
if calo_init.args.dPhi:
    dPhi = calo_init.args.dPhi
    nPhi = int(dPhi * 2 * pi)
if calo_init.args.clusterColl:
    nameClusterCollection = calo_init.args.clusterColl
if calo_init.args.particleColl:
    nameParticlesCollection = calo_init.args.particleColl
if calo_init.args.correctionParams and calo_init.args.cellColl and calo_init.args.bitfield:
# Draw graphs
graphsRes[0].Draw("aep")
for g in graphsRes[1:]:
    g.Draw("sameep")
if not calo_init.args.noLinearity:
    padLin.cd()
    graphsLin[0].Draw("aep")
    for g in graphsLin[1:]:
        g.Draw("sameep")

# Set proper names for the plot legend
if len(calo_init.args.legend) > 1:
    graphTitles = calo_init.args.legend
elif calo_init.args.legend:
    graphTitles, check = calo_init.substitute(calo_init.args.legend[0])
else:
    graphTitles=[]
for ileg, legend in enumerate(graphTitles):
    graphTitles[ileg] = legend.replace("formula","#frac{#sigma_{E}}{E} = #frac{"+str(round(samplTerm[ileg]*100.,2))+"%}{#sqrt{E}} #oplus "+str(abs(round(constTerm[ileg]*100.,2)))+"%")
graphTitles = ['#color['+str(colour[i])+']{'+t+'}' for i,t in enumerate(graphTitles)]

# Draw all labels
if not calo_init.args.noLinearity:
    padRes.cd()
    draw_text(graphTitles, [0.4,0.85 - 0.07 * len(graphTitles),0.95,0.95], 1, 0).SetTextSize(0.04)
else:
    draw_text(graphTitles, [0.3,0.8 - 0.07 * len(graphTitles),0.95,0.86], 1, 0).SetTextSize(0.04)
if not (calo_init.args.noLinearity and calo_init.args.title):
    draw_text(["energy resolution"], [0.2,0.88, 0.4,0.98], 1, 0).SetTextSize(0.05)
else:
calo_init.parser.add_argument("--rebin", help="Rebin profile (one value common for all energies or multiple values for each energy)", default = [1], type = int, nargs='+')
calo_init.parser.add_argument("--fitRangeUp", help="Range for the fitting (multiple values for each energy)", default = [], type = float, nargs='+')
calo_init.parser.add_argument("--fitRangeDown", help="Range for the fitting (multiple values for each energy)", default = [], type = float, nargs='+')
calo_init.parser.add_argument("-n","--histogramName", default="upstreamEnergy_presamplerEnergy2D", help="Name of the histogram with the histogram of energy in first layer (X-axis) and the upstrem energy (Y-axis)", type = str)
calo_init.parser.add_argument("--layerWidth", default = 0.5, help="Width of the layer (cm)", type = float)
calo_init.parser.add_argument("--roundBrackets", help="Use round brackets for unit", action = 'store_true')
calo_init.parser.add_argument("--preview", help="Plot preview of fits", action = 'store_true')
calo_init.parser.add_argument("--previewPhi", help="Plot preview of phi distribution", action = 'store_true')
calo_init.parser.add_argument("--specialLabel", help="Additional label to be plotted", type=str, default = "FCC-hh simulation")
calo_init.parse_args()
calo_init.print_config()

layer = calo_init.args.numLayers
if calo_init.args.simulation:
    ifActive = True
    activeNames, check = calo_init.substitute(calo_init.args.activeFile)
    print(activeNames)
else:
    ifActive = False
width = calo_init.args.layerWidth  # cm
if calo_init.args.roundBrackets:
    energyUnit = '(GeV)'
    angleUnit = '(rad)'
else:
    energyUnit = '[GeV]'
    angleUnit = '[rad]'

if len(calo_init.args.rebin) > 1:
    if len(calo_init.args.rebin) != len(calo_init.filenamesIn):
        print("Length of 'rebin' argument (",len(calo_init.args.rebin),") is not equal to the number of input files(",len(calo_init.filenamesIn),")")
        exit()
Example #6
0
# Draw graphs
graphsRes[0].Draw("aep")
for g in graphsRes[1:]:
    g.Draw("sameep")
if not calo_init.args.noLinearity:
    padLin.cd()
    graphsLin[0].Draw("aep")
    for g in graphsLin[1:]:
        g.Draw("sameep")

# Set proper names for the plot legend
if len(calo_init.args.legend) > 1:
    graphTitles = calo_init.args.legend
elif calo_init.args.legend:
    graphTitles, check = calo_init.substitute(calo_init.args.legend[0])
else:
    graphTitles = []
for ileg, legend in enumerate(graphTitles):
    graphTitles[ileg] = legend.replace(
        "formula", "#frac{#sigma_{E}}{E} = #frac{" +
        str(round(samplTerm[ileg] * 100., 2)) + "%}{#sqrt{E}} + " +
        str(round(constTerm[ileg] * 100., 2)) + "%")
graphTitles = [
    '#color[' + str(colour[i]) + ']{' + t + '}'
    for i, t in enumerate(graphTitles)
]

# Draw all labels
if not calo_init.args.noLinearity:
    padRes.cd()
calo_init.parser.add_argument("--cellColl", help="Name of the cells collection (fcc::CaloHitCollection) for the upstream energy correction", type = str)
calo_init.parser.add_argument("--correctionParams", help="Parameters for the upstream energy correction", type = float, nargs=4)
calo_init.parser.add_argument("--bitfield", help="Bitfield used to encode the IDs (from DD4hep xml, e.g. \"system:4,x:4,y:4\"", type = str)
calo_init.parse_args()

from math import pi, floor
# set of default parameters
maxEta = 1.716
maxPhi = pi-(pi/512.)
nPhi = 629 # artificially increase by 1 (odd number) - to make plots look OK
dEta = 0.01
nEta = int(2*maxEta/dEta + 1)
dPhi = 2*pi/nPhi
nameClusterCollection = "caloClusters"
nameParticlesCollection = "GenParticles"
filenamesSim, checkRegexInSimInput = calo_init.substitute(calo_init.args.inputSim)

# get parameters if passed from command line
if calo_init.args.maxEta:
    maxEta = calo_init.args.maxEta
if calo_init.args.numPhi:
    nPhi = calo_init.args.numPhi
    dPhi = 2*pi/nPhi
if calo_init.args.dPhi:
    dPhi = calo_init.args.dPhi
    nPhi = int(dPhi*2*pi)
if calo_init.args.clusterColl:
    nameClusterCollection = calo_init.args.clusterColl
if calo_init.args.particleColl:
    nameParticlesCollection = calo_init.args.particleColl
if calo_init.args.correctionParams and calo_init.args.cellColl and calo_init.args.bitfield:
Example #8
0
        calo_init.args.histogramName[0]
        for i in range(0, len(calo_init.filenamesIn))
    ]
else:
    histogramNames = calo_init.args.histogramName
if len(histogramNames) > 1 and len(histogramNames) != len(
        calo_init.filenamesIn):
    print(
        "If names of the histograms differ in each input file, the same amount of filenames and histogram names needs to be given."
    )
    exit()

if len(calo_init.args.legend) == 0:
    legend = ["" for i in range(0, len(calo_init.filenamesIn))]
elif len(calo_init.args.legend) == 1:
    legend, check = calo_init.substitute(calo_init.args.legend[0])
    legend = [leg + ": " for leg in legend]
else:
    legend = calo_init.args.legend
    legend = [leg + ": " for leg in legend]
print(legend)

from ROOT import gSystem, gROOT, TCanvas, TGraphErrors, TF1, gStyle, kRed, kBlue, kGray, TFile, TTree, TPad, TGaxis, gPad, TLine, kOrange, kGreen, SetOwnership
from draw_functions import prepare_histogram, prepare_divided_canvas, prepare_single_canvas, draw_text, draw_1histogram
import numpy

gStyle.SetOptFit(0)
gStyle.SetOptStat(0)

colours = [kRed + 2, 8, kGray + 3, kOrange + 1, 8, 9]
coloursFit = [kRed, kGreen + 2, kGray + 3, kOrange + 2, kGreen + 2, kBlue + 2]