24int main(
int argc,
char** argv)
29 char const* inFileName = argc > argi ? argv[argi++] :
"data.hipo";
30 int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1;
33 hipo::reader reader(inFileName,{0});
36 hipo::banklist banks = reader.getBanks({
"REC::Particle",
"RUN::config"});
39 auto b_particle = hipo::getBanklistIndex(banks,
"REC::Particle");
40 auto b_config = hipo::getBanklistIndex(banks,
"RUN::config");
51 algo_eventbuilder_filter.
SetOption(
"log",
"debug");
52 algo_momentum_correction.
SetOption(
"log",
"debug");
55 algo_eventbuilder_filter.
SetOption<std::vector<int>>(
"pids", {11, 211, -211});
58 algo_eventbuilder_filter.
Start();
59 algo_momentum_correction.
Start();
63 while(reader.next(banks) && (numEvents == 0 || iEvent++ < numEvents)) {
66 auto& particleBank = banks.at(b_particle);
67 auto& configBank = banks.at(b_config);
71 for(
auto const& row : particleBank.getRowList()) {
74 auto pid = particleBank.getInt(
"pid", row);
75 if(algo_eventbuilder_filter.
Filter(pid)) {
82 auto [px, py, pz] = algo_momentum_correction.
Transform(
83 particleBank.getFloat(
"px", row),
84 particleBank.getFloat(
"py", row),
85 particleBank.getFloat(
"pz", row),
88 configBank.getFloat(
"torus", 0));
91 fmt::print(
"Accepted PID {}:\n", pid);
92 auto printMomentum = [](
auto v1,
auto v2)
93 { fmt::print(
" {:>20} {:>20}\n", v1, v2); };
94 printMomentum(
"p_old",
"p_new");
95 printMomentum(
"--------",
"--------");
96 printMomentum(particleBank.getFloat(
"px", row), px);
97 printMomentum(particleBank.getFloat(
"py", row), py);
98 printMomentum(particleBank.getFloat(
"pz", row), pz);
104 algo_eventbuilder_filter.
Stop();
105 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