| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Algorithm.h" | ||
| 2 | #include "TypeDefs.h" | ||
| 3 | |||
| 4 | namespace iguana::clas12::rga { | ||
| 5 | |||
| 6 | REGISTER_IGUANA_ALGORITHM(FiducialFilterPass2); | ||
| 7 | |||
| 8 | 6 | static bool banklist_has(hipo::banklist& banks, char const* name) | |
| 9 | { | ||
| 10 |
2/2✓ Branch 13 → 3 taken 21 times.
✓ Branch 13 → 14 taken 4 times.
|
25 | for(auto& b : banks) |
| 11 |
4/4✓ Branch 6 → 7 taken 16 times.
✓ Branch 6 → 9 taken 5 times.
✓ Branch 11 → 12 taken 19 times.
✓ Branch 11 → 14 taken 2 times.
|
42 | if(b.getSchema().getName() == name) |
| 12 | return true; | ||
| 13 | return false; | ||
| 14 | } | ||
| 15 | |||
| 16 | 27972 | static bool traj_has_detector(hipo::bank const* trajBank, int pindex, int detector) | |
| 17 | { | ||
| 18 |
2/2✓ Branch 2 → 3 taken 13986 times.
✓ Branch 2 → 4 taken 13986 times.
|
27972 | if(!trajBank) |
| 19 | return false; | ||
| 20 | auto const& traj = *trajBank; | ||
| 21 | int const n = traj.getRows(); | ||
| 22 |
2/2✓ Branch 10 → 3 taken 11191 times.
✓ Branch 10 → 5 taken 548979 times.
|
560170 | for(int i = 0; i < n; ++i) { |
| 23 |
4/4✓ Branch 6 → 7 taken 53686 times.
✓ Branch 6 → 9 taken 495293 times.
✓ Branch 8 → 9 taken 50891 times.
✓ Branch 8 → 11 taken 2795 times.
|
548979 | if(traj.getInt("pindex", i) == pindex && traj.getInt("detector", i) == detector) { |
| 24 | return true; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | return false; | ||
| 28 | } | ||
| 29 | |||
| 30 | 2 | void FiducialFilterPass2::LoadConfig() | |
| 31 | { | ||
| 32 |
7/14✓ Branch 2 → 3 taken 2 times.
✗ Branch 2 → 203 not taken.
✓ Branch 4 → 5 taken 2 times.
✗ Branch 4 → 198 not taken.
✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 196 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 190 not taken.
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 10 taken 2 times.
✓ Branch 14 → 15 taken 4 times.
✓ Branch 14 → 17 taken 2 times.
✗ Branch 199 → 200 not taken.
✗ Branch 199 → 202 not taken.
|
10 | m_cal_strictness = GetOptionScalar<int>("calorimeter.strictness", {"calorimeter", "strictness"}); |
| 33 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 21 taken 2 times.
|
2 | if(m_cal_strictness < 1 || m_cal_strictness > 3) { |
| 34 | ✗ | throw std::runtime_error("[RGAFID] 'calorimeter.strictness' must be 1, 2, or 3"); | |
| 35 | } | ||
| 36 | |||
| 37 | { | ||
| 38 |
6/12✓ Branch 23 → 24 taken 2 times.
✗ Branch 23 → 218 not taken.
✓ Branch 24 → 25 taken 2 times.
✗ Branch 24 → 216 not taken.
✓ Branch 25 → 26 taken 2 times.
✗ Branch 25 → 210 not taken.
✓ Branch 33 → 34 taken 4 times.
✓ Branch 33 → 36 taken 2 times.
✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 2 times.
✗ Branch 219 → 220 not taken.
✗ Branch 219 → 222 not taken.
|
8 | auto radius = GetOptionVector<double>("forward_tagger.radius", {"forward_tagger", "radius"}); |
| 39 |
1/2✗ Branch 38 → 39 not taken.
✓ Branch 38 → 42 taken 2 times.
|
2 | if(radius.size() != 2) { |
| 40 | ✗ | throw std::runtime_error("[RGAFID] 'forward_tagger.radius' must be [rmin, rmax]"); | |
| 41 | } | ||
| 42 |
1/2✗ Branch 44 → 45 not taken.
✓ Branch 44 → 46 taken 2 times.
|
2 | u_ft_params.rmin = static_cast<float>(radius[0]); |
| 43 |
1/2✓ Branch 46 → 47 taken 2 times.
✗ Branch 46 → 50 not taken.
|
2 | u_ft_params.rmax = static_cast<float>(radius[1]); |
| 44 |
3/6✓ Branch 46 → 47 taken 2 times.
✗ Branch 46 → 50 not taken.
✓ Branch 47 → 48 taken 2 times.
✗ Branch 47 → 50 not taken.
✓ Branch 48 → 49 taken 2 times.
✗ Branch 48 → 50 not taken.
|
2 | if(!(std::isfinite(u_ft_params.rmin) && std::isfinite(u_ft_params.rmax)) || |
| 45 |
1/2✗ Branch 49 → 50 not taken.
✓ Branch 49 → 52 taken 2 times.
|
2 | !(u_ft_params.rmin > 0.f && u_ft_params.rmax > u_ft_params.rmin)) { |
| 46 | ✗ | throw std::runtime_error("[RGAFID] invalid forward_tagger.radius values"); | |
| 47 | } | ||
| 48 | |||
| 49 | u_ft_params.holes.clear(); | ||
| 50 | std::vector<double> holes_flat; | ||
| 51 | try { | ||
| 52 |
5/10✓ Branch 57 → 58 taken 2 times.
✗ Branch 57 → 240 not taken.
✓ Branch 58 → 59 taken 2 times.
✗ Branch 58 → 238 not taken.
✓ Branch 59 → 60 taken 2 times.
✗ Branch 59 → 232 not taken.
✓ Branch 71 → 72 taken 4 times.
✓ Branch 71 → 74 taken 2 times.
✗ Branch 241 → 242 not taken.
✗ Branch 241 → 244 not taken.
|
8 | holes_flat = GetOptionVector<double>("forward_tagger.holes_flat", |
| 53 | {"forward_tagger", "holes_flat"}); | ||
| 54 | } | ||
| 55 | ✗ | catch(std::exception const& e) { | |
| 56 | ✗ | std::string const msg = e.what(); | |
| 57 | ✗ | if(msg.find("not found") == std::string::npos && | |
| 58 | msg.find("missing") == std::string::npos) { | ||
| 59 | ✗ | throw; | |
| 60 | } | ||
| 61 | holes_flat.clear(); | ||
| 62 | ✗ | } | |
| 63 | |||
| 64 |
2/4✓ Branch 75 → 76 taken 2 times.
✗ Branch 75 → 79 not taken.
✓ Branch 78 → 79 taken 2 times.
✗ Branch 78 → 80 not taken.
|
4 | if(!holes_flat.empty() && (holes_flat.size() % 3) != 0) { |
| 65 | ✗ | throw std::runtime_error("[RGAFID] 'forward_tagger.holes_flat' must have 3N values"); | |
| 66 | } | ||
| 67 |
2/4✗ Branch 79 → 83 not taken.
✓ Branch 79 → 84 taken 2 times.
✓ Branch 84 → 97 taken 2 times.
✗ Branch 84 → 276 not taken.
|
2 | u_ft_params.holes.reserve(holes_flat.size() / 3); |
| 68 |
2/2✓ Branch 97 → 85 taken 8 times.
✓ Branch 97 → 98 taken 2 times.
|
10 | for(std::size_t i = 0; i + 2 < holes_flat.size(); i += 3) { |
| 69 | 8 | float const R = static_cast<float>(holes_flat[i + 0]); | |
| 70 | 8 | float const cx = static_cast<float>(holes_flat[i + 1]); | |
| 71 |
1/2✓ Branch 88 → 89 taken 8 times.
✗ Branch 88 → 93 not taken.
|
8 | float const cy = static_cast<float>(holes_flat[i + 2]); |
| 72 |
4/8✓ Branch 88 → 89 taken 8 times.
✗ Branch 88 → 93 not taken.
✓ Branch 89 → 90 taken 8 times.
✗ Branch 89 → 93 not taken.
✓ Branch 90 → 91 taken 8 times.
✗ Branch 90 → 93 not taken.
✓ Branch 91 → 92 taken 8 times.
✗ Branch 91 → 93 not taken.
|
8 | if(!(std::isfinite(R) && std::isfinite(cx) && std::isfinite(cy)) || R <= 0.f) { |
| 73 | ✗ | throw std::runtime_error("[RGAFID] invalid FT hole triple in 'holes_flat'"); | |
| 74 | } | ||
| 75 |
1/4✓ Branch 92 → 96 taken 8 times.
✗ Branch 92 → 276 not taken.
✗ Branch 276 → 277 not taken.
✗ Branch 276 → 279 not taken.
|
8 | u_ft_params.holes.push_back({R, cx, cy}); |
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | { | ||
| 80 |
6/12✓ Branch 106 → 107 taken 2 times.
✗ Branch 106 → 292 not taken.
✓ Branch 107 → 108 taken 2 times.
✗ Branch 107 → 290 not taken.
✓ Branch 108 → 109 taken 2 times.
✗ Branch 108 → 284 not taken.
✓ Branch 120 → 121 taken 4 times.
✓ Branch 120 → 123 taken 2 times.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 127 taken 2 times.
✗ Branch 293 → 294 not taken.
✗ Branch 293 → 296 not taken.
|
8 | m_cvt.edge_layers = GetOptionVector<int>("cvt.edge_layers", {"cvt", "edge_layers"}); |
| 81 |
1/2✗ Branch 123 → 124 not taken.
✓ Branch 123 → 127 taken 2 times.
|
2 | if(m_cvt.edge_layers.empty()) { |
| 82 | ✗ | throw std::runtime_error("[RGAFID] 'cvt.edge_layers' must be non-empty"); | |
| 83 | } | ||
| 84 |
7/14✓ Branch 129 → 130 taken 2 times.
✗ Branch 129 → 312 not taken.
✓ Branch 130 → 131 taken 2 times.
✗ Branch 130 → 310 not taken.
✓ Branch 131 → 132 taken 2 times.
✗ Branch 131 → 304 not taken.
✓ Branch 132 → 133 taken 2 times.
✗ Branch 132 → 135 not taken.
✓ Branch 139 → 140 taken 4 times.
✓ Branch 139 → 142 taken 2 times.
✗ Branch 142 → 143 not taken.
✓ Branch 142 → 144 taken 2 times.
✗ Branch 313 → 314 not taken.
✗ Branch 313 → 316 not taken.
|
8 | m_cvt.edge_min = GetOptionScalar<double>("cvt.edge_min", {"cvt", "edge_min"}); |
| 85 | |||
| 86 | m_cvt.phi_forbidden_deg.clear(); | ||
| 87 | try { | ||
| 88 |
5/10✓ Branch 146 → 147 taken 2 times.
✗ Branch 146 → 330 not taken.
✓ Branch 147 → 148 taken 2 times.
✗ Branch 147 → 328 not taken.
✓ Branch 148 → 149 taken 2 times.
✗ Branch 148 → 322 not taken.
✓ Branch 160 → 161 taken 4 times.
✓ Branch 160 → 163 taken 2 times.
✗ Branch 331 → 332 not taken.
✗ Branch 331 → 334 not taken.
|
8 | m_cvt.phi_forbidden_deg = GetOptionVector<double>("cvt.phi_forbidden_deg", |
| 89 | 2 | {"cvt", "phi_forbidden_deg"}); | |
| 90 | } | ||
| 91 | ✗ | catch(std::exception const& e) { | |
| 92 | ✗ | std::string const msg = e.what(); | |
| 93 | ✗ | if(msg.find("not found") == std::string::npos && | |
| 94 | msg.find("missing") == std::string::npos) { | ||
| 95 | ✗ | throw; | |
| 96 | } | ||
| 97 | m_cvt.phi_forbidden_deg.clear(); | ||
| 98 | ✗ | } | |
| 99 |
2/4✓ Branch 164 → 165 taken 2 times.
✗ Branch 164 → 168 not taken.
✓ Branch 167 → 168 taken 2 times.
✗ Branch 167 → 169 not taken.
|
4 | if(!m_cvt.phi_forbidden_deg.empty() && (m_cvt.phi_forbidden_deg.size() % 2) != 0) { |
| 100 | ✗ | throw std::runtime_error("[RGAFID] 'cvt.phi_forbidden_deg' must have pairs (2N values)"); | |
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | { | ||
| 105 |
1/2✗ Branch 176 → 177 not taken.
✓ Branch 176 → 179 taken 2 times.
|
2 | m_dc.theta_small_deg = |
| 106 |
5/10✓ Branch 173 → 174 taken 2 times.
✗ Branch 173 → 374 not taken.
✓ Branch 174 → 175 taken 2 times.
✗ Branch 174 → 372 not taken.
✓ Branch 175 → 176 taken 2 times.
✗ Branch 175 → 366 not taken.
✓ Branch 183 → 184 taken 4 times.
✓ Branch 183 → 186 taken 2 times.
✗ Branch 375 → 376 not taken.
✗ Branch 375 → 378 not taken.
|
8 | GetOptionScalar<double>("dc.theta_small_deg", {"dc", "theta_small_deg"}); |
| 107 | |||
| 108 | 6 | auto need3 = [&](char const* key) -> std::array<double, 3> { | |
| 109 |
7/14✓ Branch 2 → 3 taken 6 times.
✗ Branch 2 → 77 not taken.
✓ Branch 4 → 5 taken 6 times.
✗ Branch 4 → 72 not taken.
✓ Branch 5 → 6 taken 6 times.
✗ Branch 5 → 70 not taken.
✓ Branch 8 → 9 taken 6 times.
✗ Branch 8 → 58 not taken.
✓ Branch 21 → 22 taken 12 times.
✓ Branch 21 → 24 taken 6 times.
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 26 taken 6 times.
✗ Branch 73 → 74 not taken.
✗ Branch 73 → 76 not taken.
|
36 | auto v = GetOptionVector<double>(std::string("dc.") + key, {"dc", key}); |
| 110 |
1/2✗ Branch 26 → 27 not taken.
✓ Branch 26 → 50 taken 6 times.
|
6 | if(v.size() != 3) { |
| 111 | ✗ | throw std::runtime_error(std::string("[RGAFID] 'dc.") + key + "' must be [e1,e2,e3]"); | |
| 112 | } | ||
| 113 |
2/4✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 6 times.
✗ Branch 54 → 55 not taken.
✓ Branch 54 → 56 taken 6 times.
|
6 | return {v[0], v[1], v[2]}; |
| 114 | ✗ | }; | |
| 115 | |||
| 116 | 2 | auto out = need3("thresholds_out"); | |
| 117 | 2 | auto in_s = need3("thresholds_in_smallTheta"); | |
| 118 | 2 | auto in_l = need3("thresholds_in_largeTheta"); | |
| 119 | |||
| 120 | 2 | m_dc.out_e1 = out[0]; | |
| 121 | 2 | m_dc.out_e2 = out[1]; | |
| 122 | 2 | m_dc.out_e3 = out[2]; | |
| 123 | 2 | m_dc.in_small_e1 = in_s[0]; | |
| 124 | 2 | m_dc.in_small_e2 = in_s[1]; | |
| 125 | 2 | m_dc.in_small_e3 = in_s[2]; | |
| 126 | 2 | m_dc.in_large_e1 = in_l[0]; | |
| 127 | 2 | m_dc.in_large_e2 = in_l[1]; | |
| 128 | 2 | m_dc.in_large_e3 = in_l[2]; | |
| 129 | } | ||
| 130 |
0/14✗ Branch 204 → 205 not taken.
✗ Branch 204 → 207 not taken.
✗ Branch 224 → 225 not taken.
✗ Branch 224 → 227 not taken.
✗ Branch 246 → 247 not taken.
✗ Branch 246 → 249 not taken.
✗ Branch 298 → 299 not taken.
✗ Branch 298 → 301 not taken.
✗ Branch 318 → 319 not taken.
✗ Branch 318 → 321 not taken.
✗ Branch 336 → 337 not taken.
✗ Branch 336 → 339 not taken.
✗ Branch 380 → 381 not taken.
✗ Branch 380 → 383 not taken.
|
2 | } |
| 131 | |||
| 132 | 2 | void FiducialFilterPass2::Start(hipo::banklist& banks) | |
| 133 | { | ||
| 134 |
2/4✓ Branch 3 → 4 taken 2 times.
✗ Branch 3 → 49 not taken.
✓ Branch 4 → 5 taken 2 times.
✗ Branch 4 → 7 not taken.
|
2 | b_particle = GetBankIndex(banks, "REC::Particle"); |
| 135 |
2/4✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 55 not taken.
✓ Branch 11 → 12 taken 2 times.
✗ Branch 11 → 14 not taken.
|
2 | b_config = GetBankIndex(banks, "RUN::config"); |
| 136 |
2/2✓ Branch 17 → 18 taken 1 time.
✓ Branch 17 → 26 taken 1 time.
|
2 | if(banklist_has(banks, "REC::Calorimeter")) { |
| 137 |
2/4✓ Branch 19 → 20 taken 1 time.
✗ Branch 19 → 61 not taken.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 23 taken 1 time.
|
1 | b_calor = GetBankIndex(banks, "REC::Calorimeter"); |
| 138 | 1 | m_have_calor = true; | |
| 139 | } | ||
| 140 |
1/2✗ Branch 27 → 28 not taken.
✓ Branch 27 → 36 taken 2 times.
|
2 | if(banklist_has(banks, "REC::ForwardTagger")) { |
| 141 | ✗ | b_ft = GetBankIndex(banks, "REC::ForwardTagger"); | |
| 142 | ✗ | m_have_ft = true; | |
| 143 | } | ||
| 144 |
2/2✓ Branch 37 → 38 taken 1 time.
✓ Branch 37 → 46 taken 1 time.
|
2 | if(banklist_has(banks, "REC::Traj")) { |
| 145 |
2/4✓ Branch 39 → 40 taken 1 time.
✗ Branch 39 → 73 not taken.
✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 43 not taken.
|
1 | b_traj = GetBankIndex(banks, "REC::Traj"); |
| 146 | 1 | m_have_traj = true; | |
| 147 | } | ||
| 148 | |||
| 149 | 2 | ParseYAMLConfig(); | |
| 150 | 2 | LoadConfig(); | |
| 151 | 2 | } | |
| 152 | |||
| 153 | 2000 | bool FiducialFilterPass2::Run(hipo::banklist& banks) const | |
| 154 | { | ||
| 155 |
1/2✓ Branch 15 → 16 taken 2000 times.
✗ Branch 15 → 48 not taken.
|
2000 | return Run( |
| 156 |
3/8✓ Branch 13 → 14 taken 2000 times.
✗ Branch 13 → 54 not taken.
✓ Branch 14 → 15 taken 2000 times.
✗ Branch 14 → 48 not taken.
✓ Branch 21 → 22 taken 2000 times.
✗ Branch 21 → 24 not taken.
✗ Branch 54 → 55 not taken.
✗ Branch 54 → 57 not taken.
|
4000 | GetBank(banks, b_particle, "REC::Particle"), |
| 157 |
2/4✓ Branch 11 → 12 taken 2000 times.
✗ Branch 11 → 60 not taken.
✓ Branch 12 → 13 taken 2000 times.
✗ Branch 12 → 54 not taken.
|
2000 | GetBank(banks, b_config, "RUN::config"), |
| 158 |
6/10✓ Branch 8 → 9 taken 1000 times.
✓ Branch 8 → 11 taken 1000 times.
✓ Branch 9 → 10 taken 1000 times.
✗ Branch 9 → 67 not taken.
✓ Branch 10 → 11 taken 1000 times.
✗ Branch 10 → 61 not taken.
✓ Branch 26 → 27 taken 1000 times.
✓ Branch 26 → 33 taken 1000 times.
✗ Branch 60 → 61 not taken.
✗ Branch 60 → 67 not taken.
|
4000 | m_have_calor ? &GetBank(banks, b_calor, "REC::Calorimeter") : nullptr, |
| 159 |
6/10✓ Branch 5 → 6 taken 1000 times.
✓ Branch 5 → 8 taken 1000 times.
✓ Branch 6 → 7 taken 1000 times.
✗ Branch 6 → 75 not taken.
✓ Branch 7 → 8 taken 1000 times.
✗ Branch 7 → 69 not taken.
✓ Branch 33 → 34 taken 1000 times.
✓ Branch 33 → 40 taken 1000 times.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 75 not taken.
|
4000 | m_have_traj ? &GetBank(banks, b_traj, "REC::Traj") : nullptr, |
| 160 |
2/8✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 2000 times.
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 77 not taken.
✗ Branch 40 → 41 not taken.
✓ Branch 40 → 47 taken 2000 times.
✗ Branch 76 → 77 not taken.
✗ Branch 76 → 83 not taken.
|
4000 | m_have_ft ? &GetBank(banks, b_ft, "REC::ForwardTagger") : nullptr); |
| 161 | } | ||
| 162 | |||
| 163 | 2000 | bool FiducialFilterPass2::Run( | |
| 164 | hipo::bank& particle, | ||
| 165 | hipo::bank const& conf, | ||
| 166 | hipo::bank const* cal, | ||
| 167 | hipo::bank const* traj, | ||
| 168 | hipo::bank const* ft) const | ||
| 169 | { | ||
| 170 |
1/2✓ Branch 4 → 5 taken 2000 times.
✗ Branch 4 → 9 not taken.
|
2000 | particle.getMutableRowList().filter([this, &conf, cal, traj, ft](auto bank, auto row) { |
| 171 | 13986 | bool const keep = Filter(row, bank, conf, cal, traj, ft); | |
| 172 |
2/2✓ Branch 3 → 4 taken 350 times.
✓ Branch 3 → 5 taken 13636 times.
|
13986 | return keep ? 1 : 0; |
| 173 | }); | ||
| 174 | 2000 | return !particle.getRowList().empty(); | |
| 175 | } | ||
| 176 | |||
| 177 | FiducialFilterPass2::CalLayers | ||
| 178 | 1662 | FiducialFilterPass2::CollectCalHitsForTrack(hipo::bank const& cal, int pindex) | |
| 179 | { | ||
| 180 | CalLayers out; | ||
| 181 | int const n = cal.getRows(); | ||
| 182 |
2/2✓ Branch 19 → 3 taken 13308 times.
✓ Branch 19 → 20 taken 1662 times.
|
14970 | for(int i = 0; i < n; ++i) { |
| 183 |
2/2✓ Branch 4 → 5 taken 10777 times.
✓ Branch 4 → 6 taken 2531 times.
|
13308 | if(cal.getInt("pindex", i) != pindex) |
| 184 | 11646 | continue; | |
| 185 |
2/2✓ Branch 7 → 8 taken 869 times.
✓ Branch 7 → 9 taken 1662 times.
|
2531 | if(cal.getInt("layer", i) != DetectorLayer::PCAL) |
| 186 | 869 | continue; // PCal only | |
| 187 | CalHit h; | ||
| 188 | 1662 | h.sector = cal.getInt("sector", i); | |
| 189 | 1662 | h.lv = cal.getFloat("lv", i); | |
| 190 | 1662 | h.lw = cal.getFloat("lw", i); | |
| 191 | 1662 | h.lu = cal.getFloat("lu", i); | |
| 192 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 1662 times.
|
1662 | out.L1.push_back(h); |
| 193 | 1662 | out.has_any = true; | |
| 194 | } | ||
| 195 | 1662 | return out; | |
| 196 | } | ||
| 197 | |||
| 198 | 1662 | bool FiducialFilterPass2::PassCalStrictness(CalLayers const& H, int strictness) | |
| 199 | { | ||
| 200 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 1662 times.
|
1662 | if(!H.has_any) |
| 201 | return true; | ||
| 202 | |||
| 203 | float min_lv = std::numeric_limits<float>::infinity(); | ||
| 204 | float min_lw = std::numeric_limits<float>::infinity(); | ||
| 205 |
2/2✓ Branch 10 → 5 taken 1662 times.
✓ Branch 10 → 11 taken 1662 times.
|
3324 | for(auto const& hit : H.L1) { |
| 206 |
1/2✓ Branch 5 → 6 taken 1662 times.
✗ Branch 5 → 7 not taken.
|
1662 | if(std::isfinite(hit.lv) && hit.lv < min_lv) |
| 207 | min_lv = hit.lv; | ||
| 208 |
1/2✓ Branch 7 → 8 taken 1662 times.
✗ Branch 7 → 9 not taken.
|
1662 | if(std::isfinite(hit.lw) && hit.lw < min_lw) |
| 209 | min_lw = hit.lw; | ||
| 210 | } | ||
| 211 | |||
| 212 |
1/4✗ Branch 11 → 12 not taken.
✓ Branch 11 → 14 taken 1662 times.
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 14 not taken.
|
1662 | float const thr = (strictness == 1 ? 9.0f : strictness == 2 ? 13.5f |
| 213 | : 18.0f); | ||
| 214 |
4/4✓ Branch 14 → 15 taken 1628 times.
✓ Branch 14 → 16 taken 34 times.
✓ Branch 15 → 3 taken 1558 times.
✓ Branch 15 → 16 taken 70 times.
|
1662 | return !(min_lv < thr || min_lw < thr); |
| 215 | } | ||
| 216 | |||
| 217 | ✗ | bool FiducialFilterPass2::PassFTFiducial(int pindex, hipo::bank const* ftBank) const | |
| 218 | { | ||
| 219 | ✗ | if(!ftBank) | |
| 220 | return true; | ||
| 221 | |||
| 222 | auto const& ft = *ftBank; | ||
| 223 | int const n = ft.getRows(); | ||
| 224 | ✗ | for(int i = 0; i < n; ++i) { | |
| 225 | ✗ | if(ft.getInt("pindex", i) != pindex) | |
| 226 | continue; | ||
| 227 | |||
| 228 | ✗ | double const x = ft.getFloat("x", i); | |
| 229 | ✗ | double const y = ft.getFloat("y", i); | |
| 230 | ✗ | double const r = std::hypot(x, y); | |
| 231 | |||
| 232 | ✗ | if(r < u_ft_params.rmin) | |
| 233 | return false; | ||
| 234 | ✗ | if(r > u_ft_params.rmax) | |
| 235 | return false; | ||
| 236 | |||
| 237 | ✗ | for(auto const& H : u_ft_params.holes) { | |
| 238 | ✗ | double const R = H[0], cx = H[1], cy = H[2]; | |
| 239 | ✗ | double const d = std::hypot(x - cx, y - cy); | |
| 240 | ✗ | if(d < R) | |
| 241 | return false; | ||
| 242 | } | ||
| 243 | return true; | ||
| 244 | } | ||
| 245 | return true; | ||
| 246 | } | ||
| 247 | |||
| 248 | 360 | bool FiducialFilterPass2::PassCVTFiducial(int pindex, hipo::bank const* trajBank) const | |
| 249 | { | ||
| 250 |
1/2✓ Branch 2 → 3 taken 360 times.
✗ Branch 2 → 61 not taken.
|
360 | if(!trajBank) |
| 251 | return true; | ||
| 252 | |||
| 253 | auto const& traj = *trajBank; | ||
| 254 | int const n = traj.getRows(); | ||
| 255 | |||
| 256 | std::map<int, double> edge_at_layer; | ||
| 257 | |||
| 258 | double x12 = 0.0, y12 = 0.0; | ||
| 259 | bool saw12 = false; | ||
| 260 | |||
| 261 |
2/2✓ Branch 28 → 4 taken 18776 times.
✓ Branch 28 → 29 taken 360 times.
|
19136 | for(int i = 0; i < n; ++i) { |
| 262 |
2/2✓ Branch 5 → 6 taken 15558 times.
✓ Branch 5 → 7 taken 3218 times.
|
18776 | if(traj.getInt("pindex", i) != pindex) |
| 263 | 16976 | continue; | |
| 264 |
2/2✓ Branch 8 → 9 taken 1418 times.
✓ Branch 8 → 10 taken 1800 times.
|
3218 | if(traj.getInt("detector", i) != DetectorType::CVT) |
| 265 | 1418 | continue; | |
| 266 | |||
| 267 | 1800 | int const layer = traj.getInt("layer", i); | |
| 268 | 1800 | double const edge = static_cast<double>(traj.getFloat("edge", i)); | |
| 269 | |||
| 270 |
1/2✓ Branch 16 → 17 taken 1800 times.
✗ Branch 16 → 19 not taken.
|
1800 | if(std::find(m_cvt.edge_layers.begin(), m_cvt.edge_layers.end(), layer) != m_cvt.edge_layers.end()) { |
| 271 |
1/2✓ Branch 17 → 18 taken 1800 times.
✗ Branch 17 → 62 not taken.
|
1800 | edge_at_layer[layer] = edge; |
| 272 | } | ||
| 273 | |||
| 274 |
2/2✓ Branch 19 → 20 taken 1440 times.
✓ Branch 19 → 21 taken 360 times.
|
1800 | if(layer == 12) { |
| 275 | 360 | double const x = static_cast<double>(traj.getFloat("x", i)); | |
| 276 |
1/2✗ Branch 23 → 20 not taken.
✓ Branch 23 → 24 taken 360 times.
|
360 | double const y = static_cast<double>(traj.getFloat("y", i)); |
| 277 |
2/4✗ Branch 23 → 20 not taken.
✓ Branch 23 → 24 taken 360 times.
✗ Branch 24 → 20 not taken.
✓ Branch 24 → 25 taken 360 times.
|
360 | if(std::isfinite(x) && std::isfinite(y)) { |
| 278 | x12 = x; | ||
| 279 | y12 = y; | ||
| 280 | saw12 = true; | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 |
2/2✓ Branch 44 → 30 taken 1644 times.
✓ Branch 44 → 45 taken 259 times.
|
1903 | for(int L : m_cvt.edge_layers) { |
| 286 | auto it = edge_at_layer.find(L); | ||
| 287 |
1/2✗ Branch 39 → 40 not taken.
✓ Branch 39 → 41 taken 1644 times.
|
1644 | if(it == edge_at_layer.end()) |
| 288 | continue; | ||
| 289 |
2/2✓ Branch 41 → 42 taken 101 times.
✓ Branch 41 → 43 taken 1543 times.
|
1644 | if(!(it->second > m_cvt.edge_min)) { |
| 290 | return false; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 |
2/4✓ Branch 45 → 46 taken 259 times.
✗ Branch 45 → 58 not taken.
✓ Branch 46 → 47 taken 259 times.
✗ Branch 46 → 58 not taken.
|
259 | if(saw12 && !m_cvt.phi_forbidden_deg.empty()) { |
| 295 | 259 | double phi = std::atan2(y12, x12) * (180.0 / M_PI); | |
| 296 |
2/2✓ Branch 47 → 48 taken 128 times.
✓ Branch 47 → 49 taken 131 times.
|
259 | if(phi < 0) |
| 297 | 128 | phi += 360.0; | |
| 298 |
3/4✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 1013 times.
✓ Branch 57 → 50 taken 766 times.
✓ Branch 57 → 58 taken 247 times.
|
1013 | for(std::size_t i = 0; i + 1 < m_cvt.phi_forbidden_deg.size(); i += 2) { |
| 299 | 766 | double const lo = m_cvt.phi_forbidden_deg[i]; | |
| 300 | 766 | double const hi = m_cvt.phi_forbidden_deg[i + 1]; | |
| 301 |
4/4✓ Branch 52 → 53 taken 445 times.
✓ Branch 52 → 54 taken 321 times.
✓ Branch 53 → 42 taken 12 times.
✓ Branch 53 → 54 taken 433 times.
|
766 | if(phi > lo && phi < hi) { |
| 302 | return false; | ||
| 303 | } | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | return true; | ||
| 308 | } | ||
| 309 | |||
| 310 | 1542 | bool FiducialFilterPass2::PassDCFiducial(int pindex, hipo::bank const& particleBank, | |
| 311 | hipo::bank const& configBank, hipo::bank const* trajBank) const | ||
| 312 | { | ||
| 313 |
1/2✓ Branch 2 → 3 taken 1542 times.
✗ Branch 2 → 45 not taken.
|
1542 | if(!trajBank) |
| 314 | return true; | ||
| 315 | |||
| 316 | 1542 | int const pid = particleBank.getInt("pid", pindex); | |
| 317 |
2/2✓ Branch 4 → 5 taken 1064 times.
✓ Branch 4 → 6 taken 478 times.
|
1542 | bool const isNeg = (pid == 11 || pid == -211 || pid == -321 || pid == -2212); |
| 318 |
4/4✓ Branch 6 → 7 taken 658 times.
✓ Branch 6 → 9 taken 884 times.
✓ Branch 7 → 8 taken 501 times.
✓ Branch 7 → 9 taken 157 times.
|
1542 | bool const isPos = (pid == -11 || pid == 211 || pid == 321 || pid == 2212); |
| 319 |
1/2✓ Branch 8 → 9 taken 501 times.
✗ Branch 8 → 45 not taken.
|
501 | if(!(isNeg || isPos)) |
| 320 | return true; | ||
| 321 | |||
| 322 | 1542 | float const torus = configBank.getFloat("torus", 0); | |
| 323 | bool const electron_out = (torus == 1.0f); | ||
| 324 |
1/2✓ Branch 10 → 11 taken 1542 times.
✗ Branch 10 → 12 not taken.
|
1542 | bool const particle_inb = (electron_out ? isPos : isNeg); |
| 325 | bool const particle_out = !particle_inb; | ||
| 326 | |||
| 327 | 1542 | double const px = particleBank.getFloat("px", pindex); | |
| 328 | 1542 | double const py = particleBank.getFloat("py", pindex); | |
| 329 | 1542 | double const pz = particleBank.getFloat("pz", pindex); | |
| 330 | 1542 | double const rho = std::hypot(px, py); | |
| 331 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 1542 times.
|
1542 | double const theta = std::atan2(rho, (pz == 0.0 ? 1e-12 : pz)) * (180.0 / M_PI); |
| 332 | |||
| 333 | double e1 = 0.0, e2 = 0.0, e3 = 0.0; | ||
| 334 | bool saw_dc = false; | ||
| 335 | |||
| 336 | auto const& traj = *trajBank; | ||
| 337 | int const n = traj.getRows(); | ||
| 338 |
2/2✓ Branch 32 → 18 taken 77915 times.
✓ Branch 32 → 33 taken 1542 times.
|
79457 | for(int i = 0; i < n; ++i) { |
| 339 |
2/2✓ Branch 19 → 20 taken 52972 times.
✓ Branch 19 → 22 taken 24943 times.
|
77915 | if(traj.getInt("pindex", i) != pindex) |
| 340 | 52972 | continue; | |
| 341 |
2/2✓ Branch 23 → 24 taken 20317 times.
✓ Branch 23 → 25 taken 4626 times.
|
24943 | if(traj.getInt("detector", i) != DetectorType::DC) |
| 342 | 20317 | continue; | |
| 343 | saw_dc = true; | ||
| 344 | 4626 | int const layer = traj.getInt("layer", i); | |
| 345 | 4626 | double const e = traj.getFloat("edge", i); | |
| 346 |
2/2✓ Branch 27 → 28 taken 3084 times.
✓ Branch 27 → 31 taken 1542 times.
|
4626 | if(layer == 6) |
| 347 | e1 = e; | ||
| 348 |
2/2✓ Branch 28 → 29 taken 1542 times.
✓ Branch 28 → 31 taken 1542 times.
|
3084 | else if(layer == 18) |
| 349 | e2 = e; | ||
| 350 |
1/2✓ Branch 29 → 30 taken 1542 times.
✗ Branch 29 → 31 not taken.
|
1542 | else if(layer == 36) |
| 351 | e3 = e; | ||
| 352 | } | ||
| 353 | |||
| 354 |
1/2✓ Branch 33 → 34 taken 1542 times.
✗ Branch 33 → 45 not taken.
|
1542 | if(!saw_dc) |
| 355 | return true; | ||
| 356 | |||
| 357 | auto pass3 = [](double a1, double a2, double a3, double t1, double t2, double t3) -> bool { | ||
| 358 |
11/12✓ Branch 37 → 38 taken 15 times.
✗ Branch 37 → 46 not taken.
✓ Branch 38 → 45 taken 8 times.
✓ Branch 38 → 46 taken 7 times.
✓ Branch 40 → 41 taken 447 times.
✓ Branch 40 → 46 taken 3 times.
✓ Branch 41 → 45 taken 433 times.
✓ Branch 41 → 46 taken 14 times.
✓ Branch 43 → 44 taken 969 times.
✓ Branch 43 → 46 taken 1 time.
✓ Branch 44 → 45 taken 968 times.
✓ Branch 44 → 46 taken 1 time.
|
1435 | return (a1 > t1 && a2 > t2 && a3 > t3); |
| 359 | }; | ||
| 360 | |||
| 361 |
2/2✓ Branch 34 → 35 taken 501 times.
✓ Branch 34 → 42 taken 1041 times.
|
1542 | if(particle_inb) { |
| 362 |
2/2✓ Branch 35 → 36 taken 41 times.
✓ Branch 35 → 39 taken 460 times.
|
501 | if(theta < m_dc.theta_small_deg) { |
| 363 |
2/2✓ Branch 36 → 37 taken 15 times.
✓ Branch 36 → 46 taken 26 times.
|
41 | return pass3(e1, e2, e3, m_dc.in_small_e1, m_dc.in_small_e2, m_dc.in_small_e3); |
| 364 | } | ||
| 365 |
2/2✓ Branch 39 → 40 taken 450 times.
✓ Branch 39 → 46 taken 10 times.
|
460 | return pass3(e1, e2, e3, m_dc.in_large_e1, m_dc.in_large_e2, m_dc.in_large_e3); |
| 366 | } | ||
| 367 | else if(particle_out) { | ||
| 368 |
2/2✓ Branch 42 → 43 taken 970 times.
✓ Branch 42 → 46 taken 71 times.
|
1041 | return pass3(e1, e2, e3, m_dc.out_e1, m_dc.out_e2, m_dc.out_e3); |
| 369 | } | ||
| 370 | return true; | ||
| 371 | } | ||
| 372 | |||
| 373 | 13986 | bool FiducialFilterPass2::Filter(int track_index, hipo::bank const& particleBank, | |
| 374 | hipo::bank const& configBank, hipo::bank const* calBank, | ||
| 375 | hipo::bank const* trajBank, hipo::bank const* ftBank) const | ||
| 376 | { | ||
| 377 | |||
| 378 | 13986 | int const pid = particleBank.getInt("pid", track_index); | |
| 379 | 13986 | int const strictness = m_cal_strictness; | |
| 380 | |||
| 381 | 27972 | auto has_assoc = [&track_index](hipo::bank const* b) -> bool { | |
| 382 |
2/2✓ Branch 2 → 3 taken 20979 times.
✓ Branch 2 → 4 taken 6993 times.
|
27972 | if(!b) |
| 383 | return false; | ||
| 384 | int const n = b->getRows(); | ||
| 385 |
2/2✓ Branch 8 → 3 taken 3207 times.
✓ Branch 8 → 5 taken 37923 times.
|
41130 | for(int i = 0; i < n; ++i) |
| 386 |
2/2✓ Branch 6 → 7 taken 34137 times.
✓ Branch 6 → 9 taken 3786 times.
|
37923 | if(b->getInt("pindex", i) == track_index) |
| 387 | return true; | ||
| 388 | return false; | ||
| 389 | 13986 | }; | |
| 390 | |||
| 391 | 13986 | bool const hasCal = has_assoc(calBank); | |
| 392 | 13986 | bool const hasFT = has_assoc(ftBank); | |
| 393 | 13986 | bool const hasCVT = traj_has_detector(trajBank, track_index, DetectorType::CVT); | |
| 394 | 13986 | bool const hasDC = traj_has_detector(trajBank, track_index, DetectorType::DC); | |
| 395 | |||
| 396 | bool pass = true; | ||
| 397 | |||
| 398 |
2/2✓ Branch 7 → 8 taken 1300 times.
✓ Branch 7 → 25 taken 12686 times.
|
13986 | if(pid == 11 || pid == -11) { |
| 399 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 12 taken 1300 times.
|
1300 | if(hasFT) { |
| 400 | ✗ | pass = pass && PassFTFiducial(track_index, ftBank); | |
| 401 | } | ||
| 402 | else { | ||
| 403 |
2/2✓ Branch 12 → 13 taken 156 times.
✓ Branch 12 → 19 taken 1144 times.
|
1300 | if(hasCal) { |
| 404 | 156 | auto calhits = CollectCalHitsForTrack(*calBank, track_index); | |
| 405 |
1/2✓ Branch 14 → 15 taken 156 times.
✗ Branch 14 → 52 not taken.
|
156 | pass = pass && PassCalStrictness(calhits, strictness); |
| 406 | } | ||
| 407 |
2/2✓ Branch 19 → 20 taken 156 times.
✓ Branch 19 → 24 taken 1144 times.
|
1300 | if(hasDC) { |
| 408 |
4/4✓ Branch 20 → 11 taken 22 times.
✓ Branch 20 → 21 taken 134 times.
✓ Branch 22 → 11 taken 8 times.
✓ Branch 22 → 23 taken 126 times.
|
156 | pass = pass && PassDCFiducial(track_index, particleBank, configBank, trajBank); |
| 409 | } | ||
| 410 | } | ||
| 411 | 1300 | return pass; | |
| 412 | } | ||
| 413 | |||
| 414 |
2/2✓ Branch 25 → 26 taken 3678 times.
✓ Branch 25 → 38 taken 9008 times.
|
12686 | if(pid == 22) { |
| 415 |
1/2✗ Branch 26 → 27 not taken.
✓ Branch 26 → 29 taken 3678 times.
|
3678 | if(hasFT) { |
| 416 | ✗ | pass = pass && PassFTFiducial(track_index, ftBank); | |
| 417 | } | ||
| 418 |
2/2✓ Branch 29 → 30 taken 2172 times.
✓ Branch 29 → 31 taken 1506 times.
|
3678 | else if(hasCal) { |
| 419 | 1506 | auto calhits = CollectCalHitsForTrack(*calBank, track_index); | |
| 420 |
1/2✓ Branch 32 → 33 taken 1506 times.
✗ Branch 32 → 56 not taken.
|
1506 | pass = pass && PassCalStrictness(calhits, strictness); |
| 421 | } | ||
| 422 | 3678 | return pass; | |
| 423 | } | ||
| 424 | |||
| 425 |
2/2✓ Branch 38 → 39 taken 6922 times.
✓ Branch 38 → 41 taken 2086 times.
|
9008 | if(pid == 211 || pid == 321 || pid == 2212 || |
| 426 |
4/4✓ Branch 39 → 40 taken 5558 times.
✓ Branch 39 → 41 taken 1364 times.
✓ Branch 40 → 41 taken 86 times.
✓ Branch 40 → 51 taken 5472 times.
|
6922 | pid == -211 || pid == -321 || pid == -2212) { |
| 427 |
2/2✓ Branch 41 → 42 taken 3176 times.
✓ Branch 41 → 43 taken 360 times.
|
3536 | if(hasCVT) |
| 428 |
2/2✓ Branch 44 → 42 taken 247 times.
✓ Branch 44 → 45 taken 113 times.
|
360 | pass = pass && PassCVTFiducial(track_index, trajBank); |
| 429 |
2/2✓ Branch 45 → 46 taken 1408 times.
✓ Branch 45 → 50 taken 2128 times.
|
3536 | if(hasDC) |
| 430 |
3/4✓ Branch 46 → 47 taken 1408 times.
✗ Branch 46 → 49 not taken.
✓ Branch 48 → 49 taken 125 times.
✓ Branch 48 → 50 taken 1283 times.
|
1408 | pass = pass && PassDCFiducial(track_index, particleBank, configBank, trajBank); |
| 431 | 3536 | return pass; | |
| 432 | } | ||
| 433 | |||
| 434 | return true; | ||
| 435 | } | ||
| 436 | |||
| 437 | } | ||
| 438 |