Skip to content

Commit

Permalink
Added printers for the implemented getters in ReconstructedParticle
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanki0396 committed Aug 8, 2024
1 parent 3a92ad5 commit 1358df8
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
48 changes: 48 additions & 0 deletions include/ral/ReconstructedParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,54 @@ struct print_PDG {
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

struct print_energy {
int m_n_events;
int m_n_printed;
print_energy(int n_events);
int operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

struct print_momentum {
int m_n_events;
int m_n_printed;
print_momentum(int n_events);
int operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

struct print_referencePoint {
int m_n_events;
int m_n_printed;
print_referencePoint(int n_events);
int operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

struct print_mass {
int m_n_events;
int m_n_printed;
print_mass(int n_events);
int operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

struct print_charge {
int m_n_events;
int m_n_printed;
print_charge(int n_events);
int operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

struct print_goodnessOfPID {
int m_n_events;
int m_n_printed;
print_goodnessOfPID(int n_events);
int operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles);
};

} // namespace ReconstructedParticle
} // namespace k4::ral

Expand Down
103 changes: 103 additions & 0 deletions src/ReconstructedParticle.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ral/ReconstructedParticle.h"
#include <Math/Vector3Dfwd.h>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
Expand Down Expand Up @@ -96,5 +97,107 @@ int print_PDG::operator()(
return 0;
}

print_energy::print_energy(int n_events) : m_n_events{n_events}, m_n_printed{0} {}

int print_energy::operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles) {
if (m_n_events == m_n_printed) {
throw std::runtime_error("End printing");
}
auto energies = get_energy(particles);
std::cout << "Printing energy from event " << m_n_printed << std::endl;
for (const float &energy : energies) {
std::cout << energy << " ";
}
std::cout << std::endl;
m_n_printed += 1;
return 0;
}

print_momentum::print_momentum(int n_events) : m_n_events{n_events}, m_n_printed{0} {}

int print_momentum::operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles) {
if (m_n_events == m_n_printed) {
throw std::runtime_error("End printing");
}
auto vectors = get_momentum(particles);
std::cout << "Printing momentum from event " << m_n_printed << std::endl;
for (const ROOT::Math::XYZVector &momentum : vectors) {
std::cout << momentum << " ";
}
std::cout << std::endl;
m_n_printed += 1;
return 0;
}

print_referencePoint::print_referencePoint(int n_events) : m_n_events{n_events}, m_n_printed{0} {}

int print_referencePoint::operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles) {
if (m_n_events == m_n_printed) {
throw std::runtime_error("End printing");
}
auto points = get_referencePoint(particles);
std::cout << "Printing referencePoint from event " << m_n_printed << std::endl;
for (const ROOT::Math::XYZVector &referencePoint : points) {
std::cout << referencePoint << " ";
}
std::cout << std::endl;
m_n_printed += 1;
return 0;
}

print_charge::print_charge(int n_events) : m_n_events{n_events}, m_n_printed{0} {}

int print_charge::operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles) {
if (m_n_events == m_n_printed) {
throw std::runtime_error("End printing");
}
auto charges = get_charge(particles);
std::cout << "Printing charge from event " << m_n_printed << std::endl;
for (const float &charge : charges) {
std::cout << charge << " ";
}
std::cout << std::endl;
m_n_printed += 1;
return 0;
}

print_mass::print_mass(int n_events) : m_n_events{n_events}, m_n_printed{0} {}

int print_mass::operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles) {
if (m_n_events == m_n_printed) {
throw std::runtime_error("End printing");
}
auto masses = get_mass(particles);
std::cout << "Printing mass from event " << m_n_printed << std::endl;
for (const float &mass : masses) {
std::cout << mass << " ";
}
std::cout << std::endl;
m_n_printed += 1;
return 0;
}

print_goodnessOfPID::print_goodnessOfPID(int n_events) : m_n_events{n_events}, m_n_printed{0} {}

int print_goodnessOfPID::operator()(
ROOT::VecOps::RVec<edm4hep::ReconstructedParticleData> particles) {
if (m_n_events == m_n_printed) {
throw std::runtime_error("End printing");
}
auto goodnessOfPIDs = get_goodnessOfPID(particles);
std::cout << "Printing goodnessOfPID from event " << m_n_printed << std::endl;
for (const float &goodnessOfPID : goodnessOfPIDs) {
std::cout << goodnessOfPID << " ";
}
std::cout << std::endl;
m_n_printed += 1;
return 0;
}

} // namespace ReconstructedParticle
} // namespace k4::ral

0 comments on commit 1358df8

Please sign in to comment.