Skip to content
Snippets Groups Projects

DaVinci example to show how to get charged particles in a DaVinci script

Closed Guillaume Max Pietrzyk requested to merge guillaume_davinci_example into master
1 file
+ 34
4
Compare changes
  • Side-by-side
  • Inline
@@ -9,12 +9,16 @@
# or submit itself to any jurisdiction. #
###############################################################################
from DaVinci import Options, make_config
from DaVinci.algorithms import add_filter
from FunTuple import FunTuple_Particles as Funtuple
from Hlt2Conf.standard_particles import (
make_long_muons,
make_long_electrons_with_brem,
make_long_kaons,
make_long_pions,
)
from PyConf.reading import get_particles
import FunTuple.functorcollections as FC
"""
Very simple DaVinci option file.
@@ -24,9 +28,17 @@ Not using with reconstruction.bind(from_file=True, spruce=True) can make it look
This script assumes persistreco for every event.
"""
def main(options: Options):
fields_leptons = {
"Bu": "[B+ -> J/psi(1S) K+]CC",
}
line = 'Hlt2TrackEff_Velo2Long_B2JpsiK_MuonProbe_VELO'
process = 'HLT2'
input_data = get_particles(f"/Event/{process}/{line}/Particles")
from RecoConf.reconstruction_objects import reconstruction, upfront_reconstruction
# TODO, ideally it should work without an explicit bind by the user
with reconstruction.bind(from_file=True, spruce=True):
@@ -37,9 +49,27 @@ def main(options: Options):
# TODO, ideally it would not be necessary to explicitly add the unpacking to the control flow
unpack_data = upfront_reconstruction()
## DEFINE INSTANCE OF FUNTUPLE
Tdir = "Tuple"
TTree = "DecayTree"
variables_all = FC.Kinematics()
variables = {
'ALL': variables_all
}
tuple_data = Funtuple(
Tdir,
TTree,
fields=fields_leptons,
variables=variables,
inputs=input_data)
filter_line = add_filter("HDRFilter_Bu2JpsiK", f"HLT_PASS('{line}')")
algs = {
"B02JpsiK": unpack_data +
[long_muons, long_electrons, long_kaons, long_pions],
"B02JpsiK": [filter_line, tuple_data] + unpack_data + [long_muons, long_electrons, long_kaons, long_pions]
}
return make_config(options, algs)
return make_config(options, algs)
\ No newline at end of file
Loading