Skip to content
Snippets Groups Projects

Adding example for track isolation variables

Merged Tommaso Fulghesu requested to merge tfulghes-SUMCONE-functor into master
1 file
+ 88
0
Compare changes
  • Side-by-side
  • Inline
###############################################################################
# (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. #
###############################################################################
"""
Option file for testing the ParticleIsolationAlg algorithm and the related ThOr functors SUMCONE and SUM_RANGE.
The job runs over a spruced sample and retrieves a set of B0 -> Ds K+ candidates. For each candidate the ParticleIsolationAlg
looks at the TES location defined via the 'make_long_pions_from_spruce' function and creates a 'one-to-many' relation map
relating all the available tracks to the B candidate of the events.
Then the SUMCONE functor takes in input this relation map and evaluates the sum of the result of the application of an external functor (i.e F.P, F.PT)
on each entry via the SUM_RANGE functor.
This example is meant to be run with
$ ./run davinci run-mc --inputfiledb Spruce_all_lines_dst Phys/DaVinci/options/DaVinciDB-Example.yaml --user_algorithms DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_isolation:main
"""
import Functors as F
from PyConf.application import make_data_with_FetchDataFromFile
from PyConf.Algorithms import ParticleIsolationAlg, ParticleContainerMerger
from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple
from DaVinci.algorithms import add_filter
from DaVinci.standard_particles import _make_particles
bd2dsk_line = "SpruceB2OC_BdToDsmK_DsmToHHH_FEST_Line"
bd2dsk_data = make_data_with_FetchDataFromFile(
f"/Event/Spruce/{bd2dsk_line}/Particles")
make_parts = _make_particles()
isolation_container = ParticleContainerMerger(
InputContainers=[make_parts]).OutputContainer
tagAlg = ParticleTaggerAlg(
Input=bd2dsk_data, ParticleContainer=isolation_container, OutputLevel=3)
tagAlg_out = tagAlg.Output
tagAlg_rels = tagAlg.OutputRelations
#make collection of functors
variables_B = FunctorCollection({
'THOR_MASS':
F.MASS,
"Sum_P":
F.SUM_CONE(Functor=F.SUM_RANGE(Functor=F.P), Relations=isoAlg_rels),
"Sum_PT":
F.SUM_CONE(
Functor=F.SUM_RANGE(Functor=F.PT), Relations=isoAlg_rels),
})
#make collection of functors for Muplus
variables_all = FunctorCollection({
'THOR_P': F.P,
'THOR_PT': F.PT,
})
fields = {
'B0': "[B0 -> D_s- K+]CC",
'Ds': "[B0 -> ^D_s- K+]CC",
'Kp': "[B0 -> D_s- ^K+]CC",
}
variables = {
'ALL': variables_all, #adds variables to all fields
'B0': variables_B,
}
tuple_B0DsK = Funtuple(
name="B0DsK_Tuple",
tuple_name="DecayTree",
fields=fields,
variables=variables,
inputs=bd2dsk_data)
filter_B0DsK = add_filter("HDRFilter_B0DsK", f"HLT_PASS('{bd2dsk_line}Decision')")
from DaVinci import options
options.annsvc_config = 'root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/spruce_all_lines_realtime.tck.json'
options.histo_file = 'DV-example-isolation-his.root'
options.ntuple_file = 'DV-example-isolation-ntp.root'
def main():
algs = [filter_B0DsK, tuple_B0DsK]
return algs, []
Loading