diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py index 56470d87d5b971da1afc2663301778e75ebca3ab..8590341c1f8224571974b165315ce1340cfe575e 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/AllFunctors.py @@ -15,6 +15,7 @@ __author__ = "P. Koppenburg" __date__ = "2021-11-23" import Functors as F +import FunTuple.functorcollections as FC from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple from PyConf.reading import get_particles, get_pvs @@ -23,7 +24,6 @@ from PyConf.reading import get_odin # get_decreports, from DecayTreeFitter import DecayTreeFitter from DaVinciMCTools import MCTruthAndBkgCat from PyConf.Algorithms import PrintDecayTree -import FunTuple.functorcollections as FC from DaVinci import Options, make_config @@ -52,7 +52,7 @@ def all_variables(pvs, dtf, mctruth, ptype, candidates=None, ftAlg=None): basic = (_basic == ptype) # is not composite top = (_toplevel == ptype) # the B - # First import everuthing that comes in functorcollections + # First import everything that comes in functorcollections all_vars += FC.Kinematics() if basic: all_vars += FC.ParticleID(extra_info=True) diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py index 049efbaaac289cf3ea0c17d244d883bc04774553..a2d47a43e92012a15323a21b661a7381c4679382 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py @@ -20,7 +20,7 @@ from Gaudi.Configuration import INFO from DaVinci import Options, make_config from DaVinci.algorithms import add_filter from DecayTreeFitter import DecayTreeFitter -from FunTuple import FunctorCollection as FC +from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple from PyConf.reading import get_particles @@ -43,14 +43,14 @@ def main(options: Options): output_level=INFO) #make collection of functors for all particles - variables_all = FC({ + variables_all = FunctorCollection({ 'THOR_P': F.P, 'THOR_PT': F.PT, 'THOR_MASS': F.MASS, }) #make collection of functors for Ds meson - variables_ds = FC({ + variables_ds = FunctorCollection({ 'DTF_PT': DTF(F.PT), 'DTF_MASS': 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 80b60494ceb87fb5ad15b0e04baac542ab662c4e..2490fad15f4e6a761f78fc88a85ec4300006889c 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_substitutePID.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_DTF_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". # @@ -13,13 +13,12 @@ Example options to show the usage of the new DaVinciTools: DecayTreeFitter. """ from Gaudi.Configuration import INFO -from FunTuple import FunTuple_Particles as Funtuple -from FunTuple import FunctorCollection as FC -from DaVinci.algorithms import add_filter from PyConf.reading import get_particles, get_pvs_v1 -from DecayTreeFitter import DecayTreeFitter - import Functors as F +from DecayTreeFitter import DecayTreeFitter +from FunTuple import FunTuple_Particles as Funtuple +from FunTuple import FunctorCollection +from DaVinci.algorithms import add_filter from DaVinci import Options, make_config @@ -59,7 +58,7 @@ def main(options: Options): 'KM': "[ B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ ^K-) ]CC", } - variables_all = FC({ + variables_all = FunctorCollection({ # Original particle 'ORIGINAL_ID': F.PARTICLE_ID, 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 81055ffd025a23a5fe4371dd78a1ffd553b26f96..b58a82366c0df77c00c80ab01cbbaf9d9c7f35d4 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_array_taggers.py @@ -37,7 +37,8 @@ from PyConf.reading import get_particles from PyConf.Algorithms import ParticleTaggerAlg, ParticleContainerMerger import Functors as F -from FunTuple import FunctorCollection as FC, FunTuple_Particles as Funtuple +from FunTuple import FunctorCollection +from FunTuple import FunTuple_Particles as Funtuple from DaVinci import Options, make_config from DaVinci.algorithms import add_filter @@ -89,7 +90,7 @@ def main(options: Options): # #N.B: a default value has to be defined for functors returning an int/bool value (or an array of int/bool values) #in case the output is empty: e.g. "TRUEID" or "TagTr_TRUEKEY[nTags]". - variables_B = FC({ + variables_B = FunctorCollection({ 'THOR_MASS': F.MASS, 'PT': @@ -155,7 +156,7 @@ def main(options: Options): }) # Make collection of functors for all the signal decay chain particles - variables_all = FC({ + variables_all = FunctorCollection({ 'THOR_P': F.P, 'THOR_PT': F.PT, }) 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 ffb03e4f3b5ef326720593d8c31908e0f55831a5..6eb1bd7f0199ecd1308510b067a9ee3334349ce0 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_unreconstructed_info.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_unreconstructed_info.py @@ -12,7 +12,7 @@ Read an HLT2 file and create an ntuple with truth information about unreconstructed particles """ import Functors as F -from FunTuple import FunctorCollection as FC +from FunTuple import FunctorCollection from FunTuple import FunTuple_Particles as Funtuple from DaVinci.algorithms import add_filter from DaVinci import make_config, Options @@ -56,14 +56,21 @@ 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), - '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) + lb_variables = FunctorCollection({ + '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/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py index 399e3ab61d33c9e15b02e4333fd5a292097df33c..50691e432fcae144708adbd61ae2b04aa9c0fbdf 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial1_functors_specialfield.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 @@ import Functors as F 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 FunctorCollection from FunTuple import FunTuple_Particles as Funtuple @@ -37,14 +37,14 @@ def main(options: Options): # For more info on ThOr see https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/selection/thor_functors.html#functor-cache # For list of ThOr functors see https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/selection/thor_functors_reference.html # Here we define functor collection to be added to "ALL" fields (Bs, Jpsi, Phi, etc) - all_vars = FC({ + all_vars = FunctorCollection({ "THOR_P": F.P, #ThOr momentum functor "ID": F. PARTICLE_ID, #Refer to "ParticleTable.txt" for particle ID (see above on how to get this file) }) # Define functors to be added only to Bs and Jpsi fields - bs_jpsi_fun = FC({"PT_THOR": F.PT, "PX": F.PX, "PY": F.PY}) + bs_jpsi_fun = FunctorCollection({"PT_THOR": F.PT, "PX": F.PX, "PY": F.PY}) #Define variables dictionary "field name" -> Collections of functor. # "ALL" is a special field name that adds PT to all the fields defined above (i.e. Bs,Jpsi,Mup,Mum,Kp,Km) diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py index 832481630d544ee7603287d3205e66f6caee34e0..bfbe57464af04f32ce2af1f5b9a54bad683d4198 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial2_LoKi.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 @@ import Functors as F 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 FunctorCollection from FunTuple import FunTuple_Particles as Funtuple @@ -32,7 +32,7 @@ def main(options: Options): # For more info on ThOr see https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/selection/thor_functors.html#functor-cache # For list of ThOr functors see https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/selection/thor_functors_reference.html # For information on LoKi functor see https://lhcb.github.io/starterkit-lessons/first-analysis-steps/loki-functors.html - mom_fun = FC({ + mom_fun = FunctorCollection({ "THOR_PT": F.PT, "THOR_PX": F.PX, "THOR_PY": F.PY, @@ -47,7 +47,7 @@ def main(options: Options): loki_preamble = ['TRACK_MAX_PT = MAXTREE(ISBASIC & HASTRACK, PT, -1)'] # Define collections to be added to fields - max_pt_fun = FC({ + max_pt_fun = FunctorCollection({ # With LoKi "MAX_PT_LOKI": "TRACK_MAX_PT", # ThOr (not equivalent, sum of pT of composites not basic). MAXTREE ThOr doesn't exist yet. diff --git a/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py b/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py index 35f4b74c8f5fb22a877b29d1a4a051058d637d64..abff5a48c4dc8c937ec091cda307dfd865c8410d 100644 --- a/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.py +++ b/DaVinciTutorials/python/DaVinciTutorials/tutorial3_ThOrfunctors.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". # @@ -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, get_pvs 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, get_pvs -from FunTuple import FunctorCollection as FC -from FunTuple import FunTuple_Particles as Funtuple def main(options: Options): @@ -82,8 +82,8 @@ def main(options: Options): #Define variables dictionary "field name" -> Collections of functor variables = { - "ALL": FC(all_vars), - "Bs": FC(bs_vars), + "ALL": FunctorCollection(all_vars), + "Bs": FunctorCollection(bs_vars), } #Load data from dst onto a TES