added ghost rate to CompareEfficiency.py
This commit is contained in:
parent
8aec15d8db
commit
1fd219d206
BIN
data_results/CompareBestLongBDefaultElectronResidual.root
Normal file
BIN
data_results/CompareBestLongBDefaultElectronResidual.root
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
data_results/CompareMatchBDefaultElectronResidual.root
Normal file
BIN
data_results/CompareMatchBDefaultElectronResidual.root
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -45,14 +45,12 @@ from RecoConf.hlt1_tracking import (
|
||||
# sample = "Bs2PhiPhi_MU"
|
||||
|
||||
|
||||
decay = "B"
|
||||
decay = "D"
|
||||
|
||||
|
||||
options.evt_max = -1
|
||||
|
||||
options.ntuple_file = (
|
||||
f"data/resolutions_and_effs_{decay}_with_electron_weights_as_residual.root"
|
||||
)
|
||||
options.ntuple_file = f"data/resolutions_and_effs_{decay}_with_electron_weights_as_residual_mergedmatch.root"
|
||||
options.input_type = "ROOT"
|
||||
|
||||
|
||||
@ -131,7 +129,7 @@ def run_tracking_resolution():
|
||||
get_hit_type_mask("Forward"),
|
||||
)
|
||||
eff_checker_match = check_tracking_efficiency(
|
||||
"Match",
|
||||
"DefaultMatch",
|
||||
tracks["Match"],
|
||||
links_to_match,
|
||||
links_to_lhcbids,
|
||||
@ -139,7 +137,7 @@ def run_tracking_resolution():
|
||||
get_hit_type_mask("Match"),
|
||||
)
|
||||
eff_checker_mergedmatch = check_tracking_efficiency(
|
||||
"MergedMatch",
|
||||
"Match",
|
||||
tracks["MergedMatch"],
|
||||
links_to_mergedmatch,
|
||||
links_to_lhcbids,
|
||||
|
@ -20,6 +20,8 @@ python scripts/CompareEfficiency.py
|
||||
--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
|
||||
@ -68,6 +70,7 @@ def getOriginFolders():
|
||||
"Forward": {},
|
||||
"Match": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
"BestLong": {},
|
||||
"Seed": {},
|
||||
}
|
||||
@ -79,6 +82,9 @@ def getOriginFolders():
|
||||
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() + "/"
|
||||
|
||||
@ -97,6 +103,7 @@ def getTrackNames():
|
||||
"Forward": {},
|
||||
"Match": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
"BestLong": {},
|
||||
"Seed": {},
|
||||
}
|
||||
@ -106,6 +113,7 @@ def getTrackNames():
|
||||
basedict["Forward"] = "Forward"
|
||||
basedict["Match"] = "Match"
|
||||
basedict["MergedMatch"] = "MergedMatch"
|
||||
basedict["DefaultMatch"] = "DefaultMatch"
|
||||
basedict["BestLong"] = "BestLong"
|
||||
basedict["Seed"] = "Seed"
|
||||
return basedict
|
||||
@ -122,7 +130,7 @@ def get_elec_colors():
|
||||
kRed + 1,
|
||||
kGreen + 1,
|
||||
kViolet,
|
||||
kOrange - 3,
|
||||
kOrange - 8,
|
||||
kTeal - 1,
|
||||
kGray + 1,
|
||||
]
|
||||
@ -138,11 +146,12 @@ def get_fillstyles():
|
||||
|
||||
def getGhostHistoNames():
|
||||
basedict = {
|
||||
"Velo": {},
|
||||
"Upstream": {},
|
||||
# "Velo": {},
|
||||
# "Upstream": {},
|
||||
"Forward": {},
|
||||
"Match": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
"BestLong": {},
|
||||
"Seed": {},
|
||||
}
|
||||
@ -152,6 +161,7 @@ def getGhostHistoNames():
|
||||
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"]
|
||||
|
||||
@ -177,7 +187,7 @@ def argument_parser():
|
||||
"--trackers",
|
||||
type=str,
|
||||
nargs="+",
|
||||
default=["Forward", "Match", "BestLong", "Seed"], # ---
|
||||
default=["Match", "BestLong", "Seed"], # Forward
|
||||
help="Trackers to plot.",
|
||||
)
|
||||
parser.add_argument(
|
||||
@ -259,6 +269,11 @@ def get_eff(eff, hist, tf, histoName, label, var):
|
||||
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^{-}")
|
||||
@ -310,6 +325,36 @@ def get_ghost(eff, hist, tf, histoName, label):
|
||||
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(
|
||||
filename,
|
||||
outfile,
|
||||
@ -355,6 +400,7 @@ def PrCheckerEfficiency(
|
||||
compareDict = getCompare()
|
||||
compareCuts = getCompCuts(compare_cuts)
|
||||
compareColors = getCompColors()
|
||||
compareGhostHisto = ["eta", "p", "pt", "nPV"]
|
||||
trackers = getTrackers(trackers)
|
||||
folders = getOriginFolders()
|
||||
|
||||
@ -833,13 +879,85 @@ def PrCheckerEfficiency(
|
||||
# canvas.SetRightMargin(0.05)
|
||||
canvas.Write()
|
||||
|
||||
# # calculate ghost rate
|
||||
# for histo in ghostHistos: # [p, pt, eta, nPV]
|
||||
# canvastitle = "ghost_rate_vs_" + histo + "_" + jcut
|
||||
# name = "ghost_rate_vs_" + histo + "_" + jcut
|
||||
# canvas = TCanvas(name, canvastitle)
|
||||
# canvas.SetRightMargin(0.1)
|
||||
# mg = TMultiGraph()
|
||||
# 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/" + tracker + "_ghost_rate_" + histo + "." + ftype,
|
||||
)
|
||||
canvas.Write()
|
||||
|
||||
outputfile.cd()
|
||||
|
||||
outputfile.Write()
|
||||
|
@ -53,6 +53,7 @@ def getOriginFolders():
|
||||
"BestLong": {},
|
||||
"Seed": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
}
|
||||
# evtl anpassen wenn die folders anders heissen
|
||||
basedict["Velo"]["folder"] = "VeloTrackChecker/"
|
||||
@ -64,7 +65,9 @@ def getOriginFolders():
|
||||
basedict["MergedMatch"]["folder"] = (
|
||||
"MergedMatchTrackChecker" + unique_name_ext_re() + "/"
|
||||
)
|
||||
|
||||
basedict["DefaultMatch"]["folder"] = (
|
||||
"DefaultMatchTrackChecker" + unique_name_ext_re() + "/"
|
||||
)
|
||||
# basedict["Forward"]["folder"] = "ForwardTrackChecker_7a0dbfa7/"
|
||||
# basedict["Match"]["folder"] = "MatchTrackChecker_29e3152a/"
|
||||
# basedict["BestLong"]["folder"] = "BestLongTrackChecker_4ddacce1/"
|
||||
@ -82,6 +85,7 @@ def getTrackNames():
|
||||
"BestLong": {},
|
||||
"Seed": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
}
|
||||
|
||||
basedict["Velo"] = "Velo"
|
||||
@ -91,6 +95,7 @@ def getTrackNames():
|
||||
basedict["BestLong"] = "BestLong"
|
||||
basedict["Seed"] = "Seed"
|
||||
basedict["MergedMatch"] = "MergedMatch"
|
||||
basedict["DefaultMatch"] = "DefaultMatch"
|
||||
return basedict
|
||||
|
||||
|
||||
@ -120,6 +125,7 @@ def getGhostHistoNames():
|
||||
"Forward": {},
|
||||
"Match": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
"BestLong": {},
|
||||
"Seed": {},
|
||||
}
|
||||
@ -129,6 +135,7 @@ def getGhostHistoNames():
|
||||
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"]
|
||||
|
||||
@ -154,7 +161,7 @@ def argument_parser():
|
||||
"--trackers",
|
||||
type=str,
|
||||
nargs="+",
|
||||
default=["Forward", "Match", "BestLong", "Seed"], # ---
|
||||
default=["Forward", "Match", "BestLong", "Seed"], # DefaultMatch
|
||||
help="Trackers to plot.",
|
||||
)
|
||||
parser.add_argument(
|
||||
|
@ -26,18 +26,21 @@ def getCompare():
|
||||
basedict["long"]["Seed"] = "02_long"
|
||||
basedict["long"]["Match"] = "01_long"
|
||||
basedict["long"]["MergedMatch"] = "01_long"
|
||||
basedict["long"]["DefaultMatch"] = "01_long"
|
||||
basedict["long"]["Forward"] = "01_long"
|
||||
|
||||
basedict["long_fromB"]["BestLong"] = "05_long_fromB"
|
||||
basedict["long_fromB"]["Seed"] = "04_long_fromB"
|
||||
basedict["long_fromB"]["Match"] = "05_long_fromB"
|
||||
basedict["long_fromB"]["MergedMatch"] = "05_long_fromB"
|
||||
basedict["long_fromB"]["DefaultMatch"] = "05_long_fromB"
|
||||
basedict["long_fromB"]["Forward"] = "05_long_fromB"
|
||||
|
||||
basedict["long_fromB_P>5GeV"]["BestLong"] = "06_long_fromB_P>5GeV"
|
||||
basedict["long_fromB_P>5GeV"]["Seed"] = "05_long_fromB_P>5GeV"
|
||||
basedict["long_fromB_P>5GeV"]["Match"] = "06_long_fromB_P>5GeV"
|
||||
basedict["long_fromB_P>5GeV"]["MergedMatch"] = "06_long_fromB_P>5GeV"
|
||||
basedict["long_fromB_P>5GeV"]["DefaultMatch"] = "06_long_fromB_P>5GeV"
|
||||
basedict["long_fromB_P>5GeV"]["Forward"] = "06_long_fromB_P>5GeV"
|
||||
|
||||
return basedict
|
||||
@ -48,13 +51,15 @@ def getCompColors():
|
||||
"Forward": {},
|
||||
"Match": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
"Seed": {},
|
||||
"BestLong": {},
|
||||
}
|
||||
|
||||
basedict["Forward"] = 0
|
||||
basedict["Match"] = 4
|
||||
basedict["MergedMatch"] = 5
|
||||
basedict["MergedMatch"] = 4
|
||||
basedict["DefaultMatch"] = 4
|
||||
basedict["Seed"] = 6
|
||||
basedict["BestLong"] = 1
|
||||
|
||||
|
@ -78,6 +78,7 @@ def getCuts():
|
||||
"MuonMatch": {},
|
||||
"Match": {},
|
||||
"MergedMatch": {},
|
||||
"DefaultMatch": {},
|
||||
"Seed": {},
|
||||
"Downstream": {},
|
||||
"BestLong": {},
|
||||
@ -133,6 +134,8 @@ def getCuts():
|
||||
|
||||
basedict["MergedMatch"] = basedict["Match"]
|
||||
|
||||
basedict["DefaultMatch"] = basedict["Match"]
|
||||
|
||||
basedict["Seed"] = [
|
||||
"01_hasT",
|
||||
"02_long",
|
||||
@ -403,6 +406,52 @@ def categoriesDict():
|
||||
"plotElectrons"
|
||||
] = False
|
||||
|
||||
# DefaultMatch
|
||||
basedict["DefaultMatch"]["01_long"]["Electrons"] = "07_long_electrons"
|
||||
basedict["DefaultMatch"]["05_long_fromB"]["Electrons"] = "08_long_fromB_electrons"
|
||||
basedict["DefaultMatch"]["06_long_fromB_P>5GeV"][
|
||||
"Electrons"
|
||||
] = "09_long_fromB_electrons_P>5GeV"
|
||||
basedict["DefaultMatch"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][
|
||||
"Electrons"
|
||||
] = "10_long_fromB_electrons_P>3GeV_Pt>0.5GeV"
|
||||
|
||||
basedict["DefaultMatch"]["01_long"]["title"] = "Long, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["02_long_P>5GeV"]["title"] = "Long, p>5GeV, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["03_long_strange"][
|
||||
"title"
|
||||
] = "Long, from strange, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["04_long_strange_P>5GeV"][
|
||||
"title"
|
||||
] = "Long, from strange, p>5GeV, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["05_long_fromB"]["title"] = "Long from B, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["06_long_fromB_P>5GeV"][
|
||||
"title"
|
||||
] = "Long from B, p>5GeV 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["10_long_fromB_P>3GeV_Pt>0.5GeV"][
|
||||
"title"
|
||||
] = "Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["10_long_strange_P>3GeV_Pt>0.5GeV"][
|
||||
"title"
|
||||
] = "Long from strange, p>3GeV, pt>0.5GeV, 2 <#eta < 5"
|
||||
basedict["DefaultMatch"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][
|
||||
"title"
|
||||
] = "UT Long from B, p>3GeV, pt>0.5GeV, 2 <#eta < 5"
|
||||
|
||||
basedict["DefaultMatch"]["01_long"]["plotElectrons"] = True
|
||||
basedict["DefaultMatch"]["02_long_P>5GeV"]["plotElectrons"] = False
|
||||
basedict["DefaultMatch"]["03_long_strange"]["plotElectrons"] = False
|
||||
basedict["DefaultMatch"]["04_long_strange_P>5GeV"]["plotElectrons"] = False
|
||||
basedict["DefaultMatch"]["05_long_fromB"]["plotElectrons"] = True
|
||||
basedict["DefaultMatch"]["06_long_fromB_P>5GeV"]["plotElectrons"] = True
|
||||
basedict["DefaultMatch"]["10_long_fromB_P>3GeV_Pt>0.5GeV"]["plotElectrons"] = False
|
||||
basedict["DefaultMatch"]["10_long_strange_P>3GeV_Pt>0.5GeV"][
|
||||
"plotElectrons"
|
||||
] = False
|
||||
basedict["DefaultMatch"]["11_UT_long_fromB_P>3GeV_Pt>0.5GeV"][
|
||||
"plotElectrons"
|
||||
] = False
|
||||
|
||||
# SEED
|
||||
basedict["Seed"]["01_hasT"]["Electrons"] = "13_hasT_electrons"
|
||||
basedict["Seed"]["02_long"]["Electrons"] = "14_long_electrons"
|
||||
|
Loading…
Reference in New Issue
Block a user