GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 6 / 0 / 6
Functions: 100.0% 3 / 0 / 3
Branches: 42.9% 6 / 0 / 14

src/iguana/algorithms/clas12/rga/FiducialFilterPass2/Algorithm.h
Line Branch Exec Source
1 #pragma once
2
3 #include "iguana/algorithms/Algorithm.h"
4
5 namespace iguana::clas12::rga {
6
7 /// @algo_brief{Filter the `REC::Particle` bank using subsystem-specific fiducial cuts}
8 /// @algo_type_filter
9 ///
10 /// RGA fiducial filter:
11 ///
12 /// - PCal-only edge cuts on lv & lw with strictness thresholds
13 /// - Forward Tagger annulus + low efficiency hole vetoes
14 /// - Central detector (CVT) fiducial:
15 /// - require edge > edge_min (default 0) and vetoes on gaps between CVT sectors
16 /// - Drift Chamber (DC) fiducial:
17 /// - three region edge thresholds with separate inbending/outbending track logic
18 ///
19 /// **References:**
20 ///
21 /// - https://clas12-docdb.jlab.org/DocDB/0012/001240/001/rga_fiducial_cuts.pdf
22 ///
23 /// **NOTE:** this algorithm has multiple `Run(hipo::bank bank1, ...)` functions, which
24 /// take `hipo::bank` parameters, and some parameters may be optional, since you may
25 /// be reading data which lack certain banks. If you use these functions, take a look at all them
26 /// to decide which one best suits your use case.
27 ///
28 /// @doc_config{clas12/rga/FiducialFilterPass2}
29 class FiducialFilterPass2 : public Algorithm
30 {
31
6/14
✓ Branch 2 → 3 taken 2 times.
✗ Branch 2 → 6 not taken.
✗ Branch 5 → 7 not taken.
✓ Branch 5 → 8 taken 2 times.
✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 32 not taken.
✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 17 not taken.
✓ Branch 17 → 18 taken 2 times.
✗ Branch 17 → 40 not taken.
✓ Branch 24 → 25 taken 2 times.
✗ Branch 24 → 40 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 39 not taken.
18 DEFINE_IGUANA_ALGORITHM(FiducialFilterPass2, clas12::rga::FiducialFilterPass2)
32
33 private: // hooks
34 void ConfigHook() override;
35 void StartHook(hipo::banklist& banks) override;
36 bool RunHook(hipo::banklist& banks) const override;
37
38 private:
39 2 struct FTParams {
40 float rmin = 0;
41 float rmax = 0;
42 std::vector<std::array<float, 3>> holes; // {R,cx,cy}
43 };
44 struct CVTParams {
45 std::vector<int> edge_layers; // e.g. {1,3,5,7,12}
46 double edge_min = 0.0; // > edge_min
47 std::vector<double> phi_forbidden_deg;
48 };
49 struct DCParams {
50 // thresholds (cm)
51 double theta_small_deg = 10.0; // tighter boundary for inbending
52 // inbending, theta < theta_small_deg
53 double in_small_e1 = 10.0, in_small_e2 = 10.0, in_small_e3 = 10.0;
54 // inbending, theta >= theta_small_deg
55 double in_large_e1 = 3.0, in_large_e2 = 3.0, in_large_e3 = 10.0;
56 // outbending (any theta)
57 double out_e1 = 3.0, out_e2 = 3.0, out_e3 = 10.0;
58 };
59
60 public:
61
62 /// @run_function
63 /// @param [in,out] particle `REC::Particle` bank, which will be filtered
64 /// @param [in] conf `RUN::config` bank
65 /// @param [in] cal pointer to `REC::Calorimeter` bank; it is a _pointer_ since it is _optional_ (use `nullptr` for "unused")
66 /// @param [in] traj pointer to `REC::Traj` bank; it is a _pointer_ since it is _optional_ (use `nullptr` for "unused")
67 /// @param [in] ft pointer to `REC::ForwardTagger` bank; it is a _pointer_ since it is _optional_ (use `nullptr` for "unused")
68 /// @returns `false` if all particles are filtered out
69 bool Run(
70 hipo::bank& particle,
71 hipo::bank const& conf,
72 hipo::bank const* cal,
73 hipo::bank const* traj,
74 hipo::bank const* ft) const;
75
76 /// @run_function
77 /// @param [in,out] particle `REC::Particle` bank, which will be filtered
78 /// @param [in] conf `RUN::config` bank
79 /// @param [in] cal `REC::Calorimeter` bank
80 /// @param [in] traj `REC::Traj` bank
81 /// @returns `false` if all particles are filtered out
82 bool Run(
83 hipo::bank& particle,
84 hipo::bank const& conf,
85 hipo::bank const& cal,
86 hipo::bank const& traj) const
87 {
88 return Run(particle, conf, &cal, &traj, nullptr);
89 }
90
91 /// @run_function
92 /// @param [in,out] particle `REC::Particle` bank, which will be filtered
93 /// @param [in] conf `RUN::config` bank
94 /// @param [in] cal `REC::Calorimeter` bank
95 /// @param [in] traj `REC::Traj` bank
96 /// @param [in] ft `REC::ForwardTagger` bank
97 /// @returns `false` if all particles are filtered out
98 bool Run(
99 hipo::bank& particle,
100 hipo::bank const& conf,
101 hipo::bank const& cal,
102 hipo::bank const& traj,
103 hipo::bank const& ft) const
104 {
105 return Run(particle, conf, &cal, &traj, &ft);
106 }
107
108 /// @returns calorimeter strictness
109 int CalStrictness() const { return m_cal_strictness; }
110 /// @returns FT configuration parameters
111 FTParams const& FT() const { return u_ft_params; }
112 /// @returns CVT configuration parameters
113 CVTParams const& CVT() const { return m_cvt; }
114 /// @returns DC configuration parameters
115 DCParams const& DC() const { return m_dc; }
116
117 private:
118 // bank indices and presence flags
119 hipo::banklist::size_type b_particle{};
120 hipo::banklist::size_type b_config{};
121 hipo::banklist::size_type b_calor{};
122 hipo::banklist::size_type b_ft{};
123 hipo::banklist::size_type b_traj{};
124 bool m_have_calor = false;
125 bool m_have_ft = false;
126 bool m_have_traj = false;
127
128 // FT params (loaded from YAML)
129 FTParams u_ft_params{};
130
131 // core filter functions
132 struct CalHit {
133 int sector = 0;
134 float lv = 0, lw = 0, lu = 0;
135 };
136 1662 struct CalLayers {
137 std::vector<CalHit> L1;
138 bool has_any = false;
139 };
140
141 static CalLayers CollectCalHitsForTrack(hipo::bank const& cal, int pindex);
142 static bool PassCalStrictness(CalLayers const& h, int strictness);
143 bool PassFTFiducial(int track_index, hipo::bank const* ftBank) const;
144 bool PassCVTFiducial(int track_index, hipo::bank const* trajBank) const;
145 bool PassDCFiducial(int track_index, hipo::bank const& particleBank,
146 hipo::bank const& configBank, hipo::bank const* trajBank) const;
147 bool Filter(int track_index, hipo::bank const& particleBank, hipo::bank const& configBank,
148 hipo::bank const* calBank, hipo::bank const* trajBank, hipo::bank const* ftBank) const;
149
150 // CVT/DC params;
151 int m_cal_strictness = 1;
152 CVTParams m_cvt{};
153 DCParams m_dc{};
154 };
155
156 }
157