diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py index a429ed4b96f2114aaf91aae72588147ecf490f9d..2622bde810a426ca5925073f21b6d05e95262686 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py @@ -17,8 +17,7 @@ __date__ = "2021-11-23" import Functors as F from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from DaVinci.reco_objects import make_pvs -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_pvs from DaVinci.algorithms import add_filter, get_decreports, get_odin from DecayTreeFitter import DTFAlg from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg @@ -30,7 +29,7 @@ from DaVinci import Options, make_config # Definition of strucing line # bd2dsk_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line" -bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles") +bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles", "Spruce") _basic = 'basic' _composite = 'composite' @@ -259,7 +258,7 @@ def alg_config(options: Options): # # DecayTreeFitter Algorithm # - v2_pvs = make_pvs() + v2_pvs = get_pvs(options.process) # # DecayTreeFitter Algorithm diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py index 742b7c128ed98b00038a28743aa6d96a0a4fd477..5c42822524e00c2c5e8f432731b259cff9a6d81e 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py @@ -18,8 +18,7 @@ from DaVinciMCTools import MCReconstructible, MCReconstructed from DaVinci import Options, make_config from RecoConf.data_from_file import make_mc_track_info from FunTuple.functorcollections import MCReconstructed_Collection, MCReconstructible_Collection -from PyConf.reading import get_mc_particles, get_pp2mcp_relations -from DaVinci.reco_objects import make_charged_protoparticles, make_neutral_protoparticles +from PyConf.reading import get_mc_particles, get_pp2mcp_relations, get_charged_protoparticles, get_neutral_protoparticles def main(options: Options): @@ -29,8 +28,8 @@ def main(options: Options): # PP2MCP relations need MC particles and ProtoParticles # Since MC is already unpacked, only unpack protos and relations extra_inputs = [] - extra_inputs += [make_charged_protoparticles(options.process)] - extra_inputs += [make_neutral_protoparticles(options.process)] + extra_inputs += [get_charged_protoparticles(options.process)] + extra_inputs += [get_neutral_protoparticles(options.process)] relations = [ get_pp2mcp_relations( diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py index a1789d6041412cd05fa943959681123132271f04..ad9787fd35a7a65f02f9b7fba75892da8333abc3 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py @@ -19,8 +19,7 @@ from DaVinci.algorithms import add_filter from DaVinci import make_config, Options from DaVinci.algorithms import get_odin from FunTuple.functorcollections import EventInfo -from DaVinci.reco_objects import get_rec_summary -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_rec_summary def main(options: Options): diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py index e0412fc7e6bd0c5bfe5342941278ed85a3463232..6fb55289d55beea85511f0ddd8f6a5cf984a64f4 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py @@ -14,8 +14,7 @@ Read an HLT2 file and create an ntuple with the new DaVinci configuration. import Functors as F from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple -from DaVinci.reco_objects import make_pvs -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_pvs from DaVinci.algorithms import add_filter from DaVinci import Options, make_config from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg @@ -31,7 +30,7 @@ def main(options: Options): } # Creating v2 reconstructed vertices to be used in the following functor - v2_pvs = make_pvs(process=options.process) + v2_pvs = get_pvs(process=options.process) d0_variables = FC({ "ID": F.PARTICLE_ID, diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py index 4f6c0eb4444de47b67b0503a16414ac0898bf57f..7cea8ff46cfc0f0331a8297e8d435d95943a35c0 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py @@ -22,8 +22,7 @@ import Functors as F from PyConf.Algorithms import WeightedRelTableAlg from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple from FunTuple.functorcollections import TrackIsolation -from DaVinci.reco_objects import make_pvs -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_pvs from DaVinci.algorithms import add_filter from DaVinci import Options, make_config @@ -42,7 +41,7 @@ def main(options: Options): "/Event/HLT2/Hlt2B2JpsiKLine/LongTaggingParticles/Particles", process=options.process) - pvs = make_pvs(process=options.process) + pvs = get_pvs(process=options.process) ftAlg = WeightedRelTableAlg( ReferenceParticles=b2jpsik_data, diff --git a/DaVinciTests/python/DaVinciTests/recVertices.py b/DaVinciTests/python/DaVinciTests/recVertices.py index 3ab692ea246dcc524546eb0c4ed50a004a7d01ac..fc5034ad998f1bfe4bc11b50076ab058c5ea9b24 100644 --- a/DaVinciTests/python/DaVinciTests/recVertices.py +++ b/DaVinciTests/python/DaVinciTests/recVertices.py @@ -14,21 +14,21 @@ Test for the function returning DataHandle for v2 RecVertices for usage in ThOr import Functors as F from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from DaVinci.reco_objects import make_pvs -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_pvs from DaVinci.algorithms import add_filter from DaVinci import Options, make_config def main(options: Options): bd2dsk_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line" - bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles") + bd2dsk_data = get_particles(f"/Event/Spruce/{bd2dsk_line}/Particles", + options.process) fields_dsk = { 'B0': "[B0 -> D_s- K+]CC", } - v2_pvs = make_pvs(process=options.process) + v2_pvs = get_pvs(process=options.process) variables_pvs = FunctorCollection({ "BPVDIRA": F.BPVDIRA(v2_pvs), diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py index 82edb42ad339a5ccbb4d053444b4524accb00809..7bdd55146c70bc76e6c00ced0493c9f454142e84 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py @@ -11,8 +11,7 @@ import Functors as F from DaVinci import Options, make_config from DaVinci.algorithms import add_filter -from DaVinci.reco_objects import make_pvs -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_pvs from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple @@ -31,7 +30,7 @@ def main(options: Options): # Creating v2 reconstructed vertices to be used in the following functor # For the time being there's a mix of legacy and v2 event classes. That will eventually be cleaned once the # event model is fixed. In the meantime there are helper functions in DaVinci. - pvs = make_pvs(process=options.process) + pvs = get_pvs(process=options.process) #Evaluate the impact parameter all_vars = {} diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py index 81d86f169381cea86d49e839d1add14dabf98471..9a31d44399f4238c52d50b165efd2d5c13afe5df 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py @@ -11,7 +11,8 @@ import Functors as F from DaVinci import Options, make_config from DaVinci.algorithms import add_filter -from PyConf.reading import get_particles +from PyConf.reading import get_particles, get_pvs, get_pvs_v1 + from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple from FunTuple.functorcollections import Kinematics @@ -63,9 +64,8 @@ def main(options: Options): # The function "make_pvs()" returns v2 vertices whereas "make_pvs_v1()" returns v1 verticies. # The PV constraint in the Decay tree fitter currently only works with v1 # (see https://gitlab.cern.ch/lhcb/Rec/-/issues/318 and https://gitlab.cern.ch/lhcb/Rec/-/issues/309) - from DaVinci.reco_objects import make_pvs, make_pvs_v1 - pvs = make_pvs_v1(process=options.process) - pvs_v2 = make_pvs(process=options.process) + pvs = get_pvs_v1(process=options.process) + pvs_v2 = get_pvs(process=options.process) #Add not only mass but also constrain Bs to be coming from primary vertex DTFpv = DTFAlg( diff --git a/Phys/DaVinci/python/DaVinci/common_particles.py b/Phys/DaVinci/python/DaVinci/common_particles.py index 12205341ada83542867d7ac846d5704d97ba9054..0a37a2157088fa8bc5ebff859ae1c246d7e4ee60 100644 --- a/Phys/DaVinci/python/DaVinci/common_particles.py +++ b/Phys/DaVinci/python/DaVinci/common_particles.py @@ -20,8 +20,8 @@ from Hlt2Conf.standard_particles import (make_long_kaons, make_long_muons, standard_protoparticle_filter, get_long_track_selector) from Hlt2Conf.algorithms_thor import ParticleFilter, ParticleCombiner -from DaVinci.reco_objects import (make_charged_protoparticles as - _make_charged_protoparticles) +from PyConf.reading import (get_charged_protoparticles as + _make_charged_protoparticles) from RecoConf.reco_objects_from_file import make_pvs as _make_pvs_v2 from DaVinci.filter_selectors import default_particle_cuts diff --git a/Phys/DaVinci/python/DaVinci/reco_objects.py b/Phys/DaVinci/python/DaVinci/reco_objects.py deleted file mode 100644 index 26fca98b643fd1180abc4f9e5251bccbb7d4ab52..0000000000000000000000000000000000000000 --- a/Phys/DaVinci/python/DaVinci/reco_objects.py +++ /dev/null @@ -1,114 +0,0 @@ -############################################################################### -# (c) Copyright 2020-2021 CERN for the benefit of the LHCb Collaboration # -# # -# This software is distributed under the terms of the GNU General Public # -# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # -# # -# In applying this licence, CERN does not waive the privileges and immunities # -# granted to it by virtue of its status as an Intergovernmental Organization # -# or submit itself to any jurisdiction. # -############################################################################### -""" -Configurables to make the various reconstruction objects from the -packed data on file. - -.. note:: - 1) What is defined here relies on data paths used in Runs 1 & 2, - and may need a revision once the Run 3 event model is finalised - and the definition of what gets persisted gets formalised. - 2) Code very heavily relies on its Moore equivalent. Thank you, RTA team. -""" - -from PyConf.packing import reco_locations, unpackers_map - -from PyConf.components import force_location -from PyConf.tonic import configurable -from PyConf.reading import upfront_decoder - - -@configurable -def upfront_reconstruction(process='Spruce'): - """Return a list DataHandles that define the upfront reconstruction output. - - This differs from `reconstruction` as it should not be used as inputs to - other algorithms, but only to define the control flow, i.e. the return - value of this function should be ran before all HLT2 lines. - """ - stream = '/Event/Spruce/HLT2' - if process in ['Hlt2', 'Turbo']: - stream = '/Event/HLT2' - - reco_loc = reco_locations(stream) - unpacker_algs = [] - unpackers = unpackers_map() - - for loc, k in reco_loc.values(): - unp = unpackers[k] - unpacker_algs += [ - unp(InputName=upfront_decoder(process), - outputs={"OutputName": force_location(loc)}, - OutputLevel=5) - ] - - return unpacker_algs - - -@configurable -def reconstruction(process='Spruce'): - """Return a {name: DataHandle} dict that define the reconstruction output.""" - - stream = '/Event/Spruce/HLT2' - if process in ['Hlt2', 'Turbo']: - stream = '/Event/HLT2' - - unpackers = upfront_reconstruction(process) - - reco_map = {} - reco_loc = reco_locations(stream) - for key, value in reco_loc.items(): - for v in unpackers: - if "OutputName" in v.outputs.keys( - ) and v.OutputName.location == value[0]: - # values are in format (location, type), need location here - reco_map[key] = v.OutputName - break - - ### Temporary: as long as we persist v1, we need to insert a converter for the new PVs - from PyConf.Algorithms import RecV1ToPVConverter - reco_map["PVs_v1"] = reco_map["PVs"] - reco_map["PVs"] = RecV1ToPVConverter( - InputVertices=reco_map["PVs_v1"]).OutputVertices - - return reco_map - - -def make_rich_pids(process='Spruce'): - return reconstruction(process=process)['RichPIDs'] - - -def make_muon_pids(process='Spruce'): - return reconstruction(process=process)['MuonPIDs'] - - -def make_charged_protoparticles(process='Spruce'): - return reconstruction(process=process)['ChargedProtos'] - - -def make_neutral_protoparticles(process='Spruce'): - return reconstruction(process=process)['NeutralProtos'] - - -def make_pvs(process='Spruce'): - return reconstruction(process=process)['PVs'] - - -def make_pvs_v1(process='Spruce'): - return reconstruction(process=process)['PVs_v1'] - - -def make_tracks(process='Spruce'): - return reconstruction(process=process)['Tracks'] - - -def get_rec_summary(process="Spruce"): - return reconstruction(process=process)['RecSummary'] diff --git a/Phys/DaVinci/python/DaVinci/truth_matching.py b/Phys/DaVinci/python/DaVinci/truth_matching.py index c62235482cce1e784c9e7f7afb21766b0f408b0f..7a72d95c51e5534b9f8d2665a09a3aefd73991a4 100644 --- a/Phys/DaVinci/python/DaVinci/truth_matching.py +++ b/Phys/DaVinci/python/DaVinci/truth_matching.py @@ -15,9 +15,8 @@ from PyConf.Algorithms import MCTruthAndBkgCatAlg from PyConf.Tools import DaVinciSmartAssociator, MCMatchObjP2MCRelator, ParticleDescendants from PyConf.Tools import BackgroundCategory, BackgroundCategoryViaRelations from PyConf.Tools import P2MCPFromProtoP -from PyConf.reading import get_pp2mcp_relations, get_mc_particles +from PyConf.reading import get_pp2mcp_relations, get_mc_particles, get_charged_protoparticles, get_neutral_protoparticles from PyConf.location_prefix import prefix -from DaVinci.reco_objects import make_charged_protoparticles, make_neutral_protoparticles def configured_MCTruthAndBkgCatAlg( @@ -72,8 +71,8 @@ def configured_MCTruthAndBkgCatAlg( # No algorithm is asking for mc particles and proto particles explicitely # But pp2mcp relation unpacker needs them, so give them as extra_inputs extra_inputs = [] - extra_inputs += [make_charged_protoparticles(process)] - extra_inputs += [make_neutral_protoparticles(process)] + extra_inputs += [get_charged_protoparticles(process)] + extra_inputs += [get_neutral_protoparticles(process)] mc_loc = root_in_tes + "/MC/Particles" extra_inputs += [get_mc_particles(mc_loc)]