File indexing completed on 2024-09-28 07:02:56
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) {
0016 m_log = logger;
0017 }
0018
0019 std::unique_ptr<edm4eic::ReconstructedParticleCollection> ElectronReconstruction::execute(
0020 const edm4eic::ReconstructedParticleCollection *rcparts
0021 ) {
0022
0023
0024
0025
0026
0027
0028
0029 auto out_electrons = std::make_unique<edm4eic::ReconstructedParticleCollection>();
0030 out_electrons->setSubsetCollection();
0031
0032 for (const auto particle : *rcparts) {
0033
0034 if (particle.getClusters().size() == 0) {
0035 continue;
0036 }
0037 if (particle.getCharge() == 0) {
0038 continue;
0039 }
0040 double E = particle.getClusters()[0].getEnergy();
0041 double p = edm4hep::utils::magnitude(particle.getMomentum());
0042 double EOverP = E / p;
0043
0044 m_log->trace("ReconstructedElectron: Energy={} GeV, p={} GeV, E/p = {} for PDG (from truth): {}", E, p, 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 }
0051 m_log->debug("Found {} electron candidates", out_electrons->size());
0052 return out_electrons;
0053 }
0054 }