File indexing completed on 2025-07-01 07:56:25
0001
0002
0003 #include "ElectronReconstruction.h"
0004
0005 #include <edm4eic/ClusterCollection.h>
0006 #include <edm4eic/ReconstructedParticleCollection.h>
0007 #include <edm4hep/utils/vector_utils.h>
0008 #include <fmt/core.h>
0009 #include <podio/RelationRange.h>
0010
0011 #include "algorithms/reco/ElectronReconstructionConfig.h"
0012
0013 namespace eicrecon {
0014
0015 void ElectronReconstruction::init(std::shared_ptr<spdlog::logger> logger) { m_log = logger; }
0016
0017 std::unique_ptr<edm4eic::ReconstructedParticleCollection>
0018 ElectronReconstruction::execute(const edm4eic::ReconstructedParticleCollection* rcparts) {
0019
0020
0021
0022
0023
0024
0025
0026 auto out_electrons = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0027 out_electrons
0028 ->setSubsetCollection();
0029
0030 for (const auto particle : *rcparts) {
0031
0032 if (particle.getClusters().empty()) {
0033 continue;
0034 }
0035 if (particle.getCharge() == 0) {
0036 continue;
0037 }
0038 double E = particle.getClusters()[0].getEnergy();
0039 double p = edm4hep::utils::magnitude(particle.getMomentum());
0040 double EOverP = E / p;
0041
0042 m_log->trace(
0043 "ReconstructedElectron: Energy={} GeV, p={} GeV, E/p = {} for PDG (from truth): {}", E, p,
0044 EOverP, particle.getPDG());
0045
0046 if (EOverP >= m_cfg.min_energy_over_momentum && EOverP <= m_cfg.max_energy_over_momentum) {
0047 out_electrons->push_back(particle);
0048 }
0049 }
0050 m_log->debug("Found {} electron candidates", out_electrons->size());
0051 return out_electrons;
0052 }
0053 }