| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Algorithm.h" | ||
| 2 | |||
| 3 | // ROOT | ||
| 4 | #include <Math/Vector4D.h> | ||
| 5 | |||
| 6 | namespace iguana::physics { | ||
| 7 | |||
| 8 | REGISTER_IGUANA_ALGORITHM(InclusiveKinematics, "physics::InclusiveKinematics"); | ||
| 9 | |||
| 10 | 8 | void InclusiveKinematics::Start(hipo::banklist& banks) | |
| 11 | { | ||
| 12 | // parse config file | ||
| 13 | 8 | ParseYAMLConfig(); | |
| 14 |
2/4✓ Branch 4 → 5 taken 8 times.
✗ Branch 4 → 186 not taken.
✓ Branch 5 → 6 taken 8 times.
✗ Branch 5 → 180 not taken.
|
16 | o_particle_bank = GetOptionScalar<std::string>("particle_bank"); |
| 15 | 8 | o_runnum = ConcurrentParamFactory::Create<int>(); | |
| 16 | 8 | o_target_PxPyPzM = ConcurrentParamFactory::Create<std::vector<double>>(); | |
| 17 |
1/2✓ Branch 30 → 31 taken 8 times.
✗ Branch 30 → 201 not taken.
|
16 | o_beam_PxPyPzM = ConcurrentParamFactory::Create<std::vector<double>>(); |
| 18 | |||
| 19 | // get reconstruction method configuration | ||
| 20 |
5/10✓ Branch 32 → 33 taken 8 times.
✗ Branch 32 → 196 not taken.
✓ Branch 33 → 34 taken 8 times.
✗ Branch 33 → 194 not taken.
✓ Branch 34 → 35 taken 8 times.
✗ Branch 34 → 188 not taken.
✓ Branch 42 → 43 taken 16 times.
✓ Branch 42 → 45 taken 8 times.
✗ Branch 197 → 198 not taken.
✗ Branch 197 → 200 not taken.
|
32 | auto method_reconstruction_str = GetOptionScalar<std::string>("reconstruction", {"method", "reconstruction"}); |
| 21 |
1/2✓ Branch 45 → 46 taken 8 times.
✗ Branch 45 → 48 not taken.
|
8 | if(method_reconstruction_str == "scattered_lepton") { |
| 22 |
1/2✓ Branch 46 → 47 taken 8 times.
✗ Branch 46 → 227 not taken.
|
8 | o_method_reconstruction = method_reconstruction::scattered_lepton; |
| 23 | } | ||
| 24 | else { | ||
| 25 | ✗ | m_log->Error("Unknown reconstruction method {:?}", method_reconstruction_str); | |
| 26 | ✗ | throw std::runtime_error("Start failed"); | |
| 27 | } | ||
| 28 | |||
| 29 | // get scattered lepton finder configuration | ||
| 30 |
5/12✓ Branch 61 → 62 taken 8 times.
✗ Branch 61 → 222 not taken.
✓ Branch 62 → 63 taken 8 times.
✗ Branch 62 → 220 not taken.
✓ Branch 63 → 64 taken 8 times.
✗ Branch 63 → 214 not taken.
✓ Branch 71 → 72 taken 16 times.
✓ Branch 71 → 74 taken 8 times.
✗ Branch 223 → 224 not taken.
✗ Branch 223 → 226 not taken.
✗ Branch 300 → 301 not taken.
✗ Branch 300 → 303 not taken.
|
32 | auto method_lepton_finder_str = GetOptionScalar<std::string>("lepton_finder", {"method", "lepton_finder"}); |
| 31 |
1/2✓ Branch 74 → 75 taken 8 times.
✗ Branch 74 → 77 not taken.
|
8 | if(method_lepton_finder_str == "highest_energy_FD_trigger") { |
| 32 | 8 | o_method_lepton_finder = method_lepton_finder::highest_energy_FD_trigger; | |
| 33 | } | ||
| 34 | else { | ||
| 35 | ✗ | m_log->Error("Unknown lepton finder method {:?}", method_lepton_finder_str); | |
| 36 | ✗ | throw std::runtime_error("Start failed"); | |
| 37 | } | ||
| 38 | |||
| 39 | // get beam PDG and mass | ||
| 40 |
1/2✓ Branch 75 → 76 taken 8 times.
✗ Branch 75 → 253 not taken.
|
8 | o_beam_pdg = 0; |
| 41 |
5/12✓ Branch 90 → 91 taken 8 times.
✗ Branch 90 → 248 not taken.
✓ Branch 91 → 92 taken 8 times.
✗ Branch 91 → 246 not taken.
✓ Branch 92 → 93 taken 8 times.
✗ Branch 92 → 240 not taken.
✓ Branch 100 → 101 taken 16 times.
✓ Branch 100 → 103 taken 8 times.
✗ Branch 249 → 250 not taken.
✗ Branch 249 → 252 not taken.
✗ Branch 294 → 295 not taken.
✗ Branch 294 → 297 not taken.
|
32 | auto beam_particle = GetOptionScalar<std::string>("beam_particle", {"method", "beam_particle"}); |
| 42 |
1/2✓ Branch 108 → 104 taken 80 times.
✗ Branch 108 → 109 not taken.
|
80 | for(auto const& [pdg, name] : particle::name) { |
| 43 |
2/2✓ Branch 104 → 105 taken 8 times.
✓ Branch 104 → 107 taken 72 times.
|
80 | if(name == beam_particle) { |
| 44 |
1/2✓ Branch 105 → 106 taken 8 times.
✗ Branch 105 → 288 not taken.
|
8 | o_beam_pdg = pdg; |
| 45 | 8 | o_beam_mass = particle::mass.at(pdg); | |
| 46 | 8 | break; | |
| 47 | } | ||
| 48 | } | ||
| 49 |
1/2✗ Branch 109 → 110 not taken.
✓ Branch 109 → 123 taken 8 times.
|
8 | if(o_beam_pdg == 0) { |
| 50 | ✗ | m_log->Error("Unknown beam particle {:?}", beam_particle); | |
| 51 | ✗ | throw std::runtime_error("Start failed"); | |
| 52 | } | ||
| 53 | |||
| 54 | // get bank indices | ||
| 55 |
1/2✓ Branch 123 → 124 taken 8 times.
✗ Branch 123 → 288 not taken.
|
8 | b_particle = GetBankIndex(banks, o_particle_bank); |
| 56 |
4/8✓ Branch 124 → 125 taken 8 times.
✗ Branch 124 → 288 not taken.
✓ Branch 125 → 126 taken 8 times.
✗ Branch 125 → 266 not taken.
✓ Branch 126 → 127 taken 8 times.
✗ Branch 126 → 129 not taken.
✓ Branch 131 → 132 taken 8 times.
✗ Branch 131 → 288 not taken.
|
16 | b_config = GetBankIndex(banks, "RUN::config"); |
| 57 | |||
| 58 | // create the output bank | ||
| 59 |
1/4✓ Branch 132 → 133 taken 8 times.
✗ Branch 132 → 272 not taken.
✗ Branch 288 → 289 not taken.
✗ Branch 288 → 291 not taken.
|
8 | auto result_schema = CreateBank(banks, b_result, GetClassName()); |
| 60 |
1/2✓ Branch 138 → 139 taken 8 times.
✗ Branch 138 → 286 not taken.
|
8 | i_pindex = result_schema.getEntryOrder("pindex"); |
| 61 |
1/2✓ Branch 139 → 140 taken 8 times.
✗ Branch 139 → 286 not taken.
|
8 | i_Q2 = result_schema.getEntryOrder("Q2"); |
| 62 |
1/2✓ Branch 140 → 141 taken 8 times.
✗ Branch 140 → 286 not taken.
|
8 | i_x = result_schema.getEntryOrder("x"); |
| 63 |
1/2✓ Branch 141 → 142 taken 8 times.
✗ Branch 141 → 286 not taken.
|
8 | i_y = result_schema.getEntryOrder("y"); |
| 64 |
1/2✓ Branch 142 → 143 taken 8 times.
✗ Branch 142 → 286 not taken.
|
8 | i_W = result_schema.getEntryOrder("W"); |
| 65 |
1/2✓ Branch 143 → 144 taken 8 times.
✗ Branch 143 → 286 not taken.
|
8 | i_nu = result_schema.getEntryOrder("nu"); |
| 66 |
1/2✓ Branch 144 → 145 taken 8 times.
✗ Branch 144 → 286 not taken.
|
8 | i_qx = result_schema.getEntryOrder("qx"); |
| 67 |
1/2✓ Branch 145 → 146 taken 8 times.
✗ Branch 145 → 286 not taken.
|
8 | i_qy = result_schema.getEntryOrder("qy"); |
| 68 |
1/2✓ Branch 146 → 147 taken 8 times.
✗ Branch 146 → 286 not taken.
|
8 | i_qz = result_schema.getEntryOrder("qz"); |
| 69 |
1/2✓ Branch 147 → 148 taken 8 times.
✗ Branch 147 → 286 not taken.
|
8 | i_qE = result_schema.getEntryOrder("qE"); |
| 70 |
1/2✓ Branch 148 → 149 taken 8 times.
✗ Branch 148 → 286 not taken.
|
8 | i_beamPz = result_schema.getEntryOrder("beamPz"); |
| 71 |
1/2✓ Branch 149 → 150 taken 8 times.
✗ Branch 149 → 286 not taken.
|
8 | i_targetM = result_schema.getEntryOrder("targetM"); |
| 72 | |||
| 73 | // instantiate RCDB reader `m_rcdb` | ||
| 74 |
1/2✓ Branch 150 → 151 taken 8 times.
✗ Branch 150 → 286 not taken.
|
8 | StartRCDBReader(); |
| 75 |
4/8✓ Branch 151 → 152 taken 8 times.
✗ Branch 151 → 286 not taken.
✓ Branch 153 → 154 taken 8 times.
✗ Branch 153 → 284 not taken.
✓ Branch 154 → 155 taken 8 times.
✗ Branch 154 → 278 not taken.
✗ Branch 155 → 156 not taken.
✓ Branch 155 → 158 taken 8 times.
|
24 | o_override_beam_energy = GetOptionScalar<double>("override_beam_energy"); |
| 76 |
1/2✗ Branch 161 → 162 not taken.
✓ Branch 161 → 163 taken 8 times.
|
8 | if(o_override_beam_energy > 0) |
| 77 | ✗ | m_rcdb->SetBeamEnergyOverride(o_override_beam_energy); | |
| 78 |
0/6✗ Branch 202 → 203 not taken.
✗ Branch 202 → 205 not taken.
✗ Branch 228 → 229 not taken.
✗ Branch 228 → 231 not taken.
✗ Branch 254 → 255 not taken.
✗ Branch 254 → 257 not taken.
|
16 | } |
| 79 | |||
| 80 | /////////////////////////////////////////////////////////////////////////////// | ||
| 81 | |||
| 82 | 8000 | bool InclusiveKinematics::Run(hipo::banklist& banks) const | |
| 83 | { | ||
| 84 |
1/2✓ Branch 7 → 8 taken 8000 times.
✗ Branch 7 → 19 not taken.
|
16000 | return Run( |
| 85 |
1/2✓ Branch 6 → 7 taken 8000 times.
✗ Branch 6 → 19 not taken.
|
8000 | GetBank(banks, b_particle, o_particle_bank), |
| 86 |
3/8✓ Branch 4 → 5 taken 8000 times.
✗ Branch 4 → 25 not taken.
✓ Branch 5 → 6 taken 8000 times.
✗ Branch 5 → 19 not taken.
✗ Branch 13 → 14 not taken.
✓ Branch 13 → 16 taken 8000 times.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 28 not taken.
|
16000 | GetBank(banks, b_config, "RUN::config"), |
| 87 |
1/2✓ Branch 3 → 4 taken 8000 times.
✗ Branch 3 → 25 not taken.
|
16000 | GetBank(banks, b_result, GetClassName())); |
| 88 | } | ||
| 89 | |||
| 90 | 8000 | bool InclusiveKinematics::Run( | |
| 91 | hipo::bank const& particle_bank, | ||
| 92 | hipo::bank const& config_bank, | ||
| 93 | hipo::bank& result_bank) const | ||
| 94 | { | ||
| 95 | 8000 | result_bank.reset(); // IMPORTANT: always first `reset` the created bank(s) | |
| 96 |
1/2✓ Branch 6 → 7 taken 8000 times.
✗ Branch 6 → 54 not taken.
|
16000 | ShowBank(particle_bank, Logger::Header("INPUT PARTICLES")); |
| 97 | |||
| 98 | 8000 | auto key = PrepareEvent(config_bank.getInt("run", 0)); | |
| 99 | |||
| 100 | 8000 | auto lepton_pindex = FindScatteredLepton(particle_bank, key); | |
| 101 |
2/2✓ Branch 15 → 16 taken 6856 times.
✓ Branch 15 → 26 taken 1144 times.
|
8000 | if(lepton_pindex < 0) { |
| 102 |
1/2✓ Branch 19 → 20 taken 6856 times.
✗ Branch 19 → 60 not taken.
|
13712 | ShowBank(result_bank, Logger::Header("CREATED BANK IS EMPTY")); |
| 103 | 6856 | return false; | |
| 104 | } | ||
| 105 | |||
| 106 | 1144 | auto result_vars = ComputeFromLepton( | |
| 107 | 1144 | particle_bank.getFloat("px", lepton_pindex), | |
| 108 | 1144 | particle_bank.getFloat("py", lepton_pindex), | |
| 109 | 1144 | particle_bank.getFloat("pz", lepton_pindex), | |
| 110 | key); | ||
| 111 | result_vars.pindex = lepton_pindex; // FIXME: should be done in `ComputeFromLepton`, but need a proper action function first... | ||
| 112 | |||
| 113 | 1144 | result_bank.setRows(1); | |
| 114 | 1144 | result_bank.putShort(i_pindex, 0, static_cast<int16_t>(result_vars.pindex)); | |
| 115 | 1144 | result_bank.putDouble(i_Q2, 0, result_vars.Q2); | |
| 116 | 1144 | result_bank.putDouble(i_x, 0, result_vars.x); | |
| 117 | 1144 | result_bank.putDouble(i_y, 0, result_vars.y); | |
| 118 | 1144 | result_bank.putDouble(i_W, 0, result_vars.W); | |
| 119 | 1144 | result_bank.putDouble(i_nu, 0, result_vars.nu); | |
| 120 | 1144 | result_bank.putDouble(i_qx, 0, result_vars.qx); | |
| 121 | 1144 | result_bank.putDouble(i_qy, 0, result_vars.qy); | |
| 122 | 1144 | result_bank.putDouble(i_qz, 0, result_vars.qz); | |
| 123 | 1144 | result_bank.putDouble(i_qE, 0, result_vars.qE); | |
| 124 | 1144 | result_bank.putDouble(i_beamPz, 0, result_vars.beamPz); | |
| 125 | 1144 | result_bank.putDouble(i_targetM, 0, result_vars.targetM); | |
| 126 | |||
| 127 |
1/2✓ Branch 46 → 47 taken 1144 times.
✗ Branch 46 → 66 not taken.
|
2288 | ShowBank(result_bank, Logger::Header("CREATED BANK")); |
| 128 | 1144 | return true; | |
| 129 | } | ||
| 130 | |||
| 131 | /////////////////////////////////////////////////////////////////////////////// | ||
| 132 | |||
| 133 | 8000 | int InclusiveKinematics::FindScatteredLepton(hipo::bank const& particle_bank, concurrent_key_t const key) const | |
| 134 | { | ||
| 135 | int const not_found = -1; | ||
| 136 | bool lepton_found = false; | ||
| 137 | int lepton_row = not_found; | ||
| 138 | double lepton_energy = 0; | ||
| 139 | |||
| 140 |
1/2✓ Branch 2 → 14 taken 8000 times.
✗ Branch 2 → 33 not taken.
|
8000 | switch(o_method_lepton_finder) { |
| 141 | case method_lepton_finder::highest_energy_FD_trigger: { | ||
| 142 | |||
| 143 | // loop over ALL rows, not just filtered rows, since we don't want to accidentally pick the wrong electron | ||
| 144 |
2/2✓ Branch 14 → 3 taken 55944 times.
✓ Branch 14 → 15 taken 8000 times.
|
63944 | for(int row = 0; row < particle_bank.getRows(); row++) { |
| 145 |
2/2✓ Branch 4 → 5 taken 50832 times.
✓ Branch 4 → 6 taken 5112 times.
|
55944 | if(particle_bank.getInt("pid", row) == o_beam_pdg) { // if beam PDG |
| 146 | 5112 | auto status = particle_bank.getShort("status", row); | |
| 147 |
2/2✓ Branch 7 → 5 taken 3968 times.
✓ Branch 7 → 8 taken 1144 times.
|
5112 | if(status > -3000 && status <= -2000) { // if in FD trigger |
| 148 | 1144 | m_log->Trace("row {} status {} is in FD trigger", row, status); | |
| 149 | 1144 | double en = std::sqrt( | |
| 150 | 1144 | std::pow(particle_bank.getFloat("px", row), 2) + | |
| 151 | 1144 | std::pow(particle_bank.getFloat("py", row), 2) + | |
| 152 | 1144 | std::pow(particle_bank.getFloat("pz", row), 2) + | |
| 153 | 1144 | std::pow(o_beam_mass, 2)); | |
| 154 |
1/2✗ Branch 12 → 5 not taken.
✓ Branch 12 → 13 taken 1144 times.
|
1144 | if(en > lepton_energy) { // select max-E |
| 155 | lepton_found = true; | ||
| 156 | lepton_row = row; | ||
| 157 | lepton_energy = en; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
| 162 |
2/2✓ Branch 15 → 16 taken 1144 times.
✓ Branch 15 → 33 taken 6856 times.
|
8000 | if(lepton_found) { |
| 163 |
1/2✗ Branch 16 → 17 not taken.
✓ Branch 16 → 19 taken 1144 times.
|
1144 | if(lepton_row != 0) |
| 164 | ✗ | m_log->Warn("Found scattered lepton which is NOT at pindex 0"); | |
| 165 | // make sure `lepton_row` was not filtered | ||
| 166 |
2/4✓ Branch 19 → 20 taken 1144 times.
✗ Branch 19 → 36 not taken.
✓ Branch 20 → 21 taken 1144 times.
✗ Branch 20 → 36 not taken.
|
1144 | auto rowlist = particle_bank.getRowList(); |
| 167 |
1/2✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 1144 times.
|
1144 | if(std::find(rowlist.begin(), rowlist.end(), lepton_row) == rowlist.end()) |
| 168 | lepton_found = false; | ||
| 169 | } | ||
| 170 | break; | ||
| 171 | } | ||
| 172 | } | ||
| 173 |
1/2✓ Branch 30 → 31 taken 1144 times.
✗ Branch 30 → 33 not taken.
|
1144 | if(lepton_found) { |
| 174 | 1144 | m_log->Debug("Found scattered lepton: row={}, energy={}", lepton_row, lepton_energy); | |
| 175 | 1144 | return lepton_row; | |
| 176 | } | ||
| 177 | else { | ||
| 178 | 6856 | m_log->Debug("Scattered lepton not found"); | |
| 179 | 6856 | return not_found; | |
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | /////////////////////////////////////////////////////////////////////////////// | ||
| 184 | |||
| 185 | 8000 | concurrent_key_t InclusiveKinematics::PrepareEvent(int const runnum, double const beam_energy) const | |
| 186 | { | ||
| 187 |
2/2✓ Branch 3 → 4 taken 4000 times.
✓ Branch 3 → 8 taken 4000 times.
|
8000 | m_log->Trace("calling PrepareEvent({})", runnum); |
| 188 |
2/2✓ Branch 3 → 4 taken 4000 times.
✓ Branch 3 → 8 taken 4000 times.
|
8000 | if(o_runnum->NeedsHashing()) { |
| 189 | std::hash<int> hash_ftn; | ||
| 190 | auto hash_key = hash_ftn(runnum); | ||
| 191 |
2/2✓ Branch 5 → 6 taken 4 times.
✓ Branch 5 → 7 taken 3996 times.
|
4000 | if(!o_runnum->HasKey(hash_key)) |
| 192 | 4 | Reload(runnum, beam_energy, hash_key); | |
| 193 | return hash_key; | ||
| 194 | } | ||
| 195 | else { | ||
| 196 |
3/4✓ Branch 8 → 9 taken 3996 times.
✓ Branch 8 → 11 taken 4 times.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 12 taken 3996 times.
|
4000 | if(o_runnum->IsEmpty() || o_runnum->Load(0) != runnum) |
| 197 | 4 | Reload(runnum, beam_energy, 0); | |
| 198 | 4000 | return 0; | |
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | /////////////////////////////////////////////////////////////////////////////// | ||
| 203 | |||
| 204 | 8 | void InclusiveKinematics::Reload(int const runnum, double const user_beam_energy, concurrent_key_t key) const | |
| 205 | { | ||
| 206 | 8 | std::lock_guard<std::mutex> const lock(m_mutex); | |
| 207 |
2/4✓ Branch 3 → 4 taken 8 times.
✗ Branch 3 → 202 not taken.
✓ Branch 4 → 5 taken 8 times.
✗ Branch 4 → 202 not taken.
|
8 | m_log->Trace("-> calling Reload({}, {}, {})", runnum, user_beam_energy, key); |
| 208 |
1/2✓ Branch 4 → 5 taken 8 times.
✗ Branch 4 → 202 not taken.
|
8 | o_runnum->Save(runnum, key); |
| 209 | |||
| 210 | // parse config params | ||
| 211 |
2/4✓ Branch 5 → 6 taken 8 times.
✗ Branch 5 → 7 not taken.
✓ Branch 6 → 7 taken 8 times.
✗ Branch 6 → 202 not taken.
|
8 | auto beam_energy = user_beam_energy < 0 ? m_rcdb->GetBeamEnergy(runnum) : user_beam_energy; |
| 212 |
10/20✓ Branch 7 → 8 taken 8 times.
✗ Branch 7 → 142 not taken.
✓ Branch 8 → 9 taken 8 times.
✗ Branch 8 → 142 not taken.
✓ Branch 9 → 10 taken 8 times.
✗ Branch 9 → 142 not taken.
✓ Branch 10 → 11 taken 8 times.
✗ Branch 10 → 136 not taken.
✓ Branch 14 → 15 taken 8 times.
✗ Branch 14 → 128 not taken.
✓ Branch 15 → 16 taken 8 times.
✗ Branch 15 → 126 not taken.
✓ Branch 16 → 17 taken 8 times.
✗ Branch 16 → 120 not taken.
✓ Branch 24 → 25 taken 24 times.
✓ Branch 24 → 27 taken 8 times.
✓ Branch 34 → 35 taken 8 times.
✗ Branch 34 → 169 not taken.
✗ Branch 129 → 130 not taken.
✗ Branch 129 → 132 not taken.
|
56 | auto beam_direction = GetOptionVector<double>("beam_direction", {"initial_state", GetConfig()->InRange("runs", runnum), "beam_direction"}); |
| 213 |
8/18✓ Branch 35 → 36 taken 8 times.
✗ Branch 35 → 169 not taken.
✓ Branch 36 → 37 taken 8 times.
✗ Branch 36 → 169 not taken.
✓ Branch 37 → 38 taken 8 times.
✗ Branch 37 → 163 not taken.
✓ Branch 41 → 42 taken 8 times.
✗ Branch 41 → 155 not taken.
✓ Branch 42 → 43 taken 8 times.
✗ Branch 42 → 153 not taken.
✓ Branch 43 → 44 taken 8 times.
✗ Branch 43 → 147 not taken.
✓ Branch 51 → 52 taken 24 times.
✓ Branch 51 → 54 taken 8 times.
✗ Branch 156 → 157 not taken.
✗ Branch 156 → 159 not taken.
✗ Branch 198 → 199 not taken.
✗ Branch 198 → 201 not taken.
|
56 | auto target_particle = GetOptionScalar<std::string>("target_particle", {"initial_state", GetConfig()->InRange("runs", runnum), "target_particle"}); |
| 214 | |||
| 215 | // get the target mass and momentum | ||
| 216 | double target_mass = -1; | ||
| 217 |
1/2✓ Branch 66 → 62 taken 56 times.
✗ Branch 66 → 67 not taken.
|
56 | for(auto const& [pdg, name] : particle::name) { |
| 218 |
2/2✓ Branch 62 → 63 taken 8 times.
✓ Branch 62 → 65 taken 48 times.
|
56 | if(name == target_particle) { |
| 219 | 8 | target_mass = particle::mass.at(pdg); | |
| 220 | 8 | break; | |
| 221 | } | ||
| 222 | } | ||
| 223 |
1/2✗ Branch 67 → 68 not taken.
✓ Branch 67 → 81 taken 8 times.
|
8 | if(target_mass < 0) { |
| 224 | ✗ | m_log->Error("Unknown target particle {:?}", target_particle); | |
| 225 | ✗ | throw std::runtime_error("Reload failed"); | |
| 226 | } | ||
| 227 | double target_px = 0.0; | ||
| 228 | double target_py = 0.0; | ||
| 229 | double target_pz = 0.0; | ||
| 230 | |||
| 231 | // get the beam momentum | ||
| 232 | double beam_px, beam_py, beam_pz; | ||
| 233 |
1/2✗ Branch 83 → 84 not taken.
✓ Branch 83 → 88 taken 8 times.
|
8 | if(beam_direction.size() != 3) { |
| 234 | ✗ | m_log->Error("Beam direction is not a 3-vector; assuming it is (0, 0, 1) instead"); | |
| 235 | ✗ | beam_direction = {0.0, 0.0, 1.0}; | |
| 236 | } | ||
| 237 | 8 | auto dir_mag = std::hypot(beam_direction[0], beam_direction[1], beam_direction[2]); | |
| 238 | 8 | auto beam_p = std::sqrt(std::pow(beam_energy, 2) - std::pow(o_beam_mass, 2)); | |
| 239 |
1/2✓ Branch 93 → 94 taken 8 times.
✗ Branch 93 → 96 not taken.
|
8 | if(dir_mag > 0) { |
| 240 | 8 | beam_px = beam_direction[0] * beam_p / dir_mag; | |
| 241 | 8 | beam_py = beam_direction[1] * beam_p / dir_mag; | |
| 242 |
1/2✓ Branch 94 → 95 taken 8 times.
✗ Branch 94 → 192 not taken.
|
8 | beam_pz = beam_direction[2] * beam_p / dir_mag; |
| 243 | } | ||
| 244 | else { | ||
| 245 | ✗ | m_log->Error("Beam direction magnitude is not > 0"); | |
| 246 | ✗ | throw ::std::runtime_error("Reload failed"); | |
| 247 | } | ||
| 248 | |||
| 249 | // save the configuration | ||
| 250 |
1/2✓ Branch 95 → 100 taken 8 times.
✗ Branch 95 → 192 not taken.
|
8 | m_log->Trace("-> Reloaded beam: ({}, {}, {}, {})", beam_px, beam_py, beam_pz, o_beam_mass); |
| 251 |
1/2✓ Branch 100 → 101 taken 8 times.
✗ Branch 100 → 192 not taken.
|
8 | m_log->Trace("-> Reloaded target: ({}, {}, {}, {})", target_px, target_py, target_pz, target_mass); |
| 252 |
3/6✓ Branch 100 → 101 taken 8 times.
✗ Branch 100 → 192 not taken.
✓ Branch 101 → 102 taken 8 times.
✗ Branch 101 → 184 not taken.
✓ Branch 105 → 106 taken 8 times.
✗ Branch 105 → 192 not taken.
|
16 | o_beam_PxPyPzM->Save({beam_px, beam_py, beam_pz, o_beam_mass}, key); |
| 253 |
3/8✓ Branch 105 → 106 taken 8 times.
✗ Branch 105 → 192 not taken.
✓ Branch 106 → 107 taken 8 times.
✗ Branch 106 → 188 not taken.
✓ Branch 110 → 111 taken 8 times.
✗ Branch 110 → 113 not taken.
✗ Branch 192 → 193 not taken.
✗ Branch 192 → 195 not taken.
|
16 | o_target_PxPyPzM->Save({target_px, target_py, target_pz, target_mass}, key); |
| 254 |
0/4✗ Branch 143 → 144 not taken.
✗ Branch 143 → 146 not taken.
✗ Branch 170 → 171 not taken.
✗ Branch 170 → 173 not taken.
|
8 | } |
| 255 | |||
| 256 | /////////////////////////////////////////////////////////////////////////////// | ||
| 257 | |||
| 258 | 1144 | InclusiveKinematicsVars InclusiveKinematics::ComputeFromLepton( | |
| 259 | vector_element_t const lepton_px, | ||
| 260 | vector_element_t const lepton_py, | ||
| 261 | vector_element_t const lepton_pz, | ||
| 262 | concurrent_key_t const key) const | ||
| 263 | { | ||
| 264 | 1144 | InclusiveKinematicsVars result; | |
| 265 | |||
| 266 | 1144 | m_log->Trace("Reconstruct inclusive kinematics from lepton with p=({}, {}, {}), key={}", lepton_px, lepton_py, lepton_pz, key); | |
| 267 | |||
| 268 | enum { px, | ||
| 269 | py, | ||
| 270 | pz, | ||
| 271 | m }; | ||
| 272 | 1144 | auto beam = o_beam_PxPyPzM->Load(key); | |
| 273 |
1/2✓ Branch 4 → 5 taken 1144 times.
✗ Branch 4 → 57 not taken.
|
1144 | auto target = o_target_PxPyPzM->Load(key); |
| 274 | |||
| 275 | ROOT::Math::PxPyPzMVector vec_beam(beam[px], beam[py], beam[pz], beam[m]); | ||
| 276 | ROOT::Math::PxPyPzMVector vec_target(target[px], target[py], target[pz], target[m]); | ||
| 277 | ROOT::Math::PxPyPzMVector vec_lepton(lepton_px, lepton_py, lepton_pz, beam[m]); | ||
| 278 | |||
| 279 | auto vec_q = vec_beam - vec_lepton; | ||
| 280 | 1144 | result.qx = vec_q.Px(); | |
| 281 | 1144 | result.qy = vec_q.Py(); | |
| 282 | 1144 | result.qz = vec_q.Pz(); | |
| 283 |
1/2✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 1144 times.
|
1144 | result.qE = vec_q.E(); |
| 284 | 1144 | result.Q2 = -1 * vec_q.M2(); | |
| 285 | 1144 | result.x = result.Q2 / (2 * vec_q.Dot(vec_target)); | |
| 286 |
1/2✓ Branch 32 → 33 taken 1144 times.
✗ Branch 32 → 53 not taken.
|
1144 | result.y = vec_target.Dot(vec_q) / vec_target.Dot(vec_beam); |
| 287 | ✗ | result.W = (vec_beam + vec_target - vec_lepton).M(); | |
| 288 |
1/2✗ Branch 41 → 42 not taken.
✓ Branch 41 → 43 taken 1144 times.
|
2288 | result.nu = vec_target.Dot(vec_q) / target[m]; |
| 289 | 1144 | result.beamPz = beam[pz]; | |
| 290 |
1/2✓ Branch 45 → 46 taken 1144 times.
✗ Branch 45 → 53 not taken.
|
1144 | result.targetM = target[m]; |
| 291 | |||
| 292 |
1/2✓ Branch 46 → 47 taken 1144 times.
✗ Branch 46 → 49 not taken.
|
1144 | m_log->Trace("Result: Q2={} x={} W={}", result.Q2, result.x, result.W); |
| 293 | |||
| 294 | 1144 | return result; | |
| 295 | } | ||
| 296 | |||
| 297 | /////////////////////////////////////////////////////////////////////////////// | ||
| 298 | |||
| 299 | 4 | void InclusiveKinematics::Stop() | |
| 300 | { | ||
| 301 | 4 | } | |
| 302 | |||
| 303 | } | ||
| 304 |