Iguana LATEST
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
Validator.h
1#pragma once
2
3// ProtonEnergyLossCorrectionValidator
4//
5// For each processed event:
6// 1) Find all protons (pid==2212) in REC::Particle.
7// 2) Compute their theta before correction, place them into theta bins.
8// 3) Run the ProtonEnergyLossCorrection algorithm in place.
9// 4) Recompute momentum magnitude p after correction.
10// 5) Accumulate mean p_before and mean p_after per theta bin.
11//
12// Output
13// ------
14// In StopHook(), print a table:
15// theta bin range, N, <p_before>, <p_after>, <delta>
16//
17
18#include "iguana/algorithms/Validator.h"
19#include "iguana/algorithms/AlgorithmSequence.h"
20
21#include <array>
22#include <memory>
23#include <mutex>
24
25namespace iguana::clas12::rga {
26
30
31 private:
32 void StartHook(hipo::banklist& banks) override;
33 bool RunHook(hipo::banklist& banks) const override;
34 void StopHook() override;
35
36 private:
37 // Cached bank indices.
38 hipo::banklist::size_type m_b_particle{};
39 hipo::banklist::size_type m_b_config{};
40
41 std::unique_ptr<AlgorithmSequence> m_algo_seq;
42
43 // Theta binning configuration (degrees).
44 // Bins: [5,10), [10,15), ...
45 static constexpr double kThetaMinDeg = 5.0;
46 static constexpr double kThetaMaxDeg = 70.0;
47 static constexpr double kThetaStepDeg = 5.0;
48 static constexpr int kNBins = (int)((kThetaMaxDeg - kThetaMinDeg) / kThetaStepDeg);
49
50 // Simple per-bin accumulators.
51 struct BinAccum {
52 long long n = 0;
53 double sum_p_before = 0.0;
54 double sum_p_after = 0.0;
55 };
56
57 // accumulate over events -> these must be mutable.
58 mutable std::array<BinAccum, kNBins> m_bins{};
59 mutable long long m_total_protons_in_range = 0;
60 mutable long long m_total_protons_all = 0;
61
62 // Protect shared accumulation
63 mutable std::mutex m_mutex{};
64
65 private:
66 // Map theta (deg) to bin index.
67 static int ThetaBinIndex(double theta_deg);
68
69 // Compute theta (deg) from (px,py,pz).
70 static double ThetaDegFromPxPyPz(double px, double py, double pz);
71 };
72
73}
#define DEFINE_IGUANA_VALIDATOR(VDOR_NAME, VDOR_FULL_NAME)
Validator(std::string_view name="validator")
Definition Validator.h:27
iguana::rga::ProtonEnergyLossCorrection validator
Definition Validator.h:28
CLAS12 Run Group A algorithms.
Definition Algorithm.h:5