From be7550309a28f0aa95418a0d6e8ae076623a4130 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Wed, 3 Jul 2024 14:46:38 +0200 Subject: [PATCH 1/3] Add decay-tree refit --- .../python/RecoConf/track_refitting.py | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/track_refitting.py b/Hlt/RecoConf/python/RecoConf/track_refitting.py index aca98c6eac3..347c860547d 100644 --- a/Hlt/RecoConf/python/RecoConf/track_refitting.py +++ b/Hlt/RecoConf/python/RecoConf/track_refitting.py @@ -25,12 +25,21 @@ from RecoConf.hlt2_tracking import get_global_measurement_provider from PyConf.Algorithms import V1V1PrKalmanFilter +# Algorithms to take care of decay-tree refitting +from PyConf.Algorithms import LHCbIDOverlapRelationTableParticleToTrack +from PyConf.Algorithms import RecombineDecayTrees +from PyConf.Algorithms import FlattenDecayTree +from PyConf.Algorithms import SelectTracksForParticles + # algorithms to get the Pr hits from PyConf.Algorithms import VPLightClustersToVPHitsConverter from PyConf.Algorithms import UTHitClustersToPrUTHitsConverter +from Hlt2Conf.algorithms_thor import ParticleFilter +import Functors as F + -def refit_tracks(tracks, get_clusters_from_track=True, use_PrKF=False): +def refit_tracks(tracks, get_clusters_from_track, use_PrKF): if get_clusters_from_track: velo_micro_clusters_on_tracks = SelectVPMicroClustersFromTracks( Inputs=[tracks]) @@ -94,11 +103,60 @@ def refit_tracks(tracks, get_clusters_from_track=True, use_PrKF=False): ReferenceExtrapolator=TrackMasterExtrapolator( MaterialLocator=get_global_materiallocator()), TrackAddClusterTool=clusters_on_track_tool, - MaxChi2PreOutlierRemoval=20, - MaxChi2=2.8, + MaxChi2PreOutlierRemoval= + 9999999, # disable - try to keep as many tracks as possible + MaxChi2= + 9999999, # disable - try to keep as many tracks as possible UniqueIDGenerator=make_unique_id_generator()), Input=tracks).OutputTracks refitted_tracks = track_refitter return refitted_tracks + + +def refit_decay_tree(input_particles, + get_clusters_from_track=True, + use_PrKF=True): + """ Takes an input DataHandle that contains LHCb::Particles (such as the + output of a trigger line), and: + (1) finds out which particles are basic particles, and calls the + track refitter on those + (2) takes the refitted tracks, along with the relation table, + to then call the DecayTree recombiner which re-combines the + particles together, and fits again the decay vertices. + + The output contains particles, the new vertices, the new protoparticles, + and again a relation table between the old particles and the new ones. + + When use_PrKF is false, the TrackEventFitter is used to refit the tracks. + + When get_clusters_from_track is false, the clusters are instead searched + for in the standard raw event - this only works when this is persisted. + """ + flat_particles = FlattenDecayTree(InputParticles=input_particles) + basic_particles = ParticleFilter( + flat_particles.OutputParticles, + F.FILTER(F.ISBASICPARTICLE), # ideally swap to some F.HASTRACK functor + name="SelectBasicParticlesForRefit_{hash}") + + tracks_from_particles = SelectTracksForParticles( + Inputs=[basic_particles]).OutputTracks + + tracks_from_dst = refit_tracks( + tracks_from_particles, get_clusters_from_track, use_PrKF=use_PrKF) + + relation_table_match_by_veloid_to_track = LHCbIDOverlapRelationTableParticleToTrack( + MatchFrom=basic_particles, + MatchTo=tracks_from_dst, + IncludeVP=True, + IncludeFT=True, + IncludeUT=True).OutputRelations + + recombined_trees = RecombineDecayTrees( + InputParticles=input_particles, + InputTracks=tracks_from_dst, # the refitted tracks + InputTrackRelations=relation_table_match_by_veloid_to_track + ) # the relation table + + return recombined_trees -- GitLab From 125fd61ec1baebb5ee4bc2eb1379ef8d333e0597 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Sat, 13 Jul 2024 13:34:03 +0200 Subject: [PATCH 2/3] Pass PV argument --- Hlt/RecoConf/python/RecoConf/track_refitting.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Hlt/RecoConf/python/RecoConf/track_refitting.py b/Hlt/RecoConf/python/RecoConf/track_refitting.py index 347c860547d..8ebd3b0b34f 100644 --- a/Hlt/RecoConf/python/RecoConf/track_refitting.py +++ b/Hlt/RecoConf/python/RecoConf/track_refitting.py @@ -116,6 +116,7 @@ def refit_tracks(tracks, get_clusters_from_track, use_PrKF): def refit_decay_tree(input_particles, + input_pvs, get_clusters_from_track=True, use_PrKF=True): """ Takes an input DataHandle that contains LHCb::Particles (such as the @@ -155,6 +156,7 @@ def refit_decay_tree(input_particles, recombined_trees = RecombineDecayTrees( InputParticles=input_particles, + InputPVs=input_pvs, InputTracks=tracks_from_dst, # the refitted tracks InputTrackRelations=relation_table_match_by_veloid_to_track ) # the relation table -- GitLab From 99f0f84e858c926787d352b1a5be43995c45e0c4 Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Tue, 23 Jul 2024 10:16:36 +0200 Subject: [PATCH 3/3] Fallback for no PVs --- Hlt/RecoConf/python/RecoConf/track_refitting.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/track_refitting.py b/Hlt/RecoConf/python/RecoConf/track_refitting.py index 8ebd3b0b34f..fb9c6ac5fb7 100644 --- a/Hlt/RecoConf/python/RecoConf/track_refitting.py +++ b/Hlt/RecoConf/python/RecoConf/track_refitting.py @@ -15,11 +15,15 @@ from PyConf.Algorithms import SelectFTClustersFromTracks, VPMicroClustersToVPLig from PyConf.Algorithms import SelectUTClustersFromTracks, UTHitClustersToUTHitHandlerConverter from RecoConf.legacy_rec_hlt1_tracking import make_ut_hit_clusters, make_PrStoreUTHit_hits - from RecoConf.legacy_rec_hlt1_tracking import make_velo_micro_clusters, make_VPClus_hits from RecoConf.legacy_rec_hlt1_tracking import make_FTRawBankDecoder_clusters from RecoConf.legacy_rec_hlt1_tracking import make_PrStoreSciFiHits_hits +# Algorithms to get the Pr hits +from PyConf.Algorithms import VPLightClustersToVPHitsConverter +from PyConf.Algorithms import UTHitClustersToPrUTHitsConverter + +# Algotihms to perform the fit from RecoConf.hlt2_tracking import get_track_master_fitter from RecoConf.hlt2_tracking import get_global_measurement_provider @@ -31,13 +35,13 @@ from PyConf.Algorithms import RecombineDecayTrees from PyConf.Algorithms import FlattenDecayTree from PyConf.Algorithms import SelectTracksForParticles -# algorithms to get the Pr hits -from PyConf.Algorithms import VPLightClustersToVPHitsConverter -from PyConf.Algorithms import UTHitClustersToPrUTHitsConverter - from Hlt2Conf.algorithms_thor import ParticleFilter + import Functors as F +# Optional workflow on PV association +from PyConf.Algorithms import PVsEmptyProducer + def refit_tracks(tracks, get_clusters_from_track, use_PrKF): if get_clusters_from_track: @@ -154,6 +158,9 @@ def refit_decay_tree(input_particles, IncludeFT=True, IncludeUT=True).OutputRelations + if input_pvs is None: + input_pvs = PVsEmptyProducer() + recombined_trees = RecombineDecayTrees( InputParticles=input_particles, InputPVs=input_pvs, -- GitLab