endvelo p
This commit is contained in:
parent
bb73083251
commit
b6c3791bdf
BIN
data_results/CompareBEndVelo.root
Normal file
BIN
data_results/CompareBEndVelo.root
Normal file
Binary file not shown.
BIN
data_results/CompareBEndVeloDefault.root
Normal file
BIN
data_results/CompareBEndVeloDefault.root
Normal file
Binary file not shown.
BIN
data_results/CompareBEndVeloElectron.root
Normal file
BIN
data_results/CompareBEndVeloElectron.root
Normal file
Binary file not shown.
Binary file not shown.
BIN
data_results/PrCheckerBEndVeloDefault.root
Normal file
BIN
data_results/PrCheckerBEndVeloDefault.root
Normal file
Binary file not shown.
@ -36,11 +36,11 @@ from RecoConf.hlt1_tracking import (
|
|||||||
get_global_materiallocator,
|
get_global_materiallocator,
|
||||||
)
|
)
|
||||||
|
|
||||||
decay = "test"
|
decay = "B"
|
||||||
|
|
||||||
options.evt_max = 1
|
options.evt_max = -1
|
||||||
|
|
||||||
options.ntuple_file = f"data/resolutions_and_effs_{decay}_endVelo_idealstateP.root"
|
options.ntuple_file = f"data/resolutions_and_effs_{decay}_EndVeloP.root"
|
||||||
options.input_type = "ROOT"
|
options.input_type = "ROOT"
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ elif decay == "test":
|
|||||||
options.dddb_tag = "dddb-20210617"
|
options.dddb_tag = "dddb-20210617"
|
||||||
options.conddb_tag = "sim-20210617-vc-md100"
|
options.conddb_tag = "sim-20210617-vc-md100"
|
||||||
options.simulation = True
|
options.simulation = True
|
||||||
options.output_level = 2
|
options.output_level = 3
|
||||||
|
|
||||||
|
|
||||||
def run_tracking_resolution():
|
def run_tracking_resolution():
|
||||||
@ -92,19 +92,19 @@ def run_tracking_resolution():
|
|||||||
LinksToLHCbIDs=links_to_lhcbids,
|
LinksToLHCbIDs=links_to_lhcbids,
|
||||||
)
|
)
|
||||||
|
|
||||||
# res_checker_forward = check_track_resolution(tracks["Forward"], suffix="Forward")
|
res_checker_forward = check_track_resolution(tracks["Forward"], suffix="Forward")
|
||||||
# res_checker_best_long = check_track_resolution(
|
res_checker_best_long = check_track_resolution(
|
||||||
# tracks["BestLong"],
|
tracks["BestLong"],
|
||||||
# suffix="BestLong",
|
suffix="BestLong",
|
||||||
# )
|
)
|
||||||
# res_checker_best_forward = check_track_resolution(
|
res_checker_best_forward = check_track_resolution(
|
||||||
# dict(v1=fitted_forward_tracks),
|
dict(v1=fitted_forward_tracks),
|
||||||
# suffix="BestForward",
|
suffix="BestForward",
|
||||||
# )
|
)
|
||||||
# res_checker_seed = check_track_resolution(
|
res_checker_seed = check_track_resolution(
|
||||||
# tracks["Seed"],
|
tracks["Seed"],
|
||||||
# suffix="Seed",
|
suffix="Seed",
|
||||||
# )
|
)
|
||||||
|
|
||||||
eff_checker_forward = check_tracking_efficiency(
|
eff_checker_forward = check_tracking_efficiency(
|
||||||
"Forward",
|
"Forward",
|
||||||
@ -140,10 +140,10 @@ def run_tracking_resolution():
|
|||||||
)
|
)
|
||||||
|
|
||||||
data = [
|
data = [
|
||||||
# res_checker_forward,
|
res_checker_forward,
|
||||||
# res_checker_best_long,
|
res_checker_best_long,
|
||||||
# res_checker_best_forward,
|
res_checker_best_forward,
|
||||||
# res_checker_seed,
|
res_checker_seed,
|
||||||
eff_checker_forward,
|
eff_checker_forward,
|
||||||
eff_checker_match,
|
eff_checker_match,
|
||||||
eff_checker_best_long,
|
eff_checker_best_long,
|
||||||
|
@ -58,7 +58,7 @@ options.dddb_tag = "dddb-20210617"
|
|||||||
options.simulation = True
|
options.simulation = True
|
||||||
options.input_type = "ROOT"
|
options.input_type = "ROOT"
|
||||||
|
|
||||||
options.ntuple_file = f"data/tracking_losses_ntuple_{decay}_endVelo_idealstateP.root"
|
options.ntuple_file = f"data/tracking_losses_ntuple_{decay}_EndVeloP.root"
|
||||||
|
|
||||||
|
|
||||||
def run_tracking_losses():
|
def run_tracking_losses():
|
||||||
|
866
scripts/BakCompareEfficiency.py
Normal file
866
scripts/BakCompareEfficiency.py
Normal file
@ -0,0 +1,866 @@
|
|||||||
|
# flake8: noqa
|
||||||
|
|
||||||
|
"""
|
||||||
|
Script for accessing histograms of reconstructible and
|
||||||
|
reconstructed tracks for different tracking categories
|
||||||
|
and trackers.
|
||||||
|
|
||||||
|
The efficency is calculated usig TGraphAsymmErrors
|
||||||
|
and Bayesian error bars
|
||||||
|
|
||||||
|
author: Furkan Cetin
|
||||||
|
date: 10/2023
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Takes data from Recent_get_resolution_and_eff_data.py and calculates efficiencies
|
||||||
|
|
||||||
|
python scripts/CompareEfficiency.py
|
||||||
|
--filename data/res_and_effs_B.root data/resolutions_and_effs_Bd2KstEE_MDmaster.root
|
||||||
|
--trackers Match --label new old --outfile data/compare_effs.root
|
||||||
|
|
||||||
|
python scripts/CompareEfficiency.py --filename data/resolutions_and_effs_D_default_weights.root data/resolutions_and_effs_D_with_electron_weights_as_residual.root --trackers BestLong Seed --label default new --outfile data_results/CompareEfficiencyDDefaultResidual.root
|
||||||
|
|
||||||
|
recreate: defaultresidual, electronresidual, residual
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os, sys
|
||||||
|
import argparse
|
||||||
|
from ROOT import TMultiGraph, TLatex, TCanvas, TFile, TGaxis
|
||||||
|
from ROOT import (
|
||||||
|
kGreen,
|
||||||
|
kBlue,
|
||||||
|
kBlack,
|
||||||
|
kAzure,
|
||||||
|
kGray,
|
||||||
|
kOrange,
|
||||||
|
kMagenta,
|
||||||
|
kCyan,
|
||||||
|
kViolet,
|
||||||
|
kTeal,
|
||||||
|
kRed,
|
||||||
|
)
|
||||||
|
from ROOT import gROOT, gStyle, gPad
|
||||||
|
from ROOT import TEfficiency
|
||||||
|
from array import array
|
||||||
|
|
||||||
|
|
||||||
|
gROOT.SetBatch(True)
|
||||||
|
|
||||||
|
from utils.components import unique_name_ext_re, findRootObjByName
|
||||||
|
|
||||||
|
|
||||||
|
def getEfficiencyHistoNames():
|
||||||
|
return ["p", "pt", "phi", "eta", "nPV"]
|
||||||
|
|
||||||
|
|
||||||
|
def getTrackers(trackers):
|
||||||
|
return trackers
|
||||||
|
|
||||||
|
|
||||||
|
def getCompCuts(compare_cuts):
|
||||||
|
return compare_cuts
|
||||||
|
|
||||||
|
|
||||||
|
# data/resolutions_and_effs_Bd2KstEE_MDmaster.root:Track/...
|
||||||
|
def getOriginFolders():
|
||||||
|
basedict = {
|
||||||
|
"Velo": {},
|
||||||
|
"Upstream": {},
|
||||||
|
"Forward": {},
|
||||||
|
"Match": {},
|
||||||
|
"MergedMatch": {},
|
||||||
|
"DefaultMatch": {},
|
||||||
|
"BestLong": {},
|
||||||
|
"Seed": {},
|
||||||
|
}
|
||||||
|
# evtl anpassen wenn die folders anders heissen
|
||||||
|
basedict["Velo"]["folder"] = "VeloTrackChecker/"
|
||||||
|
basedict["Upstream"]["folder"] = "UpstreamTrackChecker/"
|
||||||
|
basedict["Forward"]["folder"] = "ForwardTrackChecker" + unique_name_ext_re() + "/"
|
||||||
|
basedict["Match"]["folder"] = "MatchTrackChecker" + unique_name_ext_re() + "/"
|
||||||
|
basedict["MergedMatch"]["folder"] = (
|
||||||
|
"MergedMatchTrackChecker" + unique_name_ext_re() + "/"
|
||||||
|
)
|
||||||
|
basedict["DefaultMatch"]["folder"] = (
|
||||||
|
"DefaultMatchTrackChecker" + unique_name_ext_re() + "/"
|
||||||
|
)
|
||||||
|
basedict["BestLong"]["folder"] = "BestLongTrackChecker" + unique_name_ext_re() + "/"
|
||||||
|
basedict["Seed"]["folder"] = "SeedTrackChecker" + unique_name_ext_re() + "/"
|
||||||
|
|
||||||
|
# basedict["Forward"]["folder"] = "ForwardTrackChecker_7a0dbfa7/"
|
||||||
|
# basedict["Match"]["folder"] = "MatchTrackChecker_29e3152a/"
|
||||||
|
# basedict["BestLong"]["folder"] = "BestLongTrackChecker_4ddacce1/"
|
||||||
|
# basedict["Seed"]["folder"] = "SeedTrackChecker_1b1d5575/"
|
||||||
|
|
||||||
|
return basedict
|
||||||
|
|
||||||
|
|
||||||
|
def getTrackNames():
|
||||||
|
basedict = {
|
||||||
|
"Velo": {},
|
||||||
|
"Upstream": {},
|
||||||
|
"Forward": {},
|
||||||
|
"Match": {},
|
||||||
|
"MergedMatch": {},
|
||||||
|
"DefaultMatch": {},
|
||||||
|
"BestLong": {},
|
||||||
|
"Seed": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
basedict["Velo"] = "Velo"
|
||||||
|
basedict["Upstream"] = "VeloUT"
|
||||||
|
basedict["Forward"] = "Forward"
|
||||||
|
basedict["Match"] = "Match"
|
||||||
|
basedict["MergedMatch"] = "MergedMatch"
|
||||||
|
basedict["DefaultMatch"] = "DefaultMatch"
|
||||||
|
basedict["BestLong"] = "BestLong"
|
||||||
|
basedict["Seed"] = "Seed"
|
||||||
|
return basedict
|
||||||
|
|
||||||
|
|
||||||
|
def get_colors():
|
||||||
|
return [kBlack, kAzure, kGreen + 2, kMagenta + 2, kRed, kCyan + 2, kGray + 1]
|
||||||
|
|
||||||
|
|
||||||
|
def get_elec_colors():
|
||||||
|
return [
|
||||||
|
kGray + 2,
|
||||||
|
kBlue - 3,
|
||||||
|
kRed + 1,
|
||||||
|
kGreen + 1,
|
||||||
|
kViolet,
|
||||||
|
kTeal - 1,
|
||||||
|
kOrange + 8,
|
||||||
|
kGray + 1,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_markers():
|
||||||
|
return [20, 21, 24, 25, 22, 23, 26, 32]
|
||||||
|
|
||||||
|
|
||||||
|
def get_fillstyles():
|
||||||
|
return [1003, 3001, 3002, 3325, 3144, 3244, 3444]
|
||||||
|
|
||||||
|
|
||||||
|
def getGhostHistoNames():
|
||||||
|
basedict = {
|
||||||
|
# "Velo": {},
|
||||||
|
# "Upstream": {},
|
||||||
|
"Forward": {},
|
||||||
|
"Match": {},
|
||||||
|
"MergedMatch": {},
|
||||||
|
"DefaultMatch": {},
|
||||||
|
"BestLong": {},
|
||||||
|
"Seed": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
basedict["Velo"] = ["eta", "nPV"]
|
||||||
|
basedict["Upstream"] = ["eta", "p", "pt", "nPV"]
|
||||||
|
basedict["Forward"] = ["eta", "p", "pt", "nPV"]
|
||||||
|
basedict["Match"] = ["eta", "p", "pt", "nPV"]
|
||||||
|
basedict["MergedMatch"] = basedict["Match"]
|
||||||
|
basedict["DefaultMatch"] = basedict["Match"]
|
||||||
|
basedict["BestLong"] = ["eta", "p", "pt", "nPV"]
|
||||||
|
basedict["Seed"] = ["eta", "p", "pt", "nPV"]
|
||||||
|
|
||||||
|
return basedict
|
||||||
|
|
||||||
|
|
||||||
|
def argument_parser():
|
||||||
|
parser = argparse.ArgumentParser(description="location of the tuple file")
|
||||||
|
parser.add_argument(
|
||||||
|
"--filename",
|
||||||
|
type=str,
|
||||||
|
default=["data/resolutions_and_effs_B.root"],
|
||||||
|
nargs="+",
|
||||||
|
help="input files, including path",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--outfile",
|
||||||
|
type=str,
|
||||||
|
default="data_results/compare_efficiency.root",
|
||||||
|
help="output file",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--trackers",
|
||||||
|
type=str,
|
||||||
|
nargs="+",
|
||||||
|
default=["Match", "BestLong", "Seed"], # Forward
|
||||||
|
help="Trackers to plot.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--label",
|
||||||
|
nargs="+",
|
||||||
|
default=["Eff"],
|
||||||
|
help="label for files",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--savepdf",
|
||||||
|
action="store_true",
|
||||||
|
help="save plots in pdf format",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--compare",
|
||||||
|
default=True,
|
||||||
|
action="store_true",
|
||||||
|
help="compare efficiencies",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--compare-cuts",
|
||||||
|
type=str,
|
||||||
|
nargs="+",
|
||||||
|
default=["long", "long_fromB", "long_fromB_P>5GeV"],
|
||||||
|
help="which cuts get compared",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--plot-electrons",
|
||||||
|
default=True,
|
||||||
|
action="store_true",
|
||||||
|
help="plot electrons",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--plot-electrons-only",
|
||||||
|
action="store_true",
|
||||||
|
help="plot only electrons",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--plot-velo",
|
||||||
|
action="store_true",
|
||||||
|
help="plot using momentum at EndVelo",
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def get_files(tf, filename, label):
|
||||||
|
for i, f in enumerate(filename):
|
||||||
|
tf[label[i]] = TFile(f, "read")
|
||||||
|
return tf
|
||||||
|
|
||||||
|
|
||||||
|
def get_nicer_var_string(var: str):
|
||||||
|
nice_vars = dict(pt="p_{T}", eta="#eta", phi="#phi")
|
||||||
|
try:
|
||||||
|
return nice_vars[var]
|
||||||
|
except KeyError:
|
||||||
|
return var
|
||||||
|
|
||||||
|
|
||||||
|
def get_eff(eff, hist, tf, histoName, label, var):
|
||||||
|
eff = {}
|
||||||
|
hist = {}
|
||||||
|
var = get_nicer_var_string(var)
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
numeratorName = histoName + "_reconstructed"
|
||||||
|
numerator = findRootObjByName(tf[lab], numeratorName)
|
||||||
|
denominatorName = histoName + "_reconstructible"
|
||||||
|
denominator = findRootObjByName(tf[lab], denominatorName)
|
||||||
|
if numerator.GetEntries() == 0 or denominator.GetEntries() == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
teff = TEfficiency(numerator, denominator)
|
||||||
|
teff.SetStatisticOption(7)
|
||||||
|
eff[lab] = teff.CreateGraph()
|
||||||
|
eff[lab].SetName(lab)
|
||||||
|
eff[lab].SetTitle(lab)
|
||||||
|
if histoName.find("Forward") != -1:
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
eff[lab].SetTitle(lab + " Forward, e^{-}")
|
||||||
|
else:
|
||||||
|
eff[lab].SetTitle(lab + " Forward")
|
||||||
|
if histoName.find("Merged") != -1:
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
eff[lab].SetTitle(lab + " MergedMatch, e^{-}")
|
||||||
|
else:
|
||||||
|
eff[lab].SetTitle(lab + " MergedMatch")
|
||||||
|
elif histoName.find("DefaultMatch") != -1:
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
eff[lab].SetTitle(lab + " DefaultMatch, e^{-}")
|
||||||
|
else:
|
||||||
|
eff[lab].SetTitle(lab + " DefaultMatch")
|
||||||
|
elif histoName.find("Match") != -1:
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
eff[lab].SetTitle(lab + " Match, e^{-}")
|
||||||
|
else:
|
||||||
|
eff[lab].SetTitle(lab + " Match")
|
||||||
|
if histoName.find("Seed") != -1:
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
eff[lab].SetTitle(lab + " Seed, e^{-}")
|
||||||
|
else:
|
||||||
|
eff[lab].SetTitle(lab + " Seed")
|
||||||
|
if histoName.find("BestLong") != -1:
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
eff[lab].SetTitle(lab + " BestLong, e^{-}")
|
||||||
|
else:
|
||||||
|
eff[lab].SetTitle(lab + " BestLong")
|
||||||
|
if histoName.find("EndVelo") != -1:
|
||||||
|
eff[lab].SetTitle(eff[lab].GetTitle() + " EndVelo")
|
||||||
|
|
||||||
|
hist[lab] = denominator.Clone()
|
||||||
|
hist[lab].SetName("h_numerator_notElectrons")
|
||||||
|
hist[lab].SetTitle(var + " distribution, not e^{-}")
|
||||||
|
if histoName.find("strange") != -1:
|
||||||
|
hist[lab].SetTitle(var + " distribution, stranges")
|
||||||
|
if histoName.find("electron") != -1:
|
||||||
|
hist[lab].SetTitle(var + " distribution, e^{-}")
|
||||||
|
if histoName.find("EndVelo") != -1:
|
||||||
|
hist[lab].SetTitle(hist[lab].GetTitle() + ", EndVelo")
|
||||||
|
|
||||||
|
return eff, hist
|
||||||
|
|
||||||
|
|
||||||
|
def get_ghost(eff, hist, tf, histoName, label):
|
||||||
|
ghost = {}
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
numeratorName = histoName + "_Ghosts"
|
||||||
|
denominatorName = histoName + "_Total"
|
||||||
|
numerator = findRootObjByName(tf[lab], numeratorName)
|
||||||
|
denominator = findRootObjByName(tf[lab], denominatorName)
|
||||||
|
print("Numerator = " + numeratorName.replace(unique_name_ext_re(), ""))
|
||||||
|
print("Denominator = " + denominatorName.replace(unique_name_ext_re(), ""))
|
||||||
|
teff = TEfficiency(numerator, denominator)
|
||||||
|
teff.SetStatisticOption(7)
|
||||||
|
ghost[lab] = teff.CreateGraph()
|
||||||
|
print(lab)
|
||||||
|
ghost[lab].SetName(lab)
|
||||||
|
|
||||||
|
return ghost
|
||||||
|
|
||||||
|
|
||||||
|
def PrCheckerEfficiency(
|
||||||
|
filename,
|
||||||
|
outfile,
|
||||||
|
label,
|
||||||
|
trackers,
|
||||||
|
savepdf,
|
||||||
|
compare,
|
||||||
|
compare_cuts,
|
||||||
|
plot_electrons,
|
||||||
|
plot_electrons_only,
|
||||||
|
plot_velo,
|
||||||
|
):
|
||||||
|
from utils.LHCbStyle import setLHCbStyle, set_style
|
||||||
|
from utils.ConfigHistos import (
|
||||||
|
efficiencyHistoDict,
|
||||||
|
ghostHistoDict,
|
||||||
|
categoriesDict,
|
||||||
|
getCuts,
|
||||||
|
)
|
||||||
|
from utils.CompareConfigHistos import getCompare, getCompColors
|
||||||
|
from utils.Legend import place_legend
|
||||||
|
|
||||||
|
setLHCbStyle()
|
||||||
|
|
||||||
|
markers = get_markers()
|
||||||
|
colors = get_colors()
|
||||||
|
elec_colors = get_elec_colors()
|
||||||
|
styles = get_fillstyles()
|
||||||
|
|
||||||
|
tf = {}
|
||||||
|
tf = get_files(tf, filename, label)
|
||||||
|
outputfile = TFile(outfile, "recreate")
|
||||||
|
|
||||||
|
latex = TLatex()
|
||||||
|
latex.SetNDC()
|
||||||
|
latex.SetTextSize(0.05)
|
||||||
|
|
||||||
|
efficiencyHistoDict = efficiencyHistoDict()
|
||||||
|
efficiencyHistos = getEfficiencyHistoNames()
|
||||||
|
ghostHistos = getGhostHistoNames()
|
||||||
|
ghostHistoDict = ghostHistoDict()
|
||||||
|
categories = categoriesDict()
|
||||||
|
cuts = getCuts()
|
||||||
|
compareDict = getCompare()
|
||||||
|
compareCuts = getCompCuts(compare_cuts)
|
||||||
|
compareColors = getCompColors()
|
||||||
|
compareGhostHisto = ["eta", "p", "pt", "nPV"]
|
||||||
|
trackers = getTrackers(trackers)
|
||||||
|
folders = getOriginFolders()
|
||||||
|
|
||||||
|
for tracker in trackers:
|
||||||
|
outputfile.cd()
|
||||||
|
trackerDir = outputfile.mkdir(tracker)
|
||||||
|
trackerDir.cd()
|
||||||
|
|
||||||
|
for cut in cuts[tracker]:
|
||||||
|
cutDir = trackerDir.mkdir(cut)
|
||||||
|
cutDir.cd()
|
||||||
|
folder = folders[tracker]["folder"]
|
||||||
|
print("folder: " + folder.replace(unique_name_ext_re(), ""))
|
||||||
|
histoBaseName = "Track/" + folder + tracker + "/" + cut + "_"
|
||||||
|
|
||||||
|
# calculate efficiency
|
||||||
|
for histo in efficiencyHistos:
|
||||||
|
canvastitle = (
|
||||||
|
"efficiency_" + histo + ", " + categories[tracker][cut]["title"]
|
||||||
|
)
|
||||||
|
# get efficiency for not electrons category
|
||||||
|
histoName = histoBaseName + "" + efficiencyHistoDict[histo]["variable"]
|
||||||
|
print("not electrons: " + histoName.replace(unique_name_ext_re(), ""))
|
||||||
|
eff = {}
|
||||||
|
hist_den = {}
|
||||||
|
eff, hist_den = get_eff(eff, hist_den, tf, histoName, label, histo)
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
histoNameElec = (
|
||||||
|
"Track/"
|
||||||
|
+ folder
|
||||||
|
+ tracker
|
||||||
|
+ "/"
|
||||||
|
+ categories[tracker][cut]["Electrons"]
|
||||||
|
)
|
||||||
|
histoName_e = (
|
||||||
|
histoNameElec + "_" + efficiencyHistoDict[histo]["variable"]
|
||||||
|
)
|
||||||
|
print("electrons: " + histoName_e.replace(unique_name_ext_re(), ""))
|
||||||
|
eff_elec = {}
|
||||||
|
hist_elec = {}
|
||||||
|
eff_elec, hist_elec = get_eff(
|
||||||
|
eff_elec,
|
||||||
|
hist_elec,
|
||||||
|
tf,
|
||||||
|
histoName_e,
|
||||||
|
label,
|
||||||
|
histo,
|
||||||
|
)
|
||||||
|
name = "efficiency_" + histo
|
||||||
|
canvas = TCanvas(name, canvastitle)
|
||||||
|
canvas.SetRightMargin(0.1)
|
||||||
|
mg = TMultiGraph()
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
if not plot_electrons_only:
|
||||||
|
mg.Add(eff[lab])
|
||||||
|
set_style(eff[lab], colors[i], markers[i], styles[i])
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
mg.Add(eff_elec[lab])
|
||||||
|
set_style(eff_elec[lab], elec_colors[i], markers[i], styles[i])
|
||||||
|
|
||||||
|
mg.Draw("AP")
|
||||||
|
mg.GetYaxis().SetRangeUser(0, 1.05)
|
||||||
|
xtitle = efficiencyHistoDict[histo]["xTitle"]
|
||||||
|
unit_l = xtitle.split("[")
|
||||||
|
if "]" in unit_l[-1]:
|
||||||
|
unit = unit_l[-1].replace("]", "")
|
||||||
|
else:
|
||||||
|
unit = "a.u."
|
||||||
|
print(unit)
|
||||||
|
mg.GetXaxis().SetTitle(xtitle)
|
||||||
|
mg.GetXaxis().SetTitleSize(0.06)
|
||||||
|
mg.GetYaxis().SetTitle(
|
||||||
|
"Efficiency of Long Tracks",
|
||||||
|
) # (" + str(round(hist_den[label[0]].GetBinWidth(1), 2)) + f"{unit})"+"^{-1}")
|
||||||
|
mg.GetYaxis().SetTitleSize(0.06)
|
||||||
|
mg.GetYaxis().SetTitleOffset(1.1)
|
||||||
|
mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
|
||||||
|
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
||||||
|
mygray = 18
|
||||||
|
myblue = kBlue - 9
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
rightmax = 1.05 * hist_den[lab].GetMaximum()
|
||||||
|
scale = gPad.GetUymax() / rightmax
|
||||||
|
hist_den[lab].Scale(scale)
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
rightmax = 1.05 * hist_elec[lab].GetMaximum()
|
||||||
|
scale = gPad.GetUymax() / rightmax
|
||||||
|
hist_elec[lab].Scale(scale)
|
||||||
|
if i == 0:
|
||||||
|
if not plot_electrons_only:
|
||||||
|
set_style(hist_den[lab], mygray, markers[i], styles[i])
|
||||||
|
gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
|
hist_den[lab].Draw("HIST PLC SAME")
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
set_style(hist_elec[lab], myblue, markers[i], styles[i])
|
||||||
|
hist_elec[lab].SetFillColorAlpha(myblue, 0.35)
|
||||||
|
hist_elec[lab].Draw("HIST PLC SAME")
|
||||||
|
# else:
|
||||||
|
# print(
|
||||||
|
# "No distribution plotted for other labels.",
|
||||||
|
# "Can be added by uncommenting the code below this print statement.",
|
||||||
|
# )
|
||||||
|
# # set_style(hist_den[lab], mygray, markers[i], styles[i])
|
||||||
|
# # gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
|
# # hist_den[lab].Draw("HIST PLC SAME")
|
||||||
|
|
||||||
|
# if histo == "p":
|
||||||
|
# pos = [0.5, 0.3, 1.0, 0.6]
|
||||||
|
# elif histo == "pt":
|
||||||
|
# pos = [0.5, 0.3, 0.99, 0.6]
|
||||||
|
# elif histo == "phi":
|
||||||
|
# pos = [0.3, 0.25, 0.8, 0.55]
|
||||||
|
# else:
|
||||||
|
# pos = [0.3, 0.25, 0.8, 0.55]
|
||||||
|
|
||||||
|
if histo == "p":
|
||||||
|
pos = [0.5, 0.3, 1.0, 0.5] # [0.53, 0.4, 1.01, 0.71]
|
||||||
|
elif histo == "pt":
|
||||||
|
pos = [0.5, 0.3, 0.99, 0.5] # [0.5, 0.4, 0.98, 0.71]
|
||||||
|
elif histo == "phi":
|
||||||
|
pos = [0.4, 0.3, 0.9, 0.5]
|
||||||
|
elif histo == "eta":
|
||||||
|
pos = [0.5, 0.25, 1.0, 0.45]
|
||||||
|
else:
|
||||||
|
pos = [0.35, 0.25, 0.85, 0.45]
|
||||||
|
|
||||||
|
legend = place_legend(
|
||||||
|
canvas, *pos, header="LHCb Simulation", option="LPE"
|
||||||
|
)
|
||||||
|
for le in legend.GetListOfPrimitives():
|
||||||
|
if "distribution" in le.GetLabel():
|
||||||
|
le.SetOption("LF")
|
||||||
|
legend.SetTextFont(132)
|
||||||
|
legend.SetTextSize(0.04)
|
||||||
|
legend.Draw()
|
||||||
|
for lab in label:
|
||||||
|
if not plot_electrons_only:
|
||||||
|
eff[lab].Draw("P SAME")
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
eff_elec[lab].Draw("P SAME")
|
||||||
|
cutName = categories[tracker][cut]["title"]
|
||||||
|
latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
|
||||||
|
low = 0
|
||||||
|
high = 1.05
|
||||||
|
gPad.Update()
|
||||||
|
axis = TGaxis(
|
||||||
|
gPad.GetUxmax(),
|
||||||
|
gPad.GetUymin(),
|
||||||
|
gPad.GetUxmax(),
|
||||||
|
gPad.GetUymax(),
|
||||||
|
low,
|
||||||
|
high,
|
||||||
|
510,
|
||||||
|
"+U",
|
||||||
|
)
|
||||||
|
axis.SetTitleFont(132)
|
||||||
|
axis.SetTitleSize(0.06)
|
||||||
|
axis.SetTitleOffset(0.55)
|
||||||
|
axis.SetTitle(
|
||||||
|
"# Tracks " + get_nicer_var_string(histo) + " distribution [a.u.]",
|
||||||
|
)
|
||||||
|
axis.SetLabelSize(0)
|
||||||
|
axis.Draw()
|
||||||
|
# canvas.RedrawAxis()
|
||||||
|
if savepdf and (1 == 0):
|
||||||
|
filestypes = ["pdf"] # , "pdf", "eps", "C", "ps", "tex"]
|
||||||
|
for ftype in filestypes:
|
||||||
|
if not plot_electrons_only:
|
||||||
|
canvasName = tracker + "_" + cut + "_" + histo + "." + ftype
|
||||||
|
else:
|
||||||
|
canvasName = (
|
||||||
|
tracker
|
||||||
|
+ "_Electrons_"
|
||||||
|
+ cut
|
||||||
|
+ "_"
|
||||||
|
+ histo
|
||||||
|
+ "."
|
||||||
|
+ ftype
|
||||||
|
)
|
||||||
|
canvas.SaveAs("checks/" + canvasName)
|
||||||
|
# canvas.SetRightMargin(0.05)
|
||||||
|
canvas.Write()
|
||||||
|
|
||||||
|
# calculate ghost rate
|
||||||
|
print("\ncalculate ghost rate: ")
|
||||||
|
histoBaseName = "Track/" + folder + tracker + "/"
|
||||||
|
for histo in ghostHistos[tracker]:
|
||||||
|
trackerDir.cd()
|
||||||
|
title = "ghost_rate_vs_" + histo
|
||||||
|
|
||||||
|
gPad.SetTicks()
|
||||||
|
histoName = histoBaseName + ghostHistoDict[histo]["variable"]
|
||||||
|
|
||||||
|
ghost = {}
|
||||||
|
hist_den = {}
|
||||||
|
ghost = get_ghost(ghost, hist_den, tf, histoName, label)
|
||||||
|
canvas = TCanvas(title, title)
|
||||||
|
mg = TMultiGraph()
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
mg.Add(ghost[lab])
|
||||||
|
set_style(ghost[lab], colors[i], markers[2 * i], styles[i])
|
||||||
|
|
||||||
|
xtitle = ghostHistoDict[histo]["xTitle"]
|
||||||
|
mg.GetXaxis().SetTitle(xtitle)
|
||||||
|
mg.GetYaxis().SetTitle("Fraction of fake tracks")
|
||||||
|
mg.Draw("ap")
|
||||||
|
mg.GetXaxis().SetTitleSize(0.06)
|
||||||
|
mg.GetYaxis().SetTitleSize(0.06)
|
||||||
|
mg.GetYaxis().SetTitleOffset(1.1)
|
||||||
|
mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
|
||||||
|
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
||||||
|
# for lab in label:
|
||||||
|
# ghost[lab].Draw("P SAME")
|
||||||
|
if histo == "p":
|
||||||
|
pos = [0.53, 0.4, 1.00, 0.71]
|
||||||
|
elif histo == "pt":
|
||||||
|
pos = [0.5, 0.4, 0.98, 0.71]
|
||||||
|
elif histo == "eta":
|
||||||
|
pos = [0.35, 0.6, 0.85, 0.9]
|
||||||
|
elif histo == "phi":
|
||||||
|
pos = [0.3, 0.3, 0.9, 0.6]
|
||||||
|
else:
|
||||||
|
pos = [0.4, 0.37, 0.80, 0.68]
|
||||||
|
legend = place_legend(canvas, *pos, header="LHCb Simulation", option="LPE")
|
||||||
|
legend.SetTextFont(132)
|
||||||
|
legend.SetTextSize(0.04)
|
||||||
|
legend.Draw()
|
||||||
|
# if histo != "nPV":
|
||||||
|
# latex.DrawLatex(0.7, 0.85, "LHCb simulation")
|
||||||
|
# else:
|
||||||
|
# latex.DrawLatex(0.2, 0.85, "LHCb simulation")
|
||||||
|
# mg.GetYaxis().SetRangeUser(0, 0.4)
|
||||||
|
if histo == "eta":
|
||||||
|
mg.GetYaxis().SetRangeUser(0, 0.4)
|
||||||
|
# track_name = names[tracker] + " tracks"
|
||||||
|
# latex.DrawLatex(0.7, 0.75, track_name)
|
||||||
|
# canvas.PlaceLegend()
|
||||||
|
if savepdf and (1 == 0):
|
||||||
|
filestypes = ["pdf"] # , "pdf", "eps", "C", "ps", "tex"]
|
||||||
|
for ftype in filestypes:
|
||||||
|
canvas.SaveAs(
|
||||||
|
"checks/" + tracker + "_ghost_rate_" + histo + "." + ftype,
|
||||||
|
)
|
||||||
|
canvas.Write()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Compare electron efficiencies of different trackers
|
||||||
|
#
|
||||||
|
|
||||||
|
plot_electrons_only = True
|
||||||
|
if compare:
|
||||||
|
print("\nCompare Efficiencies: ")
|
||||||
|
outputfile.cd()
|
||||||
|
|
||||||
|
for jcut in compareCuts: # [long, long_fromB, long_fromB_P>5GeV]
|
||||||
|
compareDir = outputfile.mkdir("compare_" + jcut)
|
||||||
|
compareDir.cd()
|
||||||
|
for histo in efficiencyHistos: # [p, pt, phi, eta, nPV]
|
||||||
|
canvastitle = "efficiency_" + histo + "_" + jcut
|
||||||
|
name = "efficiency_" + histo + "_" + jcut
|
||||||
|
canvas = TCanvas(name, canvastitle)
|
||||||
|
canvas.SetRightMargin(0.1)
|
||||||
|
mg = TMultiGraph()
|
||||||
|
dist_eff = {}
|
||||||
|
dist_hist_den = {}
|
||||||
|
dist_eff_elec = {}
|
||||||
|
dist_hist_elec = {}
|
||||||
|
First = True
|
||||||
|
dist_tracker = ""
|
||||||
|
markeritr = 0
|
||||||
|
|
||||||
|
for tracker in trackers: # [BestLong, Forward, Match, Seed]
|
||||||
|
cut = compareDict[jcut][tracker]
|
||||||
|
folder = folders[tracker]["folder"]
|
||||||
|
print("folder: " + folder.replace(unique_name_ext_re(), ""))
|
||||||
|
|
||||||
|
jcolor = compareColors[tracker]
|
||||||
|
|
||||||
|
histoName = (
|
||||||
|
"Track/"
|
||||||
|
+ folder
|
||||||
|
+ tracker
|
||||||
|
+ "/"
|
||||||
|
+ cut
|
||||||
|
+ "_"
|
||||||
|
+ ""
|
||||||
|
+ efficiencyHistoDict[histo]["variable"]
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"not electrons: " + histoName.replace(unique_name_ext_re(), "")
|
||||||
|
)
|
||||||
|
eff = {}
|
||||||
|
hist_den = {}
|
||||||
|
eff, hist_den = get_eff(eff, hist_den, tf, histoName, label, histo)
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
histoNameElec = (
|
||||||
|
"Track/"
|
||||||
|
+ folder
|
||||||
|
+ tracker
|
||||||
|
+ "/"
|
||||||
|
+ categories[tracker][cut]["Electrons"]
|
||||||
|
)
|
||||||
|
histoName_e = (
|
||||||
|
histoNameElec + "_" + efficiencyHistoDict[histo]["variable"]
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"electrons: "
|
||||||
|
+ histoName_e.replace(unique_name_ext_re(), "")
|
||||||
|
)
|
||||||
|
eff_elec = {}
|
||||||
|
hist_elec = {}
|
||||||
|
eff_elec, hist_elec = get_eff(
|
||||||
|
eff_elec,
|
||||||
|
hist_elec,
|
||||||
|
tf,
|
||||||
|
histoName_e,
|
||||||
|
label,
|
||||||
|
histo,
|
||||||
|
)
|
||||||
|
if First:
|
||||||
|
dist_eff_elec = eff_elec
|
||||||
|
dist_hist_elec = hist_elec
|
||||||
|
|
||||||
|
if First:
|
||||||
|
dist_tracker = tracker
|
||||||
|
dist_eff = eff
|
||||||
|
dist_hist_den = hist_den
|
||||||
|
First = False
|
||||||
|
|
||||||
|
seeditr = 0
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if (tracker == "Seed") and (seeditr != 0):
|
||||||
|
continue
|
||||||
|
if tracker == "Seed":
|
||||||
|
seeditr += 1
|
||||||
|
mg.Add(eff_elec[lab])
|
||||||
|
set_style(
|
||||||
|
eff_elec[lab],
|
||||||
|
colors[jcolor],
|
||||||
|
markers[i + markeritr],
|
||||||
|
styles[i],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
mg.Add(eff_elec[lab])
|
||||||
|
set_style(
|
||||||
|
eff_elec[lab],
|
||||||
|
elec_colors[jcolor + markeritr],
|
||||||
|
markers[i + markeritr],
|
||||||
|
styles[i],
|
||||||
|
)
|
||||||
|
markeritr = markeritr + 1
|
||||||
|
# set_style(
|
||||||
|
# eff_elec[lab], colors[jcolor], markers[i], styles[i]
|
||||||
|
# )
|
||||||
|
markeritr = 0
|
||||||
|
|
||||||
|
mg.Draw("AP")
|
||||||
|
mg.GetYaxis().SetRangeUser(0, 1.05)
|
||||||
|
xtitle = efficiencyHistoDict[histo]["xTitle"]
|
||||||
|
unit_l = xtitle.split("[")
|
||||||
|
if "]" in unit_l[-1]:
|
||||||
|
unit = unit_l[-1].replace("]", "")
|
||||||
|
else:
|
||||||
|
unit = "a.u."
|
||||||
|
print(unit)
|
||||||
|
mg.GetXaxis().SetTitle(xtitle)
|
||||||
|
mg.GetXaxis().SetTitleSize(0.06)
|
||||||
|
mg.GetYaxis().SetTitle(
|
||||||
|
"Efficiency of Long Tracks",
|
||||||
|
) # (" + str(round(hist_den[label[0]].GetBinWidth(1), 2)) + f"{unit})"+"^{-1}")
|
||||||
|
mg.GetYaxis().SetTitleSize(0.06)
|
||||||
|
mg.GetYaxis().SetTitleOffset(1.1)
|
||||||
|
mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
|
||||||
|
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
||||||
|
mygray = 16
|
||||||
|
myblue = kBlue - 7
|
||||||
|
|
||||||
|
dist_cut = compareDict[jcut][dist_tracker]
|
||||||
|
|
||||||
|
for i, lab in enumerate(label):
|
||||||
|
rightmax = 1.05 * dist_hist_den[lab].GetMaximum()
|
||||||
|
scale = gPad.GetUymax() / rightmax
|
||||||
|
dist_hist_den[lab].Scale(scale)
|
||||||
|
if (
|
||||||
|
categories[dist_tracker][dist_cut]["plotElectrons"]
|
||||||
|
and plot_electrons
|
||||||
|
):
|
||||||
|
rightmax = 1.05 * dist_hist_elec[lab].GetMaximum()
|
||||||
|
scale = gPad.GetUymax() / rightmax
|
||||||
|
dist_hist_elec[lab].Scale(scale)
|
||||||
|
if i == len(label) - 1:
|
||||||
|
if not plot_electrons_only:
|
||||||
|
set_style(dist_hist_den[lab], mygray, markers[i], styles[i])
|
||||||
|
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
|
dist_hist_den[lab].SetFillColorAlpha(mygray, 0.5)
|
||||||
|
dist_hist_den[lab].Draw("HIST PLC SAME")
|
||||||
|
if (
|
||||||
|
categories[dist_tracker][dist_cut]["plotElectrons"]
|
||||||
|
and plot_electrons
|
||||||
|
):
|
||||||
|
set_style(
|
||||||
|
dist_hist_elec[lab], mygray, markers[i], styles[i]
|
||||||
|
)
|
||||||
|
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
|
# dist_hist_elec[lab].SetFillColor(myblue)
|
||||||
|
dist_hist_elec[lab].SetFillColorAlpha(myblue, 0.5)
|
||||||
|
dist_hist_elec[lab].Draw("HIST PLC SAME")
|
||||||
|
# else:
|
||||||
|
# print(
|
||||||
|
# "No distribution plotted for other labels.",
|
||||||
|
# "Can be added by uncommenting the code below this print statement.",
|
||||||
|
# )
|
||||||
|
# set_style(dist_hist_den[lab], mygray, markers[i], styles[i])
|
||||||
|
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
|
# dist_hist_den[lab].Draw("HIST PLC SAME")
|
||||||
|
|
||||||
|
if histo == "p":
|
||||||
|
pos = [0.5, 0.3, 1.0, 0.5] # [0.53, 0.4, 1.01, 0.71]
|
||||||
|
elif histo == "pt":
|
||||||
|
pos = [0.5, 0.3, 0.99, 0.5] # [0.5, 0.4, 0.98, 0.71]
|
||||||
|
elif histo == "phi":
|
||||||
|
pos = [0.4, 0.3, 0.9, 0.5]
|
||||||
|
elif histo == "eta":
|
||||||
|
pos = [0.5, 0.25, 1.0, 0.45]
|
||||||
|
else:
|
||||||
|
pos = [0.35, 0.25, 0.85, 0.45]
|
||||||
|
legend = place_legend(
|
||||||
|
canvas, *pos, header="LHCb Simulation", option="LPE"
|
||||||
|
)
|
||||||
|
for le in legend.GetListOfPrimitives():
|
||||||
|
if "distribution" in le.GetLabel():
|
||||||
|
le.SetOption("LF")
|
||||||
|
legend.SetTextFont(132)
|
||||||
|
legend.SetTextSize(0.04)
|
||||||
|
legend.Draw()
|
||||||
|
for lab in label:
|
||||||
|
if not plot_electrons_only:
|
||||||
|
dist_eff[lab].Draw("P SAME")
|
||||||
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
dist_eff_elec[lab].Draw("P SAME")
|
||||||
|
cutName = categories[tracker][cut]["title"]
|
||||||
|
latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
|
||||||
|
low = 0
|
||||||
|
high = 1.05
|
||||||
|
gPad.Update()
|
||||||
|
axis = TGaxis(
|
||||||
|
gPad.GetUxmax(),
|
||||||
|
gPad.GetUymin(),
|
||||||
|
gPad.GetUxmax(),
|
||||||
|
gPad.GetUymax(),
|
||||||
|
low,
|
||||||
|
high,
|
||||||
|
510,
|
||||||
|
"+U",
|
||||||
|
)
|
||||||
|
axis.SetTitleFont(132)
|
||||||
|
axis.SetTitleSize(0.06)
|
||||||
|
axis.SetTitleOffset(0.55)
|
||||||
|
axis.SetTitle(
|
||||||
|
"# Tracks " + get_nicer_var_string(histo) + " distribution [a.u.]",
|
||||||
|
)
|
||||||
|
axis.SetLabelSize(0)
|
||||||
|
axis.Draw()
|
||||||
|
# canvas.Draw()
|
||||||
|
canvas.RedrawAxis()
|
||||||
|
# canvas.PlaceLegend()
|
||||||
|
if savepdf:
|
||||||
|
filestypes = ["pdf"] # , "png", "eps", "C", "ps", "tex"]
|
||||||
|
for ftype in filestypes:
|
||||||
|
if not plot_electrons_only:
|
||||||
|
canvasName = "Compare_" + jcut + "_" + histo + "." + ftype
|
||||||
|
else:
|
||||||
|
canvasName = (
|
||||||
|
"Compare_Electrons_" + jcut + "_" + histo + "." + ftype
|
||||||
|
)
|
||||||
|
canvas.SaveAs("checks/" + canvasName)
|
||||||
|
# canvas.SetRightMargin(0.05)
|
||||||
|
canvas.Write()
|
||||||
|
outputfile.cd()
|
||||||
|
|
||||||
|
outputfile.Write()
|
||||||
|
outputfile.Close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argument_parser()
|
||||||
|
args = parser.parse_args()
|
||||||
|
PrCheckerEfficiency(**vars(args))
|
@ -225,6 +225,16 @@ def argument_parser():
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="plot only electrons",
|
help="plot only electrons",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--plot-velo",
|
||||||
|
action="store_true",
|
||||||
|
help="plot using momentum at EndVelo",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--plot-velo-only",
|
||||||
|
action="store_true",
|
||||||
|
help="plot using only momentum at EndVelo",
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -289,12 +299,8 @@ def get_eff(eff, hist, tf, histoName, label, var):
|
|||||||
eff[lab].SetTitle(lab + " BestLong, e^{-}")
|
eff[lab].SetTitle(lab + " BestLong, e^{-}")
|
||||||
else:
|
else:
|
||||||
eff[lab].SetTitle(lab + " BestLong")
|
eff[lab].SetTitle(lab + " BestLong")
|
||||||
|
if histoName.find("EndVelo") != -1:
|
||||||
# eff[lab].SetTitle(lab + " not e^{-}")
|
eff[lab].SetTitle(eff[lab].GetTitle() + " EndVelo")
|
||||||
# if histoName.find("strange") != -1:
|
|
||||||
# eff[lab].SetTitle(lab + " from stranges")
|
|
||||||
# if histoName.find("electron") != -1:
|
|
||||||
# eff[lab].SetTitle(lab + " e^{-}")
|
|
||||||
|
|
||||||
hist[lab] = denominator.Clone()
|
hist[lab] = denominator.Clone()
|
||||||
hist[lab].SetName("h_numerator_notElectrons")
|
hist[lab].SetName("h_numerator_notElectrons")
|
||||||
@ -303,6 +309,8 @@ def get_eff(eff, hist, tf, histoName, label, var):
|
|||||||
hist[lab].SetTitle(var + " distribution, stranges")
|
hist[lab].SetTitle(var + " distribution, stranges")
|
||||||
if histoName.find("electron") != -1:
|
if histoName.find("electron") != -1:
|
||||||
hist[lab].SetTitle(var + " distribution, e^{-}")
|
hist[lab].SetTitle(var + " distribution, e^{-}")
|
||||||
|
if histoName.find("EndVelo") != -1:
|
||||||
|
hist[lab].SetTitle(hist[lab].GetTitle() + ", EndVelo")
|
||||||
|
|
||||||
return eff, hist
|
return eff, hist
|
||||||
|
|
||||||
@ -325,36 +333,6 @@ def get_ghost(eff, hist, tf, histoName, label):
|
|||||||
return ghost
|
return ghost
|
||||||
|
|
||||||
|
|
||||||
def get_compare_ghost(eff, hist, tf, histoName, label):
|
|
||||||
ghost = {}
|
|
||||||
for i, lab in enumerate(label):
|
|
||||||
numeratorName = histoName + "_Ghosts"
|
|
||||||
denominatorName = histoName + "_Total"
|
|
||||||
numerator = findRootObjByName(tf[lab], numeratorName)
|
|
||||||
denominator = findRootObjByName(tf[lab], denominatorName)
|
|
||||||
print("Numerator = " + numeratorName.replace(unique_name_ext_re(), ""))
|
|
||||||
print("Denominator = " + denominatorName.replace(unique_name_ext_re(), ""))
|
|
||||||
teff = TEfficiency(numerator, denominator)
|
|
||||||
teff.SetStatisticOption(7)
|
|
||||||
ghost[lab] = teff.CreateGraph()
|
|
||||||
print(lab)
|
|
||||||
ghost[lab].SetName(lab)
|
|
||||||
if histoName.find("Forward") != -1:
|
|
||||||
ghost[lab].SetName(lab + " Ghosts, Forward")
|
|
||||||
if histoName.find("Merged") != -1:
|
|
||||||
ghost[lab].SetName(lab + " Ghosts, MergedMatch")
|
|
||||||
elif histoName.find("DefaultMatch") != -1:
|
|
||||||
ghost[lab].SetName(lab + " Ghosts, DefaultMatch")
|
|
||||||
elif histoName.find("Match") != -1:
|
|
||||||
ghost[lab].SetName(lab + " Ghosts, Match")
|
|
||||||
if histoName.find("Seed") != -1:
|
|
||||||
ghost[lab].SetName(lab + " Ghosts, Seed")
|
|
||||||
if histoName.find("BestLong") != -1:
|
|
||||||
ghost[lab].SetName(lab + " Ghosts, BestLong")
|
|
||||||
|
|
||||||
return ghost
|
|
||||||
|
|
||||||
|
|
||||||
def PrCheckerEfficiency(
|
def PrCheckerEfficiency(
|
||||||
filename,
|
filename,
|
||||||
outfile,
|
outfile,
|
||||||
@ -365,6 +343,8 @@ def PrCheckerEfficiency(
|
|||||||
compare_cuts,
|
compare_cuts,
|
||||||
plot_electrons,
|
plot_electrons,
|
||||||
plot_electrons_only,
|
plot_electrons_only,
|
||||||
|
plot_velo,
|
||||||
|
plot_velo_only,
|
||||||
):
|
):
|
||||||
from utils.LHCbStyle import setLHCbStyle, set_style
|
from utils.LHCbStyle import setLHCbStyle, set_style
|
||||||
from utils.ConfigHistos import (
|
from utils.ConfigHistos import (
|
||||||
@ -449,17 +429,59 @@ def PrCheckerEfficiency(
|
|||||||
label,
|
label,
|
||||||
histo,
|
histo,
|
||||||
)
|
)
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
histoNameEndVelo = (
|
||||||
|
"Track/"
|
||||||
|
+ folder
|
||||||
|
+ tracker
|
||||||
|
+ "/"
|
||||||
|
+ categories[tracker][cut]["EndVelo"]
|
||||||
|
)
|
||||||
|
histoName_v = (
|
||||||
|
histoNameEndVelo
|
||||||
|
+ "_"
|
||||||
|
+ efficiencyHistoDict[histo]["variable"]
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"EndVelo: " + histoName_v.replace(unique_name_ext_re(), "")
|
||||||
|
)
|
||||||
|
eff_velo = {}
|
||||||
|
hist_velo = {}
|
||||||
|
eff_velo, hist_velo = get_eff(
|
||||||
|
eff_velo,
|
||||||
|
hist_velo,
|
||||||
|
tf,
|
||||||
|
histoName_v,
|
||||||
|
label,
|
||||||
|
histo,
|
||||||
|
)
|
||||||
name = "efficiency_" + histo
|
name = "efficiency_" + histo
|
||||||
canvas = TCanvas(name, canvastitle)
|
canvas = TCanvas(name, canvastitle)
|
||||||
canvas.SetRightMargin(0.1)
|
canvas.SetRightMargin(0.1)
|
||||||
mg = TMultiGraph()
|
mg = TMultiGraph()
|
||||||
for i, lab in enumerate(label):
|
for i, lab in enumerate(label):
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
mg.Add(eff[lab])
|
mg.Add(eff[lab])
|
||||||
set_style(eff[lab], colors[i], markers[i], styles[i])
|
set_style(eff[lab], colors[i], markers[i], styles[i])
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
mg.Add(eff_elec[lab])
|
mg.Add(eff_elec[lab])
|
||||||
set_style(eff_elec[lab], elec_colors[i], markers[i], styles[i])
|
set_style(
|
||||||
|
eff_elec[lab], elec_colors[i], markers[i], styles[i]
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
mg.Add(eff_velo[lab])
|
||||||
|
set_style(
|
||||||
|
eff_velo[lab], kMagenta + 1, markers[i], styles[i]
|
||||||
|
)
|
||||||
|
|
||||||
mg.Draw("AP")
|
mg.Draw("AP")
|
||||||
mg.GetYaxis().SetRangeUser(0, 1.05)
|
mg.GetYaxis().SetRangeUser(0, 1.05)
|
||||||
@ -481,6 +503,7 @@ def PrCheckerEfficiency(
|
|||||||
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
||||||
mygray = 18
|
mygray = 18
|
||||||
myblue = kBlue - 9
|
myblue = kBlue - 9
|
||||||
|
mypurple = kMagenta - 7
|
||||||
for i, lab in enumerate(label):
|
for i, lab in enumerate(label):
|
||||||
rightmax = 1.05 * hist_den[lab].GetMaximum()
|
rightmax = 1.05 * hist_den[lab].GetMaximum()
|
||||||
scale = gPad.GetUymax() / rightmax
|
scale = gPad.GetUymax() / rightmax
|
||||||
@ -489,32 +512,43 @@ def PrCheckerEfficiency(
|
|||||||
rightmax = 1.05 * hist_elec[lab].GetMaximum()
|
rightmax = 1.05 * hist_elec[lab].GetMaximum()
|
||||||
scale = gPad.GetUymax() / rightmax
|
scale = gPad.GetUymax() / rightmax
|
||||||
hist_elec[lab].Scale(scale)
|
hist_elec[lab].Scale(scale)
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
rightmax = 1.05 * hist_velo[lab].GetMaximum()
|
||||||
|
scale = gPad.GetUymax() / rightmax
|
||||||
|
hist_velo[lab].Scale(scale)
|
||||||
|
|
||||||
if i == 0:
|
if i == 0:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
set_style(hist_den[lab], mygray, markers[i], styles[i])
|
set_style(hist_den[lab], mygray, markers[i], styles[i])
|
||||||
gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
hist_den[lab].Draw("HIST PLC SAME")
|
hist_den[lab].Draw("HIST PLC SAME")
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
set_style(hist_elec[lab], myblue, markers[i], styles[i])
|
set_style(hist_elec[lab], myblue, markers[i], styles[i])
|
||||||
hist_elec[lab].SetFillColorAlpha(myblue, 0.35)
|
hist_elec[lab].SetFillColorAlpha(myblue, 0.35)
|
||||||
hist_elec[lab].Draw("HIST PLC SAME")
|
hist_elec[lab].Draw("HIST PLC SAME")
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
set_style(
|
||||||
|
hist_velo[lab], mypurple, markers[i], styles[i]
|
||||||
|
)
|
||||||
|
hist_velo[lab].SetFillColorAlpha(mypurple, 0.35)
|
||||||
|
hist_velo[lab].Draw("HIST PLC SAME")
|
||||||
# else:
|
# else:
|
||||||
# print(
|
# print(
|
||||||
# "No distribution plotted for other labels.",
|
# "No distribution plotted for other labels.",
|
||||||
# "Can be added by uncommenting the code below this print statement.",
|
# "Can be added by uncommenting the code below this print statement.",
|
||||||
# )
|
# )
|
||||||
# # set_style(hist_den[lab], mygray, markers[i], styles[i])
|
# set_style(hist_den[lab], mygray, markers[i], styles[i])
|
||||||
# # gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
# # hist_den[lab].Draw("HIST PLC SAME")
|
# hist_den[lab].Draw("HIST PLC SAME")
|
||||||
|
|
||||||
# if histo == "p":
|
|
||||||
# pos = [0.5, 0.3, 1.0, 0.6]
|
|
||||||
# elif histo == "pt":
|
|
||||||
# pos = [0.5, 0.3, 0.99, 0.6]
|
|
||||||
# elif histo == "phi":
|
|
||||||
# pos = [0.3, 0.25, 0.8, 0.55]
|
|
||||||
# else:
|
|
||||||
# pos = [0.3, 0.25, 0.8, 0.55]
|
|
||||||
|
|
||||||
if histo == "p":
|
if histo == "p":
|
||||||
pos = [0.5, 0.3, 1.0, 0.5] # [0.53, 0.4, 1.01, 0.71]
|
pos = [0.5, 0.3, 1.0, 0.5] # [0.53, 0.4, 1.01, 0.71]
|
||||||
@ -526,7 +560,6 @@ def PrCheckerEfficiency(
|
|||||||
pos = [0.5, 0.25, 1.0, 0.45]
|
pos = [0.5, 0.25, 1.0, 0.45]
|
||||||
else:
|
else:
|
||||||
pos = [0.35, 0.25, 0.85, 0.45]
|
pos = [0.35, 0.25, 0.85, 0.45]
|
||||||
|
|
||||||
legend = place_legend(
|
legend = place_legend(
|
||||||
canvas, *pos, header="LHCb Simulation", option="LPE"
|
canvas, *pos, header="LHCb Simulation", option="LPE"
|
||||||
)
|
)
|
||||||
@ -537,10 +570,17 @@ def PrCheckerEfficiency(
|
|||||||
legend.SetTextSize(0.04)
|
legend.SetTextSize(0.04)
|
||||||
legend.Draw()
|
legend.Draw()
|
||||||
for lab in label:
|
for lab in label:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
eff[lab].Draw("P SAME")
|
eff[lab].Draw("P SAME")
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
eff_elec[lab].Draw("P SAME")
|
eff_elec[lab].Draw("P SAME")
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
eff_velo[lab].Draw("P SAME")
|
||||||
cutName = categories[tracker][cut]["title"]
|
cutName = categories[tracker][cut]["title"]
|
||||||
latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
|
latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
|
||||||
low = 0
|
low = 0
|
||||||
@ -564,21 +604,15 @@ def PrCheckerEfficiency(
|
|||||||
)
|
)
|
||||||
axis.SetLabelSize(0)
|
axis.SetLabelSize(0)
|
||||||
axis.Draw()
|
axis.Draw()
|
||||||
# canvas.RedrawAxis()
|
canvas.RedrawAxis()
|
||||||
if savepdf and (1 == 0):
|
if savepdf:
|
||||||
filestypes = ["pdf"] # , "pdf", "eps", "C", "ps", "tex"]
|
filestypes = ["pdf"] # , "png", "eps", "C", "ps", "tex"]
|
||||||
for ftype in filestypes:
|
for ftype in filestypes:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only:
|
||||||
canvasName = tracker + "_" + cut + "_" + histo + "." + ftype
|
canvasName = tracker + "_" + cut + "_" + histo + "." + ftype
|
||||||
else:
|
else:
|
||||||
canvasName = (
|
canvasName = (
|
||||||
tracker
|
tracker + "Electrons_" + cut + "_" + histo + "." + ftype
|
||||||
+ "_Electrons_"
|
|
||||||
+ cut
|
|
||||||
+ "_"
|
|
||||||
+ histo
|
|
||||||
+ "."
|
|
||||||
+ ftype
|
|
||||||
)
|
)
|
||||||
canvas.SaveAs("checks/" + canvasName)
|
canvas.SaveAs("checks/" + canvasName)
|
||||||
# canvas.SetRightMargin(0.05)
|
# canvas.SetRightMargin(0.05)
|
||||||
@ -638,14 +672,13 @@ def PrCheckerEfficiency(
|
|||||||
# track_name = names[tracker] + " tracks"
|
# track_name = names[tracker] + " tracks"
|
||||||
# latex.DrawLatex(0.7, 0.75, track_name)
|
# latex.DrawLatex(0.7, 0.75, track_name)
|
||||||
# canvas.PlaceLegend()
|
# canvas.PlaceLegend()
|
||||||
if savepdf and (1 == 0):
|
if savepdf:
|
||||||
filestypes = ["pdf"] # , "pdf", "eps", "C", "ps", "tex"]
|
filestypes = ["pdf"] # , "png", "eps", "C", "ps", "tex"]
|
||||||
for ftype in filestypes:
|
for ftype in filestypes:
|
||||||
canvas.SaveAs(
|
canvas.SaveAs(
|
||||||
"checks/" + tracker + "_ghost_rate_" + histo + "." + ftype,
|
"checks/" + tracker + "ghost_rate_" + histo + "." + ftype,
|
||||||
)
|
)
|
||||||
canvas.Write()
|
canvas.Write()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compare electron efficiencies of different trackers
|
# Compare electron efficiencies of different trackers
|
||||||
#
|
#
|
||||||
@ -668,8 +701,12 @@ def PrCheckerEfficiency(
|
|||||||
dist_hist_den = {}
|
dist_hist_den = {}
|
||||||
dist_eff_elec = {}
|
dist_eff_elec = {}
|
||||||
dist_hist_elec = {}
|
dist_hist_elec = {}
|
||||||
|
dist_eff_velo = {}
|
||||||
|
dist_hist_velo = {}
|
||||||
First = True
|
First = True
|
||||||
|
First_Velo = True
|
||||||
dist_tracker = ""
|
dist_tracker = ""
|
||||||
|
dist_tracker_velo = ""
|
||||||
markeritr = 0
|
markeritr = 0
|
||||||
|
|
||||||
for tracker in trackers: # [BestLong, Forward, Match, Seed]
|
for tracker in trackers: # [BestLong, Forward, Match, Seed]
|
||||||
@ -723,6 +760,42 @@ def PrCheckerEfficiency(
|
|||||||
if First:
|
if First:
|
||||||
dist_eff_elec = eff_elec
|
dist_eff_elec = eff_elec
|
||||||
dist_hist_elec = hist_elec
|
dist_hist_elec = hist_elec
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
histoNameEndVelo = (
|
||||||
|
"Track/"
|
||||||
|
+ folder
|
||||||
|
+ tracker
|
||||||
|
+ "/"
|
||||||
|
+ categories[tracker][cut]["EndVelo"]
|
||||||
|
)
|
||||||
|
histoName_v = (
|
||||||
|
histoNameEndVelo
|
||||||
|
+ "_"
|
||||||
|
+ efficiencyHistoDict[histo]["variable"]
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"EndVelo: "
|
||||||
|
+ histoName_v.replace(unique_name_ext_re(), "")
|
||||||
|
)
|
||||||
|
eff_velo = {}
|
||||||
|
hist_velo = {}
|
||||||
|
eff_velo, hist_velo = get_eff(
|
||||||
|
eff_velo,
|
||||||
|
hist_velo,
|
||||||
|
tf,
|
||||||
|
histoName_v,
|
||||||
|
label,
|
||||||
|
histo,
|
||||||
|
)
|
||||||
|
if First:
|
||||||
|
dist_eff_velo = eff_velo
|
||||||
|
dist_hist_velo = hist_velo
|
||||||
|
# dist_tracker_velo = tracker
|
||||||
|
# First_Velo = False
|
||||||
|
|
||||||
if First:
|
if First:
|
||||||
dist_tracker = tracker
|
dist_tracker = tracker
|
||||||
@ -733,6 +806,7 @@ def PrCheckerEfficiency(
|
|||||||
seeditr = 0
|
seeditr = 0
|
||||||
for i, lab in enumerate(label):
|
for i, lab in enumerate(label):
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
if (tracker == "Seed") and (seeditr != 0):
|
if (tracker == "Seed") and (seeditr != 0):
|
||||||
continue
|
continue
|
||||||
if tracker == "Seed":
|
if tracker == "Seed":
|
||||||
@ -752,10 +826,20 @@ def PrCheckerEfficiency(
|
|||||||
markers[i + markeritr],
|
markers[i + markeritr],
|
||||||
styles[i],
|
styles[i],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
mg.Add(eff_velo[lab])
|
||||||
|
set_style(
|
||||||
|
eff_velo[lab],
|
||||||
|
colors[jcolor + 1],
|
||||||
|
markers[i + markeritr],
|
||||||
|
styles[i],
|
||||||
|
)
|
||||||
markeritr = markeritr + 1
|
markeritr = markeritr + 1
|
||||||
# set_style(
|
|
||||||
# eff_elec[lab], colors[jcolor], markers[i], styles[i]
|
|
||||||
# )
|
|
||||||
markeritr = 0
|
markeritr = 0
|
||||||
|
|
||||||
mg.Draw("AP")
|
mg.Draw("AP")
|
||||||
@ -778,8 +862,10 @@ def PrCheckerEfficiency(
|
|||||||
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
||||||
mygray = 16
|
mygray = 16
|
||||||
myblue = kBlue - 7
|
myblue = kBlue - 7
|
||||||
|
mypurple = kMagenta - 7
|
||||||
|
|
||||||
dist_cut = compareDict[jcut][dist_tracker]
|
dist_cut = compareDict[jcut][dist_tracker]
|
||||||
|
# dist_cut_velo = compareDict[jcut][dist_tracker_velo]
|
||||||
|
|
||||||
for i, lab in enumerate(label):
|
for i, lab in enumerate(label):
|
||||||
rightmax = 1.05 * dist_hist_den[lab].GetMaximum()
|
rightmax = 1.05 * dist_hist_den[lab].GetMaximum()
|
||||||
@ -792,8 +878,16 @@ def PrCheckerEfficiency(
|
|||||||
rightmax = 1.05 * dist_hist_elec[lab].GetMaximum()
|
rightmax = 1.05 * dist_hist_elec[lab].GetMaximum()
|
||||||
scale = gPad.GetUymax() / rightmax
|
scale = gPad.GetUymax() / rightmax
|
||||||
dist_hist_elec[lab].Scale(scale)
|
dist_hist_elec[lab].Scale(scale)
|
||||||
|
if (
|
||||||
|
categories[dist_tracker][dist_cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
rightmax = 1.05 * dist_hist_velo[lab].GetMaximum()
|
||||||
|
scale = gPad.GetUymax() / rightmax
|
||||||
|
dist_hist_velo[lab].Scale(scale)
|
||||||
if i == len(label) - 1:
|
if i == len(label) - 1:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
set_style(dist_hist_den[lab], mygray, markers[i], styles[i])
|
set_style(dist_hist_den[lab], mygray, markers[i], styles[i])
|
||||||
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
dist_hist_den[lab].SetFillColorAlpha(mygray, 0.5)
|
dist_hist_den[lab].SetFillColorAlpha(mygray, 0.5)
|
||||||
@ -802,13 +896,24 @@ def PrCheckerEfficiency(
|
|||||||
categories[dist_tracker][dist_cut]["plotElectrons"]
|
categories[dist_tracker][dist_cut]["plotElectrons"]
|
||||||
and plot_electrons
|
and plot_electrons
|
||||||
):
|
):
|
||||||
|
if not plot_velo_only:
|
||||||
set_style(
|
set_style(
|
||||||
dist_hist_elec[lab], mygray, markers[i], styles[i]
|
dist_hist_elec[lab], mygray, markers[i], styles[i]
|
||||||
)
|
)
|
||||||
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
# gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
# dist_hist_elec[lab].SetFillColor(myblue)
|
# dist_hist_elec[lab].SetFillColor(myblue)
|
||||||
dist_hist_elec[lab].SetFillColorAlpha(myblue, 0.5)
|
dist_hist_elec[lab].SetFillColorAlpha(myblue - 3, 0.35)
|
||||||
dist_hist_elec[lab].Draw("HIST PLC SAME")
|
dist_hist_elec[lab].Draw("HIST PLC SAME")
|
||||||
|
if (
|
||||||
|
categories[dist_tracker][dist_cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
set_style(
|
||||||
|
dist_hist_velo[lab], mypurple, markers[i], styles[i]
|
||||||
|
)
|
||||||
|
dist_hist_velo[lab].SetFillColorAlpha(mypurple, 0.35)
|
||||||
|
dist_hist_velo[lab].Draw("HIST PLC SAME")
|
||||||
# else:
|
# else:
|
||||||
# print(
|
# print(
|
||||||
# "No distribution plotted for other labels.",
|
# "No distribution plotted for other labels.",
|
||||||
@ -838,10 +943,17 @@ def PrCheckerEfficiency(
|
|||||||
legend.SetTextSize(0.04)
|
legend.SetTextSize(0.04)
|
||||||
legend.Draw()
|
legend.Draw()
|
||||||
for lab in label:
|
for lab in label:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
dist_eff[lab].Draw("P SAME")
|
dist_eff[lab].Draw("P SAME")
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
dist_eff_elec[lab].Draw("P SAME")
|
dist_eff_elec[lab].Draw("P SAME")
|
||||||
|
if (
|
||||||
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
and plot_velo
|
||||||
|
and (histo == "p" or histo == "pt")
|
||||||
|
):
|
||||||
|
dist_eff_velo[lab].Draw("P SAME")
|
||||||
cutName = categories[tracker][cut]["title"]
|
cutName = categories[tracker][cut]["title"]
|
||||||
latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
|
latex.DrawLatex(legend.GetX1() + 0.01, legend.GetY1() - 0.05, cutName)
|
||||||
low = 0
|
low = 0
|
||||||
@ -880,86 +992,6 @@ def PrCheckerEfficiency(
|
|||||||
canvas.SaveAs("checks/" + canvasName)
|
canvas.SaveAs("checks/" + canvasName)
|
||||||
# canvas.SetRightMargin(0.05)
|
# canvas.SetRightMargin(0.05)
|
||||||
canvas.Write()
|
canvas.Write()
|
||||||
|
|
||||||
# # calculate ghost rate
|
|
||||||
# print("\ncalculate ghost rate: ")
|
|
||||||
# for histo in compareGhostHisto: # [Match, Seed, ...]
|
|
||||||
# cut = compareDict[jcut][tracker]
|
|
||||||
|
|
||||||
# canvastitle = "ghost_rate_vs_" + histo + "_" + jcut
|
|
||||||
# name = "ghost_rate_vs_" + histo + "_" + jcut
|
|
||||||
# canvas = TCanvas(name, canvastitle)
|
|
||||||
# canvas.SetRightMargin(0.1)
|
|
||||||
# mg = TMultiGraph()
|
|
||||||
# jitr = 0
|
|
||||||
# for tracker in trackers:
|
|
||||||
# if tracker == "Seed":
|
|
||||||
# continue
|
|
||||||
# folder = folders[tracker]["folder"]
|
|
||||||
# jcolor = compareColors[tracker]
|
|
||||||
# gPad.SetTicks()
|
|
||||||
# histoName = (
|
|
||||||
# "Track/"
|
|
||||||
# + folder
|
|
||||||
# + tracker
|
|
||||||
# + "/"
|
|
||||||
# + ghostHistoDict[histo]["variable"]
|
|
||||||
# )
|
|
||||||
# ghost = {}
|
|
||||||
# hist_den = {}
|
|
||||||
# ghost = get_compare_ghost(ghost, hist_den, tf, histoName, label)
|
|
||||||
# for i, lab in enumerate(label):
|
|
||||||
# mg.Add(ghost[lab])
|
|
||||||
# set_style(
|
|
||||||
# ghost[lab], colors[jcolor + jitr], markers[2 * i], styles[i]
|
|
||||||
# )
|
|
||||||
# jitr += 1
|
|
||||||
|
|
||||||
# xtitle = ghostHistoDict[histo]["xTitle"]
|
|
||||||
# mg.GetXaxis().SetTitle(xtitle)
|
|
||||||
# mg.GetYaxis().SetTitle("Fraction of fake tracks")
|
|
||||||
# mg.Draw("ap")
|
|
||||||
# mg.GetXaxis().SetTitleSize(0.06)
|
|
||||||
# mg.GetYaxis().SetTitleSize(0.06)
|
|
||||||
# mg.GetYaxis().SetTitleOffset(1.1)
|
|
||||||
# mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
|
|
||||||
# mg.GetXaxis().SetNdivisions(10, 5, 0)
|
|
||||||
# # for lab in label:
|
|
||||||
# # ghost[lab].Draw("P SAME")
|
|
||||||
# if histo == "p":
|
|
||||||
# pos = [0.53, 0.4, 1.00, 0.71]
|
|
||||||
# elif histo == "pt":
|
|
||||||
# pos = [0.5, 0.4, 0.98, 0.71]
|
|
||||||
# elif histo == "eta":
|
|
||||||
# pos = [0.35, 0.6, 0.85, 0.9]
|
|
||||||
# elif histo == "phi":
|
|
||||||
# pos = [0.3, 0.3, 0.9, 0.6]
|
|
||||||
# else:
|
|
||||||
# pos = [0.4, 0.37, 0.80, 0.68]
|
|
||||||
# legend = place_legend(
|
|
||||||
# canvas, *pos, header="LHCb Simulation", option="LPE"
|
|
||||||
# )
|
|
||||||
# legend.SetTextFont(132)
|
|
||||||
# legend.SetTextSize(0.04)
|
|
||||||
# legend.Draw()
|
|
||||||
# # if histo != "nPV":
|
|
||||||
# # latex.DrawLatex(0.7, 0.85, "LHCb simulation")
|
|
||||||
# # else:
|
|
||||||
# # latex.DrawLatex(0.2, 0.85, "LHCb simulation")
|
|
||||||
# # mg.GetYaxis().SetRangeUser(0, 0.4)
|
|
||||||
# if histo == "eta":
|
|
||||||
# mg.GetYaxis().SetRangeUser(0, 0.4)
|
|
||||||
# # track_name = names[tracker] + " tracks"
|
|
||||||
# # latex.DrawLatex(0.7, 0.75, track_name)
|
|
||||||
# # canvas.PlaceLegend()
|
|
||||||
# if savepdf:
|
|
||||||
# filestypes = ["pdf"] # , "png", "eps", "C", "ps", "tex"]
|
|
||||||
# for ftype in filestypes:
|
|
||||||
# canvas.SaveAs(
|
|
||||||
# "checks/" + name + "." + ftype,
|
|
||||||
# )
|
|
||||||
# canvas.Write()
|
|
||||||
|
|
||||||
outputfile.cd()
|
outputfile.cd()
|
||||||
|
|
||||||
outputfile.Write()
|
outputfile.Write()
|
||||||
|
@ -106,7 +106,7 @@ def get_colors():
|
|||||||
|
|
||||||
def get_elec_colors():
|
def get_elec_colors():
|
||||||
# [kBlack, kGreen + 3, kAzure, kMagenta + 2, kOrange, kCyan + 2]
|
# [kBlack, kGreen + 3, kAzure, kMagenta + 2, kOrange, kCyan + 2]
|
||||||
return [kGray + 2, kBlue - 7, kGreen + 1, kViolet, kOrange - 3, kTeal - 1]
|
return [kBlue - 7, kGray + 2, kGreen + 1, kViolet, kOrange - 3, kTeal - 1]
|
||||||
|
|
||||||
|
|
||||||
def get_markers():
|
def get_markers():
|
||||||
@ -191,6 +191,11 @@ def argument_parser():
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="plot using momentum at EndVelo",
|
help="plot using momentum at EndVelo",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--plot-velo-only",
|
||||||
|
action="store_true",
|
||||||
|
help="plot using only momentum at EndVelo",
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +262,7 @@ def get_eff(eff, hist, tf, histoName, label, var):
|
|||||||
else:
|
else:
|
||||||
eff[lab].SetTitle(lab + " BestLong")
|
eff[lab].SetTitle(lab + " BestLong")
|
||||||
if histoName.find("EndVelo") != -1:
|
if histoName.find("EndVelo") != -1:
|
||||||
eff[lab].SetTitle(lab + " EndVelo, e^{-}")
|
eff[lab].SetTitle(eff[lab].GetTitle() + " EndVelo")
|
||||||
|
|
||||||
hist[lab] = denominator.Clone()
|
hist[lab] = denominator.Clone()
|
||||||
hist[lab].SetName("h_numerator_notElectrons")
|
hist[lab].SetName("h_numerator_notElectrons")
|
||||||
@ -267,7 +272,7 @@ def get_eff(eff, hist, tf, histoName, label, var):
|
|||||||
if histoName.find("electron") != -1:
|
if histoName.find("electron") != -1:
|
||||||
hist[lab].SetTitle(var + " distribution, e^{-}")
|
hist[lab].SetTitle(var + " distribution, e^{-}")
|
||||||
if histoName.find("EndVelo") != -1:
|
if histoName.find("EndVelo") != -1:
|
||||||
hist[lab].SetTitle(var + " distribution, EndVelo, e^{-}")
|
hist[lab].SetTitle(hist[lab].GetTitle() + ", EndVelo")
|
||||||
|
|
||||||
return eff, hist
|
return eff, hist
|
||||||
|
|
||||||
@ -299,6 +304,7 @@ def PrCheckerEfficiency(
|
|||||||
plot_electrons,
|
plot_electrons,
|
||||||
plot_electrons_only,
|
plot_electrons_only,
|
||||||
plot_velo,
|
plot_velo,
|
||||||
|
plot_velo_only,
|
||||||
):
|
):
|
||||||
from utils.LHCbStyle import setLHCbStyle, set_style
|
from utils.LHCbStyle import setLHCbStyle, set_style
|
||||||
from utils.ConfigHistos import (
|
from utils.ConfigHistos import (
|
||||||
@ -416,12 +422,15 @@ def PrCheckerEfficiency(
|
|||||||
canvas.SetRightMargin(0.1)
|
canvas.SetRightMargin(0.1)
|
||||||
mg = TMultiGraph()
|
mg = TMultiGraph()
|
||||||
for i, lab in enumerate(label):
|
for i, lab in enumerate(label):
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
mg.Add(eff[lab])
|
mg.Add(eff[lab])
|
||||||
set_style(eff[lab], colors[i], markers[i], styles[i])
|
set_style(eff[lab], colors[i], markers[i], styles[i])
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
mg.Add(eff_elec[lab])
|
mg.Add(eff_elec[lab])
|
||||||
set_style(eff_elec[lab], elec_colors[i], markers[i], styles[i])
|
set_style(
|
||||||
|
eff_elec[lab], elec_colors[i], markers[i], styles[i]
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
categories[tracker][cut]["plotEndVelo"]
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
and plot_velo
|
and plot_velo
|
||||||
@ -451,8 +460,8 @@ def PrCheckerEfficiency(
|
|||||||
mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
|
mg.GetXaxis().SetRangeUser(*efficiencyHistoDict[histo]["range"])
|
||||||
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
mg.GetXaxis().SetNdivisions(10, 5, 0)
|
||||||
mygray = 18
|
mygray = 18
|
||||||
myblue = kBlue - 9
|
myblue = kBlue - 10
|
||||||
mypurple = kMagenta - 7
|
mypurple = kMagenta - 10
|
||||||
for i, lab in enumerate(label):
|
for i, lab in enumerate(label):
|
||||||
rightmax = 1.05 * hist_den[lab].GetMaximum()
|
rightmax = 1.05 * hist_den[lab].GetMaximum()
|
||||||
scale = gPad.GetUymax() / rightmax
|
scale = gPad.GetUymax() / rightmax
|
||||||
@ -471,13 +480,14 @@ def PrCheckerEfficiency(
|
|||||||
hist_velo[lab].Scale(scale)
|
hist_velo[lab].Scale(scale)
|
||||||
|
|
||||||
if i == 0:
|
if i == 0:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
set_style(hist_den[lab], mygray, markers[i], styles[i])
|
set_style(hist_den[lab], mygray, markers[i], styles[i])
|
||||||
gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
gStyle.SetPalette(2, array("i", [mygray - 1, myblue + 1]))
|
||||||
hist_den[lab].Draw("HIST PLC SAME")
|
hist_den[lab].Draw("HIST PLC SAME")
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
set_style(hist_elec[lab], myblue, markers[i], styles[i])
|
set_style(hist_elec[lab], myblue, markers[i], styles[i])
|
||||||
hist_elec[lab].SetFillColorAlpha(myblue, 0.35)
|
# hist_elec[lab].SetFillColor(myblue)
|
||||||
hist_elec[lab].Draw("HIST PLC SAME")
|
hist_elec[lab].Draw("HIST PLC SAME")
|
||||||
if (
|
if (
|
||||||
categories[tracker][cut]["plotEndVelo"]
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
@ -487,7 +497,7 @@ def PrCheckerEfficiency(
|
|||||||
set_style(
|
set_style(
|
||||||
hist_velo[lab], mypurple, markers[i], styles[i]
|
hist_velo[lab], mypurple, markers[i], styles[i]
|
||||||
)
|
)
|
||||||
hist_velo[lab].SetFillColorAlpha(mypurple, 0.35)
|
hist_velo[lab].SetFillColorAlpha(mypurple, 0.5)
|
||||||
hist_velo[lab].Draw("HIST PLC SAME")
|
hist_velo[lab].Draw("HIST PLC SAME")
|
||||||
# else:
|
# else:
|
||||||
# print(
|
# print(
|
||||||
@ -518,9 +528,10 @@ def PrCheckerEfficiency(
|
|||||||
legend.SetTextSize(0.04)
|
legend.SetTextSize(0.04)
|
||||||
legend.Draw()
|
legend.Draw()
|
||||||
for lab in label:
|
for lab in label:
|
||||||
if not plot_electrons_only:
|
if not plot_electrons_only and not plot_velo_only:
|
||||||
eff[lab].Draw("P SAME")
|
eff[lab].Draw("P SAME")
|
||||||
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
if categories[tracker][cut]["plotElectrons"] and plot_electrons:
|
||||||
|
if not plot_velo_only:
|
||||||
eff_elec[lab].Draw("P SAME")
|
eff_elec[lab].Draw("P SAME")
|
||||||
if (
|
if (
|
||||||
categories[tracker][cut]["plotEndVelo"]
|
categories[tracker][cut]["plotEndVelo"]
|
||||||
|
@ -39,7 +39,7 @@ def setLHCbStyle():
|
|||||||
|
|
||||||
lhcbStyle = TStyle("lhcbStyle", "LHCb plots style")
|
lhcbStyle = TStyle("lhcbStyle", "LHCb plots style")
|
||||||
lhcbStyle.SetFillColor(1)
|
lhcbStyle.SetFillColor(1)
|
||||||
lhcbStyle.SetFillStyle(1001) # solid
|
lhcbStyle.SetFillStyle(1001) # solid 1001
|
||||||
lhcbStyle.SetFrameFillColor(0)
|
lhcbStyle.SetFrameFillColor(0)
|
||||||
lhcbStyle.SetFrameBorderMode(0)
|
lhcbStyle.SetFrameBorderMode(0)
|
||||||
lhcbStyle.SetPadBorderMode(0)
|
lhcbStyle.SetPadBorderMode(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user