| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Algorithm.h" | ||
| 2 | #include "iguana/algorithms/TypeDefs.h" | ||
| 3 | |||
| 4 | namespace iguana::clas12 { | ||
| 5 | |||
| 6 | REGISTER_IGUANA_ALGORITHM(TrajLinker, "REC::Particle::Traj"); | ||
| 7 | |||
| 8 | 3 | void TrajLinker::Start(hipo::banklist& banks) | |
| 9 | { | ||
| 10 |
2/4✓ Branch 3 → 4 taken 3 times.
✗ Branch 3 → 39 not taken.
✓ Branch 4 → 5 taken 3 times.
✗ Branch 4 → 7 not taken.
|
3 | b_particle = GetBankIndex(banks, "REC::Particle"); |
| 11 |
2/4✓ Branch 10 → 11 taken 3 times.
✗ Branch 10 → 45 not taken.
✓ Branch 11 → 12 taken 3 times.
✗ Branch 11 → 14 not taken.
|
3 | b_traj = GetBankIndex(banks, "REC::Traj"); |
| 12 |
1/2✓ Branch 17 → 18 taken 3 times.
✗ Branch 17 → 51 not taken.
|
3 | auto result_schema = CreateBank(banks, b_result, "REC::Particle::Traj"); |
| 13 |
1/2✓ Branch 23 → 24 taken 3 times.
✗ Branch 23 → 57 not taken.
|
3 | i_pindex = result_schema.getEntryOrder("pindex"); |
| 14 |
1/2✓ Branch 24 → 25 taken 3 times.
✗ Branch 24 → 57 not taken.
|
3 | i_sector = result_schema.getEntryOrder("sector"); |
| 15 |
1/2✓ Branch 25 → 26 taken 3 times.
✗ Branch 25 → 57 not taken.
|
3 | i_r1_found = result_schema.getEntryOrder("r1_found"); |
| 16 |
1/2✓ Branch 26 → 27 taken 3 times.
✗ Branch 26 → 57 not taken.
|
3 | i_r1_x = result_schema.getEntryOrder("r1_x"); |
| 17 |
1/2✓ Branch 27 → 28 taken 3 times.
✗ Branch 27 → 57 not taken.
|
3 | i_r1_y = result_schema.getEntryOrder("r1_y"); |
| 18 |
1/2✓ Branch 28 → 29 taken 3 times.
✗ Branch 28 → 57 not taken.
|
3 | i_r1_z = result_schema.getEntryOrder("r1_z"); |
| 19 |
1/2✓ Branch 29 → 30 taken 3 times.
✗ Branch 29 → 57 not taken.
|
3 | i_r2_found = result_schema.getEntryOrder("r2_found"); |
| 20 |
1/2✓ Branch 30 → 31 taken 3 times.
✗ Branch 30 → 57 not taken.
|
3 | i_r2_x = result_schema.getEntryOrder("r2_x"); |
| 21 |
1/2✓ Branch 31 → 32 taken 3 times.
✗ Branch 31 → 57 not taken.
|
3 | i_r2_y = result_schema.getEntryOrder("r2_y"); |
| 22 |
1/2✓ Branch 32 → 33 taken 3 times.
✗ Branch 32 → 57 not taken.
|
3 | i_r2_z = result_schema.getEntryOrder("r2_z"); |
| 23 |
1/2✓ Branch 33 → 34 taken 3 times.
✗ Branch 33 → 57 not taken.
|
3 | i_r3_found = result_schema.getEntryOrder("r3_found"); |
| 24 |
1/2✓ Branch 34 → 35 taken 3 times.
✗ Branch 34 → 57 not taken.
|
3 | i_r3_x = result_schema.getEntryOrder("r3_x"); |
| 25 |
1/2✓ Branch 35 → 36 taken 3 times.
✗ Branch 35 → 57 not taken.
|
3 | i_r3_y = result_schema.getEntryOrder("r3_y"); |
| 26 |
1/2✓ Branch 36 → 37 taken 3 times.
✗ Branch 36 → 57 not taken.
|
3 | i_r3_z = result_schema.getEntryOrder("r3_z"); |
| 27 | 3 | } | |
| 28 | |||
| 29 | 3000 | bool TrajLinker::Run(hipo::banklist& banks) const | |
| 30 | { | ||
| 31 |
1/2✓ Branch 8 → 9 taken 3000 times.
✗ Branch 8 → 25 not taken.
|
3000 | return Run( |
| 32 |
3/8✓ Branch 6 → 7 taken 3000 times.
✗ Branch 6 → 31 not taken.
✓ Branch 7 → 8 taken 3000 times.
✗ Branch 7 → 25 not taken.
✓ Branch 14 → 15 taken 3000 times.
✗ Branch 14 → 17 not taken.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 34 not taken.
|
6000 | GetBank(banks, b_particle, "REC::Particle"), |
| 33 |
3/8✓ Branch 4 → 5 taken 3000 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 3000 times.
✗ Branch 5 → 31 not taken.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 22 taken 3000 times.
✗ Branch 37 → 38 not taken.
✗ Branch 37 → 40 not taken.
|
6000 | GetBank(banks, b_traj, "REC::Traj"), |
| 34 |
1/2✓ Branch 3 → 4 taken 3000 times.
✗ Branch 3 → 37 not taken.
|
6000 | GetBank(banks, b_result, "REC::Particle::Traj")); |
| 35 | } | ||
| 36 | |||
| 37 | 3000 | bool TrajLinker::Run( | |
| 38 | hipo::bank const& bank_particle, | ||
| 39 | hipo::bank const& bank_traj, | ||
| 40 | hipo::bank& bank_result) const | ||
| 41 | { | ||
| 42 | 3000 | bank_result.reset(); // IMPORTANT: always first `reset` the created bank(s) | |
| 43 |
1/2✓ Branch 6 → 7 taken 3000 times.
✗ Branch 6 → 93 not taken.
|
6000 | ShowBank(bank_particle, Logger::Header("INPUT PARTICLE BANK")); |
| 44 |
1/2✓ Branch 15 → 16 taken 3000 times.
✗ Branch 15 → 99 not taken.
|
9000 | ShowBank(bank_traj, Logger::Header("INPUT TRAJECTORY BANK")); |
| 45 | |||
| 46 | // sync new bank with particle bank, and fill it with zeroes | ||
| 47 | 3000 | bank_result.setRows(bank_particle.getRows()); | |
| 48 | 3000 | bank_result.getMutableRowList().setList(bank_particle.getRowList()); | |
| 49 |
2/2✓ Branch 40 → 25 taken 20979 times.
✓ Branch 40 → 41 taken 3000 times.
|
23979 | for(int row = 0; row < bank_result.getRows(); row++) { |
| 50 | 20979 | bank_result.putShort(i_pindex, row, static_cast<int16_t>(row)); | |
| 51 | 20979 | bank_result.putInt(i_sector, row, 0); | |
| 52 | 20979 | bank_result.putByte(i_r1_found, row, 0); | |
| 53 | 20979 | bank_result.putFloat(i_r1_x, row, 0); | |
| 54 | 20979 | bank_result.putFloat(i_r1_y, row, 0); | |
| 55 | 20979 | bank_result.putFloat(i_r1_z, row, 0); | |
| 56 | 20979 | bank_result.putByte(i_r2_found, row, 0); | |
| 57 | 20979 | bank_result.putFloat(i_r2_x, row, 0); | |
| 58 | 20979 | bank_result.putFloat(i_r2_y, row, 0); | |
| 59 | 20979 | bank_result.putFloat(i_r2_z, row, 0); | |
| 60 | 20979 | bank_result.putByte(i_r3_found, row, 0); | |
| 61 | 20979 | bank_result.putFloat(i_r3_x, row, 0); | |
| 62 | 20979 | bank_result.putFloat(i_r3_y, row, 0); | |
| 63 | 20979 | bank_result.putFloat(i_r3_z, row, 0); | |
| 64 | } | ||
| 65 | |||
| 66 | // map particle `pindex` -> `TrajLinkerVars` object | ||
| 67 | std::map<int, TrajLinkerVars> link_map; | ||
| 68 | |||
| 69 | // loop over particle rows | ||
| 70 |
3/4✓ Branch 41 → 42 taken 3000 times.
✗ Branch 41 → 111 not taken.
✓ Branch 81 → 43 taken 16312 times.
✓ Branch 81 → 82 taken 3000 times.
|
19312 | for(auto const& row_particle : bank_particle.getRowList()) { |
| 71 | // create new `TrajLinkerVars` object for this particle | ||
| 72 |
1/2✓ Branch 43 → 44 taken 16312 times.
✗ Branch 43 → 111 not taken.
|
16312 | auto& link_particle = link_map[row_particle]; |
| 73 | // loop over `REC::Traj` rows, setting elements of linked `TrajLinkerVars` | ||
| 74 |
3/4✓ Branch 44 → 45 taken 16312 times.
✗ Branch 44 → 111 not taken.
✓ Branch 66 → 46 taken 731743 times.
✓ Branch 66 → 67 taken 16312 times.
|
748055 | for(auto const& row_traj : bank_traj.getRowList()) { |
| 75 |
2/2✓ Branch 47 → 48 taken 103712 times.
✓ Branch 47 → 65 taken 628031 times.
|
731743 | if(row_particle == bank_traj.getShort("pindex", row_traj)) { |
| 76 |
2/2✓ Branch 49 → 50 taken 15735 times.
✓ Branch 49 → 65 taken 87977 times.
|
103712 | if(bank_traj.getByte("detector", row_traj) == DetectorType::DC) { // only apply to DC |
| 77 |
3/4✓ Branch 51 → 52 taken 5245 times.
✓ Branch 51 → 56 taken 5245 times.
✓ Branch 51 → 61 taken 5245 times.
✗ Branch 51 → 65 not taken.
|
15735 | switch(bank_traj.getInt("layer", row_traj)) { |
| 78 | 5245 | case 6: // region 1 | |
| 79 | 5245 | link_particle.r1_found = 1; | |
| 80 | 5245 | link_particle.r1_x = bank_traj.getFloat("x", row_traj); | |
| 81 | 5245 | link_particle.r1_y = bank_traj.getFloat("y", row_traj); | |
| 82 | 5245 | link_particle.r1_z = bank_traj.getFloat("z", row_traj); | |
| 83 | 5245 | break; | |
| 84 | 5245 | case 18: // region 2 | |
| 85 | 5245 | link_particle.r2_found = 1; | |
| 86 | 5245 | link_particle.r2_x = bank_traj.getFloat("x", row_traj); | |
| 87 | 5245 | link_particle.r2_y = bank_traj.getFloat("y", row_traj); | |
| 88 | 5245 | link_particle.r2_z = bank_traj.getFloat("z", row_traj); | |
| 89 | // Determine Sector from the center of the DC | ||
| 90 |
1/2✓ Branch 59 → 60 taken 5245 times.
✗ Branch 59 → 111 not taken.
|
5245 | link_particle.sector = GetSector(link_particle.r2_x, link_particle.r2_y, link_particle.r2_z); |
| 91 | 5245 | break; | |
| 92 | 5245 | case 36: // region 3 | |
| 93 | 5245 | link_particle.r3_found = 1; | |
| 94 | 5245 | link_particle.r3_x = bank_traj.getFloat("x", row_traj); | |
| 95 | 5245 | link_particle.r3_y = bank_traj.getFloat("y", row_traj); | |
| 96 | 5245 | link_particle.r3_z = bank_traj.getFloat("z", row_traj); | |
| 97 | 5245 | break; | |
| 98 | } | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
| 102 | // fill output bank | ||
| 103 | 16312 | bank_result.putInt(i_sector, row_particle, link_particle.sector); | |
| 104 | 16312 | bank_result.putByte(i_r1_found, row_particle, link_particle.r1_found); | |
| 105 | 16312 | bank_result.putFloat(i_r1_x, row_particle, link_particle.r1_x); | |
| 106 | 16312 | bank_result.putFloat(i_r1_y, row_particle, link_particle.r1_y); | |
| 107 | 16312 | bank_result.putFloat(i_r1_z, row_particle, link_particle.r1_z); | |
| 108 | 16312 | bank_result.putByte(i_r2_found, row_particle, link_particle.r2_found); | |
| 109 | 16312 | bank_result.putFloat(i_r2_x, row_particle, link_particle.r2_x); | |
| 110 | 16312 | bank_result.putFloat(i_r2_y, row_particle, link_particle.r2_y); | |
| 111 | 16312 | bank_result.putFloat(i_r2_z, row_particle, link_particle.r2_z); | |
| 112 | 16312 | bank_result.putByte(i_r3_found, row_particle, link_particle.r3_found); | |
| 113 | 16312 | bank_result.putFloat(i_r3_x, row_particle, link_particle.r3_x); | |
| 114 | 16312 | bank_result.putFloat(i_r3_y, row_particle, link_particle.r3_y); | |
| 115 | 16312 | bank_result.putFloat(i_r3_z, row_particle, link_particle.r3_z); | |
| 116 | } | ||
| 117 |
2/4✓ Branch 82 → 83 taken 3000 times.
✗ Branch 82 → 111 not taken.
✓ Branch 85 → 86 taken 3000 times.
✗ Branch 85 → 105 not taken.
|
9000 | ShowBank(bank_result, Logger::Header("CREATED BANK")); |
| 118 | 3000 | return true; | |
| 119 | } | ||
| 120 | |||
| 121 | 3 | void TrajLinker::Stop() | |
| 122 | { | ||
| 123 | 3 | } | |
| 124 | |||
| 125 | 5245 | int TrajLinker::GetSector(float const& x, float const& y, float const& z) const | |
| 126 | { | ||
| 127 | 5245 | float phi = 180 / M_PI * atan2(y / sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)), x / sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2))); | |
| 128 |
4/4✓ Branch 2 → 3 taken 3056 times.
✓ Branch 2 → 4 taken 2189 times.
✓ Branch 3 → 4 taken 2132 times.
✓ Branch 3 → 13 taken 924 times.
|
5245 | if(phi < 30 && phi >= -30) |
| 129 | return 1; | ||
| 130 |
4/4✓ Branch 4 → 5 taken 3023 times.
✓ Branch 4 → 6 taken 1298 times.
✓ Branch 5 → 6 taken 2132 times.
✓ Branch 5 → 13 taken 891 times.
|
4321 | else if(phi < 90 && phi >= 30) |
| 131 | return 2; | ||
| 132 |
4/4✓ Branch 6 → 7 taken 2999 times.
✓ Branch 6 → 8 taken 431 times.
✓ Branch 7 → 9 taken 2132 times.
✓ Branch 7 → 13 taken 867 times.
|
3430 | else if(phi < 150 && phi >= 90) |
| 133 | return 3; | ||
| 134 |
3/4✗ Branch 8 → 9 not taken.
✓ Branch 8 → 13 taken 431 times.
✓ Branch 9 → 10 taken 1733 times.
✓ Branch 9 → 13 taken 399 times.
|
2563 | else if(phi >= 150 || phi < -150) |
| 135 | return 4; | ||
| 136 |
2/2✓ Branch 10 → 11 taken 811 times.
✓ Branch 10 → 13 taken 922 times.
|
1733 | else if(phi < -90 && phi >= -150) |
| 137 | return 5; | ||
| 138 |
1/2✓ Branch 11 → 12 taken 811 times.
✗ Branch 11 → 13 not taken.
|
811 | else if(phi < -30 && phi >= -90) |
| 139 | 811 | return 6; | |
| 140 | return -1; | ||
| 141 | } | ||
| 142 | |||
| 143 | } | ||
| 144 |