DecayTreeFitter in DaVinci
This example shows how to:
select two detached opposite-charge muons
create a tuple of the selected candidates
run DecayTreeFitterAlg and stores some output
import Functors as F
from RecoConf.standard_particles import make_detached_mumu
from RecoConf.reconstruction_objects import make_pvs
from FunTuple import FunctorCollection
from FunTuple import FunTuple_Particles as Funtuple
from DecayTreeFitter import DecayTreeFitter
from DaVinci import Options, make_config
def main(options: Options):
# Prepare the node with the selection
dimuons = make_detached_mumu()
pvs = make_pvs()
# DecayTreeFitter Algorithm.
# One with PV constraint and one without
DTF = DecayTreeFitter(
name="DTF_dimuons",
input_particles=dimuons,
mass_constraints=["J/psi(1S)"],
)
# FunTuple: Jpsi info
fields = {}
fields["Jpsi"] = "J/psi(1S) -> mu+ mu-"
fields["MuPlus"] = "J/psi(1S) -> ^mu+ mu-"
# make collection of functors for Jpsi
variables_jpsi = FunctorCollection(
{
"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,
"THOR_MASS": F.MASS,
"DTF_PT": DTF(F.PT),
"DTF_MASS": DTF(F.MASS),
}
)
#
# Another way of adding variables.
#
DTF_pv = DecayTreeFitter(
name="DTF_PVConstraints",
input_particles=dimuons,
input_pvs=pvs, # input PVs
mass_constraints=["J/psi(1S)"],
)
variables_jpsi.update(
DTF_pv.apply_functors(functors=[F.PT, F.MASS], head="DTF_PV_")
)
# make collection of functors for Muplus
variables_muplus = FunctorCollection(
{
"LOKI_P": "P",
"THOR_P": F.P,
"DTF_PT": DTF(F.PT),
}
)
# associate FunctorCollection to field (branch) name
variables = {}
variables["Jpsi"] = variables_jpsi
variables["MuPlus"] = variables_muplus
# FunTuple: define list of preambles for loki
loki_preamble = ["TRACK_MAX_PT = MAXTREE(ISBASIC & HASTRACK, PT, -1)"]
# Configure Funtuple algorithm
tuple_dimuons = Funtuple(
name="DimuonsTuple",
tuple_name="DecayTree",
fields=fields,
variables=variables,
loki_preamble=loki_preamble,
inputs=dimuons,
)
return make_config(options, [tuple_dimuons])
To run the example:
lbexec DaVinciExamples.tupling.DTF_run_mc:main $DAVINCIEXAMPLESROOT/example_data/Upgrade_Bd2KstarMuMu_ldst.yaml+$DAVINCIEXAMPLESROOT/example_options/example_tupling_DTF_run_mc.yaml
For reference, these are the options of this example
testfiledb_key: Spruce_all_lines_dst
input_manifest_file: root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/spruce_all_lines_realtime_newPacking_newDst.tck.json
lumi: False
write_fsr: False
histo_file: sprucing_histos.root
ntuple_file: sprucing_tuple.root
input_raw_format: 0.5
input_process: Spruce
persistreco_version: 0.0
evt_max: 10
histo_file: DV-example-tupling-DTF-his.root
input_raw_format: 4.3
ntuple_file: DV-example-tupling-DTF-ntp.root