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
PrintDecayTree
add a tuple of the selected candidates.
import Functors as F
from Hlt2Conf.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
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 = {
"LOKI_P": "P",
"LOKI_PT": "PT",
"LOKI_Muonp_PT": "CHILD(PT, 1)",
"LOKI_Muonm_PT": "CHILD(PT, 2)",
"LOKI_MAXPT": "TRACK_MAX_PT",
"LOKI_N_HIGHPT_TRCKS": "NINTREE(ISBASIC & HASTRACK & (PT > 1500*MeV))",
"THOR_P": F.P,
"THOR_PT": F.PT,
}
# FunTuple: make collection of functors for Muplus
variables_muplus = {"LOKI_P": "P", "THOR_P": F.P}
# FunTuple: associate functor collections to field (branch) name
variables = {}
variables["Jpsi"] = FunctorCollection(variables_jpsi)
variables["MuPlus"] = FunctorCollection(variables_muplus)
# FunTuple: define list of preambles for loki
loki_preamble = ["TRACK_MAX_PT = MAXTREE(ISBASIC & HASTRACK, PT, -1)"]
# FunTuple: Configure Funtuple algorithm
tuple_dimuons = Funtuple(
name="DimuonsTuple",
tuple_name="DecayTree",
fields=fields,
variables=variables,
loki_preamble=loki_preamble,
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,
loki_preamble=loki_preamble,
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/Upgrade_Bd2KstarMuMu_ldst.yaml+$DAVINCIEXAMPLESROOT/example_options/example_tupling_basic.yaml
For reference, these are the options of this example
input_files: root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/MC/Upgrade/LDST/00076720/0000/00076720_000000{01,02,04,27,36,37,38,39,43,51,57,68}_1.ldst
input_type: ROOT
simulation: true
conddb_tag: sim-20171127-vc-md100
dddb_tag: dddb-20171126
conditions_version: master
geometry_version: run3/trunk
input_process: Brunel
persistreco_version: 0.0
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