| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Algorithm.h" | ||
| 2 | |||
| 3 | namespace iguana::physics { | ||
| 4 | |||
| 5 | REGISTER_IGUANA_ALGORITHM(Depolarization, "physics::Depolarization"); | ||
| 6 | |||
| 7 | 2 | void Depolarization::Start(hipo::banklist& banks) | |
| 8 | { | ||
| 9 |
2/4✓ Branch 3 → 4 taken 2 times.
✗ Branch 3 → 24 not taken.
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 7 taken 2 times.
|
4 | b_inc_kin = GetBankIndex(banks, "physics::InclusiveKinematics"); |
| 10 | |||
| 11 | // create the output bank | ||
| 12 |
1/2✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 30 not taken.
|
2 | auto result_schema = CreateBank(banks, b_result, GetClassName()); |
| 13 |
1/2✓ Branch 16 → 17 taken 2 times.
✗ Branch 16 → 36 not taken.
|
2 | i_epsilon = result_schema.getEntryOrder("epsilon"); |
| 14 |
1/2✓ Branch 17 → 18 taken 2 times.
✗ Branch 17 → 36 not taken.
|
2 | i_A = result_schema.getEntryOrder("A"); |
| 15 |
1/2✓ Branch 18 → 19 taken 2 times.
✗ Branch 18 → 36 not taken.
|
2 | i_B = result_schema.getEntryOrder("B"); |
| 16 |
1/2✓ Branch 19 → 20 taken 2 times.
✗ Branch 19 → 36 not taken.
|
2 | i_C = result_schema.getEntryOrder("C"); |
| 17 |
1/2✓ Branch 20 → 21 taken 2 times.
✗ Branch 20 → 36 not taken.
|
2 | i_V = result_schema.getEntryOrder("V"); |
| 18 |
1/2✓ Branch 21 → 22 taken 2 times.
✗ Branch 21 → 36 not taken.
|
2 | i_W = result_schema.getEntryOrder("W"); |
| 19 | 2 | } | |
| 20 | |||
| 21 | /////////////////////////////////////////////////////////////////////////////// | ||
| 22 | |||
| 23 | 286 | bool Depolarization::Run(hipo::banklist& banks) const | |
| 24 | { | ||
| 25 |
1/2✓ Branch 6 → 7 taken 286 times.
✗ Branch 6 → 18 not taken.
|
572 | return Run( |
| 26 |
3/8✓ Branch 4 → 5 taken 286 times.
✗ Branch 4 → 24 not taken.
✓ Branch 5 → 6 taken 286 times.
✗ Branch 5 → 18 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 15 taken 286 times.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 27 not taken.
|
572 | GetBank(banks, b_inc_kin, "physics::InclusiveKinematics"), |
| 27 |
1/2✓ Branch 3 → 4 taken 286 times.
✗ Branch 3 → 24 not taken.
|
572 | GetBank(banks, b_result, GetClassName())); |
| 28 | } | ||
| 29 | |||
| 30 | 286 | bool Depolarization::Run( | |
| 31 | hipo::bank const& inc_kin_bank, | ||
| 32 | hipo::bank& result_bank) const | ||
| 33 | { | ||
| 34 | 286 | result_bank.reset(); // IMPORTANT: always first `reset` the created bank(s) | |
| 35 |
1/2✓ Branch 6 → 7 taken 286 times.
✗ Branch 6 → 52 not taken.
|
572 | ShowBank(inc_kin_bank, Logger::Header("INPUT INCLUSIVE KINEMATICS")); |
| 36 | |||
| 37 | // set `result_bank` rows and rowlist to match those of `inc_kin_bank` | ||
| 38 | 286 | auto const& inc_kin_bank_rowlist = inc_kin_bank.getRowList(); | |
| 39 | 286 | result_bank.setRows(inc_kin_bank.getRows()); | |
| 40 | 286 | result_bank.getMutableRowList().setList(inc_kin_bank_rowlist); | |
| 41 | |||
| 42 | // loop over ALL `inc_kin_bank`'s rows; calculate depolarization for only the rows | ||
| 43 | // that are in its current rowlist, and zero the rest | ||
| 44 |
2/2✓ Branch 41 → 17 taken 286 times.
✓ Branch 41 → 42 taken 286 times.
|
572 | for(int row = 0; row < inc_kin_bank.getRows(); row++) { |
| 45 |
1/2✓ Branch 21 → 22 taken 286 times.
✗ Branch 21 → 34 not taken.
|
286 | if(std::find(inc_kin_bank_rowlist.begin(), inc_kin_bank_rowlist.end(), row) != inc_kin_bank_rowlist.end()) { |
| 46 | 286 | auto result_vars = Compute( | |
| 47 | inc_kin_bank.getDouble("Q2", row), | ||
| 48 | inc_kin_bank.getDouble("x", row), | ||
| 49 | inc_kin_bank.getDouble("y", row), | ||
| 50 | inc_kin_bank.getDouble("targetM", row)); | ||
| 51 | 286 | result_bank.putDouble(i_epsilon, row, result_vars.epsilon); | |
| 52 | 286 | result_bank.putDouble(i_A, row, result_vars.A); | |
| 53 | 286 | result_bank.putDouble(i_B, row, result_vars.B); | |
| 54 | 286 | result_bank.putDouble(i_C, row, result_vars.C); | |
| 55 | 286 | result_bank.putDouble(i_V, row, result_vars.V); | |
| 56 | 286 | result_bank.putDouble(i_W, row, result_vars.W); | |
| 57 | } | ||
| 58 | else { | ||
| 59 | ✗ | result_bank.putDouble(i_epsilon, row, 0); | |
| 60 | ✗ | result_bank.putDouble(i_A, row, 0); | |
| 61 | ✗ | result_bank.putDouble(i_B, row, 0); | |
| 62 | ✗ | result_bank.putDouble(i_C, row, 0); | |
| 63 | ✗ | result_bank.putDouble(i_V, row, 0); | |
| 64 | ✗ | result_bank.putDouble(i_W, row, 0); | |
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 |
1/2✓ Branch 45 → 46 taken 286 times.
✗ Branch 45 → 58 not taken.
|
572 | ShowBank(result_bank, Logger::Header("CREATED BANK")); |
| 69 | 286 | return true; | |
| 70 | } | ||
| 71 | |||
| 72 | /////////////////////////////////////////////////////////////////////////////// | ||
| 73 | |||
| 74 | 286 | DepolarizationVars Depolarization::Compute(double const Q2, double const x, double const y, double const targetM) const | |
| 75 | { | ||
| 76 | DepolarizationVars const zero_result{ | ||
| 77 | .epsilon = 0, | ||
| 78 | .A = 0, | ||
| 79 | .B = 0, | ||
| 80 | .C = 0, | ||
| 81 | .V = 0, | ||
| 82 | .W = 0}; | ||
| 83 | |||
| 84 | // calculate gamma | ||
| 85 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 5 taken 286 times.
|
286 | if(Q2 <= 0) { |
| 86 | ✗ | m_log->Warn("Q2 = {} <= 0", Q2); | |
| 87 | ✗ | return zero_result; | |
| 88 | } | ||
| 89 | 286 | auto gamma = 2 * targetM * x / std::sqrt(Q2); | |
| 90 | |||
| 91 | // calculate epsilon | ||
| 92 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 286 times.
|
286 | auto epsilon_denom = 1 - y + y * y / 2 + std::pow(gamma * y, 2) / 4; |
| 93 |
1/2✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 286 times.
|
286 | if(!(std::abs(epsilon_denom) > 0)) { |
| 94 | ✗ | m_log->Warn("epsilon denominator is zero"); | |
| 95 | ✗ | return zero_result; | |
| 96 | } | ||
| 97 | 286 | auto epsilon = (1 - y - std::pow(gamma * y, 2) / 4) / epsilon_denom; | |
| 98 | |||
| 99 | // calculate A | ||
| 100 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 11 taken 286 times.
|
286 | auto A_denom = 2 - 2 * epsilon; |
| 101 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 11 taken 286 times.
|
286 | if(!(std::abs(A_denom) > 0)) { |
| 102 | ✗ | m_log->Warn("depol. factor A denominator is zero"); | |
| 103 | ✗ | return zero_result; | |
| 104 | } | ||
| 105 | 286 | auto A = y * y / A_denom; | |
| 106 | |||
| 107 | // calculate B,C,V,W | ||
| 108 | return { | ||
| 109 | .epsilon = epsilon, | ||
| 110 | .A = A, | ||
| 111 | 286 | .B = A * epsilon, | |
| 112 | 286 | .C = A * std::sqrt(1 - epsilon * epsilon), | |
| 113 | 286 | .V = A * std::sqrt(2 * epsilon * (1 + epsilon)), | |
| 114 | 286 | .W = A * std::sqrt(2 * epsilon * (1 - epsilon))}; | |
| 115 | } | ||
| 116 | |||
| 117 | /////////////////////////////////////////////////////////////////////////////// | ||
| 118 | |||
| 119 | 1 | void Depolarization::Stop() | |
| 120 | { | ||
| 121 | 1 | } | |
| 122 | |||
| 123 | } | ||
| 124 |