Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /EICrecon/src/algorithms/reco/ChargedMCParticleSelector.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024 - 2025 Dmitry Kalinkin, Derek Anderson, Wouter Deconinck
0003 
0004 #pragma once
0005 
0006 #include <memory>
0007 #include <utility>
0008 
0009 #include <algorithms/algorithm.h>
0010 #include <edm4hep/MCParticleCollection.h>
0011 #include <spdlog/logger.h>
0012 
0013 #include "algorithms/interfaces/WithPodConfig.h"
0014 
0015 namespace eicrecon {
0016 
0017 using ChargedMCParticleSelectorAlgorithm =
0018     algorithms::Algorithm<algorithms::Input<edm4hep::MCParticleCollection>,
0019                           algorithms::Output<edm4hep::MCParticleCollection>>;
0020 
0021 class ChargedMCParticleSelector : public ChargedMCParticleSelectorAlgorithm,
0022                                   public WithPodConfig<NoConfig> {
0023 
0024 public:
0025   ChargedMCParticleSelector(std::string_view name)
0026       : ChargedMCParticleSelectorAlgorithm{
0027             name, {"inputParticles"}, {"outputParticles"}, "select charged particles"} {}
0028 
0029   // algorithm initialization
0030   void init() final {}
0031 
0032   // primary algorithm call
0033   void process(const Input& input, const Output& output) const final {
0034     const auto [mc_particles_in] = input;
0035     auto [mc_particles_out]      = output;
0036 
0037     mc_particles_out->setSubsetCollection();
0038 
0039     for (const auto& particle : *mc_particles_in) {
0040       if (particle.getCharge() != 0.) {
0041         mc_particles_out->push_back(particle);
0042       }
0043     }
0044   }
0045 };
0046 
0047 } // namespace eicrecon