Iguana LATEST
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
Algorithm.h
1#pragma once
2
3// ProtonEnergyLossCorrection
4//
5// Apply momentum and angular corrections to reconstructed protons in CLAS12 RGA
6// data; runs event-by-event and modifies REC::Particle in place.
7// For each row in REC::Particle:
8// - If pid == 2212 (proton) AND status indicates FD or CD (should always),
9// compute p, theta, phi from (px,py,pz), apply period-dependent corrections,
10// then write back corrected (px,py,pz).
11//
12// Period dependence
13// -----------------
14// The coefficients used for the corrections depend on the run number.
15// The mapping from run -> (coefficients) is defined in Config.yaml.
16// Config.yaml provides one or more "periods" blocks, each with:
17// - run_ranges: list of [min,max] run-number ranges
18// - FD coefficients
19// - CD coefficients
20//
21
22#include "iguana/algorithms/Algorithm.h"
24
25#include <map>
26#include <string>
27#include <utility>
28#include <vector>
29
30namespace iguana::clas12::rga {
31
47
50
51 public:
61 int const pid,
62 int const status,
63 int const run,
64 vector_element_t const px,
65 vector_element_t const py,
66 vector_element_t const pz) const;
67
72 bool Run(hipo::bank& rec, hipo::bank const& run) const;
73
74 private:
75 void ConfigHook() override;
76 void StartHook(hipo::banklist& banks) override;
77 bool RunHook(hipo::banklist& banks) const override;
78 void StopHook() override;
79
80 hipo::banklist::size_type m_b_rec_particle{};
81 hipo::banklist::size_type m_b_run_config{};
82
83 struct Poly {
84 std::vector<double> c;
85 };
86
87 struct RegionCoeffs {
88 Poly A_p;
89 Poly B_p;
90 Poly C_p;
91
92 Poly A_theta;
93 Poly B_theta;
94 Poly C_theta;
95
96 Poly A_phi;
97 Poly B_phi;
98 Poly C_phi;
99 };
100
101 struct PeriodDef {
102 std::vector<std::pair<int, int>> run_ranges;
103 RegionCoeffs fd;
104 RegionCoeffs cd;
105 };
106
107 std::map<std::string, PeriodDef> m_periods{};
108
109 static bool IsFD(int status);
110 static bool IsCD(int status);
111
112 static double EvalPoly(Poly const& p, double x);
113
114 static double Pmag(double px, double py, double pz);
115 static double ThetaDeg(double px, double py, double pz);
116 static double PhiDeg(double px, double py);
117
118 static void SphericalToCartesian(double p, double theta_deg, double phi_deg,
119 double& px, double& py, double& pz);
120
121 PeriodDef const* FindPeriod(int run) const;
122 };
123
124}
#define DEFINE_IGUANA_ALGORITHM(ALGO_NAME, ALGO_FULL_NAME)
common objects used in algorithms
double vector_element_t
Vector element type.
Definition TypeDefs.h:12
Algorithm(std::string_view name)
Definition Algorithm.h:74
Algorithm: Apply period-dependent momentum/angle corrections to reconstructed protons in REC::Particl...
Definition Algorithm.h:48
Momentum3 Transform(int const pid, int const status, int const run, vector_element_t const px, vector_element_t const py, vector_element_t const pz) const
Action Function:
bool Run(hipo::bank &rec, hipo::bank const &run) const
Run Function: Process an event's hipo::bank objects
CLAS12 Run Group A algorithms.
Definition Algorithm.h:5
3-momentum type
Definition TypeDefs.h:15