Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:17:47

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023 - 2025 Daniel Brandenburg, Wouter Deconinck
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 #include <gsl/pointers>
0011 
0012 #include "algorithms/reco/ElectronReconstructionConfig.h"
0013 
0014 namespace eicrecon {
0015 
0016 void ElectronReconstruction::process(const Input& input, const Output& output) const {
0017 
0018   const auto [rcparts] = input;
0019   auto [out_electrons] = output;
0020 
0021   // Some obvious improvements:
0022   // - E/p cut from real study optimized for electron finding and hadron rejection
0023   // - use of any HCAL info?
0024   // - check for duplicates?
0025 
0026   // output container
0027   out_electrons
0028       ->setSubsetCollection(); // out_electrons is a subset of the ReconstructedParticles collection
0029 
0030   for (const auto particle : *rcparts) {
0031     // if we found a reco particle then test for electron compatibility
0032     if (particle.getClusters().empty()) {
0033       continue;
0034     }
0035     if (particle.getCharge() == 0) { // Skip over photons/other particles without a track
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     trace("ReconstructedElectron: Energy={} GeV, p={} GeV, E/p = {} for PDG (from truth): {}", E, p,
0043           EOverP, particle.getPDG());
0044     // Apply the E/p cut here to select electons
0045     if (EOverP >= m_cfg.min_energy_over_momentum && EOverP <= m_cfg.max_energy_over_momentum) {
0046       out_electrons->push_back(particle);
0047     }
0048   }
0049   debug("Found {} electron candidates", out_electrons->size());
0050 }
0051 } // namespace eicrecon