diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py index e33d5cabe16e47b8a3382eb3d758cafb23da9551..049efbaaac289cf3ea0c17d244d883bc04774553 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/DTF_filtered.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". # @@ -18,7 +18,7 @@ Example of a typical DaVinci job: import Functors as F from Gaudi.Configuration import INFO from DaVinci import Options, make_config -from DaVinci.algorithms import add_filter #, filter_on +from DaVinci.algorithms import add_filter from DecayTreeFitter import DecayTreeFitter from FunTuple import FunctorCollection as FC from FunTuple import FunTuple_Particles as Funtuple @@ -32,13 +32,7 @@ def main(options: Options): fields['Ds'] = "[B0 -> ^D_s- K+]CC" fields['K'] = "[B0 -> D_s- ^K+]CC" - #Get filtered particles (Note decay_descriptor is optional, if specified only B0 decays will be selected for processing) spruce_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line" - # REPLACING TEMPORARY THE INPUT DATA - #data_filtered = filter_on( - # f"/Event/Spruce/{spruce_line}/Particles", - # options.process, - # decay_descriptor=fields['B0']) data_filtered = get_particles(f"/Event/Spruce/{spruce_line}/Particles") # DecayTreeFitter Algorithm. diff --git a/Phys/DaVinci/python/DaVinci/algorithms.py b/Phys/DaVinci/python/DaVinci/algorithms.py index 63d453cc7943bfce09c59273af887022d8303dc8..9c08f800dd5a8bf899577bc95c3241959f675a54 100644 --- a/Phys/DaVinci/python/DaVinci/algorithms.py +++ b/Phys/DaVinci/python/DaVinci/algorithms.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2020-2022 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2020-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,9 @@ import re import logging from PyConf.Algorithms import ( - FilterDecays, LoKi__HDRFilter as HDRFilter, LoKi__VoidFilter as VoidFilter, ) -from Hlt2Conf.algorithms import make_dvalgorithm from PyConf.reading import get_particles, get_hlt_reports log = logging.getLogger(__name__) @@ -191,38 +189,3 @@ def configured_FunTuple(config): dictAlgs[key].append(funTuple) return dictAlgs - - -def apply_algorithm(list_particles, algorithm, **kwargs): - """ - Function that applies an algorithm, accepting a Particle::Range as input (e.g FilterDecays), - to particles from Hlt2 or Spruce sample defined in the list of TES locations gived as argument. - The extra arguments to algorithm can be passed via kwargs. - - Args: - list_particles (list(str)): List of Transient event store (TES) location of Particles in Hlt2 or Spruce sample. - algorithm (PyConf.Algorithms): Algorithm to be applied. - kwargs : Extra arguments to the passed algorithm. - Returns: - Ouput TES location of the particles from the algorithm - """ - dv_algorithm = make_dvalgorithm(algorithm) - return dv_algorithm(ParticlesA=list_particles, **kwargs).Particles - - -def filter_on(location, decay_descriptor=None): - """ - Function to get particles from Hlt2 or Spruce sample. - A FilterDecays is applied before returning the requested particles if a decay descriptor - is specified as extra argument. - - Args: - location (str): Transient event store (TES) location of Particles in Hlt2 or Spruce sample - decay_descriptor (str, optional): Decay descriptor that will be used to select decays in the event - Returns: - data: TES location of the particles that are loaded from the input samples - """ - data = get_particles(location) - if decay_descriptor: - data = apply_algorithm([data], FilterDecays, Code=decay_descriptor) - return data diff --git a/Phys/DaVinci/tests/config/test_algorithms.py b/Phys/DaVinci/tests/config/test_algorithms.py index 0eafe7a6700ff4da824a79526fa5a188df6a5ebf..74f27e3cc731b2aa447f41766463b540b862d3f1 100644 --- a/Phys/DaVinci/tests/config/test_algorithms.py +++ b/Phys/DaVinci/tests/config/test_algorithms.py @@ -11,11 +11,9 @@ from PyConf.Algorithms import Gaudi__Examples__VoidConsumer as VoidConsumer from DaVinci import Options -from DaVinci.algorithms import ( - define_fsr_writer, - add_filter, #filter_on - apply_filters_and_unpacking, - configured_FunTuple) +from DaVinci.algorithms import (define_fsr_writer, add_filter, + apply_filters_and_unpacking, + configured_FunTuple) from PyConf.reading import get_odin, get_decreports, get_hlt_reports, upfront_decoder from PyConf.application import default_raw_event @@ -184,16 +182,3 @@ def test_get_decreports(): get_hlt_reports.bind(input_process=options.input_process, stream=options.stream): decreports = get_decreports("Hlt2") assert decreports.location == "/Event/Hlt2/DecReports" - - -""" -def test_filter_on_and_apply_algorithms(): - "" - Check if filter_on and apply_algorithms functions return a correct filtered particle location." - "" - spruce_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line" - decay_descriptor = "[B0 -> D_s- K+]CC" - data_filtered = filter_on(f"/Event/Spruce/{spruce_line}/Particles", - decay_descriptor) - assert data_filtered.location == "/Event/FilterDecays/particles" -"""