4@begin_doc_example{python}
5@file iguana_ex_python_01_action_functions.py
6@brief Python version of `iguana_ex_cpp_01_action_functions.cc` (for more details, see this `.cc` file)
17 'iguana/algorithms/clas12/EventBuilderFilter/Algorithm.h',
18 'iguana/algorithms/clas12/MomentumCorrection/Algorithm.h',
21from cppyy.gbl
import hipo, iguana
24inFile = sys.argv[1]
if len(sys.argv)>1
else 'data.hipo'
25numEvents = int(sys.argv[2])
if len(sys.argv)>2
else 3
27reader = hipo.reader(inFile)
28banks = reader.getBanks([
"REC::Particle",
"RUN::config"]);
33algo_eventbuilder_filter.SetOption(
'log',
'debug')
34algo_momentum_correction.SetOption(
'log',
'debug')
35algo_eventbuilder_filter.SetOption(
'pids', [11, 211, -211])
37algo_eventbuilder_filter.Start()
38algo_momentum_correction.Start()
41while(reader.next(banks)
and (numEvents==0
or iEvent < numEvents)):
44 particleBank = banks[0]
48 for row
in particleBank.getRowList():
50 pid = particleBank.getInt(
'pid', row)
51 if(algo_eventbuilder_filter.Filter(pid)):
57 p_corrected = algo_momentum_correction.Transform(
58 particleBank.getFloat(
"px", row),
59 particleBank.getFloat(
"py", row),
60 particleBank.getFloat(
"pz", row),
63 configBank.getFloat(
"torus", 0)
66 print(f
'Accepted PID {pid}:')
67 print(f
' p_old = ({particleBank.getFloat("px", row)}, {particleBank.getFloat("py", row)}, {particleBank.getFloat("pz", row)})')
68 print(f
' p_new = ({p_corrected.px}, {p_corrected.py}, {p_corrected.pz})')
70algo_eventbuilder_filter.Stop()
71algo_momentum_correction.Stop()
Algorithm: Filter the REC::Particle (or similar) bank by PID from the Event Builder
Algorithm: Momentum Corrections