FunTuple event-by-event

Example for tupling on and event-by-event basis via the FunTuple_Event helper. This algorithm takes no input and is configured with “void” functors, i.e. functors that expect no input. This is is contrast to FunTuple_(MC)Particles, which take as input the TES location of (MC)Particles and are configured with functors that operate on a single Particle/MCParticle.


from PyConf.reading import get_rec_summary
import Functors as F
from FunTuple import FunctorCollection
from FunTuple import FunTuple_Event as Funtuple
import FunTuple.functorcollections as FC
from DaVinci import make_config, Options


def main(options: Options):
    # get RecSummary object that holds information about nPVs, nTracks, nFTClusters
    # Note more information can be added to the RecSummary object
    # (see MRs: https://gitlab.cern.ch/lhcb/Moore/-/merge_requests/1649)
    rec_summary = get_rec_summary()

    evt_vars = FunctorCollection(
        {
            "nPVs": F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nPVs"),
            "nFTClusters": F.VALUE_OR(-1)
            @ F.RECSUMMARY_INFO(rec_summary, "nFTClusters"),
            "nLongTracks": F.VALUE_OR(-1)
            @ F.RECSUMMARY_INFO(rec_summary, "nLongTracks"),
        }
    )

    evt_vars += FC.EventInfo()

    # define tupling algorithm
    my_tuple = Funtuple(name="Tuple", tuple_name="EventInfo", variables=evt_vars)

    return make_config(options, [my_tuple])

To run the example:

lbexec DaVinciExamples.tupling.option_davinci_tupling_FunTupleEvent:main $DAVINCIEXAMPLESROOT/example_data/Upgrade_LbToLcmunu.yaml

For reference, these are the options of this example

input_files:
   - root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/Upgrade_LbToLcmunu.dst
input_manifest_file: root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/Upgrade_LbToLcmunu.tck.json
input_type: ROOT
simulation: True
conddb_tag: sim-20210617-vc-mu100
dddb_tag: dddb-20210617
conditions_version: master
geometry_version: run3/trunk
input_raw_format: 0.5
ntuple_file: 'mytuple.root'
print_freq: 1
input_process: Hlt2
input_stream: default
evt_max: 7
persistreco_version: 0.0
lumi: False
write_fsr: False