GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/clas12/CalorimeterLinker/Algorithm.cc
Date: 2025-11-25 17:57:04
Coverage Exec Excl Total
Lines: 100.0% 106 0 106
Functions: 100.0% 4 0 4
Branches: 53.2% 50 0 94

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 4 void CalorimeterLinker::Start(hipo::banklist& banks)
9 {
10
2/4
✓ Branch 3 → 4 taken 4 times.
✗ Branch 3 → 44 not taken.
✓ Branch 4 → 5 taken 4 times.
✗ Branch 4 → 7 not taken.
4 b_particle = GetBankIndex(banks, "REC::Particle");
11
2/4
✓ Branch 10 → 11 taken 4 times.
✗ Branch 10 → 50 not taken.
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 14 taken 4 times.
4 b_calorimeter = GetBankIndex(banks, "REC::Calorimeter");
12
1/2
✓ Branch 17 → 18 taken 4 times.
✗ Branch 17 → 56 not taken.
4 auto result_schema = CreateBank(banks, b_result, "REC::Particle::Calorimeter");
13
1/2
✓ Branch 23 → 24 taken 4 times.
✗ Branch 23 → 62 not taken.
4 i_pindex = result_schema.getEntryOrder("pindex");
14
1/2
✓ Branch 24 → 25 taken 4 times.
✗ Branch 24 → 62 not taken.
4 i_pcal_found = result_schema.getEntryOrder("pcal_found");
15
1/2
✓ Branch 25 → 26 taken 4 times.
✗ Branch 25 → 62 not taken.
4 i_pcal_sector = result_schema.getEntryOrder("pcal_sector");
16
1/2
✓ Branch 26 → 27 taken 4 times.
✗ Branch 26 → 62 not taken.
4 i_pcal_lu = result_schema.getEntryOrder("pcal_lu");
17
1/2
✓ Branch 27 → 28 taken 4 times.
✗ Branch 27 → 62 not taken.
4 i_pcal_lv = result_schema.getEntryOrder("pcal_lv");
18
1/2
✓ Branch 28 → 29 taken 4 times.
✗ Branch 28 → 62 not taken.
4 i_pcal_lw = result_schema.getEntryOrder("pcal_lw");
19
1/2
✓ Branch 29 → 30 taken 4 times.
✗ Branch 29 → 62 not taken.
4 i_pcal_energy = result_schema.getEntryOrder("pcal_energy");
20
1/2
✓ Branch 30 → 31 taken 4 times.
✗ Branch 30 → 62 not taken.
4 i_ecin_found = result_schema.getEntryOrder("ecin_found");
21
1/2
✓ Branch 31 → 32 taken 4 times.
✗ Branch 31 → 62 not taken.
4 i_ecin_sector = result_schema.getEntryOrder("ecin_sector");
22
1/2
✓ Branch 32 → 33 taken 4 times.
✗ Branch 32 → 62 not taken.
4 i_ecin_lu = result_schema.getEntryOrder("ecin_lu");
23
1/2
✓ Branch 33 → 34 taken 4 times.
✗ Branch 33 → 62 not taken.
4 i_ecin_lv = result_schema.getEntryOrder("ecin_lv");
24
1/2
✓ Branch 34 → 35 taken 4 times.
✗ Branch 34 → 62 not taken.
4 i_ecin_lw = result_schema.getEntryOrder("ecin_lw");
25
1/2
✓ Branch 35 → 36 taken 4 times.
✗ Branch 35 → 62 not taken.
4 i_ecin_energy = result_schema.getEntryOrder("ecin_energy");
26
1/2
✓ Branch 36 → 37 taken 4 times.
✗ Branch 36 → 62 not taken.
4 i_ecout_found = result_schema.getEntryOrder("ecout_found");
27
1/2
✓ Branch 37 → 38 taken 4 times.
✗ Branch 37 → 62 not taken.
4 i_ecout_sector = result_schema.getEntryOrder("ecout_sector");
28
1/2
✓ Branch 38 → 39 taken 4 times.
✗ Branch 38 → 62 not taken.
4 i_ecout_lu = result_schema.getEntryOrder("ecout_lu");
29
1/2
✓ Branch 39 → 40 taken 4 times.
✗ Branch 39 → 62 not taken.
4 i_ecout_lv = result_schema.getEntryOrder("ecout_lv");
30
1/2
✓ Branch 40 → 41 taken 4 times.
✗ Branch 40 → 62 not taken.
4 i_ecout_lw = result_schema.getEntryOrder("ecout_lw");
31
1/2
✓ Branch 41 → 42 taken 4 times.
✗ Branch 41 → 62 not taken.
4 i_ecout_energy = result_schema.getEntryOrder("ecout_energy");
32 4 }
33
34 3000 bool CalorimeterLinker::Run(hipo::banklist& banks) const
35 {
36
1/2
✓ Branch 8 → 9 taken 3000 times.
✗ Branch 8 → 25 not taken.
3000 return Run(
37
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 not taken.
✓ Branch 14 → 17 taken 3000 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 34 not taken.
6000 GetBank(banks, b_particle, "REC::Particle"),
38
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_calorimeter, "REC::Calorimeter"),
39
1/2
✓ Branch 3 → 4 taken 3000 times.
✗ Branch 3 → 37 not taken.
6000 GetBank(banks, b_result, "REC::Particle::Calorimeter"));
40 }
41
42 3000 bool CalorimeterLinker::Run(
43 hipo::bank const& bank_particle,
44 hipo::bank const& bank_calorimeter,
45 hipo::bank& bank_result) const
46 {
47 3000 bank_result.reset(); // IMPORTANT: always first `reset` the created bank(s)
48
1/2
✓ Branch 6 → 7 taken 3000 times.
✗ Branch 6 → 106 not taken.
6000 ShowBank(bank_particle, Logger::Header("INPUT PARTICLE BANK"));
49
1/2
✓ Branch 15 → 16 taken 3000 times.
✗ Branch 15 → 112 not taken.
9000 ShowBank(bank_calorimeter, Logger::Header("INPUT CALORIMETER BANK"));
50
51 // sync new bank with particle bank, and fill it with zeroes
52 3000 bank_result.setRows(bank_particle.getRows());
53 3000 bank_result.getMutableRowList().setList(bank_particle.getRowList());
54
2/2
✓ Branch 45 → 25 taken 20979 times.
✓ Branch 45 → 46 taken 3000 times.
23979 for(int row = 0; row < bank_result.getRows(); row++) {
55 20979 bank_result.putShort(i_pindex, row, static_cast<int16_t>(row));
56 20979 bank_result.putByte(i_pcal_found, row, 0);
57 20979 bank_result.putInt(i_pcal_sector, row, 0);
58 20979 bank_result.putFloat(i_pcal_lu, row, 0);
59 20979 bank_result.putFloat(i_pcal_lv, row, 0);
60 20979 bank_result.putFloat(i_pcal_lw, row, 0);
61 20979 bank_result.putFloat(i_pcal_energy, row, 0);
62 20979 bank_result.putByte(i_ecin_found, row, 0);
63 20979 bank_result.putInt(i_ecin_sector, row, 0);
64 20979 bank_result.putFloat(i_ecin_lu, row, 0);
65 20979 bank_result.putFloat(i_ecin_lv, row, 0);
66 20979 bank_result.putFloat(i_ecin_lw, row, 0);
67 20979 bank_result.putFloat(i_ecin_energy, row, 0);
68 20979 bank_result.putByte(i_ecout_found, row, 0);
69 20979 bank_result.putInt(i_ecout_sector, row, 0);
70 20979 bank_result.putFloat(i_ecout_lu, row, 0);
71 20979 bank_result.putFloat(i_ecout_lv, row, 0);
72 20979 bank_result.putFloat(i_ecout_lw, row, 0);
73 20979 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 3000 times.
✗ Branch 46 → 124 not taken.
✓ Branch 94 → 48 taken 16312 times.
✓ Branch 94 → 95 taken 3000 times.
19312 for(auto const& row_particle : bank_particle.getRowList()) {
81 // create new `CalorimeterLinkerVars` object for this particle
82
1/2
✓ Branch 48 → 49 taken 16312 times.
✗ Branch 48 → 124 not taken.
16312 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 16312 times.
✗ Branch 49 → 124 not taken.
✓ Branch 74 → 51 taken 117363 times.
✓ Branch 74 → 75 taken 16312 times.
133675 for(auto const& row_calorimeter : bank_calorimeter.getRowList()) {
85
2/2
✓ Branch 52 → 53 taken 14881 times.
✓ Branch 52 → 73 taken 102482 times.
117363 if(row_particle == bank_calorimeter.getShort("pindex", row_calorimeter)) {
86
3/4
✓ Branch 54 → 55 taken 7468 times.
✓ Branch 54 → 61 taken 4558 times.
✓ Branch 54 → 67 taken 2855 times.
✗ Branch 54 → 73 not taken.
14881 switch(bank_calorimeter.getByte("layer", row_calorimeter)) {
87 7468 case DetectorLayer::PCAL:
88 7468 link_particle.pcal_found = 1;
89 7468 link_particle.pcal_sector = bank_calorimeter.getByte("sector", row_calorimeter);
90 7468 link_particle.pcal_lu = bank_calorimeter.getFloat("lu", row_calorimeter);
91 7468 link_particle.pcal_lv = bank_calorimeter.getFloat("lv", row_calorimeter);
92 7468 link_particle.pcal_lw = bank_calorimeter.getFloat("lw", row_calorimeter);
93 7468 link_particle.pcal_energy = bank_calorimeter.getFloat("energy", row_calorimeter);
94 7468 break;
95 4558 case DetectorLayer::EC_INNER:
96 4558 link_particle.ecin_found = 1;
97 4558 link_particle.ecin_sector = bank_calorimeter.getByte("sector", row_calorimeter);
98 4558 link_particle.ecin_lu = bank_calorimeter.getFloat("lu", row_calorimeter);
99 4558 link_particle.ecin_lv = bank_calorimeter.getFloat("lv", row_calorimeter);
100 4558 link_particle.ecin_lw = bank_calorimeter.getFloat("lw", row_calorimeter);
101 4558 link_particle.ecin_energy = bank_calorimeter.getFloat("energy", row_calorimeter);
102 4558 break;
103 2855 case DetectorLayer::EC_OUTER:
104 2855 link_particle.ecout_found = 1;
105 2855 link_particle.ecout_sector = bank_calorimeter.getByte("sector", row_calorimeter);
106 2855 link_particle.ecout_lu = bank_calorimeter.getFloat("lu", row_calorimeter);
107 2855 link_particle.ecout_lv = bank_calorimeter.getFloat("lv", row_calorimeter);
108 2855 link_particle.ecout_lw = bank_calorimeter.getFloat("lw", row_calorimeter);
109 2855 link_particle.ecout_energy = bank_calorimeter.getFloat("energy", row_calorimeter);
110 2855 break;
111 }
112 }
113 }
114 // fill output bank
115 16312 bank_result.putByte(i_pcal_found, row_particle, link_particle.pcal_found);
116 16312 bank_result.putInt(i_pcal_sector, row_particle, link_particle.pcal_sector);
117 16312 bank_result.putFloat(i_pcal_lu, row_particle, link_particle.pcal_lu);
118 16312 bank_result.putFloat(i_pcal_lv, row_particle, link_particle.pcal_lv);
119 16312 bank_result.putFloat(i_pcal_lw, row_particle, link_particle.pcal_lw);
120 16312 bank_result.putFloat(i_pcal_energy, row_particle, link_particle.pcal_energy);
121 16312 bank_result.putByte(i_ecin_found, row_particle, link_particle.ecin_found);
122 16312 bank_result.putInt(i_ecin_sector, row_particle, link_particle.ecin_sector);
123 16312 bank_result.putFloat(i_ecin_lu, row_particle, link_particle.ecin_lu);
124 16312 bank_result.putFloat(i_ecin_lv, row_particle, link_particle.ecin_lv);
125 16312 bank_result.putFloat(i_ecin_lw, row_particle, link_particle.ecin_lw);
126 16312 bank_result.putFloat(i_ecin_energy, row_particle, link_particle.ecin_energy);
127 16312 bank_result.putByte(i_ecout_found, row_particle, link_particle.ecout_found);
128 16312 bank_result.putInt(i_ecout_sector, row_particle, link_particle.ecout_sector);
129 16312 bank_result.putFloat(i_ecout_lu, row_particle, link_particle.ecout_lu);
130 16312 bank_result.putFloat(i_ecout_lv, row_particle, link_particle.ecout_lv);
131 16312 bank_result.putFloat(i_ecout_lw, row_particle, link_particle.ecout_lw);
132 16312 bank_result.putFloat(i_ecout_energy, row_particle, link_particle.ecout_energy);
133 }
134
2/4
✓ Branch 95 → 96 taken 3000 times.
✗ Branch 95 → 124 not taken.
✓ Branch 98 → 99 taken 3000 times.
✗ Branch 98 → 118 not taken.
9000 ShowBank(bank_result, Logger::Header("CREATED BANK"));
135 3000 return true;
136 }
137
138 4 void CalorimeterLinker::Stop()
139 {
140 4 }
141
142 }
143