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 | #include "iguana/services/RCDBReader.h" | ||
7 | |||
8 | namespace iguana::physics { | ||
9 | |||
10 | /// Set of inclusive kinematics variables | ||
11 | struct InclusiveKinematicsVars { | ||
12 | /// @brief `REC::Particle` row (`pindex`) of the scattered electron | ||
13 | int pindex; | ||
14 | /// @brief @latex{x}-component of virtual photon momentum @latex{q} | ||
15 | vector_element_t qx; | ||
16 | /// @brief @latex{y}-component of virtual photon momentum @latex{q} | ||
17 | vector_element_t qy; | ||
18 | /// @brief @latex{z}-component of virtual photon momentum @latex{q} | ||
19 | vector_element_t qz; | ||
20 | /// @brief @latex{E}-component of virtual photon momentum @latex{q} | ||
21 | vector_element_t qE; | ||
22 | /// @brief @latex{Q^2} (GeV@latex{^2}) | ||
23 | double Q2; | ||
24 | /// @brief @latex{x_B} | ||
25 | double x; | ||
26 | /// @brief @latex{y} | ||
27 | double y; | ||
28 | /// @brief @latex{W} (GeV) | ||
29 | double W; | ||
30 | /// @brief @latex{\nu} | ||
31 | double nu; | ||
32 | /// @brief beam momentum @latex{z}-component (GeV) | ||
33 | double beamPz; | ||
34 | /// @brief target mass (GeV) | ||
35 | double targetM; | ||
36 | }; | ||
37 | |||
38 | /// @brief_algo Calculate inclusive kinematics quantities defined in `iguana::physics::InclusiveKinematicsVars` | ||
39 | /// | ||
40 | /// @begin_doc_algo{physics::InclusiveKinematics | Creator} | ||
41 | /// @input_banks{REC::Particle, RUN::config} | ||
42 | /// @output_banks{%physics::InclusiveKinematics} | ||
43 | /// @end_doc | ||
44 | /// | ||
45 | /// @begin_doc_config | ||
46 | /// @config_param{initial_state:beam_energy | double | beam energy [GeV]} | ||
47 | /// @config_param{initial_state:beam_direction | list[double] | beam direction vector} | ||
48 | /// @config_param{initial_state:target_particle | string | target particle} | ||
49 | /// @config_param{method:beam_particle | string | beam particle} | ||
50 | /// @config_param{method:reconstruction | string | kinematics reconstruction method; only `scattered_lepton` is available} | ||
51 | /// @config_param{method:lepton_finder | string | algorithm to find the scattered lepton; only `highest_energy_FD_trigger` is available} | ||
52 | /// @end_doc | ||
53 | class InclusiveKinematics : public Algorithm | ||
54 | { | ||
55 | |||
56 |
5/12✓ Branch 0 taken 6006 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
6060 | DEFINE_IGUANA_ALGORITHM(InclusiveKinematics, physics::InclusiveKinematics) |
57 | |||
58 | public: | ||
59 | |||
60 | void Start(hipo::banklist& banks) override; | ||
61 | void Run(hipo::banklist& banks) const override; | ||
62 | void Stop() override; | ||
63 | |||
64 | /// @action_function{reload} prepare the event | ||
65 | /// @when_to_call{for each event} | ||
66 | /// @param runnum the run number | ||
67 | /// @param beam_energy the beam energy; if negative (the default), RCDB will be used to get the beam energy from `runnum` | ||
68 | /// @returns the key to be used in `::ComputeFromLepton` | ||
69 | concurrent_key_t PrepareEvent(int const runnum, double const beam_energy = -1) const; | ||
70 | |||
71 | /// @action_function{scalar creator} compute kinematics from the scattered lepton. | ||
72 | /// @param lepton_px scattered lepton momentum component @latex{p_x} (GeV) | ||
73 | /// @param lepton_py scattered lepton momentum component @latex{p_y} (GeV) | ||
74 | /// @param lepton_pz scattered lepton momentum component @latex{p_z} (GeV) | ||
75 | /// @param key the return value of `::PrepareEvent` | ||
76 | /// @returns the reconstructed inclusive kinematics in a `iguana::physics::InclusiveKinematicsVars` instance | ||
77 | InclusiveKinematicsVars ComputeFromLepton( | ||
78 | vector_element_t const lepton_px, | ||
79 | vector_element_t const lepton_py, | ||
80 | vector_element_t const lepton_pz, | ||
81 | concurrent_key_t const key) const; | ||
82 | |||
83 | private: | ||
84 | |||
85 | /// FIXME: this could be changed to a vector action function | ||
86 | /// Find the scattered lepton. Since finding the scattered lepton requires | ||
87 | /// reading all the particles of an event, there is no **Action function**; | ||
88 | /// therefore, callers that do not have access to `hipo::bank` objects are | ||
89 | /// responsible for finding the scattered lepton. | ||
90 | /// @param particle_bank the particle bank to search | ||
91 | /// @param key the return value of `::PrepareEvent` | ||
92 | /// @returns the bank row of the scattered lepton, or `-1` if not found | ||
93 | int FindScatteredLepton(hipo::bank const& particle_bank, concurrent_key_t const key) const; | ||
94 | |||
95 | void Reload(int const runnum, double const user_beam_energy, concurrent_key_t key) const; | ||
96 | |||
97 | // banklist indices | ||
98 | hipo::banklist::size_type b_particle; | ||
99 | hipo::banklist::size_type b_config; | ||
100 | hipo::banklist::size_type b_result; | ||
101 | |||
102 | // `b_result` bank item indices | ||
103 | int i_pindex; | ||
104 | int i_Q2; | ||
105 | int i_x; | ||
106 | int i_y; | ||
107 | int i_W; | ||
108 | int i_nu; | ||
109 | int i_qx; | ||
110 | int i_qy; | ||
111 | int i_qz; | ||
112 | int i_qE; | ||
113 | int i_beamPz; | ||
114 | int i_targetM; | ||
115 | |||
116 | // config options | ||
117 | mutable std::unique_ptr<ConcurrentParam<int>> o_runnum; | ||
118 | mutable std::unique_ptr<ConcurrentParam<std::vector<double>>> o_target_PxPyPzM; | ||
119 | mutable std::unique_ptr<ConcurrentParam<std::vector<double>>> o_beam_PxPyPzM; | ||
120 | double o_beam_mass; // unlikely to change | ||
121 | int o_beam_pdg; // unlikely to change | ||
122 | |||
123 | enum method_reconstruction { scattered_lepton }; | ||
124 | enum method_lepton_finder { highest_energy_FD_trigger }; | ||
125 | method_reconstruction o_method_reconstruction; | ||
126 | method_lepton_finder o_method_lepton_finder; | ||
127 | |||
128 | std::unique_ptr<RCDBReader> m_rcdb; | ||
129 | }; | ||
130 | |||
131 | } | ||
132 |