Use configured_FunTuple

This example shows how to read the output of a Sprucing job with the new DaVinci configuration filtering on an HLT2 line decision.

from FunTuple import FunctorCollection
import FunTuple.functorcollections as FC
from DaVinci.algorithms import configured_FunTuple
from DaVinci import Options, make_config


def main(options: Options):
    # FunTuple: define fields (branches)
    fields = {
        "B0": "[B0 -> D_s- pi+]CC",
        "Ds": "[B0 -> ^D_s- pi+]CC",
        "pip": "[B0 -> D_s- ^pi+]CC",
    }

    # FunTuple: define variables for the B meson
    variables_B = {
        "LOKI_MAXPT": "TRACK_MAX_PT",
        "LOKI_Muonp_PT": "CHILD(PT, 1)",
        "LOKI_Muonm_PT": "CHILD(PT, 2)",
        "LOKI_NTRCKS_ABV_THRSHLD": "NINTREE(ISBASIC & (PT > 15*MeV))",
    }

    # FunTuple: make functor collection from the imported functor library Kinematics
    variables_all = FC.Kinematics()

    # FunTuple: associate functor collections to field (branch) name
    variables = {
        "ALL": variables_all,  # adds variables to all fields
        "B0": FunctorCollection(variables_B),
    }

    line = "SpruceB2OC_BdToDsmPi_DsmToKpKmPim"
    config = {
        "location": f"/Event/Spruce/{line}/Particles",
        "filters": [f"{line}Decision"],
        "preamble": ["TRACK_MAX_PT = MAXTREE(ISBASIC & HASTRACK, PT, -1)"],
        "tuple": "DecayTree",
        "fields": fields,
        "variables": variables,
    }

    algs = configured_FunTuple({"B0Dspi": config})

    return make_config(options, algs)

To run the example:

lbexec DaVinciExamples.tupling.option_davinci_configFuntuple:main $DAVINCIEXAMPLESROOT/example_data/Spruce_all_lines_dst.yaml

For reference, these are the options of this example

input_files:
- root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/spruce_all_lines_realtimereco_newPacking_newDst.dst
input_manifest_file: root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/spruce_all_lines_realtime_newPacking_newDst.tck.json
input_type: ROOT
simulation: true
conddb_tag: sim-20171127-vc-md100
dddb_tag: dddb-20171126
conditions_version: master
geometry_version: run3/trunk
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