diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py index 6acf6c95207c990168c7943fe338e82e9c5fba15..e05867f1c82bf11d44f23908f90986db05778c71 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -21,7 +21,7 @@ from PyConf.reading import get_particles, get_pvs from DaVinci.algorithms import add_filter from PyConf.reading import get_decreports, get_odin from DecayTreeFitter import DecayTreeFitter -from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg +from DaVinciMCTools import MCTruthAndBkgCat from PyConf.Algorithms import PrintDecayTree from DaVinci import Options, make_config @@ -36,7 +36,7 @@ _composite = 'composite' _toplevel = 'toplevel' -def all_variables(pvs, DTF, mctruth, ptype): +def all_variables(pvs, dtf, mctruth, ptype): """ function that returns dictonary of functors that work. @@ -56,7 +56,7 @@ def all_variables(pvs, DTF, mctruth, ptype): if comp: all_vars['ALV'] = F.ALV(Child1=1, Child2=2) - all_vars['BKGCAT'] = F.BKGCAT(Relations=mctruth.BkgCatTable) + all_vars['BKGCAT'] = mctruth.BkgCat if comp: # all these require a vertex all_vars['BPVCORRM'] = F.BPVCORRM(pvs) @@ -154,8 +154,8 @@ def all_variables(pvs, DTF, mctruth, ptype): if basic: all_vars['IS_PHOTON'] = F.IS_PHOTON - all_vars['DTF_PT'] = DTF.get_info(F.PT) - all_vars['DTF_BPVIPCHI2'] = DTF.get_info(F.BPVIPCHI2(pvs)) + all_vars['DTF_PT'] = dtf(F.PT) + all_vars['DTF_BPVIPCHI2'] = dtf(F.BPVIPCHI2(pvs)) all_vars['MASS'] = F.MASS if top: # B @@ -171,8 +171,8 @@ def all_variables(pvs, DTF, mctruth, ptype): # Important note: specify an invalid value for integer functors if there exists no truth info. # The invalid value for floating point functors is set to nan. - all_vars['MC_MOTHER_ID'] = F.VALUE_OR(0) @ F.MAP_INPUT( - Functor=F.MC_MOTHER(1, F.PARTICLE_ID), Relations=mctruth.MCAssocTable) + all_vars['MC_MOTHER_ID'] = F.VALUE_OR(0) @ mctruth( + F.MC_MOTHER(1, F.PARTICLE_ID)) if comp: all_vars['MINPT'] = F.MIN(F.PT) all_vars['MINIP'] = F.MINIP(pvs) @@ -192,12 +192,9 @@ def all_variables(pvs, DTF, mctruth, ptype): all_vars['OBJECT_KEY'] = F.OBJECT_KEY - all_vars['ORIGIN_VX'] = F.MAP_INPUT( - Functor=F.ORIGIN_VX, Relations=mctruth.MCAssocTable) - all_vars['ORIGIN_VY'] = F.MAP_INPUT( - Functor=F.ORIGIN_VY, Relations=mctruth.MCAssocTable) - all_vars['ORIGIN_VZ'] = F.MAP_INPUT( - Functor=F.ORIGIN_VZ, Relations=mctruth.MCAssocTable) + all_vars['ORIGIN_VX'] = mctruth(F.ORIGIN_VX) + all_vars['ORIGIN_VY'] = mctruth(F.ORIGIN_VY) + all_vars['ORIGIN_VZ'] = mctruth(F.ORIGIN_VZ) all_vars['P'] = F.P all_vars['PARTICLE_ID'] = F.PARTICLE_ID @@ -287,13 +284,13 @@ def alg_config(options: Options): v2_pvs = get_pvs() # - # DecayTreeFitter Algorithm + # DecayTreeFitter Algorithm with "name" and "input_particles" as arguments # - DTF = DecayTreeFitter(name='DTF_Bd2DsK', input=bd2dsk_data) + DTF = DecayTreeFitter(name='DTF_Bd2DsK', input_particles=bd2dsk_data) # - # MC truth + # MC truth with "input_particles" as argument # - mctruth = configured_MCTruthAndBkgCatAlg(inputs=bd2dsk_data) + MCTRUTH = MCTruthAndBkgCat(input_particles=bd2dsk_data) # # Definition of fields (branches) and functors # @@ -305,11 +302,11 @@ def alg_config(options: Options): } variables_dsk = { 'B0': FunctorCollection( - all_variables(v2_pvs, DTF, mctruth, _toplevel)), - 'Kaon': FunctorCollection(all_variables(v2_pvs, DTF, mctruth, _basic)), + all_variables(v2_pvs, DTF, MCTRUTH, _toplevel)), + 'Kaon': FunctorCollection(all_variables(v2_pvs, DTF, MCTRUTH, _basic)), 'Ds': FunctorCollection( - all_variables(v2_pvs, DTF, mctruth, _composite)), - 'pip': FunctorCollection(all_variables(v2_pvs, DTF, mctruth, _basic)), + all_variables(v2_pvs, DTF, MCTRUTH, _composite)), + 'pip': FunctorCollection(all_variables(v2_pvs, DTF, MCTRUTH, _basic)), } # diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py index 8d2b5b73cba82e4c757dea25fa4e7d0edab9f917..e33d5cabe16e47b8a3382eb3d758cafb23da9551 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py @@ -44,7 +44,7 @@ def main(options: Options): # DecayTreeFitter Algorithm. DTF = DecayTreeFitter( name='DTF_filtered', - input=data_filtered, + input_particles=data_filtered, mass_constraints=["D_s-"], output_level=INFO) @@ -58,15 +58,15 @@ def main(options: Options): #make collection of functors for Ds meson variables_ds = FC({ 'DTF_PT': - DTF.get_info(F.PT), + DTF(F.PT), 'DTF_MASS': - DTF.get_info(F.MASS), + DTF(F.MASS), # Important note: specify an invalid value for integer functors if there exists no truth info. # The invalid value for floating point functors is set to nan. 'DTF_CHILD1_ID': - F.VALUE_OR(0) @ DTF.get_info(F.CHILD(1, F.PARTICLE_ID)), + F.VALUE_OR(0) @ DTF(F.CHILD(1, F.PARTICLE_ID)), 'DTF_CHILD1_MASS': - DTF.get_info(F.CHILD(1, F.MASS)), + DTF(F.CHILD(1, F.MASS)), }) #associate FunctorCollection to field (branch) name diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_run_mc.py b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_run_mc.py index bb023fddc348d3487fa1ad7ee2f59eedbb4a8216..e597a7975cd1c20a81afcb3ddf5fd025a550b80d 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_run_mc.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_run_mc.py @@ -34,7 +34,7 @@ def main(options: Options): DTF = DecayTreeFitter( name='DTF_dimuons', - input=dimuons, + input_particles=dimuons, mass_constraints=["J/psi(1S)"], output_level=3) @@ -64,9 +64,9 @@ def main(options: Options): 'THOR_MASS': F.MASS, 'DTF_PT': - DTF.get_info(F.PT), + DTF(F.PT), 'DTF_MASS': - DTF.get_info(F.MASS), + DTF(F.MASS), }) # @@ -74,8 +74,8 @@ def main(options: Options): # DTF_pv = DecayTreeFitter( name='DTF_PVConstraints', - input=dimuons, - input_pvs=pvs, + input_particles=dimuons, + input_pvs=pvs, #input PVs mass_constraints=["J/psi(1S)"]) variables_jpsi.update( DTF_pv.apply_functors(functors=[F.PT, F.MASS], head='DTF_PV_')) @@ -84,7 +84,7 @@ def main(options: Options): variables_muplus = FunctorCollection({ 'LOKI_P': 'P', 'THOR_P': F.P, - 'DTF_PT': DTF.get_info(F.PT), + 'DTF_PT': DTF(F.PT), }) #associate FunctorCollection to field (branch) name diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/advanced_run_mc.py b/DaVinciExamples/python/DaVinciExamples/tupling/advanced_run_mc.py index 2f536f21b46ccb577ca5ba2a19bd75a06f9ea407..dc9020338c554c5e5cd01354494f240b1f94c596 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/advanced_run_mc.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/advanced_run_mc.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -18,7 +18,7 @@ from Hlt2Conf.standard_particles import make_detached_mumu, make_KsDD from RecoConf.reconstruction_objects import upfront_reconstruction from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci import Options, make_config @@ -60,7 +60,7 @@ def main(options: Options): print('Variables in Jpsi field', variables_jpsi) #FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() print('Variables in ALL field', variables_all) print('Variables in MuPlus field', variables_extra) 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 f51ad12b2d751a10a3e4f0383ebd426aa4236bfe..d2d8c54d63e5d3b45956086417a0d455b8c39a6f 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/example-tupling-mc-reconstructible-reconstructed.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -9,15 +9,14 @@ # or submit itself to any jurisdiction. # ############################################################################### """ -Example options to show the usage of the new DaVinciMCTools: MCReconstructible -and MCReconstructed. +Example options to show the usage of the new DaVinciMCTools +`MCReconstructible` and `MCReconstructed` helper classes. """ - +from PyConf.reading import get_mc_particles, get_pp2mcp_relations, get_charged_protoparticles, get_neutral_protoparticles, get_mc_track_info from FunTuple import FunTuple_MCParticles as MCFuntuple -from DaVinciMCTools import MCReconstructible, MCReconstructed +from DaVinciMCTools import MCReconstructible as MCRectible, MCReconstructed as MCRected from DaVinci import Options, make_config -from FunTuple.functorcollections import MCReconstructed_Collection, MCReconstructible_Collection -from PyConf.reading import get_mc_particles, get_pp2mcp_relations, get_charged_protoparticles, get_neutral_protoparticles, get_mc_track_info +import FunTuple.functorcollections as FC def main(options: Options): @@ -36,13 +35,14 @@ def main(options: Options): "/Event/HLT2/Relations/NeutralPP2MCP", extra_inputs=extra_inputs) #Get variables related to reconstructible information. - mcrtible = MCReconstructible(mc_track_info=get_mc_track_info()) + mcrtible = MCRectible( + input_mctrackinfo=get_mc_track_info()) # tes location of MC track info #The option extra_info is set to False by default and can be set to True to get more information - vars_rtible = MCReconstructible_Collection( + vars_rtible = FC.MCReconstructible( mcreconstructible_alg=mcrtible, extra_info=True) print('Reconstructible functors:', vars_rtible.functor_dict.keys()) - #Note instead of importing functorcollections (MCReconstructed_Collection), one - # can directly add track related information using the helper class (MCReconstructible) + #Note instead of importing functorcollections (FC.MCReconstructible), one + # can directly add track related information using the helper class (DaVinciMCTools.MCReconstructible) vars_rtible["EXTRA_MC_HASUT"] = mcrtible.HasUT vars_rtible["EXTRA_MC_HASVELO"] = mcrtible.HasVelo print('Reconstructible functors:', vars_rtible.functor_dict.keys()) @@ -53,18 +53,18 @@ def main(options: Options): # - If "use_best_mcmatch = False", all associated reconstructed # tracks to the mc particle are used (tupling arrays). # Here we set it to false for testing purposes. - mcrted_all = MCReconstructed( - MC_data, + mcrted_all = MCRected( + input_mcparticles=MC_data, use_best_mcmatch=False, relations_charged=relations_charged, relations_neutral=relations_neutral) #The option extra_info below is set to False by default in the functor collection. - vars_rted = MCReconstructed_Collection( + vars_rted = FC.MCReconstructed( mcreconstructed_alg=mcrted_all, extra_info=False) #Note: - # - Instead of importing functorcollections (MCReconstructed_Collection), one - # can directly add track related information using the helper class (MCReconstructed). - # - A new functor can be added for e.g. vars_rtible["MC_HASUT"] = mcrtible.get_info(F.NEW_TRACK_FUNCTOR) + # - Instead of importing functorcollections (FC.MCReconstructed), one + # can directly add track related information using the helper class (DaVinciMCTools.MCReconstructed). + # - A new functor can be added for e.g. vars_rtible["MC_HASUT"] = mcrtible(F.NEW_TRACK_FUNCTOR) vars_rted['TRACK_TYPE[TRACK_INDX]'] = mcrted_all.TrackType vars_rted['TRACK_HASUT[TRACK_INDX]'] = mcrted_all.HasUT print('Reconstructed functors:', vars_rted.functor_dict.keys()) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py index 5b3b5aab16d7939fbb48941829ef035ed122e24a..d2f3f7ea8503dcaa1bb702b5c471d05bcbc81308 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_configFuntuple.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -13,7 +13,7 @@ Example options to read the output of a Sprucing job with the new DaVinci config filtering on an HLT2 line decision. """ from FunTuple import FunctorCollection -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci.algorithms import configured_FunTuple from DaVinci import Options, make_config @@ -35,7 +35,7 @@ def main(options: Options): } # FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() # FunTuple: associate functor collections to field (branch) name variables = { diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py index 2a8e188a28823d75db136caa94a00ff193c118b6..80b60494ceb87fb5ad15b0e04baac542ab662c4e 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py @@ -33,20 +33,20 @@ def main(options: Options): pvs_v1 = get_pvs_v1() DTF_JpsiPhi = DecayTreeFitter( name='DTF_JpsiPhi', - input=B_Data, + input_particles=B_Data, mass_constraints=['B_s0', 'J/psi(1S)'], input_pvs=pvs_v1, output_level=INFO) DTF_JpsiKst = DecayTreeFitter( name='DTF_JpsiKst', - input=B_Data, + input_particles=B_Data, + input_pvs=pvs_v1, substitutions=[ 'B_s0{{B0}} -> (J/psi(1S) -> mu+ mu-) (phi(1020){{K*(892)0}} -> K+ K-{{pi-}})', 'B_s~0{{B0}} -> (J/psi(1S) -> mu+ mu-) (phi(1020){{K*(892)~0}} -> K- K+{{pi+}})', ], mass_constraints=['B0', 'J/psi(1S)'], - input_pvs=pvs_v1, output_level=INFO) fields = { @@ -73,26 +73,26 @@ def main(options: Options): F.CHI2DOF, # DTF Bs2JpsiPhi 'DTF_JpsiPhi_ID': - F.VALUE_OR(-1) @ DTF_JpsiPhi.get_info(F.PARTICLE_ID), + F.VALUE_OR(-1) @ DTF_JpsiPhi(F.PARTICLE_ID), 'DTF_JpsiPhi_M': - DTF_JpsiPhi.get_info(F.MASS), + DTF_JpsiPhi(F.MASS), 'DTF_JpsiPhi_P': - DTF_JpsiPhi.get_info(F.P), + DTF_JpsiPhi(F.P), 'DTF_JpsiPhi_ENERGY': - DTF_JpsiPhi.get_info(F.ENERGY), + DTF_JpsiPhi(F.ENERGY), 'DTF_JpsiPhi_CHI2DOF': - DTF_JpsiPhi.get_info(F.CHI2DOF), + DTF_JpsiPhi(F.CHI2DOF), # DTF Bd2JpsiKst 'DTF_JpsiKst_ID': - F.VALUE_OR(-1) @ DTF_JpsiKst.get_info(F.PARTICLE_ID), + F.VALUE_OR(-1) @ DTF_JpsiKst(F.PARTICLE_ID), 'DTF_JpsiKst_M': - DTF_JpsiKst.get_info(F.MASS), + DTF_JpsiKst(F.MASS), 'DTF_JpsiKst_P': - DTF_JpsiKst.get_info(F.P), + DTF_JpsiKst(F.P), 'DTF_JpsiKst_ENERGY': - DTF_JpsiKst.get_info(F.ENERGY), + DTF_JpsiKst(F.ENERGY), 'DTF_JpsiKst_CHI2DOF': - DTF_JpsiKst.get_info(F.CHI2DOF), + DTF_JpsiKst(F.CHI2DOF), }) variables = {'ALL': variables_all} diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py index d662baeafd27d707ac71769a01d9bdbd43a14689..81055ffd025a23a5fe4371dd78a1ffd553b26f96 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -27,7 +27,7 @@ Then the MAP_INPUT_ARRAY functor takes in input this relation map and for each entry stores the output of an external functor (i.e F.P, F.PT) in a vector. In addition, MC truth information for each track in the 'make_long-pions' -location is retrieved and stored in the final tuples via the 'configured_MCTruthAndBkgCatAlg' function. +location is retrieved and stored in the final tuples via the 'MCTruthAndBkgCat' function. N.B. the job runs over a spruced sample, but the same flow can be used also for turbo .dst. @@ -42,7 +42,7 @@ from FunTuple import FunctorCollection as FC, FunTuple_Particles as Funtuple from DaVinci import Options, make_config from DaVinci.algorithms import add_filter from DaVinci.common_particles import make_long_pions -from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg +from DaVinciMCTools import MCTruthAndBkgCat def main(options: Options): @@ -81,18 +81,8 @@ def main(options: Options): # particles can be followed. # For a comparison define both a relation map to the corresponding MC particles # for the decay chain ('mctruth') and for the other tracks in the event ('mctruth_pions'). - mctruth = configured_MCTruthAndBkgCatAlg(inputs=bd2dsk_data) - mctruth_pions = configured_MCTruthAndBkgCatAlg(inputs=tagging_container) - - # Helper 'lambda functions' can be used to evaluate a specific functor (func) over all the particles - # linked in a relation table, defined by the 'Relations' keyword. - # In this case we create a lambda function that apply a functor, given as input by the user, - # to all the MC particles found by the 'configured_MCTruthAndBkgCatAlg' instances - # defined before: both for the signal decay chain and for the underlying tracks. - # In particular the 'MCAssocTable' method can be used to obtain the correct relation map from the - # 'mctruth' and 'mctruth_pions' objects defined before. - MCTRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable) - MCTRUTH_pions = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth_pions.MCAssocTable) + MCTRUTH = MCTruthAndBkgCat(bd2dsk_data) + MCTRUTH_pions = MCTruthAndBkgCat(tagging_container) #make collection of functors # Define all the variables to be associated to the B field diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py index cb076806c0dadddee19f6b9e5faf9dbfd8e64e20..a0a9ba43cafbfbdb114607f3406f835fafcab228 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_eventinfo.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -12,13 +12,13 @@ Read an HLT2 file and create an ntuple with information from RecSumarry (e.g. nPVs, nTracks, nFTClusters) """ +from PyConf.reading import get_particles, get_rec_summary import Functors as F -from FunTuple import FunctorCollection as FC +from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter -from FunTuple.functorcollections import EventInfo from DaVinci import make_config, Options -from PyConf.reading import get_particles, get_rec_summary def main(options: Options): @@ -27,19 +27,22 @@ def main(options: Options): #define variables and add them to all fields #lb_variables = Kinematics() - lb_variables = FC({'PT': F.PT}) + lb_variables = FunctorCollection({'PT': F.PT}) variables = {"ALL": lb_variables} #get RecSummary object that holds information about nPVs, nTracks, nFTClusters # Note more information can be added to the RecSummary object # (see MRs: https://gitlab.cern.ch/lhcb/Moore/-/merge_requests/1649) rec_summary = get_rec_summary() - evt_vars = FC({ - 'nTracks': F.VALUE_OR(-1) @ F.NTRACKS(rec_summary), - 'nPVs': F.VALUE_OR(-1) @ F.NPVS(rec_summary), - 'nFTClusters': F.VALUE_OR(-1) @ F.NFTCLUSTERS(rec_summary) + evt_vars = FunctorCollection({ + 'nTracks': + F.VALUE_OR(-1) @ F.NTRACKS(rec_summary), + 'nPVs': + F.VALUE_OR(-1) @ F.NPVS(rec_summary), + 'nFTClusters': + F.VALUE_OR(-1) @ F.NFTCLUSTERS(rec_summary) }) - evt_vars += EventInfo() + evt_vars += FC.EventInfo() #get particles to run over line_name = 'Hlt2SLB_LbToLcMuNu_LcToPKPi_Line' diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py index fddb15b3f4d1b9cb2436980463f646ca461c5494..799f88dbe627ce19092e1409478a632ea8c8e7dc 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.py @@ -12,17 +12,16 @@ Read an HLT2 file and create an ntuple using pre-defined Functor collections. This example is also used to test all available functor collections. """ - +from Gaudi.Configuration import INFO +from PyConf.Algorithms import WeightedRelTableAlg +from PyConf.reading import get_particles, get_mc_particles, get_mc_track_info import Functors as F -from DaVinciMCTools import MCReconstructible, MCReconstructed +from DaVinciMCTools import MCReconstructible as MCRectible, MCReconstructed as MCRected from FunTuple import FunctorCollection, functorcollections as functorcollections_original from FunTuple import FunTuple_Particles as Funtuple, FunTuple_MCParticles as MCFuntuple from DaVinci.algorithms import add_filter from DaVinci import Options, make_config -from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg -from PyConf.Algorithms import WeightedRelTableAlg -from Gaudi.Configuration import INFO -from PyConf.reading import get_particles, get_mc_particles, get_mc_track_info +from DaVinciMCTools import MCTruthAndBkgCat #define functor collections that need to be excluded. #Delete the collection "HltTisTos" since the @@ -72,13 +71,14 @@ def main(options: Options): MC_data = get_mc_particles("/Event/HLT2/MC/Particles") # Get variables related to reconstructible information. - mcrtible = MCReconstructible(mc_track_info=get_mc_track_info()) + mcrtible = MCRectible( + input_mctrackinfo=get_mc_track_info()) # tes location of MC track info # Get variables related to reconstructed information. - mcrted_all = MCReconstructed(MC_data, use_best_mcmatch=True) + mcrted_all = MCRected(input_mcparticles=MC_data, use_best_mcmatch=True) # get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth_alg = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) + MCTRUTH = MCTruthAndBkgCat(d02kpi_data) # configure "WeightedRelTableAlg" algorithm for HLT2 output iso_rel_table = WeightedRelTableAlg( @@ -88,35 +88,32 @@ def main(options: Options): OutputLevel=INFO) # initialize the checker - functorcollections = check_wrapper(functorcollections_original) + FC = check_wrapper(functorcollections_original) - # use functorcollections to add variables, please expand when there's new collections :) + # use FC to add variables, please expand when there's new collections :) collections = [ - functorcollections.Kinematics(), - functorcollections.MCHierarchy(mctruth_alg=mctruth_alg), - functorcollections.MCKinematics(mctruth_alg=mctruth_alg), - functorcollections.MCVertexInfo(mctruth_alg=mctruth_alg), - functorcollections.MCPromptDecay(mctruth_alg=mctruth_alg), - functorcollections.TrackIsolation(iso_rel_table=iso_rel_table), + FC.Kinematics(), + FC.MCHierarchy(mctruth_alg=MCTRUTH), + FC.MCKinematics(mctruth_alg=MCTRUTH), + FC.MCVertexInfo(mctruth_alg=MCTRUTH), + FC.MCPromptDecay(mctruth_alg=MCTRUTH), + FC.TrackIsolation(iso_rel_table=iso_rel_table), ] MC_collections = [ - functorcollections.MCReconstructible_Collection( - mcreconstructible_alg=mcrtible, extra_info=True), - functorcollections.MCReconstructed_Collection( - mcreconstructed_alg=mcrted_all, extra_info=False), - functorcollections.MCHierarchy(), - functorcollections.MCVertexInfo(), - functorcollections.MCPromptDecay(), + FC.MCReconstructible(mcreconstructible_alg=mcrtible, extra_info=True), + FC.MCReconstructed(mcreconstructed_alg=mcrted_all, extra_info=False), + FC.MCHierarchy(), + FC.MCVertexInfo(), + FC.MCPromptDecay(), ] evt_collections = [ - functorcollections.EventInfo(), - functorcollections.SelectionInfo( - selection_type="Hlt2", trigger_lines=[line_name]) + FC.EventInfo(), + FC.SelectionInfo(selection_type="Hlt2", trigger_lines=[line_name]) ] - assert functorcollections.check( + assert FC.check( ), "Oh no! Did you forget to add a new collection to this test?" field_vars = FunctorCollection() diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_data.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_data.py index e696dfd11649a204ff73276e758da9e1431368a5..b0d095479d31da6c0b8e64374e4e611a21be7668 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_data.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_data.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -8,14 +8,13 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from PyConf.reading import get_particles, get_pvs +import Functors as F from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter from DaVinci import Options, make_config -from PyConf.reading import get_particles, get_pvs -import Functors as F -from FunTuple.functorcollections import EventInfo from PyConf.application import metainfo_repos metainfo_repos.global_bind(extra_central_tags=['commissioning']) @@ -58,7 +57,7 @@ def main(options: Options): }) #FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() # # Variables for pions. Just a technical test of functors. @@ -92,7 +91,7 @@ def main(options: Options): # # Event variables # - evt_vars = EventInfo() + evt_vars = FC.EventInfo() evt_vars['PV_SIZE'] = F.SIZE(v2_pvs) tuple_KS2PiPi = Funtuple( 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 90bd6c830b23694bcf7183ffd0fc45eb8d43376e..8312777fcd0b925eba9b227214fea875897c56d0 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py @@ -11,14 +11,14 @@ """ Read an HLT2 file and create an ntuple with the new DaVinci configuration. """ +from PyConf.reading import get_particles, get_pvs import Functors as F -from FunTuple import FunctorCollection as FC +from DaVinciMCTools import MCTruthAndBkgCat +from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from PyConf.reading import get_particles, get_pvs +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter from DaVinci import Options, make_config -from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg -from FunTuple.functorcollections import SelectionInfo def main(options: Options): @@ -31,7 +31,7 @@ def main(options: Options): # Creating v2 reconstructed vertices to be used in the following functor v2_pvs = get_pvs() - d0_variables = FC({ + d0_variables = FunctorCollection({ "ID": F.PARTICLE_ID, "KEY": F.OBJECT_KEY, "PT": F.PT, @@ -46,7 +46,7 @@ def main(options: Options): "BPVIPCHI2": F.BPVIPCHI2(v2_pvs) }) - daughter_variables = FC({ + daughter_variables = FunctorCollection({ "ID": F.PARTICLE_ID, "PT": F.PT, "PX": F.PX, @@ -69,9 +69,7 @@ def main(options: Options): my_filter = add_filter("HDRFilter_D0Kpi", f"HLT_PASS('{line_name}')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data) - #add helper lambda that configures a functor to get truth information - MCTRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable) + MCTRUTH = MCTruthAndBkgCat(d02kpi_data) trueid_bkgcat_info = { # Important note: specify an invalid value for integer functors if there exists no truth info. # The invalid value for floating point functors is set to nan. @@ -84,17 +82,17 @@ def main(options: Options): "TRUEENERGY": MCTRUTH(F.ENERGY), "TRUEP": MCTRUTH(F.P), "TRUEFOURMOMENTUM": MCTRUTH(F.FOURMOMENTUM), - "BKGCAT": F.BKGCAT(Relations=mctruth.BkgCatTable) + "BKGCAT": MCTRUTH.BkgCat } for field in variables.keys(): - variables[field] += FC(trueid_bkgcat_info) + variables[field] += FunctorCollection(trueid_bkgcat_info) ##doesn't work since no "decayProducts" method in MCParticle #sort of related issue (https://gitlab.cern.ch/lhcb/Rec/-/issues/356) - #variables['D0'] += FC({'TRUEPT_Kaon': MCTRUTH(F.CHILD(1, F.PT))}) + #variables['D0'] += FunctorCollection({'TRUEPT_Kaon': MCTRUTH(F.CHILD(1, F.PT))}) #define event level variables (just as an example) - evt_variables = SelectionInfo( + evt_variables = FC.SelectionInfo( selection_type="Hlt2", trigger_lines=[line_name]) #For now remove: The 'Hlt2' line decision is written okay but breaks unit test with an error. #This is possibly related to having long TBranch names. diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py index 3e7973e9772fcdeada7341bcd02ed96d4ee58533..c2e23265a87cda6072d2d20231985b4994dc96b1 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_passthrough.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -12,11 +12,11 @@ Test for checking the correct processing of Hlt2 .dst file where packed reco objects are persisted by means of a pass through line. """ +from PyConf.reading import get_particles from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci import Options, make_config from DaVinci.algorithms import add_filter -from PyConf.reading import get_particles def main(options: Options): @@ -29,7 +29,7 @@ def main(options: Options): } #FunTuple: make functor collection from the imported functor library Kinematic - variables_all = Kinematics() + variables_all = FC.Kinematics() #FunTuple: associate functor collections to branch name variables = { 'ALL': variables_all, #adds variables to all branches diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py index 53ac2a93530c525c12934252cbfefe50cb70a032..92eba2d1046583a9fb9782d185a57d863bae90e6 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -11,12 +11,12 @@ """ Read the output of an Sprucing job with the new DaVinci configuration. """ +from PyConf.reading import get_particles from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter from DaVinci import Options, make_config -from PyConf.reading import get_particles def main(options: Options): @@ -50,7 +50,7 @@ def main(options: Options): variables += variables_extra #FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() #FunTuple: associate functor collections to field (branch) name variables_dsk = { diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py index a40e4b60858d7ec9d2cb119421ddf8c2699740e3..d2cc31cbdb3706bd6e34046df75a87ac08c79f81 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_spruce_mc.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -11,9 +11,9 @@ from FunTuple import FunctorCollection import Functors as F from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci import Options, make_config -from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg +from DaVinciMCTools import MCTruthAndBkgCat from DaVinci.algorithms import add_filter from PyConf.reading import get_particles @@ -27,7 +27,7 @@ def main(options: Options): } #FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() #FunTuple: associate functor collections to branch name variables = { @@ -39,11 +39,8 @@ def main(options: Options): my_filter = add_filter("HDRFilter_B", f"HLT_PASS('{line_name}')") - #helper lambda function - MCTRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable) - #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg(inputs=B_data) + MCTRUTH = MCTruthAndBkgCat(B_data) #Add trueid info to each of the branches trueid_bkgcat_info = { # Important note: specify an invalid value for integer functors if there exists no truth info. @@ -57,7 +54,7 @@ def main(options: Options): "TRUEENERGY": MCTRUTH(F.ENERGY), "TRUEP": MCTRUTH(F.P), "TRUEFOURMOMENTUM": MCTRUTH(F.FOURMOMENTUM), - "BKGCAT": F.BKGCAT(Relations=mctruth.BkgCatTable), + "BKGCAT": MCTRUTH.BkgCat } for branch in variables.keys(): variables[branch] += FunctorCollection(trueid_bkgcat_info) @@ -69,4 +66,4 @@ def main(options: Options): variables=variables, inputs=B_data) - return make_config(options, [my_filter, mctruth, my_tuple]) + return make_config(options, [my_filter, my_tuple]) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_substitutePID.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_substitutePID.py index e830a7de9dad5146129d32d0909d5458cdb26f15..2d761307b2bb6d3e09f0225b85405ee848beb5f7 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_substitutePID.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_substitutePID.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -19,12 +19,12 @@ containers to tuple the swapped decay and the original decay in the same tree. from Gaudi.Configuration import INFO from FunTuple import FunTuple_Particles as Funtuple -from FunTuple import FunctorCollection as FC +from FunTuple import FunctorCollection from DaVinci.algorithms import add_filter from PyConf.reading import get_particles from DaVinciTools import SubstitutePID from PyConf.Algorithms import ParticleContainerMerger -from FunTuple.functorcollections import EventInfo +import FunTuple.functorcollections as FC from DaVinci import Options, make_config import Functors as F @@ -40,8 +40,8 @@ def main(options: Options): # Define the swap Swapped_Data = SubstitutePID( - name='Subs_SwapKpi', - input=B_Data, + 'Subs_SwapKpi', # name of the algorithm + B_Data, #input particle container substitutions=[ 'B0 -> ( D_s- -> K-{{pi-}} pi+ pi-{{K-}} ) K+', 'B~0 -> ( D_s+ -> K+{{pi+}} pi- pi+{{K+}} ) K-' @@ -63,7 +63,7 @@ def main(options: Options): 'Kplus': "[B0 -> ( D_s- -> K- pi+ pi- ) ^K+]CC", } - variables_all = FC({ + variables_all = FunctorCollection({ 'ID': F.PARTICLE_ID, 'M': F.MASS, 'P': F.P, @@ -74,7 +74,7 @@ def main(options: Options): variables = {'ALL': variables_all} # Get event information - evt_vars = EventInfo() + evt_vars = FC.EventInfo() # # Configure Funtuple algorithms diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_tistos.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_tistos.py index bff280af52a083b3ad09fb90d6cb28be80f9fe5c..f3b3419dcf99b2d749e4ce66687e9d4c487b1130 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_tistos.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_tistos.py @@ -9,13 +9,13 @@ # or submit itself to any jurisdiction. # ############################################################################### -from DaVinci import Options, make_config -from FunTuple import FunTuple_Particles as Funtuple -from DaVinci.algorithms import add_filter from PyConf.reading import get_particles -from FunTuple import FunctorCollection as FC import Functors as F -from FunTuple.functorcollections import HltTisTos, SelectionInfo +from FunTuple import FunTuple_Particles as Funtuple +from FunTuple import FunctorCollection +import FunTuple.functorcollections as FC +from DaVinci import Options, make_config +from DaVinci.algorithms import add_filter def main(options: Options): @@ -31,7 +31,7 @@ def main(options: Options): } #define variables to be added to all fields - variables_all = FC({"PT": F.PT}) + variables_all = FunctorCollection({"PT": F.PT}) #specify line name to get data and define a filter for that line line_name = "Hlt2BnoC_BdsToPhiPhi" @@ -46,14 +46,14 @@ def main(options: Options): # 1st argument is selection type: "Hlt1" or "Hlt2". Currently only "Hlt1" is supported. # 2nd argument is the list of Hlt1 line names for which TIS/TOS information is requested. # 3rd argument is the TES location of the reconstructed particles. - variables_all += HltTisTos( + variables_all += FC.HltTisTos( selection_type="Hlt1", trigger_lines=Hlt1_decisions, data=data) variables = {'ALL': variables_all} #When the TIS and TOS information of candidate wrt a line is negative but the event has still fired a Hlt1 line, #then the trigger category for candidates wrt to that line is TOB (Trigger On Both) i.e. (!TIS && !TOS && event_decision). # To store "event_decision" of Hlt1 lines and check for "TOB", we use "SelectionInfo" functor collection. - evt_variables = SelectionInfo( + evt_variables = FC.SelectionInfo( selection_type="Hlt1", trigger_lines=Hlt1_decisions) #define funtuple instance diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_unreconstructed_info.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_unreconstructed_info.py index 9e5c935797fbffbcba97c138366900dc404b45af..ffb03e4f3b5ef326720593d8c31908e0f55831a5 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_unreconstructed_info.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_unreconstructed_info.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -16,7 +16,7 @@ from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple from DaVinci.algorithms import add_filter from DaVinci import make_config, Options -from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg +from DaVinciMCTools import MCTruthAndBkgCat from PyConf.reading import get_particles @@ -30,9 +30,7 @@ def main(options: Options): my_filter = add_filter("Myfilter", f"HLT_PASS('{line_name}')") #get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output - mctruth = configured_MCTruthAndBkgCatAlg(inputs=particles) - #add helper lambda that configures a functor to get truth information - MCTRUTH = lambda func, rels: F.MAP_INPUT(Functor=func, Relations=rels) + MCTRUTH = MCTruthAndBkgCat(particles) #define variables and add them to all fields # @@ -59,20 +57,13 @@ def main(options: Options): #A returning value of NaN is needed whenever MCAssocTable is empty #i.e. has no relations inside lb_variables = FC({ - 'TRUEPX': - MCTRUTH(F.PX, mctruth.MCAssocTable), - 'Lc_TRUEPX': - F.VALUE_OR(F.NaN) @ MCTRUTH(lc_px, mctruth.MCAssocTable), - 'Mu_TRUEPX': - F.VALUE_OR(F.NaN) @ MCTRUTH(mu_px, mctruth.MCAssocTable), - 'NuMu_TRUEPX': - F.VALUE_OR(F.NaN) @ MCTRUTH(nu_px, mctruth.MCAssocTable), - 'Lc_TRUEID': - F.VALUE_OR(-1) @ MCTRUTH(lc_true_id, mctruth.MCAssocTable), - 'Mu_TRUEID': - F.VALUE_OR(-1) @ MCTRUTH(mu_true_id, mctruth.MCAssocTable), - 'NuMu_TRUEID': - F.VALUE_OR(-1) @ MCTRUTH(nu_true_id, mctruth.MCAssocTable) + 'TRUEPX': MCTRUTH(F.PX), + 'Lc_TRUEPX': F.VALUE_OR(F.NaN) @ MCTRUTH(lc_px), + 'Mu_TRUEPX': F.VALUE_OR(F.NaN) @ MCTRUTH(mu_px), + 'NuMu_TRUEPX': F.VALUE_OR(F.NaN) @ MCTRUTH(nu_px), + 'Lc_TRUEID': F.VALUE_OR(-1) @ MCTRUTH(lc_true_id), + 'Mu_TRUEID': F.VALUE_OR(-1) @ MCTRUTH(mu_true_id), + 'NuMu_TRUEID': F.VALUE_OR(-1) @ MCTRUTH(nu_true_id) }) variables = {"Lb": lb_variables} 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 2cec76af448e6f2351c0f28c65e295f902baeb04..216295200874b6acec8a10c1c4eade6e949b1ab7 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_weightedrelation_trackvariables.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -9,7 +9,7 @@ # or submit itself to any jurisdiction. # ############################################################################### """ -Option file for testing the ParticleWeightedAlg algorithm. +Option file for testing the WeightedRelTableAlg algorithm. The job runs over a spruced sample and retrieves a set of B0 -> J/psi K candidates. For each candidate the algorithm looks at the TES location which contains the tagged particles and creates a 'one-to-many' relation map relating all the available tracks to the B candidate of the events. @@ -18,11 +18,11 @@ Important: Setting DVPATH properly. To run the example: $DVPATH/run lbexec option_davinci_tupling_weightedrelation_trackvariables:main $DVPATH/DaVinciExamples/example_data/spruce_b2jpsik_opt.yaml """ -import Functors as F from PyConf.Algorithms import WeightedRelTableAlg -from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple -from FunTuple.functorcollections import TrackIsolation from PyConf.reading import get_particles, get_pvs +import Functors as F +from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter from DaVinci import Options, make_config @@ -77,7 +77,7 @@ def main(options: Options): variables_all = FunctorCollection({'THOR_P': F.P, 'THOR_PT': F.PT}) - track_iso_variables = TrackIsolation(iso_rel_table=ftAlg) + track_iso_variables = FC.TrackIsolation(iso_rel_table=ftAlg) variables_jpsik = { 'B': variables_all + extra_variables, diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py index 09182923a0a3948d8c611335fb58f9df9089d42a..14a86095551b9c81a6cab7e2caa2aa9bd03f03d7 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_trigger_decisions.py @@ -11,12 +11,12 @@ """ Read an HLT2 file and create an ntuple with the new DaVinci configuration, accessing HLT1 and HLT2 decisions. """ +from PyConf.reading import get_particles import Functors as F from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple +import FunTuple.functorcollections as FC from DaVinci import Options, make_config -from PyConf.reading import get_particles -from FunTuple.functorcollections import SelectionInfo def main(options: Options): @@ -40,7 +40,7 @@ def main(options: Options): ] #define event level variables - evt_variables = SelectionInfo( + evt_variables = FC.SelectionInfo( selection_type="Hlt1", trigger_lines=Hlt1_decisions) #define FunTuple instance diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling_array_taggers.ref b/DaVinciExamples/tests/refs/test_davinci_tupling_array_taggers.ref index eca255f566725f2fcb93ec559941875618b4318b..573c2c0b92d0f76b6507208b4bfb9902c2b1e927 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling_array_taggers.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling_array_taggers.ref @@ -57,7 +57,7 @@ FunctionalParticleMaker INFO Number of counters : 4 HDRFilter_B0DsK INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | |*"#passed" | 14 | 14 |( 100.0000 +- 0.000000)% | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 14 | MCTruthAndBkgCatAlg#1 INFO Number of counters : 3 @@ -69,10 +69,10 @@ MCTruthAndBkgCatAlg#2 INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "Events" | 14 | | "Particles" | 57 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | -PP2MCPRelationUnpacker INFO Number of counters : 1 +PP2MCPRelationUnpacker#2 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# PackedData" | 14 | 84 | 6.0000 | -PP2MCPRelationUnpacker#1 INFO Number of counters : 1 +PP2MCPRelationUnpacker#3 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# AbsentBuffer" | 14 | 0 | 0.0000 | ParticleContainerMerger INFO Number of counters : 2 @@ -88,11 +88,11 @@ ParticleUnpacker INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# Linked BufferData" | 70 | 19254 | 275.06 | | "# UnpackedData" | 28 | 3700 | 132.14 | -ProtoParticleUnpacker INFO Number of counters : 2 +ProtoParticleUnpacker#2 INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# Linked BufferData" | 77 | 71001 | 922.09 | | "# UnpackedData" | 28 | 26997 | 964.18 | -ProtoParticleUnpacker#1 INFO Number of counters : 1 +ProtoParticleUnpacker#3 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# AbsentBuffer" | 14 | 0 | 0.0000 | SpruceDecReportsDecoder INFO Number of counters : 1 diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling_eventinfo.ref b/DaVinciExamples/tests/refs/test_davinci_tupling_eventinfo.ref index 559a66dcfc557631518ce2c130cbc822149867b7..9eecb8cedaac4bc17abc87856a1895fe13399824 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling_eventinfo.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling_eventinfo.ref @@ -42,7 +42,7 @@ ApplicationMgr INFO Application Manager Terminated succe Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 7 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 7 | Myfilter INFO Number of counters : 1 diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref b/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref index db5a57cc0f8d97ee86d26bc8b6a021b45ca464e9..126e9cab8aa4af39f6c281488953edcf5c4b072c 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling_from_hlt2.ref @@ -47,17 +47,17 @@ MCTruthAndBkgCatAlg#1 INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "Events" | 7 | | "Particles" | 21 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | -PP2MCPRelationUnpacker INFO Number of counters : 1 +PP2MCPRelationUnpacker#2 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# PackedData" | 7 | 15 | 2.1429 | -PP2MCPRelationUnpacker#1 INFO Number of counters : 1 +PP2MCPRelationUnpacker#3 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# AbsentBuffer" | 7 | 0 | 0.0000 | ParticleUnpacker INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# Linked BufferData" | 56 | 30992 | 553.43 | | "# UnpackedData" | 14 | 1659 | 118.50 | -ProtoParticleUnpacker#1 INFO Number of counters : 1 +ProtoParticleUnpacker#3 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# AbsentBuffer" | 7 | 0 | 0.0000 | RecVertexUnpacker INFO Number of counters : 1 diff --git a/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref b/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref index 3983f48074cd886e36e00bab5e7a5a72e766be00..ecfa59a93b65b3e19d84ff8f76c761e3104a1c99 100644 --- a/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref +++ b/DaVinciExamples/tests/refs/test_davinci_tupling_from_passthrough.ref @@ -49,7 +49,7 @@ HDRFilter_Bs2JpsiPhi INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 1978 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 298 | ParticleUnpacker INFO Number of counters : 2 diff --git a/DaVinciTests/python/DaVinciTests/DTF_test.py b/DaVinciTests/python/DaVinciTests/DTF_test.py index f1295ed49b4928dab802c7d9d8153f1bd88ce5c2..1f7a724b551423a9bcc5e31c582091135d0b1aef 100644 --- a/DaVinciTests/python/DaVinciTests/DTF_test.py +++ b/DaVinciTests/python/DaVinciTests/DTF_test.py @@ -13,7 +13,7 @@ Example of a typical DaVinci job: - selection of two detached opposite-charge muons - tuple of the selected candidates - runs DecayTreeFitterAlg and stores some output - + Note: Below mass constraints are applied to J/psi(1S) and psi(2S) going to dimuon pairs whereas the tupling is only performed for the former. @@ -39,7 +39,7 @@ def main(options: Options): DTF = DecayTreeFitter( name='DTF_dimuons', - input=dimuons, + input_particles=dimuons, mass_constraints=["J/psi(1S)", "psi(2S)"], output_level=INFO) @@ -49,12 +49,9 @@ def main(options: Options): #make collection of functors for Jpsi variables_jpsi = FunctorCollection({ - 'THOR_MASS': - F.MASS, - 'DTF_PT': - DTF.get_info(Functor=F.PT), - 'DTF_MASS': - DTF.get_info(Functor=F.MASS), + 'THOR_MASS': F.MASS, + 'DTF_PT': DTF(Functor=F.PT), + 'DTF_MASS': DTF(Functor=F.MASS), }) #associate FunctorCollection to field (branch) name diff --git a/DaVinciTests/python/DaVinciTests/option_davinci_for_spruce.py b/DaVinciTests/python/DaVinciTests/option_davinci_for_spruce.py index a636697bbe004f8a71c6b2cfe13ce0d79a294910..3605c449a62ec0dd1464ae437a67b5c2807f5abf 100644 --- a/DaVinciTests/python/DaVinciTests/option_davinci_for_spruce.py +++ b/DaVinciTests/python/DaVinciTests/option_davinci_for_spruce.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -13,7 +13,7 @@ Read the output of an Sprucing job with the new DaVinci configuration. """ from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter from DaVinci import Options, make_config from PyConf.reading import get_particles @@ -50,7 +50,7 @@ def main(options: Options): variables += variables_extra #FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() #FunTuple: associate functor collections to field (branch) name variables_dsk = { diff --git a/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py b/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py index 0424621b6cbf19b58989d3f6a9e810e7cee8d98f..75f01af7f6753ab64f091cc6f65d422ddfd8e11c 100644 --- a/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py +++ b/DaVinciTests/python/DaVinciTests/option_davinci_for_turbo.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -12,9 +12,9 @@ Test for checking the correct processing of Hlt2 .dst file where packed reco objects are persisted by means of a pass through line. """ -from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics from PyConf.reading import get_particles +from FunTuple import FunTuple_Particles as Funtuple +import FunTuple.functorcollections as FC from DaVinci import Options, make_config from DaVinci.algorithms import add_filter @@ -29,7 +29,7 @@ def main(options: Options): } #FunTuple: make functor collection from the imported functor library Kinematic - variables_all = Kinematics() + variables_all = FC.Kinematics() #FunTuple: associate functor collections to branch name variables = { 'ALL': variables_all, #adds variables to all branches diff --git a/DaVinciTests/tests/options/option_davinci_sprucing.py b/DaVinciTests/tests/options/option_davinci_sprucing.py index eb9b1a8d76f7e61b62e094ddfe7d6a6d372d0992..007f51896ec9b21935704905e50413f943875e36 100644 --- a/DaVinciTests/tests/options/option_davinci_sprucing.py +++ b/DaVinciTests/tests/options/option_davinci_sprucing.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -11,11 +11,11 @@ """ Read the output of an Sprucing job with the new DaVinci configuration. """ +from PyConf.reading import get_particles from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC from DaVinci.algorithms import add_filter -from PyConf.reading import get_particles from DaVinci import Options, make_config @@ -42,7 +42,7 @@ def main(options: Options): variables_B0 += variables_extra #FunTuple: make functor collection from the imported functor library Kinematics - variables_all = Kinematics() + variables_all = FC.Kinematics() #FunTuple: associate functor collections to field (branch) name variables = { diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py index 6aeda2456477b07ee1c10729d4b75efe5cb55650..0aeb3e0d802ef4c2f2b48cb9f79d0c7715ce356f 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial4_trigger_eventinfo.py @@ -8,32 +8,31 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from PyConf.reading import get_particles import Functors as F +from FunTuple import FunctorCollection +from FunTuple import FunTuple_Particles as Funtuple from DaVinci import Options, make_config from DaVinci.algorithms import add_filter -from PyConf.reading import get_particles -from FunTuple import FunctorCollection as FC -from FunTuple import FunTuple_Particles as Funtuple +# To help users, there are pre-defined functor collections (Tuple-tool like objects for Run1/2 veterans) that you can import and inspect. +# Here we import a pre-defined FunctorCollection "Kinematics" via a module import. +# One can call "print(help(Kinematics))" (you have to press "q" to exit after calling) to check the usage and their arguments. +# Functors that have data dependency will naturally induce data dependency on the functor collections. +# +# To see what functor collections are available see: https://gitlab.cern.ch/lhcb/Analysis/-/blob/master/Phys/FunTuple/python/FunTuple/functorcollections.py +import FunTuple.functorcollections as FC def main(options: Options): #Define a dictionary of "field name" -> "decay descriptor component". fields = {"Bs": "B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) ->K+ K-)"} - #To help users, there are pre-defined FunctorCollections (Tuple-tool like objects for Run1/2 veterans) that you can import and inspect. - # Here we import a pre-defined FunctorCollection "Kinematics". - # One can call "print(help(Kinematics))" (you have to press "q" to exit after calling) to check the usage and their arguments. - # Functors that have data dependency will naturally induce data dependency on the functorcollections. - # - # To see what functor collections are available see: https://gitlab.cern.ch/lhcb/Analysis/-/blob/master/Phys/FunTuple/python/FunTuple/functorcollections.py - from FunTuple.functorcollections import Kinematics - #Inspect whats in the collection by printing - kin = Kinematics() + kin = FC.Kinematics() print(kin) #Define new collection - coll = FC({"ID": F.PARTICLE_ID}) + coll = FunctorCollection({"ID": F.PARTICLE_ID}) #Add to existing collections (can also subtract two collections) kin += coll @@ -51,19 +50,18 @@ def main(options: Options): # empty dictionary since we have no LoKi functors in the collection print(kin.get_loki_functors()) - #Now import two other pre-defined FunctorCollections: SelectionInfo and EventInfo + # The two other pre-defined FunctorCollections SelectionInfo and EventInfo have been imported above # - SelectionInfo: Contains functors related to storing Hlt1, Hlt2 or Sprucing trigger line decision and Trigger Configuration Key (TCK). # - EventInfo: Contains functors related to storing event information BUNCHCROSSING_ID, etc. Note the RUNNUMBER and EVENTNUMBER # are stored by default in FunTuple. # #As before you can call help with "print(help(EventInfo))" or "print(help(SelectionInfo))" (you have to press "q" to exit after calling) - from FunTuple.functorcollections import SelectionInfo, EventInfo #Get event information like RUNNUMBER, EVENTNUMBER. # These are stored in "LHCb::ODIN" C++ object which the ThOr functors take as input (like PVs in Example7), load it onto TES using "get_odin". # The attribute extra_info is False by default, if set to "True" you get info on # bunchcrossing id, ODIN TCK, GPS Time, etc - evtinfo = EventInfo() + evtinfo = FC.EventInfo() print(evtinfo) #Get selection line decision and HlT2 TCK. @@ -80,7 +78,7 @@ def main(options: Options): turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" turbo_line2 = "Hlt2BsToJpsiPhi_JPsi2ee_PhiToKK_Line" line_names = [f'{turbo_line}Decision', f'{turbo_line2}'] - selinfo = SelectionInfo( + selinfo = FC.SelectionInfo( selection_type=selection_type, trigger_lines=line_names) print(selinfo) diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py index 9864dbcd8feb1a623a17a63a1aec2cb6c8a5d962..304be238915c41147661152ca53198560cb0b977 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial5_MCTruth.py @@ -8,12 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from PyConf.reading import get_particles import Functors as F +from FunTuple import FunctorCollection +from FunTuple import FunTuple_Particles as Funtuple from DaVinci import Options, make_config from DaVinci.algorithms import add_filter -from PyConf.reading import get_particles -from FunTuple import FunctorCollection as FC -from FunTuple import FunTuple_Particles as Funtuple def main(options: Options): @@ -28,42 +28,44 @@ def main(options: Options): "Km": "B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) ->K+ ^K-)", } - #Import FunctorCollections Kinematics, MCKinematics, MCHierarchy + # Import functor collections Kinematics, MCKinematics, MCHierarchy + # (Note: import statements should really be at the top of files for almost all use-cases. + # The local import is here to be close to the comments.) # There is also "MCVertexInfo" but we won't import it here. # # See whats available at: https://gitlab.cern.ch/lhcb/Analysis/-/blob/master/Phys/FunTuple/python/FunTuple/functorcollections.py - from FunTuple.functorcollections import Kinematics, MCKinematics, MCHierarchy + import FunTuple.functorcollections as FC #We can seek help on these functorcollections using following commands (if you run these commmands, press "q" to exit and continue). - # - print(help(MCKinematics)) - # - print(help(MCHierarchy)) + # - print(help(FC.MCKinematics)) + # - print(help(FC.MCHierarchy)) # - # We see that it takes an input an algorithm configured_MCTruthAndBkgCatAlg(inputdata), so lets import that. - from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg + # We see that it takes an input an algorithm MCTruthAndBkgCat(inputdata), so lets import that. + from DaVinciMCTools import MCTruthAndBkgCat #Load data from dst onto a TES turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #Define an algorithm that builds a map i.e. one-to-one relation b/w Reco Particle -> Truth MC Particle. - mctruth_alg = configured_MCTruthAndBkgCatAlg(inputs=input_data) + MCTRUTH = MCTruthAndBkgCat(input_data) #print(mctruth_alg.MCAssocTable) #Pass it to collections - kin = Kinematics() - mckin = MCKinematics(mctruth_alg=mctruth_alg) - mchierarchy = MCHierarchy(mctruth_alg=mctruth_alg) + kin = FC.Kinematics() + mckin = FC.MCKinematics(mctruth_alg=MCTRUTH) + mchierarchy = FC.MCHierarchy(mctruth_alg=MCTRUTH) #print(mckin) #print(mchierarchy) #Loop over and keep only whats required - kin = FC({ + kin = FunctorCollection({ k: v for k, v in kin.get_thor_functors().items() if k == 'P' or k == 'M' }) - mckin = FC( + mckin = FunctorCollection( {k: v for k, v in mckin.get_thor_functors().items() if k == 'TRUEP'}) - mchierarchy = FC({ + mchierarchy = FunctorCollection({ k: v for k, v in mchierarchy.get_thor_functors().items() if k == 'TRUEID' }) @@ -71,22 +73,18 @@ def main(options: Options): #print(mckin) #print(mchierarchy) - #To get truth information with a functor that is not present in the collections - # - The 1st argument is the functor that returns the relevant information - # - The 2nd argument is relation table i.e. a one-to-one map b/w Reco Particle -> Truth MC Particle. - # Lets create a helper lambda function for that - MCTRUTH = lambda func: F.MAP_INPUT(func, mctruth_alg.MCAssocTable) + #To get truth information with a functor extra_info = { # Important note: specify an invalid value for integer functors if there exists no truth info. # The invalid value for floating point functors is set to nan. "TRUEEID": F.VALUE_OR(0) @ MCTRUTH(F.PARTICLE_ID), "TRUEEPHI": MCTRUTH(F.PHI), } - extra_info = FC(extra_info) + extra_info = FunctorCollection(extra_info) #The algorithm mctruth_alg also outputs a map b/w particle and bkg category which can be obtained using the functor # For more info on background category see: https://twiki.cern.ch/twiki/bin/view/LHCb/TupleToolMCBackgroundInfo - bkg_cat = FC({"BKGCAT": F.BKGCAT(Relations=mctruth_alg.BkgCatTable)}) + bkg_cat = FunctorCollection({"BKGCAT": MCTRUTH.BkgCat}) #Define variables dictionary "field name" -> Collections of functor variables = {"ALL": kin + mckin + mchierarchy + bkg_cat, "Kp": extra_info} diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py index bd547fbd9f63280dc886554be545f3be7bcac841..acd3c3019d0feacc859bdbe8d14888b2a6337094 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial6_DecayTreeFit.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -13,9 +13,9 @@ from DaVinci import Options, make_config from DaVinci.algorithms import add_filter from PyConf.reading import get_particles, get_pvs, get_pvs_v1 -from FunTuple import FunctorCollection as FC +from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC def main(options: Options): @@ -39,22 +39,21 @@ def main(options: Options): input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles") #get kinematic functors - kin = Kinematics() + kin = FC.Kinematics() ####### Mass constraint #For DecayTreeFitter, as with MC Truth algorithm (previous example), this algorithm builds a relation # table i.e. one-to-one map b/w B candidate -> Refitted B candidate. # The relation table is output to the TES location "DTF.Algorithm.OutputRelations" - # You can apply functors to refitted candidates using get_info member function. + # You can apply functors to refitted candidates by simply invoking the __call__ function (see below). # Note: the Jpsi constraint is applied but the phi constraint seems not to be applied (see issue: https://gitlab.cern.ch/lhcb/Rec/-/issues/309) DTF = DecayTreeFitter( - name='DTF', mass_constraints=["J/psi(1S)"], input=input_data) + name='DTF', input_particles=input_data, mass_constraints=["J/psi(1S)"]) #Loop over the functors in kinematics function and create a new functor collection - dtf_kin = FC({ - 'DTF_' + k: DTF.get_info(v) - for k, v in kin.get_thor_functors().items() - }) + dtf_kin = FunctorCollection( + {'DTF_' + k: DTF(v) + for k, v in kin.get_thor_functors().items()}) #print(dtf_kin) ######### @@ -68,24 +67,24 @@ def main(options: Options): #Add not only mass but also constrain Bs to be coming from primary vertex DTFpv = DecayTreeFitter( - name='DTFpv', + 'DTFpv', #name of algorithm + input_data, #input particles input_pvs=pvs, - mass_constraints=["J/psi(1S)", "phi(1020)"], - input=input_data) + mass_constraints=["J/psi(1S)", "phi(1020)"]) #define the functors pv_fun = {} pv_fun['BPVLTIME'] = F.BPVLTIME(pvs_v2) pv_fun['BPVIPCHI2'] = F.BPVIPCHI2(pvs_v2) - pv_coll = FC(pv_fun) + pv_coll = FunctorCollection(pv_fun) #We now take the pre-defined functor collection ("pv_fun") and add same variables to it # but using the result of the decay tree fit (DTF). These variables will have the prefix ("DTFPV_"). # The resolution on the B candidate lifetime post-DTF ("DTFPV_BPVLTIME") # should have improved compared to lifetime variable pre-DTF ("BPVLTIME"). # Below we make use of the helper function ("DTFPV_MAP") defined previously. - pv_coll += FC({ - 'DTFPV_' + k: DTFpv.get_info(v) + pv_coll += FunctorCollection({ + 'DTFPV_' + k: DTFpv(v) for k, v in pv_coll.get_thor_functors().items() }) diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py index fca181844e800cc307e234adbe1f99781c509092..5ebbc9aac4bd708c5715bd5ebc43f1c0a008e0b3 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial7_multiple_sel_lines.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2021-2023 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". # @@ -12,7 +12,7 @@ from DaVinci import Options, make_config from DaVinci.algorithms import add_filter from PyConf.reading import get_particles from FunTuple import FunTuple_Particles as Funtuple -from FunTuple.functorcollections import Kinematics +import FunTuple.functorcollections as FC def main(options: Options): @@ -29,7 +29,7 @@ def main(options: Options): } #Define variables dictionary "field name" -> Collections of functor - variables = {"ALL": Kinematics()} + variables = {"ALL": FC.Kinematics()} #Load data from dst onto a TES turbo_line1 = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line" diff --git a/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref b/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref index 97585831440005969b65dc02d2665e9a06f9b862..437c5894ca3fe1810d0a3d05eb95029a499a72ae 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial1_Functors_specialfield.ref @@ -140,7 +140,7 @@ HDRFilter_SeeNoEvil INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | ParticleUnpacker INFO Number of counters : 2 diff --git a/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref b/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref index c83570680a11d8ee6bb4efe97da005ec0566a755..8ce95f31aea1575871ef818f99155f2bdb73fbfb 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial2_LoKi.ref @@ -138,7 +138,7 @@ HDRFilter_SeeNoEvil INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | ParticleUnpacker INFO Number of counters : 2 diff --git a/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref b/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref index 7fea3a36f3cb77168e340965d06ba93b25d23ada..24a07f98a2f6b1e5ed5b488a5b5a831edf6c9c3a 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial3_ThOrfunctors.ref @@ -138,7 +138,7 @@ HDRFilter_SeeNoEvil INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | ParticleUnpacker INFO Number of counters : 2 diff --git a/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref b/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref index 58088bd675ced213d1fd49d64c22296b170ae7e5..a83b1130c9e054c15361c591a1caad79b0eaf8a6 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial5_MCTruth.ref @@ -141,7 +141,7 @@ HDRFilter_SeeNoEvil INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | MCTruthAndBkgCatAlg#1 INFO Number of counters : 3 @@ -149,10 +149,10 @@ MCTruthAndBkgCatAlg#1 INFO Number of counters : 3 | "Events" | 12 | | "Ghosts" | 107 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | | "Particles" | 210 | 0 | 0.0000 | 0.0000 | 4.2950e+09 | 0.0000 | -PP2MCPRelationUnpacker INFO Number of counters : 1 +PP2MCPRelationUnpacker#2 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# PackedData" | 12 | 75 | 6.2500 | -PP2MCPRelationUnpacker#1 INFO Number of counters : 2 +PP2MCPRelationUnpacker#3 INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# AbsentBuffer" | 3 | 0 | 0.0000 | | "# PackedData" | 9 | 1504 | 167.11 | @@ -160,7 +160,7 @@ ParticleUnpacker INFO Number of counters : 2 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# Linked BufferData" | 132 | 136208 | 1031.9 | | "# UnpackedData" | 24 | 6282 | 261.75 | -ProtoParticleUnpacker#1 INFO Number of counters : 3 +ProtoParticleUnpacker#3 INFO Number of counters : 3 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | "# AbsentBuffer" | 3 | 0 | 0.0000 | | "# Linked BufferData" | 9 | 3882 | 431.33 | diff --git a/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref b/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref index 3727f16fac6413d57793deb19ea5371483474374..9cadda084ea1174108f347ca0914f17aacd09db4 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial6_DecayTreeFit.ref @@ -150,7 +150,7 @@ HDRFilter_SeeNoEvil INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 12 | ParticleUnpacker INFO Number of counters : 2 diff --git a/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref b/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref index 1f1fbc0b281098481d1f823e1b9a1e064c037397..5a3446824e6d3e91f1b75b643ac30495222a41dc 100644 --- a/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref +++ b/DaVinciTutorials/tests/refs/test_tutorial7_multiple_sel_lines.ref @@ -148,7 +148,7 @@ HDRFilter_SeeNoEvil2 INFO Number of counters : 1 Hlt2DecReportsDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " HltDecReports has a zero TCK, and it is not explicitly specified for decoding -- make sure that this really what you want"| 100 | -HltPackedBufferDecoder INFO Number of counters : 1 +HltPackedBufferDecoder#1 INFO Number of counters : 1 | Counter | # | sum | mean/eff^* | rms/err^* | min | max | | " DstData raw bank has a zero encoding key, and it is not explicitly specified for decoding -- make sure that this really what you want"| 14 | ParticleUnpacker INFO Number of counters : 2 diff --git a/Phys/DaVinci/python/DaVinci/truth_matching.py b/Phys/DaVinci/python/DaVinci/truth_matching.py deleted file mode 100644 index 8b9d73b59aeaac04b5b1ee4b1daf0a9ad67c4f31..0000000000000000000000000000000000000000 --- a/Phys/DaVinci/python/DaVinci/truth_matching.py +++ /dev/null @@ -1,113 +0,0 @@ -############################################################################### -# (c) Copyright 2022 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. # -############################################################################### - -from Gaudi.Configuration import INFO - -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, get_charged_protoparticles, get_neutral_protoparticles, get_tes_root -from PyConf.location_prefix import prefix - - -def configured_MCTruthAndBkgCatAlg( - inputs, - relations_locs=["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"], - root_in_tes=None, - redo_neutral_assoc=False, - filter_MCP=True, - output_level=INFO): - """ - Function to help configure the tools instantiated by the `MCTruthAndBkgCatAlg` algorithm. - - The tools configured are `DaVinciSmartAssociator`, `MCMatchObjP2MCRelator`, - `BackgroundCategory`, `BackgroundCategoryViaRelations` and `P2MCPFromProtoP`. - - The configuration for Sprucing output is the same as for HLT2 output - provided the correct `relations_locs` and `root_in_tes` arguments are set. - - The output of this algorithm is two relation tables: - one for MC association (P->MCP) and one for background category (P->BKGCAT). - The MC association table can be used as input to the `MAP_INPUT` functor - and the background category table serves as input for `BKGCAT` functor. - - Args: - inputs (DataHandle): Output of `Gaudi::Hive::FetchDataFromFile` (the input TES location to the particles). - relations_locs (list, optional): TES locations to the pre-existing relations for charged and neutral particles. - Defaults to ["Relations/ChargedPP2MCP", "Relations/NeutralPP2MCP"]. - root_in_tes (str, optional): RootInTES location that can be different for streamed output. Defaults is None. - If not 'None' then it is inferred from the 'input_process' option in yaml file. - redo_neutral_assoc (bool, optional): Whether or not to redo MC association of pure neutral calorimetric basic particle, - i.e. gamma and pi0-merged with pi0-resolved treated as composite. - Defaults to False. - output_level (int, optional): the standard `OutputLevel` from `Gaudi.Configuration` - to set for all instantiated algorithms and tools. Defaults to `output_level=INFO=3`. - - Returns: - MCTruthAndBkgCatAlg: configured instance of algorithm MCTruthAndBkgCatAlg. - """ - - if not root_in_tes: - root_in_tes = get_tes_root() - - # 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 += [get_charged_protoparticles()] - extra_inputs += [get_neutral_protoparticles()] - - mc_loc = root_in_tes + "/MC/Particles" - extra_inputs += [get_mc_particles(mc_loc)] - - relations = [ - get_pp2mcp_relations(prefix(rel, root_in_tes), extra_inputs) - for rel in relations_locs - ] - - # Tool used by DaVinciSmartAssociator - p2mctool = P2MCPFromProtoP( - Locations=relations, RootInTES=root_in_tes, OutputLevel=output_level) - - # Tools used by MCTruthAndBkgCatAlg - bkg_cat = BackgroundCategory( - P2MCTool=p2mctool, - ExtraInputs=relations, - vetoNeutralRedo=not redo_neutral_assoc, - RootInTES=root_in_tes, - OutputLevel=output_level) - bkg_cat_via_rel = BackgroundCategoryViaRelations( - RootInTES=root_in_tes, OutputLevel=output_level) - dv_assc = DaVinciSmartAssociator( - P2MCTool=p2mctool, - RedoNeutral=redo_neutral_assoc, - RootInTES=root_in_tes, - BackgroundCategoryTool=bkg_cat, - OutputLevel=output_level) - mcrel_assc = MCMatchObjP2MCRelator( - RelTableLocations=relations, - #Setting RootInTES for this tool gives a segfaul (why?), we anyway use DaVinciSmartAssociator for association. - #RootInTES=root_in_tes, - OutputLevel=output_level) - part_desc = ParticleDescendants( - RootInTES=root_in_tes, OutputLevel=output_level) - - mctruth = MCTruthAndBkgCatAlg( - Input=inputs, - filter_MCP=filter_MCP, - DaVinciSmartAssociator=dv_assc, - MCMatchObjP2MCRelator=mcrel_assc, - BackgroundCategory=bkg_cat, - BackgroundCategoryViaRelations=bkg_cat_via_rel, - ParticleDescendants=part_desc, - OutputLevel=output_level) - - return mctruth diff --git a/Phys/DaVinci/tests/config/test_algorithms.py b/Phys/DaVinci/tests/config/test_algorithms.py index 4c97aadd53df096753cd97b161e1a2b2784f61a2..0eafe7a6700ff4da824a79526fa5a188df6a5ebf 100644 --- a/Phys/DaVinci/tests/config/test_algorithms.py +++ b/Phys/DaVinci/tests/config/test_algorithms.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2022-2023 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". # @@ -120,9 +120,9 @@ def test_configured_funtuple(): """ Check if the configured_FunTuple provides a correct instance of FunTuple. """ - from FunTuple.functorcollections import Kinematics + import FunTuple.functorcollections as FC fields = {'B0': "[B0 -> D_s- pi+]CC"} - variables = {'B0': Kinematics()} + variables = {'B0': FC.Kinematics()} config = { "TestTuple": { "location": "/Event/Spruce/SpruceTestLine/Particles",