Belle II Software light-2406-ragdoll
formulaVariablesExample.py
1#!/usr/bin/env python3
2
3
10
11# An example/test of using the formula() metavariable
12#
13# For full documentation please refer to https://software.belle2.org
14# Anything unclear? Ask questions at https://questions.belle2.org
15
16import basf2
17from modularAnalysis import inputMdstList
18from stdCharged import stdPi
19
20mypath = basf2.Path() # create a path
21
22# add input data and ParticleLoader modules to the path
23inputMdstList([basf2.find_file('analysis/tests/mdst.root')], path=mypath)
24stdPi('95eff', path=mypath) # grab the standard pions list
25
26# you can (and should) make this into something more sensible
27nonsense_formula = 'formula(p+nTracks)'
28
29# Add the VariablesToNtuple module explicitly
30# this will write out one row per candidate in the pi+ list and evaluate
31# the nonsense formula for all of them
32mypath.add_module(
33 'VariablesToNtuple',
34 particleList='pi+:95eff',
35 variables=['nTracks', 'p', nonsense_formula],
36 fileName='formulaTest.root'
37)
38
39# process the data
40basf2.process(mypath)
41print(basf2.statistics)