4@begin_doc_example{python}
5@file iguana_ex_python_00_run_functions.py
6@brief Python version of `iguana_ex_cpp_00_run_functions.cc` (for more details, see this `.cc` file)
7@note You may need to run this example using `stdbuf -o0` (preceding your command) if the output appears to be jumbled
17pyiguana.include(
'hipo4/reader.h',
'iguana/algorithms/AlgorithmSequence.h')
19from cppyy.gbl
import hipo, iguana
23inFile = sys.argv[1]
if len(sys.argv)>1
else 'data.hipo'
24numEvents = int(sys.argv[2])
if len(sys.argv)>2
else 3
27reader = hipo.reader(inFile)
30banks = reader.getBanks([
40seq.Add(
'clas12::EventBuilderFilter')
41seq.Add(
'clas12::SectorFinder')
42seq.Add(
'clas12::rga::MomentumCorrection')
50seq.SetConfigFileForEachAlgorithm(
"examples/config_for_examples.yaml")
61b_sector = seq.GetCreatedBankIndex(banks,
"clas12::SectorFinder")
65while(reader.next(banks)
and (numEvents==0
or iEvent < numEvents)):
72 print(f
'===== EVENT {banks[b_config].getInt("event", 0)} =====', flush=
True)
75 print(
'----- BEFORE IGUANA -----', flush=
True)
76 banks[b_particle].show()
82 print(
'----- AFTER IGUANA -----', flush=
True)
83 banks[b_particle].show()
84 banks[b_sector].show()
87 print(
'----- Analysis Particles -----', flush=
True)
88 print(f
' {"row == pindex":<20} {"PDG":<20} {"|p|":<20} {"sector":<20}', flush=
True)
93 for row
in list(banks[b_particle].getRowList()):
95 banks[b_particle].getFloat(
'px', row),
96 banks[b_particle].getFloat(
'py', row),
97 banks[b_particle].getFloat(
'pz', row))
98 pdg = banks[b_particle].getInt(
'pid', row)
99 sector = banks[b_sector].getInt(
'sector', row)
100 print(f
' {row:<20} {pdg:<20} {p:<20.3f} {sector:<20}', flush=
True)
Algorithm: An algorithm that can run a sequence of algorithms