From 5e184c4606b28b102b328816e5e3089c0e55b030 Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Tue, 21 Jan 2025 00:20:24 +0100 Subject: [PATCH 01/13] make calo reco compatible with TTracks --- .../python/RecoConf/calorimeter_reconstruction.py | 13 ++++++++++--- Hlt/RecoConf/python/RecoConf/protoparticles.py | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index 047e120d924..182dde0c246 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -341,12 +341,14 @@ def make_calo_chargedpids( hypomatches, clustermatches, eshower, + trackrels, bremmethod="Mixed", accepted_types={ "brem": ["Long", "Downstream", "Upstream", "Velo"], "calo": ["Long", "Downstream", "Ttrack"] }, base=r"CaloCharged{0}Alg_{1}_{{hash}}", + use_track_ancestor = False ): pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): @@ -358,7 +360,9 @@ def make_calo_chargedpids( HcalEnergy=calo_energies[tt]["HcalE"], Tracks2Clusters=clustermatches[tt], Tracks2Electrons=hypomatches[tt]["ElectronMatch"], - ElectronShower=eshower[tt]) + ElectronShower=eshower[tt], + TracksRelations=trackrels[tt], + UseTrackAncestor=use_track_ancestor if type(use_track_ancestor) is bool else tt in use_track_ancestor) if tt in accepted_types["brem"]: pids["breminfos"][tt] = CaloChargedBremAlg( name=base.format("Brem", tt), @@ -447,7 +451,7 @@ def make_calo(tracks, pvs, make_raw=default_raw_banks, chargedpid_types={ - "calo": ["Long", "Downstream"], + "calo": ["Long", "Downstream", "Ttrack"], "brem": ["Long", "Downstream", "Upstream"] }, trackrels=None): @@ -494,6 +498,7 @@ def make_calo(tracks, thmatches, tcmatches, eshower, + trackrels, accepted_types=chargedpid_types) calopids_v1 = make_convert_calo_chargedpids(calopids_v3, trackrels) @@ -563,7 +568,9 @@ def make_calo(tracks, "v2_photons": photons, "v2_electrons": electrons, "v2_mergedPi0s": mergedPi0s, - "v2_clustertrackmatches": tcmatches["combined"], + "v2_clustertrackmatches": tcmatches, + "v2_trackhypomatches": thmatches, + "v2_trackcaloenergies": track2caloe } diff --git a/Hlt/RecoConf/python/RecoConf/protoparticles.py b/Hlt/RecoConf/python/RecoConf/protoparticles.py index f867a203416..820cee957b0 100644 --- a/Hlt/RecoConf/python/RecoConf/protoparticles.py +++ b/Hlt/RecoConf/python/RecoConf/protoparticles.py @@ -117,7 +117,7 @@ def make_neutral_protoparticles(calo_pids, MergedPi0s=calo_pids["v1_mergedPi0s"], Photons=calo_pids["v1_photons"], SplitPhotons=calo_pids["v1_splitPhotons"], - TrackMatchTable=calo_pids["v2_clustertrackmatches"], + TrackMatchTable=calo_pids["v2_clustertrackmatches"]["combined"], outputs={ 'ProtoParticleLocation': location_protos, 'NeutralPID': location_PIDs -- GitLab From 8b4ce093f3ba4722faeede63e9fa4b3806ed6e7f Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Tue, 21 Jan 2025 00:22:05 +0100 Subject: [PATCH 02/13] implement calo PID for TTracks --- .../python/RecoConf/ttrack_selections_reco.py | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py index 1ce89a5ffe4..971ab88fccf 100644 --- a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py +++ b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py @@ -28,7 +28,7 @@ from PyConf.Tools import (ParticleVertexFitter, TrackRungeKuttaExtrapolator, from PyConf import configurable -def make_fitted_ttracks(global_reco=reconstruction, skip_UT=True): +def make_fitted_ttracks(global_reco=reconstruction, skip_UT=False): tracks = global_reco()['AllTrackHandles'] decloned_seed_fitted = tracks['SeedDeclonedFitted']['v1'] decloned_seed = global_reco()['Ttracks'] @@ -47,7 +47,7 @@ def make_fitted_ttracks(global_reco=reconstruction, skip_UT=True): return {"v1": best_decloned_seed} -def make_mva_ttracks(global_reco=reconstruction, skip_UT=True): +def make_mva_ttracks(global_reco=reconstruction, skip_UT=False): tracks = global_reco()["AllTrackHandles"] decloned_seed = global_reco()['Ttracks'] decloned_filtered_seed_fitted = tracks['FilteredSeedDeclonedFitted']['v1'] @@ -91,7 +91,31 @@ def make_ttrack_muon_pids(ttracks): return muon_pids["Ttrack"] +def make_ttrack_calo_pids(ttracks,global_reco=reconstruction): + from RecoConf.calorimeter_reconstruction import make_acceptance,make_trackbased_eshower,make_convert_calo_chargedpids,make_calo_chargedpids,make_track_energy_in_calo + + tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1({ + "Ttrack": + ttracks["v1"] + }) + tracks_incalo = make_acceptance(tracks_v3) + digitsEcal = global_reco()['AllCaloHandles']['digitsEcal'] + digitsHcal = global_reco()['AllCaloHandles']['digitsHcal'] + track2caloe = make_track_energy_in_calo(tracks_incalo, digitsEcal, digitsHcal) + eshower = make_trackbased_eshower(tracks_incalo,digitsEcal) + calopids_v3 = make_calo_chargedpids(tracks_incalo, + track2caloe, + global_reco()['AllCaloHandles']['v2_trackhypomatches'], + global_reco()['AllCaloHandles']['v2_clustertrackmatches'], + eshower, + tracks_rels, + use_track_ancestor = True) + + calopids_v1 = make_convert_calo_chargedpids(calopids_v3, tracks_rels) + return {'v1_chargedpids': calopids_v1['chargedpids'], + 'v1_electrons_relations': global_reco()['AllCaloHandles']['v1_electrons_relations']} + # All the T track reco @configurable def make_ttrack_reco(global_reco, make_ttracks, skipRich=False, @@ -99,8 +123,7 @@ def make_ttrack_reco(global_reco, make_ttracks, skipRich=False, good_ttracks = make_ttracks() rich_pids = make_ttrack_rich_pids(good_ttracks) if not skipRich else None - # TODO calo reco was configured wrong (to be added appropriately) - calo_pids = None + calo_pids = make_ttrack_calo_pids(good_ttracks) if not skipCalo else None muon_pids = make_ttrack_muon_pids(good_ttracks) return { @@ -131,7 +154,7 @@ def make_ttrack_protoparticles(track_type='Ttrack', calo_pids=ttrack_reco["calo_pids"], muon_pids=ttrack_reco["muon_pids"], track_types=["Ttrack"], - use_track_ancestor_calo=True) + use_track_ancestor_calo=False) def make_ttrack_MVAfiltered_protoparticles(): -- GitLab From 28dc3d5ba9d95ae2d10de2814a3b6ffe7cf132b6 Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Tue, 21 Jan 2025 00:22:40 +0100 Subject: [PATCH 03/13] add electrons with ttracks in standard particles --- Hlt/RecoConf/python/RecoConf/standard_particles.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py index 4210cf5fda5..c689255aa21 100644 --- a/Hlt/RecoConf/python/RecoConf/standard_particles.py +++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py @@ -29,7 +29,7 @@ Implemented filters and builders: - make_long_{muons, pions, kaons, protons, deuterons, helium3} : basic builder for long muons, pions, kaons, protons, deuterons, helium3 - make_ismuon_long_muon : basic builder for long muons with ISMUON condition - make_{up, down}_{electrons_no_brem, muons, pions, kaons, protons, deuterons, helium3} : basic builders for upstream or downstream electrons (no brem correction), muons, pions, kaons, protons, deuterons, helium3 -- make_ttrack_{pions, protons, muons, kaons} : basic builders for ttrack protons or pions +- make_ttrack_{pions, protons, muons, kaons, electrons} : basic builders for ttrack pions, protons, muons, kaons and electrons - make_has_rich_{long, down, up}_{pions, kaons, protons, deuterons, helium3} : basic builders for longstream, downstream and upstream pions, kaons, protons, deuterons, helium3 - make_has_rich_ttrack_{pions, protons, muons, kaons} : basic builders for ttrack pions, protons - make_{resolved, merged}_pi0s : basic builder to make resolved and merged pi0 @@ -530,6 +530,14 @@ def make_ttrack_kaons(make_protoparticles=make_ttrack_protoparticles): make_protoparticle_filter=standard_protoparticle_filter) +@configurable +def make_ttrack_electrons(make_protoparticles=make_ttrack_protoparticles): + return _make_particles( + species="electron", + make_protoparticles=make_protoparticles, + make_protoparticle_filter=standard_protoparticle_filter) + + # HASRICH definitions of pions/K: long, down, up @@ -669,6 +677,9 @@ def make_mva_ttrack_kaons(): return make_ttrack_kaons( make_protoparticles=make_ttrack_MVAfiltered_protoparticles) +def make_mva_ttrack_electrons(): + return make_ttrack_electrons( + make_protoparticles=make_ttrack_MVAfiltered_protoparticles) # Definitions of pi0 @configurable -- GitLab From 4c6c8a4785e77a89ca21cd9798d0bb6ca51a8f93 Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Tue, 18 Feb 2025 22:07:26 +0000 Subject: [PATCH 04/13] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/51256284 --- .../RecoConf/calorimeter_reconstruction.py | 23 +++++----- .../python/RecoConf/standard_particles.py | 2 + .../python/RecoConf/ttrack_selections_reco.py | 42 +++++++++++-------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index 182dde0c246..c06d37bd47a 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -348,8 +348,7 @@ def make_calo_chargedpids( "calo": ["Long", "Downstream", "Ttrack"] }, base=r"CaloCharged{0}Alg_{1}_{{hash}}", - use_track_ancestor = False -): + use_track_ancestor=False): pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): if tt in accepted_types["calo"]: @@ -362,7 +361,8 @@ def make_calo_chargedpids( Tracks2Electrons=hypomatches[tt]["ElectronMatch"], ElectronShower=eshower[tt], TracksRelations=trackrels[tt], - UseTrackAncestor=use_track_ancestor if type(use_track_ancestor) is bool else tt in use_track_ancestor) + UseTrackAncestor=use_track_ancestor if + type(use_track_ancestor) is bool else tt in use_track_ancestor) if tt in accepted_types["brem"]: pids["breminfos"][tt] = CaloChargedBremAlg( name=base.format("Brem", tt), @@ -447,14 +447,15 @@ def make_merged_pi0_various(ecalClusters, pvs): @configurable -def make_calo(tracks, - pvs, - make_raw=default_raw_banks, - chargedpid_types={ - "calo": ["Long", "Downstream", "Ttrack"], - "brem": ["Long", "Downstream", "Upstream"] - }, - trackrels=None): +def make_calo( + tracks, + pvs, + make_raw=default_raw_banks, + chargedpid_types={ + "calo": ["Long", "Downstream", "Ttrack"], + "brem": ["Long", "Downstream", "Upstream"] + }, + trackrels=None): # digits digitsCalo = make_digits() digitsEcal = digitsCalo["digitsEcal"] diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py index c689255aa21..507c4e16df0 100644 --- a/Hlt/RecoConf/python/RecoConf/standard_particles.py +++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py @@ -677,10 +677,12 @@ def make_mva_ttrack_kaons(): return make_ttrack_kaons( make_protoparticles=make_ttrack_MVAfiltered_protoparticles) + def make_mva_ttrack_electrons(): return make_ttrack_electrons( make_protoparticles=make_ttrack_MVAfiltered_protoparticles) + # Definitions of pi0 @configurable def make_resolved_pi0s(particles=make_photons, diff --git a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py index 971ab88fccf..93266bf6eab 100644 --- a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py +++ b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py @@ -91,31 +91,39 @@ def make_ttrack_muon_pids(ttracks): return muon_pids["Ttrack"] -def make_ttrack_calo_pids(ttracks,global_reco=reconstruction): - from RecoConf.calorimeter_reconstruction import make_acceptance,make_trackbased_eshower,make_convert_calo_chargedpids,make_calo_chargedpids,make_track_energy_in_calo - + +def make_ttrack_calo_pids(ttracks, global_reco=reconstruction): + from RecoConf.calorimeter_reconstruction import make_acceptance, make_trackbased_eshower, make_convert_calo_chargedpids, make_calo_chargedpids, make_track_energy_in_calo + tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1({ "Ttrack": ttracks["v1"] }) tracks_incalo = make_acceptance(tracks_v3) - digitsEcal = global_reco()['AllCaloHandles']['digitsEcal'] - digitsHcal = global_reco()['AllCaloHandles']['digitsHcal'] - track2caloe = make_track_energy_in_calo(tracks_incalo, digitsEcal, digitsHcal) - eshower = make_trackbased_eshower(tracks_incalo,digitsEcal) - calopids_v3 = make_calo_chargedpids(tracks_incalo, - track2caloe, - global_reco()['AllCaloHandles']['v2_trackhypomatches'], - global_reco()['AllCaloHandles']['v2_clustertrackmatches'], - eshower, - tracks_rels, - use_track_ancestor = True) + digitsEcal = global_reco()['AllCaloHandles']['digitsEcal'] + digitsHcal = global_reco()['AllCaloHandles']['digitsHcal'] + track2caloe = make_track_energy_in_calo(tracks_incalo, digitsEcal, + digitsHcal) + eshower = make_trackbased_eshower(tracks_incalo, digitsEcal) + calopids_v3 = make_calo_chargedpids( + tracks_incalo, + track2caloe, + global_reco()['AllCaloHandles']['v2_trackhypomatches'], + global_reco()['AllCaloHandles']['v2_clustertrackmatches'], + eshower, + tracks_rels, + use_track_ancestor=True) calopids_v1 = make_convert_calo_chargedpids(calopids_v3, tracks_rels) - return {'v1_chargedpids': calopids_v1['chargedpids'], - 'v1_electrons_relations': global_reco()['AllCaloHandles']['v1_electrons_relations']} - + return { + 'v1_chargedpids': + calopids_v1['chargedpids'], + 'v1_electrons_relations': + global_reco()['AllCaloHandles']['v1_electrons_relations'] + } + + # All the T track reco @configurable def make_ttrack_reco(global_reco, make_ttracks, skipRich=False, -- GitLab From 4d82b1633fdb659d43712e49b62c3deb37adb0b9 Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Thu, 20 Feb 2025 10:51:24 +0000 Subject: [PATCH 05/13] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/51368795 --- .../RecoConf/calorimeter_reconstruction.py | 55 ++++++++++--------- .../python/RecoConf/standard_particles.py | 6 +- .../python/RecoConf/ttrack_selections_reco.py | 44 ++++++++------- 3 files changed, 58 insertions(+), 47 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index 2a91ca38045..be05334683f 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -382,19 +382,20 @@ def make_track_electron_and_brem_matching( @configurable def make_calo_chargedpids( - tracks_incalo, - calo_energies, - hypomatches, - clustermatches, - eshower, - trackrels, - bremmethod="Mixed", - accepted_types={ - "brem": ["Long", "Downstream", "Upstream", "Velo"], - "calo": ["Long", "Downstream", "Ttrack"] - }, - base=r"CaloCharged{0}Alg_{1}_{{hash}}", - use_track_ancestor=False): + tracks_incalo, + calo_energies, + hypomatches, + clustermatches, + eshower, + trackrels, + bremmethod="Mixed", + accepted_types={ + "brem": ["Long", "Downstream", "Upstream", "Velo"], + "calo": ["Long", "Downstream", "Ttrack"], + }, + base=r"CaloCharged{0}Alg_{1}_{{hash}}", + use_track_ancestor=False, +): pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): if tt in accepted_types["calo"]: @@ -407,8 +408,10 @@ def make_calo_chargedpids( Tracks2Electrons=hypomatches[tt]["ElectronMatch"], ElectronShower=eshower[tt], TracksRelations=trackrels[tt], - UseTrackAncestor=use_track_ancestor if - type(use_track_ancestor) is bool else tt in use_track_ancestor) + UseTrackAncestor=use_track_ancestor + if type(use_track_ancestor) is bool + else tt in use_track_ancestor, + ) if tt in accepted_types["brem"]: pids["breminfos"][tt] = CaloChargedBremAlg( name=base.format("Brem", tt), @@ -504,14 +507,15 @@ def make_merged_pi0_various(ecalClusters, pvs): @configurable def make_calo( - tracks, - pvs, - make_raw=default_raw_banks, - chargedpid_types={ - "calo": ["Long", "Downstream", "Ttrack"], - "brem": ["Long", "Downstream", "Upstream"] - }, - trackrels=None): + tracks, + pvs, + make_raw=default_raw_banks, + chargedpid_types={ + "calo": ["Long", "Downstream", "Ttrack"], + "brem": ["Long", "Downstream", "Upstream"], + }, + trackrels=None, +): # digits digitsCalo = make_digits() digitsEcal = digitsCalo["digitsEcal"] @@ -555,7 +559,8 @@ def make_calo( tcmatches, eshower, trackrels, - accepted_types=chargedpid_types) + accepted_types=chargedpid_types, + ) calopids_v1 = make_convert_calo_chargedpids(calopids_v3, trackrels) # conversions to v1 versions of clusters/hypos @@ -626,7 +631,7 @@ def make_calo( "v2_mergedPi0s": mergedPi0s, "v2_clustertrackmatches": tcmatches, "v2_trackhypomatches": thmatches, - "v2_trackcaloenergies": track2caloe + "v2_trackcaloenergies": track2caloe, } diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py index d06630a89ab..9aa47c1b9a8 100644 --- a/Hlt/RecoConf/python/RecoConf/standard_particles.py +++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py @@ -597,7 +597,8 @@ def make_ttrack_electrons(make_protoparticles=make_ttrack_protoparticles): return _make_particles( species="electron", make_protoparticles=make_protoparticles, - make_protoparticle_filter=standard_protoparticle_filter) + make_protoparticle_filter=standard_protoparticle_filter, + ) # HASRICH definitions of pions/K: long, down, up @@ -740,7 +741,8 @@ def make_mva_ttrack_kaons(): def make_mva_ttrack_electrons(): return make_ttrack_electrons( - make_protoparticles=make_ttrack_MVAfiltered_protoparticles) + make_protoparticles=make_ttrack_MVAfiltered_protoparticles + ) # Definitions of pi0 diff --git a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py index 9685256c1cf..5ad520fc74e 100644 --- a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py +++ b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py @@ -35,9 +35,9 @@ from RecoConf.rich_reconstruction import default_rich_reco_options, make_rich_pi def make_fitted_ttracks(global_reco=reconstruction, skip_UT=False): - tracks = global_reco()['AllTrackHandles'] - decloned_seed_fitted = tracks['SeedDeclonedFitted']['v1'] - decloned_seed = global_reco()['Ttracks'] + tracks = global_reco()["AllTrackHandles"] + decloned_seed_fitted = tracks["SeedDeclonedFitted"]["v1"] + decloned_seed = global_reco()["Ttracks"] decloned_seed_fitted_anc = TrackAncestorAssociatorByKey( InputTracks=decloned_seed_fitted, AncestorTracks=decloned_seed ) @@ -103,34 +103,37 @@ def make_ttrack_muon_pids(ttracks): def make_ttrack_calo_pids(ttracks, global_reco=reconstruction): - from RecoConf.calorimeter_reconstruction import make_acceptance, make_trackbased_eshower, make_convert_calo_chargedpids, make_calo_chargedpids, make_track_energy_in_calo + from RecoConf.calorimeter_reconstruction import ( + make_acceptance, + make_calo_chargedpids, + make_convert_calo_chargedpids, + make_track_energy_in_calo, + make_trackbased_eshower, + ) - tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1({ - "Ttrack": - ttracks["v1"] - }) + tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1({"Ttrack": ttracks["v1"]}) tracks_incalo = make_acceptance(tracks_v3) - digitsEcal = global_reco()['AllCaloHandles']['digitsEcal'] - digitsHcal = global_reco()['AllCaloHandles']['digitsHcal'] - track2caloe = make_track_energy_in_calo(tracks_incalo, digitsEcal, - digitsHcal) + digitsEcal = global_reco()["AllCaloHandles"]["digitsEcal"] + digitsHcal = global_reco()["AllCaloHandles"]["digitsHcal"] + track2caloe = make_track_energy_in_calo(tracks_incalo, digitsEcal, digitsHcal) eshower = make_trackbased_eshower(tracks_incalo, digitsEcal) calopids_v3 = make_calo_chargedpids( tracks_incalo, track2caloe, - global_reco()['AllCaloHandles']['v2_trackhypomatches'], - global_reco()['AllCaloHandles']['v2_clustertrackmatches'], + global_reco()["AllCaloHandles"]["v2_trackhypomatches"], + global_reco()["AllCaloHandles"]["v2_clustertrackmatches"], eshower, tracks_rels, - use_track_ancestor=True) + use_track_ancestor=True, + ) calopids_v1 = make_convert_calo_chargedpids(calopids_v3, tracks_rels) return { - 'v1_chargedpids': - calopids_v1['chargedpids'], - 'v1_electrons_relations': - global_reco()['AllCaloHandles']['v1_electrons_relations'] + "v1_chargedpids": calopids_v1["chargedpids"], + "v1_electrons_relations": global_reco()["AllCaloHandles"][ + "v1_electrons_relations" + ], } @@ -172,7 +175,8 @@ def make_ttrack_protoparticles( calo_pids=ttrack_reco["calo_pids"], muon_pids=ttrack_reco["muon_pids"], track_types=["Ttrack"], - use_track_ancestor_calo=False) + use_track_ancestor_calo=False, + ) def make_ttrack_MVAfiltered_protoparticles(): -- GitLab From 8885bd7ce6b922f71d5d2e0e8211eaa8d013527d Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Mon, 24 Feb 2025 14:13:07 +0100 Subject: [PATCH 06/13] call AllCaloHandles just once --- .../python/RecoConf/ttrack_selections_reco.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py index 5ad520fc74e..f46b2bacaa5 100644 --- a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py +++ b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py @@ -110,19 +110,19 @@ def make_ttrack_calo_pids(ttracks, global_reco=reconstruction): make_track_energy_in_calo, make_trackbased_eshower, ) - + allCaloHandles = global_reco()["AllCaloHandles"] tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1({"Ttrack": ttracks["v1"]}) tracks_incalo = make_acceptance(tracks_v3) - digitsEcal = global_reco()["AllCaloHandles"]["digitsEcal"] - digitsHcal = global_reco()["AllCaloHandles"]["digitsHcal"] + digitsEcal = allCaloHandles["digitsEcal"] + digitsHcal = allCaloHandles["digitsHcal"] track2caloe = make_track_energy_in_calo(tracks_incalo, digitsEcal, digitsHcal) eshower = make_trackbased_eshower(tracks_incalo, digitsEcal) calopids_v3 = make_calo_chargedpids( tracks_incalo, track2caloe, - global_reco()["AllCaloHandles"]["v2_trackhypomatches"], - global_reco()["AllCaloHandles"]["v2_clustertrackmatches"], + allCaloHandles["v2_trackhypomatches"], + allCaloHandles["v2_clustertrackmatches"], eshower, tracks_rels, use_track_ancestor=True, @@ -131,9 +131,7 @@ def make_ttrack_calo_pids(ttracks, global_reco=reconstruction): calopids_v1 = make_convert_calo_chargedpids(calopids_v3, tracks_rels) return { "v1_chargedpids": calopids_v1["chargedpids"], - "v1_electrons_relations": global_reco()["AllCaloHandles"][ - "v1_electrons_relations" - ], + "v1_electrons_relations": allCaloHandles["v1_electrons_relations"], } -- GitLab From f9632761e0d0f2b45be9fca59c80e943a77f614f Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Mon, 24 Feb 2025 13:13:55 +0000 Subject: [PATCH 07/13] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/51856517 --- Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py index f46b2bacaa5..e532e9bdb3a 100644 --- a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py +++ b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py @@ -110,6 +110,7 @@ def make_ttrack_calo_pids(ttracks, global_reco=reconstruction): make_track_energy_in_calo, make_trackbased_eshower, ) + allCaloHandles = global_reco()["AllCaloHandles"] tracks_v3, tracks_rels = convert_tracks_to_v3_from_v1({"Ttrack": ttracks["v1"]}) -- GitLab From 81dcf0b0ce76da6f2606e62fb83c21fd7893b332 Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Wed, 26 Feb 2025 00:07:24 +0100 Subject: [PATCH 08/13] shared container for calo charged pid --- Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py | 7 +++++-- Hlt/RecoConf/python/RecoConf/standalone.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index be05334683f..bae4a3b6670 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -17,7 +17,8 @@ from PyConf.Algorithms import ( BremInfosConverter_v1, BremInfosConverter_v1Shared, CaloChargedBremAlg, - CaloChargedPIDsAlg, + CaloChargedPIDsAlg_v1, + CaloChargedPIDsAlg_v1Shared, CaloFutureMergedPi0, CaloFutureRawToDigits, ChargedPIDsConverter_v1, @@ -393,9 +394,11 @@ def make_calo_chargedpids( "brem": ["Long", "Downstream", "Upstream", "Velo"], "calo": ["Long", "Downstream", "Ttrack"], }, - base=r"CaloCharged{0}Alg_{1}_{{hash}}", use_track_ancestor=False, + shared_container=False, + base=r"CaloCharged{0}Alg_{1}_{{hash}}", ): + CaloChargedPIDsAlg = CaloChargedPIDsAlg_v1Shared if shared_container else CaloChargedPIDsAlg_v1 pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): if tt in accepted_types["calo"]: diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index d9f12cd0c3f..c560a05327f 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -58,6 +58,7 @@ from RecoConf.calorimeter_reconstruction import ( make_calo_resolution_gamma, make_calo_resolution_pi0, make_convert_calo_chargedpids, + make_calo_chargedpids, make_digits, ) from RecoConf.config import Reconstruction @@ -233,7 +234,7 @@ def standalone_hlt2_global_reco( alltracks4calo, shared_container=True, ) - with make_convert_calo_chargedpids.bind(shared_container=True): + with make_convert_calo_chargedpids.bind(shared_container=True),make_calo_chargedpids.bind(shared_container=True): calo = make_calo( tracks_v3, reco_handles["ExtendedPVs"], trackrels=trackrels ) @@ -910,7 +911,7 @@ def standalone_hlt2_light_reco( ) # Add Calo - with make_convert_calo_chargedpids.bind(shared_container=True): + with make_convert_calo_chargedpids.bind(shared_container=True),make_calo_chargedpids.bind(shared_container=True): calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) data += [calo["ecalSplitClusters"]] @@ -1428,7 +1429,7 @@ def standalone_hlt2_calo_efficiency(light_reco=False): ) # get calo reco - with make_convert_calo_chargedpids.bind(shared_container=light_reco): + with make_convert_calo_chargedpids.bind(shared_container=light_reco),make_calo_chargedpids.bind(shared_container=light_reco): calo = make_calo(tracks_v3, pvs, trackrels=trackrels) data = check_calo_efficiency_fromB(calo) -- GitLab From 9c7bc94744ccd317087723d6bd28fc72e1be9503 Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Tue, 25 Feb 2025 23:10:41 +0000 Subject: [PATCH 09/13] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/51944523 --- .../RecoConf/calorimeter_reconstruction.py | 4 +++- Hlt/RecoConf/python/RecoConf/standalone.py | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index bae4a3b6670..ef4a73580a9 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -398,7 +398,9 @@ def make_calo_chargedpids( shared_container=False, base=r"CaloCharged{0}Alg_{1}_{{hash}}", ): - CaloChargedPIDsAlg = CaloChargedPIDsAlg_v1Shared if shared_container else CaloChargedPIDsAlg_v1 + CaloChargedPIDsAlg = ( + CaloChargedPIDsAlg_v1Shared if shared_container else CaloChargedPIDsAlg_v1 + ) pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): if tt in accepted_types["calo"]: diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index c560a05327f..6a36a0f9ee6 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -54,11 +54,11 @@ from RecoConf.calorimeter_mc_checking import ( ) from RecoConf.calorimeter_reconstruction import ( make_calo, + make_calo_chargedpids, make_calo_cluster_shapes, make_calo_resolution_gamma, make_calo_resolution_pi0, make_convert_calo_chargedpids, - make_calo_chargedpids, make_digits, ) from RecoConf.config import Reconstruction @@ -234,7 +234,10 @@ def standalone_hlt2_global_reco( alltracks4calo, shared_container=True, ) - with make_convert_calo_chargedpids.bind(shared_container=True),make_calo_chargedpids.bind(shared_container=True): + with ( + make_convert_calo_chargedpids.bind(shared_container=True), + make_calo_chargedpids.bind(shared_container=True), + ): calo = make_calo( tracks_v3, reco_handles["ExtendedPVs"], trackrels=trackrels ) @@ -911,7 +914,10 @@ def standalone_hlt2_light_reco( ) # Add Calo - with make_convert_calo_chargedpids.bind(shared_container=True),make_calo_chargedpids.bind(shared_container=True): + with ( + make_convert_calo_chargedpids.bind(shared_container=True), + make_calo_chargedpids.bind(shared_container=True), + ): calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) data += [calo["ecalSplitClusters"]] @@ -1429,7 +1435,10 @@ def standalone_hlt2_calo_efficiency(light_reco=False): ) # get calo reco - with make_convert_calo_chargedpids.bind(shared_container=light_reco),make_calo_chargedpids.bind(shared_container=light_reco): + with ( + make_convert_calo_chargedpids.bind(shared_container=light_reco), + make_calo_chargedpids.bind(shared_container=light_reco), + ): calo = make_calo(tracks_v3, pvs, trackrels=trackrels) data = check_calo_efficiency_fromB(calo) -- GitLab From 3e188caa88e67f3abe16df0e574add4c338aa9dd Mon Sep 17 00:00:00 2001 From: Andrea Merli <andrea.merli@cern.ch> Date: Thu, 27 Feb 2025 19:45:24 +0100 Subject: [PATCH 10/13] fixed hlt2_loose_tracking_config test --- Hlt/RecoConf/python/RecoConf/standalone.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 6a36a0f9ee6..d0b7f8e1fa6 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -1150,7 +1150,10 @@ def standalone_hlt2_light_reco_without_UT( # Add Calo if not skip_Calo: - with make_convert_calo_chargedpids.bind(shared_container=True): + with ( + make_convert_calo_chargedpids.bind(shared_container=True), + make_calo_chargedpids.bind(shared_container=True), + ): calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) data += [calo["ecalSplitClusters"]] -- GitLab From c0784c2adff202ca1a65853ed0be2ec2bcf01b46 Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Sat, 22 Mar 2025 15:34:44 +0100 Subject: [PATCH 11/13] check shared_container if Shared in location of DataHandle; removed correlated with statements --- .../RecoConf/calorimeter_reconstruction.py | 14 ++------ Hlt/RecoConf/python/RecoConf/standalone.py | 36 +++++-------------- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index ef4a73580a9..fd2a7833174 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -395,15 +395,12 @@ def make_calo_chargedpids( "calo": ["Long", "Downstream", "Ttrack"], }, use_track_ancestor=False, - shared_container=False, base=r"CaloCharged{0}Alg_{1}_{{hash}}", ): - CaloChargedPIDsAlg = ( - CaloChargedPIDsAlg_v1Shared if shared_container else CaloChargedPIDsAlg_v1 - ) pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): if tt in accepted_types["calo"]: + CaloChargedPIDsAlg = CaloChargedPIDsAlg_v1Shared if 'Shared' in trackrels[tt].location else CaloChargedPIDsAlg_v1 pids["chargedpids"][tt] = CaloChargedPIDsAlg( name=base.format("PIDs", tt), InEcal=tracks_incalo[tt]["inEcal"], @@ -432,7 +429,6 @@ def make_calo_chargedpids( def make_convert_calo_chargedpids( calopids_v3, trackrels, - shared_container=False, base=r"{0}Converter_{1}_{{hash}}", ): pids = {"chargedpids": {}, "breminfos": {}} @@ -440,19 +436,15 @@ def make_convert_calo_chargedpids( return pids if not len(trackrels): return pids - ChargedConverter = ( - ChargedPIDsConverter_v1Shared if shared_container else ChargedPIDsConverter_v1 - ) for tt in calopids_v3["chargedpids"]: + ChargedConverter = ChargedPIDsConverter_v1Shared if 'Shared' in trackrels[tt].location else ChargedPIDsConverter_v1 pids["chargedpids"][tt] = ChargedConverter( name=base.format("ChargedCaloPIDs", tt), ChargedPIDs=calopids_v3["chargedpids"][tt], Relations=trackrels[tt], ).Output - BremConverter = ( - BremInfosConverter_v1Shared if shared_container else BremInfosConverter_v1 - ) for tt in calopids_v3["breminfos"]: + BremConverter = BremInfosConverter_v1Shared if 'Shared' in trackrels[tt].location else BremInfosConverter_v1 pids["breminfos"][tt] = BremConverter( name=base.format("BremInfos", tt), ChargedPIDs=calopids_v3["breminfos"][tt], diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index d0b7f8e1fa6..59799de6fd6 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -54,11 +54,9 @@ from RecoConf.calorimeter_mc_checking import ( ) from RecoConf.calorimeter_reconstruction import ( make_calo, - make_calo_chargedpids, make_calo_cluster_shapes, make_calo_resolution_gamma, make_calo_resolution_pi0, - make_convert_calo_chargedpids, make_digits, ) from RecoConf.config import Reconstruction @@ -234,13 +232,9 @@ def standalone_hlt2_global_reco( alltracks4calo, shared_container=True, ) - with ( - make_convert_calo_chargedpids.bind(shared_container=True), - make_calo_chargedpids.bind(shared_container=True), - ): - calo = make_calo( - tracks_v3, reco_handles["ExtendedPVs"], trackrels=trackrels - ) + calo = make_calo( + tracks_v3, reco_handles["ExtendedPVs"], trackrels=trackrels + ) data += monitor_calo(calo, tracks_v3) monitor_track_types = get_monitoring_track_types_for_light_reco() @@ -914,11 +908,7 @@ def standalone_hlt2_light_reco( ) # Add Calo - with ( - make_convert_calo_chargedpids.bind(shared_container=True), - make_calo_chargedpids.bind(shared_container=True), - ): - calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) + calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) data += [calo["ecalSplitClusters"]] data += [calo["v1_chargedpids"][tt] for tt in calo["v1_chargedpids"].keys()] @@ -1150,15 +1140,11 @@ def standalone_hlt2_light_reco_without_UT( # Add Calo if not skip_Calo: - with ( - make_convert_calo_chargedpids.bind(shared_container=True), - make_calo_chargedpids.bind(shared_container=True), - ): - calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) + calo = make_calo(tracks_v3, pvs["v3"], trackrels=trackrels) - data += [calo["ecalSplitClusters"]] - data += [calo["v1_chargedpids"][tt] for tt in calo["v1_chargedpids"].keys()] - data += [calo["v1_breminfos"][tt] for tt in calo["v1_breminfos"].keys()] + data += [calo["ecalSplitClusters"]] + data += [calo["v1_chargedpids"][tt] for tt in calo["v1_chargedpids"].keys()] + data += [calo["v1_breminfos"][tt] for tt in calo["v1_breminfos"].keys()] # Add Muon if not skip_Muon: @@ -1438,11 +1424,7 @@ def standalone_hlt2_calo_efficiency(light_reco=False): ) # get calo reco - with ( - make_convert_calo_chargedpids.bind(shared_container=light_reco), - make_calo_chargedpids.bind(shared_container=light_reco), - ): - calo = make_calo(tracks_v3, pvs, trackrels=trackrels) + calo = make_calo(tracks_v3, pvs, trackrels=trackrels) data = check_calo_efficiency_fromB(calo) -- GitLab From 9c4f52d5e00664e4d76971413f2a5711d09b7655 Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Sat, 22 Mar 2025 14:35:27 +0000 Subject: [PATCH 12/13] pre-commit fixes patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/53158955 --- .../RecoConf/calorimeter_reconstruction.py | 18 +++++++++++++++--- Hlt/RecoConf/python/RecoConf/standalone.py | 4 +--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py index fd2a7833174..1aec4170282 100644 --- a/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py +++ b/Hlt/RecoConf/python/RecoConf/calorimeter_reconstruction.py @@ -400,7 +400,11 @@ def make_calo_chargedpids( pids = {"chargedpids": {}, "breminfos": {}} for tt in tracks_incalo.keys(): if tt in accepted_types["calo"]: - CaloChargedPIDsAlg = CaloChargedPIDsAlg_v1Shared if 'Shared' in trackrels[tt].location else CaloChargedPIDsAlg_v1 + CaloChargedPIDsAlg = ( + CaloChargedPIDsAlg_v1Shared + if "Shared" in trackrels[tt].location + else CaloChargedPIDsAlg_v1 + ) pids["chargedpids"][tt] = CaloChargedPIDsAlg( name=base.format("PIDs", tt), InEcal=tracks_incalo[tt]["inEcal"], @@ -437,14 +441,22 @@ def make_convert_calo_chargedpids( if not len(trackrels): return pids for tt in calopids_v3["chargedpids"]: - ChargedConverter = ChargedPIDsConverter_v1Shared if 'Shared' in trackrels[tt].location else ChargedPIDsConverter_v1 + ChargedConverter = ( + ChargedPIDsConverter_v1Shared + if "Shared" in trackrels[tt].location + else ChargedPIDsConverter_v1 + ) pids["chargedpids"][tt] = ChargedConverter( name=base.format("ChargedCaloPIDs", tt), ChargedPIDs=calopids_v3["chargedpids"][tt], Relations=trackrels[tt], ).Output for tt in calopids_v3["breminfos"]: - BremConverter = BremInfosConverter_v1Shared if 'Shared' in trackrels[tt].location else BremInfosConverter_v1 + BremConverter = ( + BremInfosConverter_v1Shared + if "Shared" in trackrels[tt].location + else BremInfosConverter_v1 + ) pids["breminfos"][tt] = BremConverter( name=base.format("BremInfos", tt), ChargedPIDs=calopids_v3["breminfos"][tt], diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py index 59799de6fd6..c6f34e504bb 100644 --- a/Hlt/RecoConf/python/RecoConf/standalone.py +++ b/Hlt/RecoConf/python/RecoConf/standalone.py @@ -232,9 +232,7 @@ def standalone_hlt2_global_reco( alltracks4calo, shared_container=True, ) - calo = make_calo( - tracks_v3, reco_handles["ExtendedPVs"], trackrels=trackrels - ) + calo = make_calo(tracks_v3, reco_handles["ExtendedPVs"], trackrels=trackrels) data += monitor_calo(calo, tracks_v3) monitor_track_types = get_monitoring_track_types_for_light_reco() -- GitLab From 3dee11a7535a204e544bbf41375927b9b0841613 Mon Sep 17 00:00:00 2001 From: Merli Andrea <merli@lphesrv1.epfl.ch> Date: Tue, 1 Apr 2025 19:27:26 +0200 Subject: [PATCH 13/13] make compatible with master --- Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py index a6e33e81cce..7cde6444e4e 100644 --- a/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py +++ b/Hlt/RecoConf/python/RecoConf/ttrack_selections_reco.py @@ -125,6 +125,7 @@ def make_ttrack_calo_pids(ttracks, global_reco=reconstruction): allCaloHandles["v2_trackhypomatches"], allCaloHandles["v2_trackclustermatches"], eshower, + allCaloHandles["v2_photons"], tracks_rels, use_track_ancestor=True, ) -- GitLab