Browse Source

Checker

main
cetin 8 months ago
parent
commit
12df93d856
  1. BIN
      data_results/PrCheckerTestThesis.root
  2. 86
      moore_options/debug_get_resolution_and_eff_data.py
  3. 6
      moore_options/get_calo_data.py
  4. 88
      moore_options/get_resolution_and_eff_data.py
  5. 3
      scripts/PrCheckerEfficiency.py
  6. 74
      scripts/True2VeloPrCheckerEfficiency.py

BIN
data_results/PrCheckerTestThesis.root

Binary file not shown.

86
moore_options/Myget_resolution_and_eff_data.py → moore_options/debug_get_resolution_and_eff_data.py

@ -1,20 +1,15 @@
# flake8: noqa # flake8: noqa
"""
This set of options is used for reconstruction development purposes,
and assumes that the input contains MCHits (i.e. is of `Exended`
DST/digi type).
author: Furkan Cetin
date: 10/2023
Moore/run gaudirun.py /work/cetin/LHCb/reco_tuner/moore_options/get_resolution_and_eff_data.py
"""
from Moore import options, run_reconstruction from Moore import options, run_reconstruction
from Moore.config import Reconstruction from Moore.config import Reconstruction
from PyConf.Algorithms import PrKalmanFilter
from PyConf.Tools import TrackMasterExtrapolator
from PyConf.Algorithms import PrKalmanFilter, PrMatchNN, fromPrMatchTracksV1Tracks
from PyConf.Tools import TrackMasterExtrapolator, PrMCDebugMatchToolNN
from PyConf.application import make_data_with_FetchDataFromFile
from RecoConf.data_from_file import mc_unpackers
import glob import glob
from RecoConf.mc_checking import ( from RecoConf.mc_checking import (
@ -26,7 +21,7 @@ from RecoConf.mc_checking import (
make_links_tracks_mcparticles, make_links_tracks_mcparticles,
) )
from RecoConf.core_algorithms import make_unique_id_generator from RecoConf.core_algorithms import make_unique_id_generator
from RecoConf.hlt2_tracking import make_hlt2_tracks
from RecoConf.hlt2_tracking import make_hlt2_tracks, get_global_ut_hits_tool
from RecoConf.hlt1_tracking import ( from RecoConf.hlt1_tracking import (
make_VeloClusterTrackingSIMD_hits, make_VeloClusterTrackingSIMD_hits,
make_PrStorePrUTHits_hits, make_PrStorePrUTHits_hits,
@ -34,11 +29,23 @@ from RecoConf.hlt1_tracking import (
get_global_materiallocator, get_global_materiallocator,
) )
"""
This set of options is used for reconstruction development purposes,
and assumes that the input contains MCHits (i.e. is of `Exended`
DST/digi type).
author: Furkan Cetin
date: 10/2023
Moore/run gaudirun.py /work/cetin/LHCb/reco_tuner/moore_options/get_resolution_and_eff_data.py
"""
decay = "test" decay = "test"
options.evt_max = -1 options.evt_max = -1
options.ntuple_file = f"data/resolutions_and_effs_{decay}_thesis.root"
options.ntuple_file = f"data/resolutions_and_effs_{decay}_only_electrons_as_seed.root"
options.input_type = "ROOT" options.input_type = "ROOT"
@ -63,6 +70,7 @@ options.output_level = 3
def run_tracking_resolution(): def run_tracking_resolution():
tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True) tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
fitted_forward_tracks = PrKalmanFilter( fitted_forward_tracks = PrKalmanFilter(
Input=tracks["Forward"]["Pr"], Input=tracks["Forward"]["Pr"],
MaxChi2=2.8, MaxChi2=2.8,
@ -77,24 +85,60 @@ def run_tracking_resolution():
).OutputTracks ).OutputTracks
links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system()
links_to_forward = make_links_tracks_mcparticles(
InputTracks=tracks["Forward"],
links_to_best = make_links_tracks_mcparticles(
InputTracks=tracks["BestLong"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
links_to_match = make_links_tracks_mcparticles(
InputTracks=tracks["Match"],
links_to_forward = make_links_tracks_mcparticles(
InputTracks=tracks["Forward"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
links_to_best = make_links_tracks_mcparticles(
InputTracks=tracks["BestLong"],
links_to_velo = make_links_tracks_mcparticles(
InputTracks=tracks["Velo"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
links_to_seed = make_links_tracks_mcparticles( links_to_seed = make_links_tracks_mcparticles(
InputTracks=tracks["Seed"], InputTracks=tracks["Seed"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
res_checker_forward = check_track_resolution(tracks["Forward"], suffix="Forward")
match_debug = PrMatchNN(
VeloInput=tracks["Velo"]["Pr"],
SeedInput=tracks["Seed"]["Pr"],
MatchDebugToolName=PrMCDebugMatchToolNN(
VeloTracks=tracks["Velo"]["v1"],
SeedTracks=tracks["Seed"]["v1"],
VeloTrackLinks=links_to_velo,
SeedTrackLinks=links_to_seed,
TrackInfo=make_data_with_FetchDataFromFile(
"/Event/MC/TrackInfo", "LHCb::MCProperty"
),
MCParticles=mc_unpackers()["MCParticles"],
),
AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
).MatchOutput
match_tracks = {}
match_tracks["Pr"] = match_debug
match_tracks["v1"] = fromPrMatchTracksV1Tracks(
InputTracksLocation=match_debug,
VeloTracksLocation=tracks["Velo"]["v1"],
SeedTracksLocation=tracks["Seed"]["v1"],
).OutputTracksLocation
links_to_match = make_links_tracks_mcparticles(
InputTracks=match_tracks,
LinksToLHCbIDs=links_to_lhcbids,
)
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",
@ -118,7 +162,7 @@ def run_tracking_resolution():
) )
eff_checker_match = check_tracking_efficiency( eff_checker_match = check_tracking_efficiency(
"Match", "Match",
tracks["Match"],
match_tracks,
links_to_match, links_to_match,
links_to_lhcbids, links_to_lhcbids,
get_mc_categories("Match"), get_mc_categories("Match"),

6
moore_options/get_calo_data.py

@ -83,14 +83,16 @@ def standalone_hlt2_fastest_reco():
# filter with calo clusters # filter with calo clusters
calo_matched_seeds = PrFilterTracks2CaloClusters( calo_matched_seeds = PrFilterTracks2CaloClusters(
Relation=tcmatches["Ttrack"], Relation=tcmatches["Ttrack"],
Cut=F.FILTER((F.MIN_ELEMENT_NOTZERO @ F.GET(0) @ F.WEIGHT) < 20),
Cut=F.FILTER((F.MIN_ELEMENT_NOTZERO @ F.FORWARDARG0 @ F.WEIGHT) < 20),
).Output ).Output
# corrections on track (bit better for elec?) # corrections on track (bit better for elec?)
# Cut=F.FILTER(F.ALL) ).Output # Cut=F.FILTER(F.ALL) ).Output
electron_matched_seeds = PrFilterTracks2ElectronMatch( electron_matched_seeds = PrFilterTracks2ElectronMatch(
Relation=tcmatches_e["Ttrack"]["ElectronMatch"], Relation=tcmatches_e["Ttrack"]["ElectronMatch"],
Cut=F.FILTER(F.MIN_ELEMENT_NOTZERO @ F.GET(0) @ F.WEIGHT < 20),
Cut=F.FILTER(F.MIN_ELEMENT_NOTZERO @ F.FORWARDARG0 @ F.WEIGHT < 20),
).Output ).Output
# should be best; shape of shower etc; E/p statt chi2; DLL even better? GET(1) # should be best; shape of shower etc; E/p statt chi2; DLL even better? GET(1)
# Cut=F.FILTER(F.ALL)).Output # Cut=F.FILTER(F.ALL)).Output
shower_matched_seeds = PrFilterTracks2ElectronShower( shower_matched_seeds = PrFilterTracks2ElectronShower(

88
moore_options/get_resolution_and_eff_data.py

@ -1,15 +1,20 @@
# flake8: noqa # flake8: noqa
"""
This set of options is used for reconstruction development purposes,
and assumes that the input contains MCHits (i.e. is of `Exended`
DST/digi type).
author: Furkan Cetin
date: 10/2023
Moore/run gaudirun.py /work/cetin/LHCb/reco_tuner/moore_options/get_resolution_and_eff_data.py
"""
from Moore import options, run_reconstruction from Moore import options, run_reconstruction
from Moore.config import Reconstruction from Moore.config import Reconstruction
from PyConf.Algorithms import PrKalmanFilter, PrMatchNN, fromPrMatchTracksV1Tracks
from PyConf.Tools import TrackMasterExtrapolator, PrMCDebugMatchToolNN
from PyConf.application import make_data_with_FetchDataFromFile
from RecoConf.data_from_file import mc_unpackers
from PyConf.Algorithms import PrKalmanFilter
from PyConf.Tools import TrackMasterExtrapolator
import glob import glob
from RecoConf.mc_checking import ( from RecoConf.mc_checking import (
@ -21,7 +26,7 @@ from RecoConf.mc_checking import (
make_links_tracks_mcparticles, make_links_tracks_mcparticles,
) )
from RecoConf.core_algorithms import make_unique_id_generator from RecoConf.core_algorithms import make_unique_id_generator
from RecoConf.hlt2_tracking import make_hlt2_tracks, get_global_ut_hits_tool
from RecoConf.hlt2_tracking import make_hlt2_tracks
from RecoConf.hlt1_tracking import ( from RecoConf.hlt1_tracking import (
make_VeloClusterTrackingSIMD_hits, make_VeloClusterTrackingSIMD_hits,
make_PrStorePrUTHits_hits, make_PrStorePrUTHits_hits,
@ -29,23 +34,11 @@ from RecoConf.hlt1_tracking import (
get_global_materiallocator, get_global_materiallocator,
) )
"""
This set of options is used for reconstruction development purposes,
and assumes that the input contains MCHits (i.e. is of `Exended`
DST/digi type).
author: Furkan Cetin
date: 10/2023
Moore/run gaudirun.py /work/cetin/LHCb/reco_tuner/moore_options/get_resolution_and_eff_data.py
"""
decay = "test"
decay = "B"
options.evt_max = -1 options.evt_max = -1
options.ntuple_file = f"data/resolutions_and_effs_{decay}_only_electrons_as_seed.root"
options.ntuple_file = f"data/resolutions_and_effs_{decay}_thesis.root"
options.input_type = "ROOT" options.input_type = "ROOT"
@ -70,7 +63,6 @@ options.output_level = 3
def run_tracking_resolution(): def run_tracking_resolution():
tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True) tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
fitted_forward_tracks = PrKalmanFilter( fitted_forward_tracks = PrKalmanFilter(
Input=tracks["Forward"]["Pr"], Input=tracks["Forward"]["Pr"],
MaxChi2=2.8, MaxChi2=2.8,
@ -85,60 +77,24 @@ def run_tracking_resolution():
).OutputTracks ).OutputTracks
links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system() links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system()
links_to_best = make_links_tracks_mcparticles(
InputTracks=tracks["BestLong"],
LinksToLHCbIDs=links_to_lhcbids,
)
links_to_forward = make_links_tracks_mcparticles( links_to_forward = make_links_tracks_mcparticles(
InputTracks=tracks["Forward"], InputTracks=tracks["Forward"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
links_to_velo = make_links_tracks_mcparticles(
InputTracks=tracks["Velo"],
links_to_match = make_links_tracks_mcparticles(
InputTracks=tracks["Match"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
links_to_seed = make_links_tracks_mcparticles(
InputTracks=tracks["Seed"],
links_to_best = make_links_tracks_mcparticles(
InputTracks=tracks["BestLong"],
LinksToLHCbIDs=links_to_lhcbids, LinksToLHCbIDs=links_to_lhcbids,
) )
match_debug = PrMatchNN(
VeloInput=tracks["Velo"]["Pr"],
SeedInput=tracks["Seed"]["Pr"],
MatchDebugToolName=PrMCDebugMatchToolNN(
VeloTracks=tracks["Velo"]["v1"],
SeedTracks=tracks["Seed"]["v1"],
VeloTrackLinks=links_to_velo,
SeedTrackLinks=links_to_seed,
TrackInfo=make_data_with_FetchDataFromFile(
"/Event/MC/TrackInfo", "LHCb::MCProperty"
),
MCParticles=mc_unpackers()["MCParticles"],
),
AddUTHitsToolName=get_global_ut_hits_tool(enable=True),
).MatchOutput
match_tracks = {}
match_tracks["Pr"] = match_debug
match_tracks["v1"] = fromPrMatchTracksV1Tracks(
InputTracksLocation=match_debug,
VeloTracksLocation=tracks["Velo"]["v1"],
SeedTracksLocation=tracks["Seed"]["v1"],
).OutputTracksLocation
links_to_match = make_links_tracks_mcparticles(
InputTracks=match_tracks,
links_to_seed = make_links_tracks_mcparticles(
InputTracks=tracks["Seed"],
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",
@ -162,7 +118,7 @@ def run_tracking_resolution():
) )
eff_checker_match = check_tracking_efficiency( eff_checker_match = check_tracking_efficiency(
"Match", "Match",
match_tracks,
tracks["Match"],
links_to_match, links_to_match,
links_to_lhcbids, links_to_lhcbids,
get_mc_categories("Match"), get_mc_categories("Match"),

3
scripts/PrCheckerEfficiency.py

@ -9,6 +9,9 @@ python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_B_n
python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_D_electron_weights.root --outfile data_results/PrCheckerDElectron.root python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_D_electron_weights.root --outfile data_results/PrCheckerDElectron.root
python scripts/PrCheckerEfficiency.py --filename data/resolutions_and_effs_B_thesis.root
--outfile data_results/PrCheckerTestThesis.root --label particle --plot-velo --plot-velo-only --trackers Match Seed --savepdf
""" """
import argparse import argparse

74
scripts/Bak2PrCheckerEfficiency.py → scripts/True2VeloPrCheckerEfficiency.py

@ -9,6 +9,9 @@ python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_B_n
python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_D_electron_weights.root --outfile data_results/PrCheckerDElectron.root python scripts/MyPrCheckerEfficiency.py --filename data/resolutions_and_effs_D_electron_weights.root --outfile data_results/PrCheckerDElectron.root
python scripts/PrCheckerEfficiency.py --filename data/resolutions_and_effs_B_thesis.root
--outfile data_results/PrCheckerTestThesis.root --label particle --plot-velo --plot-velo-only --trackers Match Seed --savepdf
""" """
import argparse import argparse
@ -432,9 +435,13 @@ 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: # and not plot_velo_only:
mg.Add(eff[lab])
set_style(eff[lab], colors[i], markers[i], styles[i])
if (
categories[tracker][cut]["plotEndVelo"]
and plot_velo
and (histo == "p" or histo == "pt")
): # and not plot_velo_only:
mg.Add(eff_velo[lab])
set_style(eff_velo[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) or ( if (not plot_velo_only) or (
histo == "phi" or histo == "eta" or histo == "nPV" histo == "phi" or histo == "eta" or histo == "nPV"
@ -446,18 +453,6 @@ def PrCheckerEfficiency(
elec_markers[i], elec_markers[i],
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],
elec_colors[i], # elec_colors[i + 1],
elec_markers[i],
styles[i],
)
mg.Draw("AP") mg.Draw("AP")
mg.GetYaxis().SetRangeUser(0, 1.05) mg.GetYaxis().SetRangeUser(0, 1.05)
@ -477,7 +472,7 @@ def PrCheckerEfficiency(
mg.GetYaxis().SetTitleOffset(1.1) mg.GetYaxis().SetTitleOffset(1.1)
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 = kGray
mygray = 18
myblue = kBlue - 10 myblue = kBlue - 10
mypurple = kMagenta - 10 mypurple = kMagenta - 10
for i, lab in enumerate(label): for i, lab in enumerate(label):
@ -498,39 +493,23 @@ def PrCheckerEfficiency(
hist_velo[lab].Scale(scale) hist_velo[lab].Scale(scale)
if i == 0: if i == 0:
if not plot_electrons_only: # and not plot_velo_only:
set_style(hist_den[lab], mygray, markers[i], styles[i])
if (
categories[tracker][cut]["plotEndVelo"]
and plot_velo
and (histo == "p" or histo == "pt")
):
set_style(hist_velo[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_velo[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 or ( if not plot_velo_only or (
histo == "phi" or histo == "eta" or histo == "nPV" histo == "phi" or histo == "eta" or histo == "nPV"
): ):
set_style( set_style(
hist_elec[lab],
myblue,
elec_markers[i],
styles[i],
hist_elec[lab], myblue, elec_markers[i], styles[i]
) )
# hist_elec[lab].SetLineColor(kBlue - 5)
hist_elec[lab].SetFillColorAlpha(myblue, 0.5) hist_elec[lab].SetFillColorAlpha(myblue, 0.5)
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],
myblue,
elec_markers[i],
styles[i],
)
# gStyle.SetPalette(
# 2, array("i", [mygray - 1, myblue + 1])
# )
hist_velo[lab].SetFillColorAlpha(myblue, 0.5)
hist_velo[lab].Draw("HIST PLC SAME")
# else: # else:
# print( # print(
@ -562,19 +541,18 @@ 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: # and not plot_velo_only:
eff[lab].Draw("P SAME")
if (
categories[tracker][cut]["plotEndVelo"]
and plot_velo
and (histo == "p" or histo == "pt")
):
eff_velo[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 or ( if not plot_velo_only or (
histo == "phi" or histo == "eta" or histo == "nPV" histo == "phi" or histo == "eta" or histo == "nPV"
): ):
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
Loading…
Cancel
Save