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