Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-28 07:02:56

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 
0020     std::shared_ptr<spdlog::logger> m_log;
0021 
0022   public:
0023 
0024     // algorithm initialization
0025     void init(std::shared_ptr<spdlog::logger>& logger) {
0026       m_log = logger;
0027     }
0028 
0029     // primary algorithm call
0030     std::unique_ptr<edm4hep::MCParticleCollection> process(const edm4hep::MCParticleCollection* inputs) {
0031       auto outputs = std::make_unique<edm4hep::MCParticleCollection>();
0032       outputs->setSubsetCollection();
0033 
0034       for (const auto &particle : *inputs) {
0035         if (particle.getCharge() != 0.) {
0036           outputs->push_back(particle);
0037         }
0038       }
0039 
0040       return std::move(outputs);
0041     }
0042 
0043   };
0044 
0045 }