GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/physics/InclusiveKinematics/Algorithm.h
Date: 2025-11-25 17:57:04
Coverage Exec Excl Total
Lines: 100.0% 5 0 5
Functions: 100.0% 3 0 3
Branches: 41.7% 10 0 24

Line Branch Exec Source
1 #pragma once
2
3 #include "iguana/algorithms/Algorithm.h"
4 #include "iguana/algorithms/TypeDefs.h"
5 #include "iguana/services/ConcurrentParam.h"
6
7 namespace iguana::physics {
8
9 /// @algo_brief{Calculate inclusive kinematics quantities}
10 /// @algo_type_creator
11 /// @begin_doc_config{physics/InclusiveKinematics}
12 /// @config_param{beam_direction | list[double] | beam direction vector}
13 /// @config_param{target_particle | string | target particle}
14 /// @config_param{beam_particle | string | beam particle}
15 /// @config_param{reconstruction | string | kinematics reconstruction method; only `scattered_lepton` is available at this time}
16 /// @config_param{lepton_finder | string | algorithm to find the scattered lepton; only `highest_energy_FD_trigger` is available at this time}
17 /// @end_doc
18 /// @rcdb_note
19 class InclusiveKinematics : public Algorithm
20 {
21
22
10/24
iguana::physics::InclusiveKinematics::~InclusiveKinematics():
✓ Branch 2 → 3 taken 8 times.
✗ Branch 2 → 5 not taken.
iguana::physics::InclusiveKinematics::InclusiveKinematics(std::basic_string_view<char, std::char_traits<char> >):
✓ Branch 2 → 3 taken 8 times.
✗ Branch 2 → 6 not taken.
✗ Branch 5 → 7 not taken.
✓ Branch 5 → 8 taken 8 times.
✓ Branch 9 → 10 taken 8 times.
✗ Branch 9 → 32 not taken.
✓ Branch 10 → 11 taken 8 times.
✗ Branch 10 → 17 not taken.
✓ Branch 17 → 18 taken 8 times.
✗ Branch 17 → 40 not taken.
✓ Branch 24 → 25 taken 8 times.
✗ Branch 24 → 40 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 39 not taken.
✗ Branch 40 → 41 not taken.
✗ Branch 40 → 43 not taken.
None:
✓ Branch 3 → 4 taken 8000 times.
✗ Branch 3 → 25 not taken.
✓ Branch 131 → 132 taken 8 times.
✗ Branch 131 → 288 not taken.
✓ Branch 132 → 133 taken 8 times.
✗ Branch 132 → 272 not taken.
8088 DEFINE_IGUANA_ALGORITHM(InclusiveKinematics, physics::InclusiveKinematics)
23
24 public:
25
26 void Start(hipo::banklist& banks) override;
27 bool Run(hipo::banklist& banks) const override;
28 void Stop() override;
29
30 /// @run_function
31 /// @param [in] particle_bank particle bank (_e.g._, `REC::Particle`)
32 /// @param [in] config_bank `RUN::config`
33 /// @param [out] result_bank `%physics::InclusiveKinematics`, which will be created
34 /// @returns `true` if the kinematics were calculated; _e.g._, if the calculations are performed using
35 /// the scattered lepton, and no scattered lepton was found, `false` will be returned
36 bool Run(
37 hipo::bank const& particle_bank,
38 hipo::bank const& config_bank,
39 hipo::bank& result_bank) const;
40
41 /// @action_function{reload} prepare the event
42 /// @when_to_call{for each event}
43 /// @param runnum the run number
44 /// @param beam_energy the beam energy; if negative (the default), RCDB will be used to get the beam energy from `runnum`
45 /// @returns the key to be used in `::ComputeFromLepton`
46 concurrent_key_t PrepareEvent(int const runnum, double const beam_energy = -1) const;
47
48 /// @action_function{scalar creator} compute kinematics from the scattered lepton.
49 /// @param lepton_px scattered lepton momentum component @latex{p_x} (GeV)
50 /// @param lepton_py scattered lepton momentum component @latex{p_y} (GeV)
51 /// @param lepton_pz scattered lepton momentum component @latex{p_z} (GeV)
52 /// @param key the return value of `::PrepareEvent`
53 /// @returns the reconstructed inclusive kinematics in a `iguana::physics::InclusiveKinematicsVars` instance
54 InclusiveKinematicsVars ComputeFromLepton(
55 vector_element_t const lepton_px,
56 vector_element_t const lepton_py,
57 vector_element_t const lepton_pz,
58 concurrent_key_t const key) const;
59
60 private:
61
62 /// FIXME: this could be changed to a vector action function
63 /// Find the scattered lepton. Since finding the scattered lepton requires
64 /// reading all the particles of an event, there is no **Action function**;
65 /// therefore, callers that do not have access to `hipo::bank` objects are
66 /// responsible for finding the scattered lepton.
67 /// @param particle_bank the particle bank to search
68 /// @param key the return value of `::PrepareEvent`
69 /// @returns the bank row of the scattered lepton, or `-1` if not found
70 int FindScatteredLepton(hipo::bank const& particle_bank, concurrent_key_t const key) const;
71
72 void Reload(int const runnum, double const user_beam_energy, concurrent_key_t key) const;
73
74 // banklist indices
75 hipo::banklist::size_type b_particle;
76 hipo::banklist::size_type b_config;
77 hipo::banklist::size_type b_result;
78
79 // `b_result` bank item indices
80 int i_pindex;
81 int i_Q2;
82 int i_x;
83 int i_y;
84 int i_W;
85 int i_nu;
86 int i_qx;
87 int i_qy;
88 int i_qz;
89 int i_qE;
90 int i_beamPz;
91 int i_targetM;
92
93 // config options
94 std::string o_particle_bank;
95 mutable std::unique_ptr<ConcurrentParam<int>> o_runnum;
96 mutable std::unique_ptr<ConcurrentParam<std::vector<double>>> o_target_PxPyPzM;
97 mutable std::unique_ptr<ConcurrentParam<std::vector<double>>> o_beam_PxPyPzM;
98 double o_beam_mass; // unlikely to change
99 int o_beam_pdg; // unlikely to change
100 double o_override_beam_energy;
101
102 enum method_reconstruction { scattered_lepton };
103 enum method_lepton_finder { highest_energy_FD_trigger };
104 method_reconstruction o_method_reconstruction;
105 method_lepton_finder o_method_lepton_finder;
106 };
107
108 }
109