20int main(
int argc,
char** argv)
25 char const* inFileName = argc > argi ? argv[argi++] :
"data.hipo";
26 int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;
29 hipo::reader reader(inFileName,{0});
32 hipo::banklist banks = reader.getBanks({
"REC::Particle",
"RUN::config"});
33 enum banks_enum { b_particle,
45 algo_eventbuilder_filter.
SetOption(
"log",
"debug");
46 algo_momentum_correction.
SetOption(
"log",
"debug");
49 algo_eventbuilder_filter.
SetOption<std::vector<int>>(
"pids", {11, 211, -211});
52 algo_eventbuilder_filter.
Start();
53 algo_momentum_correction.
Start();
57 while(reader.next(banks) && (numEvents == 0 || iEvent++ < numEvents)) {
60 auto& particleBank = banks.at(b_particle);
61 auto& configBank = banks.at(b_config);
65 for(
auto const& row : particleBank.getRowList()) {
68 auto pid = particleBank.getInt(
"pid", row);
69 if(algo_eventbuilder_filter.
Filter(pid)) {
76 auto [px, py, pz] = algo_momentum_correction.
Transform(
77 particleBank.getFloat(
"px", row),
78 particleBank.getFloat(
"py", row),
79 particleBank.getFloat(
"pz", row),
82 configBank.getFloat(
"torus", 0));
85 fmt::print(
"Accepted PID {}:\n", pid);
86 auto printMomentum = [](
auto v1,
auto v2)
87 { fmt::print(
" {:>20} {:>20}\n", v1, v2); };
88 printMomentum(
"p_old",
"p_new");
89 printMomentum(
"--------",
"--------");
90 printMomentum(particleBank.getFloat(
"px", row), px);
91 printMomentum(particleBank.getFloat(
"py", row), py);
92 printMomentum(particleBank.getFloat(
"pz", row), pz);
98 algo_eventbuilder_filter.
Stop();
99 algo_momentum_correction.
Stop();
Momentum3 Transform(vector_element_t const px, vector_element_t const py, vector_element_t const pz, int const sec, int const pid, float const torus) const
Action Function: Apply the momentum correction