GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 104 / 0 / 104
Functions: 100.0% 3 / 0 / 3
Branches: 53.2% 50 / 0 / 94

src/iguana/algorithms/clas12/CalorimeterLinker/Algorithm.cc
Line Branch Exec Source
1 #include "Algorithm.h"
2 #include "iguana/algorithms/TypeDefs.h"
3
4 namespace iguana::clas12 {
5
6 REGISTER_IGUANA_ALGORITHM(CalorimeterLinker, "REC::Particle::Calorimeter");
7
8 5 void CalorimeterLinker::StartHook(hipo::banklist& banks)
9 {
10
2/4
✓ Branch 3 → 4 taken 5 times.
✗ Branch 3 → 44 not taken.
✓ Branch 4 → 5 taken 5 times.
✗ Branch 4 → 7 not taken.
5 b_particle = GetBankIndex(banks, "REC::Particle");
11
2/4
✓ Branch 10 → 11 taken 5 times.
✗ Branch 10 → 50 not taken.
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 14 taken 5 times.
5 b_calorimeter = GetBankIndex(banks, "REC::Calorimeter");
12
1/2
✓ Branch 17 → 18 taken 5 times.
✗ Branch 17 → 56 not taken.
5 auto result_schema = CreateBank(banks, b_result, "REC::Particle::Calorimeter");
13
1/2
✓ Branch 23 → 24 taken 5 times.
✗ Branch 23 → 62 not taken.
5 i_pindex = result_schema.getEntryOrder("pindex");
14
1/2
✓ Branch 24 → 25 taken 5 times.
✗ Branch 24 → 62 not taken.
5 i_pcal_found = result_schema.getEntryOrder("pcal_found");
15
1/2
✓ Branch 25 → 26 taken 5 times.
✗ Branch 25 → 62 not taken.
5 i_pcal_sector = result_schema.getEntryOrder("pcal_sector");
16
1/2
✓ Branch 26 → 27 taken 5 times.
✗ Branch 26 → 62 not taken.
5 i_pcal_lu = result_schema.getEntryOrder("pcal_lu");
17
1/2
✓ Branch 27 → 28 taken 5 times.
✗ Branch 27 → 62 not taken.
5 i_pcal_lv = result_schema.getEntryOrder("pcal_lv");
18
1/2
✓ Branch 28 → 29 taken 5 times.
✗ Branch 28 → 62 not taken.
5 i_pcal_lw = result_schema.getEntryOrder("pcal_lw");
19
1/2
✓ Branch 29 → 30 taken 5 times.
✗ Branch 29 → 62 not taken.
5 i_pcal_energy = result_schema.getEntryOrder("pcal_energy");
20
1/2
✓ Branch 30 → 31 taken 5 times.
✗ Branch 30 → 62 not taken.
5 i_ecin_found = result_schema.getEntryOrder("ecin_found");
21
1/2
✓ Branch 31 → 32 taken 5 times.
✗ Branch 31 → 62 not taken.
5 i_ecin_sector = result_schema.getEntryOrder("ecin_sector");
22
1/2
✓ Branch 32 → 33 taken 5 times.
✗ Branch 32 → 62 not taken.
5 i_ecin_lu = result_schema.getEntryOrder("ecin_lu");
23
1/2
✓ Branch 33 → 34 taken 5 times.
✗ Branch 33 → 62 not taken.
5 i_ecin_lv = result_schema.getEntryOrder("ecin_lv");
24
1/2
✓ Branch 34 → 35 taken 5 times.
✗ Branch 34 → 62 not taken.
5 i_ecin_lw = result_schema.getEntryOrder("ecin_lw");
25
1/2
✓ Branch 35 → 36 taken 5 times.
✗ Branch 35 → 62 not taken.
5 i_ecin_energy = result_schema.getEntryOrder("ecin_energy");
26
1/2
✓ Branch 36 → 37 taken 5 times.
✗ Branch 36 → 62 not taken.
5 i_ecout_found = result_schema.getEntryOrder("ecout_found");
27
1/2
✓ Branch 37 → 38 taken 5 times.
✗ Branch 37 → 62 not taken.
5 i_ecout_sector = result_schema.getEntryOrder("ecout_sector");
28
1/2
✓ Branch 38 → 39 taken 5 times.
✗ Branch 38 → 62 not taken.
5 i_ecout_lu = result_schema.getEntryOrder("ecout_lu");
29
1/2
✓ Branch 39 → 40 taken 5 times.
✗ Branch 39 → 62 not taken.
5 i_ecout_lv = result_schema.getEntryOrder("ecout_lv");
30
1/2
✓ Branch 40 → 41 taken 5 times.
✗ Branch 40 → 62 not taken.
5 i_ecout_lw = result_schema.getEntryOrder("ecout_lw");
31
1/2
✓ Branch 41 → 42 taken 5 times.
✗ Branch 41 → 62 not taken.
5 i_ecout_energy = result_schema.getEntryOrder("ecout_energy");
32 5 }
33
34 4000 bool CalorimeterLinker::RunHook(hipo::banklist& banks) const
35 {
36
1/2
✓ Branch 8 → 9 taken 4000 times.
✗ Branch 8 → 25 not taken.
4000 return Run(
37
3/8
✓ Branch 6 → 7 taken 4000 times.
✗ Branch 6 → 31 not taken.
✓ Branch 7 → 8 taken 4000 times.
✗ Branch 7 → 25 not taken.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 17 taken 4000 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 34 not taken.
8000 GetBank(banks, b_particle, "REC::Particle"),
38
3/8
✓ Branch 4 → 5 taken 4000 times.
✗ Branch 4 → 37 not taken.
✓ Branch 5 → 6 taken 4000 times.
✗ Branch 5 → 31 not taken.
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 22 taken 4000 times.
✗ Branch 37 → 38 not taken.
✗ Branch 37 → 40 not taken.
8000 GetBank(banks, b_calorimeter, "REC::Calorimeter"),
39
1/2
✓ Branch 3 → 4 taken 4000 times.
✗ Branch 3 → 37 not taken.
8000 GetBank(banks, b_result, "REC::Particle::Calorimeter"));
40 }
41
42 4000 bool CalorimeterLinker::Run(
43 hipo::bank const& bank_particle,
44 hipo::bank const& bank_calorimeter,
45 hipo::bank& bank_result) const
46 {
47 4000 bank_result.reset(); // IMPORTANT: always first `reset` the created bank(s)
48
1/2
✓ Branch 6 → 7 taken 4000 times.
✗ Branch 6 → 106 not taken.
8000 ShowBank(bank_particle, Logger::Header("INPUT PARTICLE BANK"));
49
1/2
✓ Branch 15 → 16 taken 4000 times.
✗ Branch 15 → 112 not taken.
12000 ShowBank(bank_calorimeter, Logger::Header("INPUT CALORIMETER BANK"));
50
51 // sync new bank with particle bank, and fill it with zeroes
52 4000 bank_result.setRows(bank_particle.getRows());
53 4000 bank_result.getMutableRowList().setList(bank_particle.getRowList());
54
2/2
✓ Branch 45 → 25 taken 27972 times.
✓ Branch 45 → 46 taken 4000 times.
31972 for(int row = 0; row < bank_result.getRows(); row++) {
55 27972 bank_result.putShort(i_pindex, row, static_cast<int16_t>(row));
56 27972 bank_result.putByte(i_pcal_found, row, 0);
57 27972 bank_result.putInt(i_pcal_sector, row, 0);
58 27972 bank_result.putFloat(i_pcal_lu, row, 0);
59 27972 bank_result.putFloat(i_pcal_lv, row, 0);
60 27972 bank_result.putFloat(i_pcal_lw, row, 0);
61 27972 bank_result.putFloat(i_pcal_energy, row, 0);
62 27972 bank_result.putByte(i_ecin_found, row, 0);
63 27972 bank_result.putInt(i_ecin_sector, row, 0);
64 27972 bank_result.putFloat(i_ecin_lu, row, 0);
65 27972 bank_result.putFloat(i_ecin_lv, row, 0);
66 27972 bank_result.putFloat(i_ecin_lw, row, 0);
67 27972 bank_result.putFloat(i_ecin_energy, row, 0);
68 27972 bank_result.putByte(i_ecout_found, row, 0);
69 27972 bank_result.putInt(i_ecout_sector, row, 0);
70 27972 bank_result.putFloat(i_ecout_lu, row, 0);
71 27972 bank_result.putFloat(i_ecout_lv, row, 0);
72 27972 bank_result.putFloat(i_ecout_lw, row, 0);
73 27972 bank_result.putFloat(i_ecout_energy, row, 0);
74 }
75
76 // map particle `pindex` -> `CalorimeterLinkerVars` object
77 std::map<int, CalorimeterLinkerVars> link_map;
78
79 // loop over particle rows
80
3/4
✓ Branch 46 → 47 taken 4000 times.
✗ Branch 46 → 124 not taken.
✓ Branch 94 → 48 taken 23305 times.
✓ Branch 94 → 95 taken 4000 times.
27305 for(auto const& row_particle : bank_particle.getRowList()) {
81 // create new `CalorimeterLinkerVars` object for this particle
82
1/2
✓ Branch 48 → 49 taken 23305 times.
✗ Branch 48 → 124 not taken.
23305 auto& link_particle = link_map[row_particle];
83 // loop over `REC::Calorimeter` rows, setting elements of linked `CalorimeterLinkerVars`
84
3/4
✓ Branch 49 → 50 taken 23305 times.
✗ Branch 49 → 124 not taken.
✓ Branch 74 → 51 taken 168171 times.
✓ Branch 74 → 75 taken 23305 times.
191476 for(auto const& row_calorimeter : bank_calorimeter.getRowList()) {
85
2/2
✓ Branch 52 → 53 taken 21010 times.
✓ Branch 52 → 73 taken 147161 times.
168171 if(row_particle == bank_calorimeter.getShort("pindex", row_calorimeter)) {
86
3/4
✓ Branch 54 → 55 taken 10614 times.
✓ Branch 54 → 61 taken 6411 times.
✓ Branch 54 → 67 taken 3985 times.
✗ Branch 54 → 73 not taken.
21010 switch(bank_calorimeter.getByte("layer", row_calorimeter)) {
87 10614 case DetectorLayer::PCAL:
88 10614 link_particle.pcal_found = 1;
89 10614 link_particle.pcal_sector = bank_calorimeter.getByte("sector", row_calorimeter);
90 10614 link_particle.pcal_lu = bank_calorimeter.getFloat("lu", row_calorimeter);
91 10614 link_particle.pcal_lv = bank_calorimeter.getFloat("lv", row_calorimeter);
92 10614 link_particle.pcal_lw = bank_calorimeter.getFloat("lw", row_calorimeter);
93 10614 link_particle.pcal_energy = bank_calorimeter.getFloat("energy", row_calorimeter);
94 10614 break;
95 6411 case DetectorLayer::EC_INNER:
96 6411 link_particle.ecin_found = 1;
97 6411 link_particle.ecin_sector = bank_calorimeter.getByte("sector", row_calorimeter);
98 6411 link_particle.ecin_lu = bank_calorimeter.getFloat("lu", row_calorimeter);
99 6411 link_particle.ecin_lv = bank_calorimeter.getFloat("lv", row_calorimeter);
100 6411 link_particle.ecin_lw = bank_calorimeter.getFloat("lw", row_calorimeter);
101 6411 link_particle.ecin_energy = bank_calorimeter.getFloat("energy", row_calorimeter);
102 6411 break;
103 3985 case DetectorLayer::EC_OUTER:
104 3985 link_particle.ecout_found = 1;
105 3985 link_particle.ecout_sector = bank_calorimeter.getByte("sector", row_calorimeter);
106 3985 link_particle.ecout_lu = bank_calorimeter.getFloat("lu", row_calorimeter);
107 3985 link_particle.ecout_lv = bank_calorimeter.getFloat("lv", row_calorimeter);
108 3985 link_particle.ecout_lw = bank_calorimeter.getFloat("lw", row_calorimeter);
109 3985 link_particle.ecout_energy = bank_calorimeter.getFloat("energy", row_calorimeter);
110 3985 break;
111 }
112 }
113 }
114 // fill output bank
115 23305 bank_result.putByte(i_pcal_found, row_particle, link_particle.pcal_found);
116 23305 bank_result.putInt(i_pcal_sector, row_particle, link_particle.pcal_sector);
117 23305 bank_result.putFloat(i_pcal_lu, row_particle, link_particle.pcal_lu);
118 23305 bank_result.putFloat(i_pcal_lv, row_particle, link_particle.pcal_lv);
119 23305 bank_result.putFloat(i_pcal_lw, row_particle, link_particle.pcal_lw);
120 23305 bank_result.putFloat(i_pcal_energy, row_particle, link_particle.pcal_energy);
121 23305 bank_result.putByte(i_ecin_found, row_particle, link_particle.ecin_found);
122 23305 bank_result.putInt(i_ecin_sector, row_particle, link_particle.ecin_sector);
123 23305 bank_result.putFloat(i_ecin_lu, row_particle, link_particle.ecin_lu);
124 23305 bank_result.putFloat(i_ecin_lv, row_particle, link_particle.ecin_lv);
125 23305 bank_result.putFloat(i_ecin_lw, row_particle, link_particle.ecin_lw);
126 23305 bank_result.putFloat(i_ecin_energy, row_particle, link_particle.ecin_energy);
127 23305 bank_result.putByte(i_ecout_found, row_particle, link_particle.ecout_found);
128 23305 bank_result.putInt(i_ecout_sector, row_particle, link_particle.ecout_sector);
129 23305 bank_result.putFloat(i_ecout_lu, row_particle, link_particle.ecout_lu);
130 23305 bank_result.putFloat(i_ecout_lv, row_particle, link_particle.ecout_lv);
131 23305 bank_result.putFloat(i_ecout_lw, row_particle, link_particle.ecout_lw);
132 23305 bank_result.putFloat(i_ecout_energy, row_particle, link_particle.ecout_energy);
133 }
134
2/4
✓ Branch 95 → 96 taken 4000 times.
✗ Branch 95 → 124 not taken.
✓ Branch 98 → 99 taken 4000 times.
✗ Branch 98 → 118 not taken.
12000 ShowBank(bank_result, Logger::Header("CREATED BANK"));
135 4000 return true;
136 }
137
138 }
139