tracking-parametrisation-tuner/moore_options/get_resolution_and_eff_data.py

169 lines
4.9 KiB
Python
Raw Normal View History

2023-12-19 13:00:59 +01:00
# flake8: noqa
2024-02-09 11:46:58 +01:00
"""
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
"""
2023-12-19 13:00:59 +01:00
from Moore import options, run_reconstruction
from Moore.config import Reconstruction
2024-02-09 11:46:58 +01:00
from PyConf.Algorithms import PrKalmanFilter
from PyConf.Tools import TrackMasterExtrapolator
2023-12-19 13:00:59 +01:00
import glob
from RecoConf.mc_checking import (
check_track_resolution,
check_tracking_efficiency,
get_mc_categories,
get_hit_type_mask,
make_links_lhcbids_mcparticles_tracking_system,
make_links_tracks_mcparticles,
get_track_checkers,
2023-12-19 13:00:59 +01:00
)
from RecoConf.core_algorithms import make_unique_id_generator
2024-02-09 11:46:58 +01:00
from RecoConf.hlt2_tracking import make_hlt2_tracks
2023-12-19 13:00:59 +01:00
from RecoConf.hlt1_tracking import (
make_VeloClusterTrackingSIMD_hits,
make_PrStorePrUTHits_hits,
make_PrStoreSciFiHits_hits,
get_global_materiallocator,
)
2024-02-16 11:27:02 +01:00
decay = "B"
2023-12-19 13:00:59 +01:00
2024-01-25 14:38:06 +01:00
options.evt_max = -1
2023-12-19 13:00:59 +01:00
2024-02-19 15:41:09 +01:00
options.ntuple_file = f"data/resolutions_and_effs_{decay}_elec_sig_def_bkg.root"
2023-12-19 13:00:59 +01:00
options.input_type = "ROOT"
if decay == "B":
options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
2024-01-16 21:50:18 +01:00
elif decay == "BJpsi":
options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
2023-12-19 13:00:59 +01:00
elif decay == "D":
options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
2024-02-08 17:42:15 +01:00
elif decay == "test2":
options.input_files = [
"/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi"
]
2023-12-19 13:00:59 +01:00
elif decay == "test":
options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]
options.dddb_tag = "dddb-20210617"
options.conddb_tag = "sim-20210617-vc-md100"
options.simulation = True
2024-01-25 14:38:06 +01:00
options.output_level = 3
2023-12-19 13:00:59 +01:00
def run_tracking_resolution():
tracks = make_hlt2_tracks(light_reco=True, fast_reco=False, use_pr_kf=True)
fitted_forward_tracks = PrKalmanFilter(
Input=tracks["Forward"]["Pr"],
MaxChi2=2.8,
MaxChi2PreOutlierRemoval=20,
HitsVP=make_VeloClusterTrackingSIMD_hits(),
HitsUT=make_PrStorePrUTHits_hits(),
HitsFT=make_PrStoreSciFiHits_hits(),
ReferenceExtrapolator=TrackMasterExtrapolator(
MaterialLocator=get_global_materiallocator(),
),
InputUniqueIDGenerator=make_unique_id_generator(),
).OutputTracks
links_to_lhcbids = make_links_lhcbids_mcparticles_tracking_system()
2024-02-08 17:42:15 +01:00
links_to_forward = make_links_tracks_mcparticles(
InputTracks=tracks["Forward"],
2023-12-19 13:00:59 +01:00
LinksToLHCbIDs=links_to_lhcbids,
)
2024-02-09 11:46:58 +01:00
links_to_match = make_links_tracks_mcparticles(
InputTracks=tracks["Match"],
2023-12-19 13:00:59 +01:00
LinksToLHCbIDs=links_to_lhcbids,
)
2024-02-09 11:46:58 +01:00
links_to_best = make_links_tracks_mcparticles(
InputTracks=tracks["BestLong"],
2023-12-19 13:00:59 +01:00
LinksToLHCbIDs=links_to_lhcbids,
)
2024-02-09 11:46:58 +01:00
links_to_seed = make_links_tracks_mcparticles(
InputTracks=tracks["Seed"],
2024-02-08 17:42:15 +01:00
LinksToLHCbIDs=links_to_lhcbids,
)
2024-02-09 11:46:58 +01:00
res_checker_forward = check_track_resolution(tracks["Forward"], suffix="Forward")
2024-01-25 14:38:06 +01:00
res_checker_best_long = check_track_resolution(
tracks["BestLong"],
suffix="BestLong",
)
res_checker_best_forward = check_track_resolution(
dict(v1=fitted_forward_tracks),
suffix="BestForward",
)
res_checker_seed = check_track_resolution(
tracks["Seed"],
suffix="Seed",
)
2023-12-19 13:00:59 +01:00
eff_checker_forward = check_tracking_efficiency(
"Forward",
tracks["Forward"],
links_to_forward,
links_to_lhcbids,
get_mc_categories("Forward"),
get_hit_type_mask("Forward"),
)
eff_checker_match = check_tracking_efficiency(
"Match",
2024-02-09 11:46:58 +01:00
tracks["Match"],
2023-12-19 13:00:59 +01:00
links_to_match,
links_to_lhcbids,
get_mc_categories("Match"),
get_hit_type_mask("Match"),
)
eff_checker_best_long = check_tracking_efficiency(
"BestLong",
tracks["BestLong"],
links_to_best,
links_to_lhcbids,
get_mc_categories("BestLong"),
get_hit_type_mask("BestLong"),
)
eff_checker_seed = check_tracking_efficiency(
"Seed",
tracks["Seed"],
links_to_seed,
links_to_lhcbids,
get_mc_categories("Seed"),
get_hit_type_mask("Seed"),
)
# types_and_locations_for_checkers = {
# "Forward": tracks["Forward"],
# "Seed": tracks["Seed"],
# "Match": tracks["Match"],
# }
# data = []
# data += get_track_checkers(types_and_locations_for_checkers)
2023-12-19 13:00:59 +01:00
data = [
2024-01-25 14:38:06 +01:00
res_checker_forward,
res_checker_best_long,
res_checker_best_forward,
res_checker_seed,
2023-12-19 13:00:59 +01:00
eff_checker_forward,
eff_checker_match,
eff_checker_best_long,
eff_checker_seed,
]
return Reconstruction("run_tracking_debug", data)
run_reconstruction(options, run_tracking_resolution)