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