Basic DaVinci Job
This example shows how to:
reconstruct and select two detached muons
add a user algorithm to print the decay tree of a candidate via
PrintDecayTreeadd a tuple of the selected candidates.
import Functors as F
from RecoConf.standard_particles import make_detached_mumu, make_KsDD
from FunTuple import FunctorCollection
from FunTuple import FunTuple_Particles as Funtuple
from DaVinci import Options, make_config
from GaudiKernel.SystemOfUnits import MeV
def main(options: Options):
# selections
dimuons = make_detached_mumu()
kshorts = make_KsDD()
# FunTuple: make fields (branches) to tuple
fields = {}
fields["Jpsi"] = "J/psi(1S) -> mu+ mu-"
fields["MuPlus"] = "J/psi(1S) -> ^mu+ mu-"
# FunTuple: make collection of functors for Jpsi
variables_jpsi = {
"THOR_Muonp_PT": F.CHILD(1, F.PT),
"THOR_Muonm_PT": F.CHILD(2, F.PT),
"THOR_MAXPT": F.MAXTREE(F.ISBASICPARTICLE & (F.HAS_VALUE @ F.TRACK), F.PT),
"THOR_N_HIGHPT_TRCKS": F.NINTREE(F.ISBASICPARTICLE & (F.PT > 1500 * MeV)),
"THOR_P": F.P,
"THOR_PT": F.PT,
}
# FunTuple: make collection of functors for Muplus
variables_muplus = {"THOR_P": F.P}
# FunTuple: associate functor collections to field (branch) name
variables = {}
variables["Jpsi"] = FunctorCollection(variables_jpsi)
variables["MuPlus"] = FunctorCollection(variables_muplus)
# FunTuple: Configure Funtuple algorithm
tuple_dimuons = Funtuple(
name="DimuonsTuple",
tuple_name="DecayTree",
fields=fields,
variables=variables,
inputs=dimuons,
)
# FunTuple: similarly for Ks we can make fields (branches), functor collections, variables and FunTuple instance
fields_KS = {}
fields_KS["KS"] = "KS0 -> pi+ pi-"
# associate the functor collections to KS field name (NB: here we use functor collection used for jpsi)
variables_KS = {}
variables_KS["KS"] = FunctorCollection(variables_jpsi)
# funtuple instance
tuple_kshorts = Funtuple(
name="KsTuple",
tuple_name="DecayTree",
fields=fields_KS,
variables=variables_KS,
inputs=kshorts,
)
algs = {
"DiMuons": [tuple_dimuons],
"KShorts": [tuple_kshorts],
}
return make_config(options, algs)
To run the example:
lbexec DaVinciExamples.tupling.basic:main $DAVINCIEXAMPLESROOT/example_data/MC_2024_Bd2KstarMuMu_dst.yaml+$DAVINCIEXAMPLESROOT/example_options/example_tupling_basic.yaml
For reference, these are the options of this example
testfiledb_key: mc_2024_sim10d_HLT2-2024.W31.34_Bd2KstMuMu_MagUp
input_process: Hlt2
lumi: False
write_fsr: False
ntuple_file: DV-example-tupling-basic-ntp.root
histo_file: DV-example-tupling-basic-his.root
evt_max: 10
input_raw_format: 4.3
input_process: Hlt2