GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/clas12/CalorimeterLinker/Algorithm.cc
Date: 2025-09-03 22:39:58
Exec Total Coverage
Lines: 103 103 100.0%
Functions: 3 3 100.0%
Branches: 45 80 56.2%

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