Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Algorithm.h" | ||
2 | #include "Pass1CutData.h" | ||
3 | |||
4 | namespace iguana::clas12 { | ||
5 | |||
6 | REGISTER_IGUANA_ALGORITHM(FiducialFilter); | ||
7 | |||
8 | 2 | void FiducialFilter::Start(hipo::banklist& banks) | |
9 | { | ||
10 | 2 | ParseYAMLConfig(); | |
11 |
3/6✓ Branch 0 (4→5) taken 2 times.
✗ Branch 1 (4→100) not taken.
✓ Branch 2 (5→6) taken 2 times.
✗ Branch 3 (5→94) not taken.
✓ Branch 4 (6→7) taken 2 times.
✗ Branch 5 (6→9) not taken.
|
4 | o_pass = GetOptionScalar<int>("pass"); |
12 |
1/2✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→15) taken 2 times.
|
2 | if(o_pass!=1){ |
13 | ✗ | m_log->Warn("FiducialFilter only contains fiducial cuts for pass1...we will default to using those..."); | |
14 | ✗ | o_pass = 1; | |
15 | } | ||
16 |
4/8✓ Branch 0 (16→17) taken 2 times.
✗ Branch 1 (16→114) not taken.
✓ Branch 2 (17→18) taken 2 times.
✗ Branch 3 (17→108) not taken.
✓ Branch 4 (18→19) taken 2 times.
✗ Branch 5 (18→102) not taken.
✓ Branch 6 (19→20) taken 2 times.
✗ Branch 7 (19→22) not taken.
|
4 | o_pcal_electron_cut_level = ParseCutLevel(GetOptionScalar<std::string>("pcal_electron_cut_level")); |
17 |
4/8✓ Branch 0 (31→32) taken 2 times.
✗ Branch 1 (31→128) not taken.
✓ Branch 2 (32→33) taken 2 times.
✗ Branch 3 (32→122) not taken.
✓ Branch 4 (33→34) taken 2 times.
✗ Branch 5 (33→116) not taken.
✓ Branch 6 (34→35) taken 2 times.
✗ Branch 7 (34→37) not taken.
|
4 | o_pcal_photon_cut_level = ParseCutLevel(GetOptionScalar<std::string>("pcal_photon_cut_level")); |
18 |
3/6✓ Branch 0 (46→47) taken 2 times.
✗ Branch 1 (46→136) not taken.
✓ Branch 2 (47→48) taken 2 times.
✗ Branch 3 (47→130) not taken.
✗ Branch 4 (48→49) not taken.
✓ Branch 5 (48→51) taken 2 times.
|
4 | o_enable_pcal_cuts = GetOptionScalar<int>("enable_pcal_cuts") == 1; |
19 |
3/6✓ Branch 0 (55→56) taken 2 times.
✗ Branch 1 (55→144) not taken.
✓ Branch 2 (56→57) taken 2 times.
✗ Branch 3 (56→138) not taken.
✓ Branch 4 (57→58) taken 2 times.
✗ Branch 5 (57→60) not taken.
|
4 | o_enable_dc_cuts = GetOptionScalar<int>("enable_dc_cuts") == 1; |
20 | |||
21 |
2/4✓ Branch 0 (64→65) taken 2 times.
✗ Branch 1 (64→146) not taken.
✓ Branch 2 (65→66) taken 2 times.
✗ Branch 3 (65→68) not taken.
|
2 | b_particle = GetBankIndex(banks, "REC::Particle"); |
22 |
2/4✓ Branch 0 (71→72) taken 2 times.
✗ Branch 1 (71→152) not taken.
✓ Branch 2 (72→73) taken 2 times.
✗ Branch 3 (72→75) not taken.
|
2 | b_config = GetBankIndex(banks, "RUN::config"); |
23 |
1/2✓ Branch 0 (77→78) taken 2 times.
✗ Branch 1 (77→93) not taken.
|
2 | if(o_pass == 1) { |
24 |
2/4✓ Branch 0 (79→80) taken 2 times.
✗ Branch 1 (79→158) not taken.
✗ Branch 2 (80→81) not taken.
✓ Branch 3 (80→83) taken 2 times.
|
2 | b_traj = GetBankIndex(banks, "REC::Particle::Traj"); |
25 |
2/4✓ Branch 0 (86→87) taken 2 times.
✗ Branch 1 (86→164) not taken.
✗ Branch 2 (87→88) not taken.
✓ Branch 3 (87→90) taken 2 times.
|
4 | b_cal = GetBankIndex(banks, "REC::Particle::Calorimeter"); |
26 | } | ||
27 | 2 | } | |
28 | |||
29 | ////////////////////////////////////////////////////////////////////////////////// | ||
30 | |||
31 | 2000 | void FiducialFilter::Run(hipo::banklist& banks) const { | |
32 | |||
33 |
1/2✓ Branch 0 (3→4) taken 2000 times.
✗ Branch 1 (3→63) not taken.
|
2000 | auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); |
34 |
1/2✓ Branch 0 (10→11) taken 2000 times.
✗ Branch 1 (10→69) not taken.
|
2000 | auto& configBank = GetBank(banks, b_config, "RUN::config"); |
35 | 2000 | auto torus = configBank.getFloat("torus", 0); | |
36 | |||
37 |
1/2✓ Branch 0 (20→21) taken 2000 times.
✗ Branch 1 (20→75) not taken.
|
4000 | ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); |
38 | |||
39 |
1/2✓ Branch 0 (26→27) taken 2000 times.
✗ Branch 1 (26→53) not taken.
|
2000 | if(o_pass == 1) { |
40 |
1/2✓ Branch 0 (28→29) taken 2000 times.
✗ Branch 1 (28→81) not taken.
|
2000 | auto& trajBank = GetBank(banks, b_traj, "REC::Particle::Traj"); |
41 |
2/4✓ Branch 0 (35→36) taken 2000 times.
✗ Branch 1 (35→87) not taken.
✓ Branch 2 (41→42) taken 2000 times.
✗ Branch 3 (41→43) not taken.
|
4000 | auto& calBank = GetBank(banks, b_cal, "REC::Particle::Calorimeter"); |
42 |
2/4✓ Branch 0 (41→42) taken 2000 times.
✗ Branch 1 (41→43) not taken.
✗ Branch 2 (42→43) not taken.
✓ Branch 3 (42→46) taken 2000 times.
|
2000 | if(auto num_rows{particleBank.getRows()}; num_rows != trajBank.getRows() || num_rows != calBank.getRows()) { |
43 | ✗ | m_log->Error("number of particle bank rows differs from 'REC::Particle::Traj' and/or 'REC::Particle::Calorimeter' rows; are you sure these input banks are being filled?"); | |
44 | ✗ | throw std::runtime_error("cannot proceed"); | |
45 | } | ||
46 |
1/2✓ Branch 0 (48→50) taken 2000 times.
✗ Branch 1 (48→95) not taken.
|
4000 | particleBank.getMutableRowList().filter([this, torus, &trajBank, &calBank](hipo::bank& bank, int row) { |
47 | 9491 | auto pid = bank.getInt("pid", row); | |
48 |
3/6✓ Branch 0 (3→4) taken 9491 times.
✗ Branch 1 (3→25) not taken.
✓ Branch 2 (4→5) taken 9491 times.
✗ Branch 3 (4→25) not taken.
✓ Branch 4 (5→6) taken 9491 times.
✗ Branch 5 (5→25) not taken.
|
9491 | if(row >= 0 && row < calBank.getRows() && row < trajBank.getRows()) { |
49 | // call the action function | ||
50 | 37964 | return FilterRgaPass1( | |
51 | calBank.getInt("pcal_sector", row), | ||
52 | calBank.getFloat("pcal_lv", row), | ||
53 | calBank.getFloat("pcal_lw", row), | ||
54 | 9491 | calBank.getByte("pcal_found", row) == 1, | |
55 | trajBank.getInt("sector", row), | ||
56 | trajBank.getFloat("r1_x", row), | ||
57 | trajBank.getFloat("r1_y", row), | ||
58 | trajBank.getFloat("r1_z", row), | ||
59 | 9491 | trajBank.getByte("r1_found", row) == 1, | |
60 | trajBank.getFloat("r2_x", row), | ||
61 | trajBank.getFloat("r2_y", row), | ||
62 | trajBank.getFloat("r2_z", row), | ||
63 | 9491 | trajBank.getByte("r2_found", row) == 1, | |
64 | trajBank.getFloat("r3_x", row), | ||
65 | trajBank.getFloat("r3_y", row), | ||
66 | trajBank.getFloat("r3_z", row), | ||
67 | 9491 | trajBank.getByte("r3_found", row) == 1, | |
68 | torus, | ||
69 | 9491 | pid); | |
70 | } | ||
71 | else | ||
72 | ✗ | throw std::runtime_error(fmt::format("FiducialFilter filter encountered bad row number {}", row)); | |
73 | }); | ||
74 | } | ||
75 | |||
76 |
1/2✓ Branch 0 (56→57) taken 2000 times.
✗ Branch 1 (56→98) not taken.
|
4000 | ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); |
77 | 2000 | } | |
78 | |||
79 | ////////////////////////////////////////////////////////////////////////////////// | ||
80 | |||
81 | 2 | void FiducialFilter::Stop() | |
82 | { | ||
83 | 2 | } | |
84 | |||
85 | ////////////////////////////////////////////////////////////////////////////////// | ||
86 | |||
87 | 4 | FiducialFilter::CutLevel FiducialFilter::ParseCutLevel(std::string const& level) const | |
88 | { | ||
89 |
2/2✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→23) taken 2 times.
|
4 | if(level == "loose") |
90 | return loose; | ||
91 |
1/2✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→23) taken 2 times.
|
2 | else if(level == "medium") |
92 | return medium; | ||
93 | ✗ | else if(level == "tight") | |
94 | return tight; | ||
95 | else | ||
96 | ✗ | throw std::runtime_error(std::string("unknown PCAL cut level ") + level); | |
97 | } | ||
98 | |||
99 | ////////////////////////////////////////////////////////////////////////////////// | ||
100 | ////////////////////////////////////////////////////////////////////////////////// | ||
101 | ////////////////////////////////////////////////////////////////////////////////// | ||
102 | |||
103 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→6) taken 9491 times.
|
9491 | bool FiducialFilter::FilterRgaPass1( |
104 | int const pcal_sector, | ||
105 | float const pcal_lv, | ||
106 | float const pcal_lw, | ||
107 | bool const pcal_found, | ||
108 | int const dc_sector, | ||
109 | float const dc_r1_x, | ||
110 | float const dc_r1_y, | ||
111 | float const dc_r1_z, | ||
112 | bool const dc_r1_found, | ||
113 | float const dc_r2_x, | ||
114 | float const dc_r2_y, | ||
115 | float const dc_r2_z, | ||
116 | bool const dc_r2_found, | ||
117 | float const dc_r3_x, | ||
118 | float const dc_r3_y, | ||
119 | float const dc_r3_z, | ||
120 | bool const dc_r3_found, | ||
121 | float const torus, | ||
122 | int const pid) const | ||
123 | { | ||
124 | |||
125 | // reject if torus is not +/-1 | ||
126 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→6) taken 9491 times.
|
9491 | if(std::abs(torus)!=1) { |
127 | ✗ | m_log->Warn("torus={}...value must be either -1 or 1, otherwise fiducial cuts are not defined...filtering out all particles...",torus); | |
128 | ✗ | return false; | |
129 | } | ||
130 | // apply cuts | ||
131 | bool result = true; | ||
132 |
2/2✓ Branch 0 (6→7) taken 6217 times.
✓ Branch 1 (6→8) taken 3274 times.
|
9491 | bool dc_found = dc_r1_found && dc_r2_found && dc_r3_found; |
133 |
4/4✓ Branch 0 (8→9) taken 3394 times.
✓ Branch 1 (8→10) taken 1319 times.
✓ Branch 2 (8→22) taken 1865 times.
✓ Branch 3 (8→40) taken 2913 times.
|
9491 | switch(pid) { |
134 | 1319 | case 11: // electrons | |
135 | case -11: // positrons | ||
136 | { | ||
137 |
1/2✗ Branch 0 (10→11) not taken.
✓ Branch 1 (10→12) taken 1319 times.
|
1319 | if(o_enable_pcal_cuts) |
138 |
4/4✓ Branch 0 (12→13) taken 261 times.
✓ Branch 1 (12→15) taken 1058 times.
✓ Branch 2 (14→11) taken 219 times.
✓ Branch 3 (14→15) taken 42 times.
|
1319 | result &= pcal_found && FilterPcalHomogeneous(pcal_sector, pcal_lv, pcal_lw, torus, pid); |
139 |
1/2✓ Branch 0 (16→17) taken 1319 times.
✗ Branch 1 (16→40) not taken.
|
1319 | if(o_enable_dc_cuts) |
140 |
4/4✓ Branch 0 (17→18) taken 261 times.
✓ Branch 1 (17→20) taken 1058 times.
✓ Branch 2 (19→20) taken 33 times.
✓ Branch 3 (19→21) taken 228 times.
|
1319 | result &= dc_found && FilterDcXY(dc_sector, dc_r1_x, dc_r1_y, dc_r1_z, dc_r2_x, dc_r2_y, dc_r2_z, dc_r3_x, dc_r3_y, dc_r3_z, torus, pid); |
141 | break; | ||
142 | } | ||
143 | 1865 | case 22: // photons | |
144 | { | ||
145 |
1/2✗ Branch 0 (22→9) not taken.
✓ Branch 1 (22→23) taken 1865 times.
|
1865 | if(o_enable_pcal_cuts) |
146 |
4/4✓ Branch 0 (23→24) taken 1543 times.
✓ Branch 1 (23→26) taken 322 times.
✓ Branch 2 (25→9) taken 1388 times.
✓ Branch 3 (25→26) taken 155 times.
|
1865 | result &= pcal_found && FilterPcalHomogeneous(pcal_sector, pcal_lv, pcal_lw, torus, pid); |
147 | } | ||
148 | case 211: // pi+ | ||
149 | case -211: // pi- | ||
150 | case 2212: // protons | ||
151 | { | ||
152 |
1/2✓ Branch 0 (27→28) taken 5259 times.
✗ Branch 1 (27→40) not taken.
|
5259 | if(o_enable_dc_cuts) { |
153 |
1/2✓ Branch 0 (28→29) taken 5259 times.
✗ Branch 1 (28→34) not taken.
|
5259 | if(torus<0) // inbending |
154 |
4/4✓ Branch 0 (29→30) taken 2696 times.
✓ Branch 1 (29→32) taken 2563 times.
✓ Branch 2 (31→32) taken 40 times.
✓ Branch 3 (31→33) taken 2656 times.
|
5259 | result &= dc_found && FilterDcThetaPhi(dc_sector, dc_r1_x, dc_r1_y, dc_r1_z, dc_r2_x, dc_r2_y, dc_r2_z, dc_r3_x, dc_r3_y, dc_r3_z, torus, pid); |
155 | ✗ | else if(torus>0) // outbending | |
156 | ✗ | result &= dc_found && FilterDcXY(dc_sector, dc_r1_x, dc_r1_y, dc_r1_z, dc_r2_x, dc_r2_y, dc_r2_z, dc_r3_x, dc_r3_y, dc_r3_z, torus, pid); | |
157 | else | ||
158 | result = false; | ||
159 | } | ||
160 | break; | ||
161 | } | ||
162 | default: | ||
163 | result = true; // cut not applied, do not filter | ||
164 | } | ||
165 | return result; | ||
166 | } | ||
167 | |||
168 | ////////////////////////////////////////////////////////////////////////////////// | ||
169 | ////////////////////////////////////////////////////////////////////////////////// | ||
170 | ////////////////////////////////////////////////////////////////////////////////// | ||
171 | |||
172 | 1804 | bool FiducialFilter::FilterPcalHomogeneous( | |
173 | int const pcal_sector, | ||
174 | float const lv, | ||
175 | float const lw, | ||
176 | float const torus, | ||
177 | int const pid) const | ||
178 | { | ||
179 |
1/2✓ Branch 0 (2→3) taken 1804 times.
✗ Branch 1 (2→28) not taken.
|
1804 | if(!o_enable_pcal_cuts) |
180 | return true; | ||
181 | // set cut level from PDG | ||
182 | CutLevel cut_level; | ||
183 |
2/3✓ Branch 0 (3→4) taken 261 times.
✓ Branch 1 (3→5) taken 1543 times.
✗ Branch 2 (3→6) not taken.
|
1804 | switch(pid) { |
184 | 261 | case 11: | |
185 | case -11: | ||
186 | 261 | cut_level = o_pcal_electron_cut_level; | |
187 | 261 | break; | |
188 | 1543 | case 22: | |
189 | 1543 | cut_level = o_pcal_photon_cut_level; | |
190 | 1543 | break; | |
191 | ✗ | default: | |
192 | ✗ | m_log->Error("called FilterPcalHomogeneous with unknown PDG {}", pid); | |
193 | ✗ | return false; | |
194 | } | ||
195 | // NOTE: lv + lw is going from the side to the back end of the PCAL, lu is going from side to side | ||
196 | // 1 scintillator bar is 4.5 cm wide. In the outer regions (back) double bars are used. | ||
197 | // A cut is only applied on lv and lw | ||
198 | double min_v = 0; | ||
199 | double max_v = 0; | ||
200 | double min_w = 0; | ||
201 | double max_w = 0; | ||
202 |
2/2✓ Branch 0 (23→10) taken 10824 times.
✓ Branch 1 (23→24) taken 1804 times.
|
12628 | for(int k = 0; k < 6; k++){ |
203 |
3/4✓ Branch 0 (10→11) taken 1804 times.
✓ Branch 1 (10→16) taken 9020 times.
✓ Branch 2 (11→12) taken 1804 times.
✗ Branch 3 (11→16) not taken.
|
10824 | if(pcal_sector-1 == k && torus < 0){ // inbending |
204 |
2/4✗ Branch 0 (12→13) not taken.
✓ Branch 1 (12→14) taken 1543 times.
✓ Branch 2 (12→15) taken 261 times.
✗ Branch 3 (12→22) not taken.
|
1804 | switch(cut_level) { |
205 | ✗ | case tight: | |
206 | ✗ | min_v = fiducial_pass1::min_lv_tight_inb[k]; | |
207 | ✗ | max_v = fiducial_pass1::max_lv_tight_inb[k]; | |
208 | ✗ | min_w = fiducial_pass1::min_lw_tight_inb[k]; | |
209 | ✗ | max_w = fiducial_pass1::max_lw_tight_inb[k]; | |
210 | ✗ | break; | |
211 | 1543 | case medium: | |
212 | 1543 | min_v = fiducial_pass1::min_lv_med_inb[k]; | |
213 | 1543 | max_v = fiducial_pass1::max_lv_med_inb[k]; | |
214 | 1543 | min_w = fiducial_pass1::min_lw_med_inb[k]; | |
215 | 1543 | max_w = fiducial_pass1::max_lw_med_inb[k]; | |
216 | 1543 | break; | |
217 | 261 | case loose: | |
218 | 261 | min_v = fiducial_pass1::min_lv_loose_inb[k]; | |
219 | 261 | max_v = fiducial_pass1::max_lv_loose_inb[k]; | |
220 | 261 | min_w = fiducial_pass1::min_lw_loose_inb[k]; | |
221 | 261 | max_w = fiducial_pass1::max_lw_loose_inb[k]; | |
222 | 261 | break; | |
223 | } | ||
224 | } | ||
225 |
1/4✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→22) taken 9020 times.
✗ Branch 2 (17→18) not taken.
✗ Branch 3 (17→22) not taken.
|
9020 | else if(pcal_sector-1 == k && torus > 0){ // outbending |
226 | ✗ | switch(cut_level) { | |
227 | ✗ | case tight: | |
228 | ✗ | min_v = fiducial_pass1::min_lv_tight_out[k]; | |
229 | ✗ | max_v = fiducial_pass1::max_lv_tight_out[k]; | |
230 | ✗ | min_w = fiducial_pass1::min_lw_tight_out[k]; | |
231 | ✗ | max_w = fiducial_pass1::max_lw_tight_out[k]; | |
232 | ✗ | break; | |
233 | ✗ | case medium: | |
234 | ✗ | min_v = fiducial_pass1::min_lv_med_out[k]; | |
235 | ✗ | max_v = fiducial_pass1::max_lv_med_out[k]; | |
236 | ✗ | min_w = fiducial_pass1::min_lw_med_out[k]; | |
237 | ✗ | max_w = fiducial_pass1::max_lw_med_out[k]; | |
238 | ✗ | break; | |
239 | ✗ | case loose: | |
240 | ✗ | min_v = fiducial_pass1::min_lv_loose_out[k]; | |
241 | ✗ | max_v = fiducial_pass1::max_lv_loose_out[k]; | |
242 | ✗ | min_w = fiducial_pass1::min_lw_loose_out[k]; | |
243 | ✗ | max_w = fiducial_pass1::max_lw_loose_out[k]; | |
244 | ✗ | break; | |
245 | } | ||
246 | } | ||
247 | } | ||
248 |
7/8✓ Branch 0 (24→8) taken 75 times.
✓ Branch 1 (24→25) taken 1729 times.
✓ Branch 2 (25→8) taken 2 times.
✓ Branch 3 (25→26) taken 1727 times.
✓ Branch 4 (26→8) taken 120 times.
✓ Branch 5 (26→27) taken 1607 times.
✗ Branch 6 (27→8) not taken.
✓ Branch 7 (27→28) taken 1607 times.
|
1804 | return lv > min_v && lv < max_v && lw > min_w && lw < max_w; |
249 | } | ||
250 | |||
251 | ////////////////////////////////////////////////////////////////////////////////// | ||
252 | |||
253 | 261 | bool FiducialFilter::FilterDcXY( | |
254 | int const dc_sector, | ||
255 | float const r1_x, | ||
256 | float const r1_y, | ||
257 | float const r1_z, | ||
258 | float const r2_x, | ||
259 | float const r2_y, | ||
260 | float const r2_z, | ||
261 | float const r3_x, | ||
262 | float const r3_y, | ||
263 | float const r3_z, | ||
264 | float const torus, | ||
265 | int const pid) const | ||
266 | { | ||
267 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 261 times.
|
261 | if(!o_enable_dc_cuts) |
268 | return true; | ||
269 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 261 times.
|
261 | if(!(dc_sector >= 1 && dc_sector <= 6)) |
270 | return false; | ||
271 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 261 times.
|
261 | const auto& minparams = ((torus<0) ? fiducial_pass1::minparams_in_XY_pass1 : fiducial_pass1::minparams_out_XY_pass1); |
272 | const auto& maxparams = ((torus<0) ? fiducial_pass1::maxparams_in_XY_pass1 : fiducial_pass1::maxparams_out_XY_pass1); | ||
273 | double X=0; | ||
274 | double Y=0; | ||
275 |
2/2✓ Branch 0 (34→3) taken 228 times.
✓ Branch 1 (34→9) taken 727 times.
|
955 | for(int region = 0 ; region < 3; region++){ |
276 | X=0; | ||
277 | Y=0; | ||
278 |
3/3✓ Branch 0 (9→10) taken 261 times.
✓ Branch 1 (9→11) taken 234 times.
✓ Branch 2 (9→12) taken 232 times.
|
727 | switch(region){ |
279 | 261 | case 0: | |
280 | 261 | X = r1_x; | |
281 | 261 | Y = r1_y; | |
282 | 261 | break; | |
283 | 234 | case 1: | |
284 | 234 | X = r2_x; | |
285 | 234 | Y = r2_y; | |
286 | 234 | break; | |
287 | 232 | case 2: | |
288 | 232 | X = r3_x; | |
289 | 232 | Y = r3_y; | |
290 | 232 | break; | |
291 | } | ||
292 |
2/2✓ Branch 0 (13→14) taken 165 times.
✓ Branch 1 (13→15) taken 562 times.
|
727 | if(dc_sector == 2) |
293 | { | ||
294 | 165 | const double X_new = X * std::cos(-60 * M_PI / 180) - Y * std::sin(-60 * M_PI / 180); | |
295 | 165 | Y = X * std::sin(-60 * M_PI / 180) + Y * std::cos(-60 * M_PI / 180); | |
296 | X = X_new; | ||
297 | } | ||
298 |
2/2✓ Branch 0 (15→16) taken 141 times.
✓ Branch 1 (15→17) taken 586 times.
|
727 | if(dc_sector == 3) |
299 | { | ||
300 | 141 | const double X_new = X * std::cos(-120 * M_PI / 180) - Y * std::sin(-120 * M_PI / 180); | |
301 | 141 | Y = X * std::sin(-120 * M_PI / 180) + Y * std::cos(-120 * M_PI / 180); | |
302 | X = X_new; | ||
303 | } | ||
304 |
2/2✓ Branch 0 (17→18) taken 66 times.
✓ Branch 1 (17→19) taken 661 times.
|
727 | if(dc_sector == 4) |
305 | { | ||
306 | 66 | const double X_new = X * std::cos(-180 * M_PI / 180) - Y * std::sin(-180 * M_PI / 180); | |
307 | 66 | Y = X * std::sin(-180 * M_PI / 180) + Y * std::cos(-180 * M_PI / 180); | |
308 | X = X_new; | ||
309 | } | ||
310 |
2/2✓ Branch 0 (19→20) taken 106 times.
✓ Branch 1 (19→21) taken 621 times.
|
727 | if(dc_sector == 5) |
311 | { | ||
312 | 106 | const double X_new = X * std::cos(120 * M_PI / 180) - Y * std::sin(120 * M_PI / 180); | |
313 | 106 | Y = X * std::sin(120 * M_PI / 180) + Y * std::cos(120 * M_PI / 180); | |
314 | X = X_new; | ||
315 | } | ||
316 |
2/2✓ Branch 0 (21→22) taken 107 times.
✓ Branch 1 (21→23) taken 620 times.
|
727 | if(dc_sector == 6) |
317 | { | ||
318 | 107 | const double X_new = X * std::cos(60 * M_PI / 180) - Y * std::sin(60 * M_PI / 180); | |
319 | 107 | Y = X * std::sin(60 * M_PI / 180) + Y * std::cos(60 * M_PI / 180); | |
320 | X = X_new; | ||
321 | } | ||
322 | int this_pid = 0; | ||
323 |
2/7✓ Branch 0 (23→5) taken 17 times.
✗ Branch 1 (23→24) not taken.
✗ Branch 2 (23→25) not taken.
✗ Branch 3 (23→26) not taken.
✗ Branch 4 (23→27) not taken.
✗ Branch 5 (23→28) not taken.
✓ Branch 6 (23→29) taken 710 times.
|
727 | switch (pid) |
324 | { | ||
325 | case 11: | ||
326 | this_pid = 0; | ||
327 | break; | ||
328 | ✗ | case 2212: | |
329 | this_pid = 1; | ||
330 | ✗ | break; | |
331 | ✗ | case 211: | |
332 | this_pid = 2; | ||
333 | ✗ | break; | |
334 | ✗ | case -211: | |
335 | this_pid = 3; | ||
336 | ✗ | break; | |
337 | ✗ | case 321: | |
338 | this_pid = 4; | ||
339 | ✗ | break; | |
340 | ✗ | case -321: | |
341 | this_pid = 5; | ||
342 | ✗ | break; | |
343 | default: | ||
344 | return false; | ||
345 | break; | ||
346 | } | ||
347 | 710 | double calc_min = minparams[this_pid][dc_sector - 1][region][0] + minparams[this_pid][dc_sector - 1][region][1] * X; | |
348 | 710 | double calc_max = maxparams[this_pid][dc_sector - 1][region][0] + maxparams[this_pid][dc_sector - 1][region][1] * X; | |
349 |
2/4✗ Branch 0 (29→5) not taken.
✓ Branch 1 (29→30) taken 710 times.
✗ Branch 2 (30→5) not taken.
✓ Branch 3 (30→31) taken 710 times.
|
710 | if(std::isnan(calc_min)||std::isnan(calc_max)) return false; |
350 |
4/4✓ Branch 0 (31→5) taken 8 times.
✓ Branch 1 (31→32) taken 702 times.
✓ Branch 2 (32→5) taken 8 times.
✓ Branch 3 (32→33) taken 694 times.
|
710 | if((Y<calc_min) || (Y>calc_max)) { return false;} |
351 | } | ||
352 | return true; | ||
353 | } | ||
354 | |||
355 | ////////////////////////////////////////////////////////////////////////////////// | ||
356 | |||
357 | 2696 | bool FiducialFilter::FilterDcThetaPhi( | |
358 | int const dc_sector, | ||
359 | float const r1_x, | ||
360 | float const r1_y, | ||
361 | float const r1_z, | ||
362 | float const r2_x, | ||
363 | float const r2_y, | ||
364 | float const r2_z, | ||
365 | float const r3_x, | ||
366 | float const r3_y, | ||
367 | float const r3_z, | ||
368 | float const torus, | ||
369 | int const pid) const | ||
370 | { | ||
371 |
1/2✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 2696 times.
|
2696 | if(!o_enable_dc_cuts) |
372 | return true; | ||
373 |
1/2✗ Branch 0 (4→5) not taken.
✓ Branch 1 (4→6) taken 2696 times.
|
2696 | if(!(dc_sector >= 1 && dc_sector <= 6)) |
374 | return false; | ||
375 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 2696 times.
|
2696 | const auto& minparams = ((torus<0) ? fiducial_pass1::minparams_in_theta_phi_pass1 : fiducial_pass1::minparams_out_theta_phi_pass1); |
376 | const auto& maxparams = ((torus<0) ? fiducial_pass1::maxparams_in_theta_phi_pass1 : fiducial_pass1::maxparams_out_theta_phi_pass1); | ||
377 | double theta_DCr = 5000; | ||
378 | double phi_DCr_raw = 5000; | ||
379 | double x=0; | ||
380 | double y=0; | ||
381 | double z=0; | ||
382 |
2/2✓ Branch 0 (38→3) taken 2656 times.
✓ Branch 1 (38→9) taken 8012 times.
|
10668 | for(int region = 0; region<3; region++){ |
383 | x=0;y=0;z=0; | ||
384 |
3/3✓ Branch 0 (9→10) taken 2696 times.
✓ Branch 1 (9→11) taken 2658 times.
✓ Branch 2 (9→12) taken 2658 times.
|
8012 | switch(region){ |
385 | 2696 | case 0: | |
386 | 2696 | x=r1_x; | |
387 | 2696 | y=r1_y; | |
388 | 2696 | z=r1_z; | |
389 | 2696 | break; | |
390 | 2658 | case 1: | |
391 | 2658 | x=r2_x; | |
392 | 2658 | y=r2_y; | |
393 | 2658 | z=r2_z; | |
394 | 2658 | break; | |
395 | 2658 | case 2: | |
396 | 2658 | x=r3_x; | |
397 | 2658 | y=r3_y; | |
398 | 2658 | z=r3_z; | |
399 | 2658 | break; | |
400 | } | ||
401 | 8012 | theta_DCr = 180 / M_PI * acos(z / sqrt(pow(x,2) + pow(y,2) + pow(z,2))); | |
402 | 8012 | phi_DCr_raw = 180 / M_PI * atan2(y / sqrt(pow(x,2) + pow(y,2) + pow(z,2)), | |
403 | 8012 | x /sqrt(pow(x,2) + pow(y,2) + pow(z,2))); | |
404 | double phi_DCr = 5000; | ||
405 |
2/2✓ Branch 0 (13→14) taken 6676 times.
✓ Branch 1 (13→16) taken 1336 times.
|
8012 | if (dc_sector == 1) phi_DCr = phi_DCr_raw; |
406 |
2/2✓ Branch 0 (14→15) taken 1284 times.
✓ Branch 1 (14→16) taken 5392 times.
|
6676 | if (dc_sector == 2) phi_DCr = phi_DCr_raw - 60; |
407 |
2/2✓ Branch 0 (16→17) taken 1444 times.
✓ Branch 1 (16→18) taken 5284 times.
|
6728 | if (dc_sector == 3) phi_DCr = phi_DCr_raw - 120; |
408 |
4/4✓ Branch 0 (18→19) taken 1244 times.
✓ Branch 1 (18→23) taken 5324 times.
✓ Branch 2 (19→20) taken 632 times.
✓ Branch 3 (19→21) taken 612 times.
|
6568 | if (dc_sector == 4 && phi_DCr_raw > 0) phi_DCr = phi_DCr_raw - 180; |
409 |
2/2✓ Branch 0 (21→22) taken 612 times.
✓ Branch 1 (21→23) taken 632 times.
|
1244 | if (dc_sector == 4 && phi_DCr_raw < 0) phi_DCr = phi_DCr_raw + 180; |
410 |
2/2✓ Branch 0 (23→24) taken 1362 times.
✓ Branch 1 (23→25) taken 6650 times.
|
8012 | if (dc_sector == 5) phi_DCr = phi_DCr_raw + 120; |
411 |
2/2✓ Branch 0 (25→26) taken 1342 times.
✓ Branch 1 (25→27) taken 5308 times.
|
6650 | if (dc_sector == 6) phi_DCr = phi_DCr_raw + 60; |
412 | int this_pid = 0; | ||
413 |
3/7✗ Branch 0 (27→5) not taken.
✓ Branch 1 (27→28) taken 902 times.
✓ Branch 2 (27→29) taken 5082 times.
✓ Branch 3 (27→30) taken 2028 times.
✗ Branch 4 (27→31) not taken.
✗ Branch 5 (27→32) not taken.
✗ Branch 6 (27→33) not taken.
|
8012 | switch (pid) |
414 | { | ||
415 | case 11: this_pid = 0; break; | ||
416 | 902 | case 2212: this_pid = 1; break; | |
417 | 5082 | case 211: this_pid = 2; break; | |
418 | 2028 | case -211: this_pid = 3; break; | |
419 | ✗ | case 321: this_pid = 4; break; | |
420 | ✗ | case -321: this_pid = 5; break; | |
421 | default: return false; break; | ||
422 | } | ||
423 | 8012 | double calc_phi_min = minparams[this_pid][dc_sector - 1][region][0] + minparams[this_pid][dc_sector - 1][region][1] * std::log(theta_DCr) | |
424 | 8012 | + minparams[this_pid][dc_sector - 1][region][2] * theta_DCr + minparams[this_pid][dc_sector - 1][region][3] * theta_DCr * theta_DCr; | |
425 | 8012 | double calc_phi_max = maxparams[this_pid][dc_sector - 1][region][0] + maxparams[this_pid][dc_sector - 1][region][1] * std::log(theta_DCr) | |
426 | 8012 | + maxparams[this_pid][dc_sector - 1][region][2] * theta_DCr + maxparams[this_pid][dc_sector - 1][region][3] * theta_DCr * theta_DCr; | |
427 |
2/4✗ Branch 0 (33→5) not taken.
✓ Branch 1 (33→34) taken 8012 times.
✗ Branch 2 (34→5) not taken.
✓ Branch 3 (34→35) taken 8012 times.
|
8012 | if(std::isnan(calc_phi_min)||std::isnan(calc_phi_max)) return false; |
428 |
4/4✓ Branch 0 (35→5) taken 12 times.
✓ Branch 1 (35→36) taken 8000 times.
✓ Branch 2 (36→5) taken 28 times.
✓ Branch 3 (36→37) taken 7972 times.
|
8012 | if((phi_DCr < calc_phi_min) || (phi_DCr > calc_phi_max)) return false; |
429 | } | ||
430 | return true; | ||
431 | } | ||
432 | |||
433 | ////////////////////////////////////////////////////////////////////////////////// | ||
434 | |||
435 | } | ||
436 |