Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:55:42

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024 Dmitry Kalinkin, Derek Anderson
0003 
0004 #pragma once
0005 
0006 #include <memory>
0007 #include <utility>
0008 
0009 #include <edm4hep/MCParticleCollection.h>
0010 #include <spdlog/logger.h>
0011 
0012 #include "algorithms/interfaces/WithPodConfig.h"
0013 
0014 namespace eicrecon {
0015 
0016 class ChargedMCParticleSelector : public WithPodConfig<NoConfig> {
0017 
0018 private:
0019   std::shared_ptr<spdlog::logger> m_log;
0020 
0021 public:
0022   // algorithm initialization
0023   void init(std::shared_ptr<spdlog::logger>& logger) { m_log = logger; }
0024 
0025   // primary algorithm call
0026   std::unique_ptr<edm4hep::MCParticleCollection>
0027   process(const edm4hep::MCParticleCollection* inputs) {
0028     auto outputs = std::make_unique<edm4hep::MCParticleCollection>();
0029     outputs->setSubsetCollection();
0030 
0031     for (const auto& particle : *inputs) {
0032       if (particle.getCharge() != 0.) {
0033         outputs->push_back(particle);
0034       }
0035     }
0036 
0037     return std::move(outputs);
0038   }
0039 };
0040 
0041 } // namespace eicrecon