GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/clas12/FTEnergyCorrection/Algorithm.cc
Date: 2025-01-05 09:03:17
Exec Total Coverage
Lines: 26 26 100.0%
Functions: 5 5 100.0%
Branches: 12 20 60.0%

Line Branch Exec Source
1 #include "Algorithm.h"
2
3 namespace iguana::clas12 {
4 REGISTER_IGUANA_ALGORITHM(FTEnergyCorrection);
5
6 1 void FTEnergyCorrection::Start(hipo::banklist& banks) {
7
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 b_ft_particle = GetBankIndex(banks, "RECFT::Particle");
8 1 electron_mass = particle::mass.at(particle::electron);
9 1 }
10
11 1000 void FTEnergyCorrection::Run(hipo::banklist& banks) const {
12
1/2
✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
2000 auto& ftParticleBank = GetBank(banks, b_ft_particle, "RECFT::Particle");
13
1/2
✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
1000 ShowBank(ftParticleBank, Logger::Header("INPUT FT PARTICLES"));
14
2/2
✓ Branch 0 taken 2576 times.
✓ Branch 1 taken 1000 times.
3576 for(auto const& row : ftParticleBank.getRowList()) {
15
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 2223 times.
2576 if(ftParticleBank.getInt("pid", row) == particle::PDG::electron) {
16 353 auto px = ftParticleBank.getFloat("px", row);
17 353 auto py = ftParticleBank.getFloat("py", row);
18 353 auto pz = ftParticleBank.getFloat("pz", row);
19 353 auto E = std::hypot(std::hypot(px, py, pz), electron_mass);
20
1/2
✓ Branch 0 taken 353 times.
✗ Branch 1 not taken.
353 auto [px_new, py_new, pz_new, E_new] = Transform(px, py, pz, E);
21
1/2
✓ Branch 0 taken 353 times.
✗ Branch 1 not taken.
353 ftParticleBank.putFloat("px", row, px_new);
22
1/2
✓ Branch 0 taken 353 times.
✗ Branch 1 not taken.
353 ftParticleBank.putFloat("py", row, py_new);
23
1/2
✓ Branch 0 taken 353 times.
✗ Branch 1 not taken.
353 ftParticleBank.putFloat("pz", row, pz_new);
24 }
25 }
26
1/2
✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
1000 ShowBank(ftParticleBank, Logger::Header("OUTPUT FT PARTICLES"));
27 1000 }
28
29 353 Momentum4 FTEnergyCorrection::Transform(
30 vector_element_t const px,
31 vector_element_t const py,
32 vector_element_t const pz,
33 vector_element_t const E) const
34 {
35 vector_element_t rho = std::hypot(px, py, pz);
36 353 vector_element_t E_new = CorrectEnergy(E);
37 353 return { E_new*(px/rho), E_new*(py/rho), E_new*(pz/rho), E_new };
38 }
39
40 353 vector_element_t FTEnergyCorrection::CorrectEnergy(vector_element_t const E) const
41 {
42 353 return E + 0.0208922 + 0.050158*E - 0.0181107*pow(E,2) + 0.00305671*pow(E,3) - 0.000178235*pow(E,4);
43 }
44
45 1 void FTEnergyCorrection::Stop() {
46 1 }
47
48 }
49