Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:09:38

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2025 Daniel Brandenburg, Wouter Deconinck
0003 
0004 #pragma once
0005 
0006 #include "extensions/jana/JOmniFactory.h"
0007 
0008 #include "algorithms/reco/ElectronReconstruction.h"
0009 
0010 namespace eicrecon {
0011 
0012 class ReconstructedElectrons_factory
0013     : public JOmniFactory<ReconstructedElectrons_factory, ElectronReconstructionConfig> {
0014 public:
0015   using AlgoT = eicrecon::ElectronReconstruction;
0016 
0017 private:
0018   // Underlying algorithm
0019   std::unique_ptr<AlgoT> m_algo;
0020 
0021   // Declare inputs
0022   PodioInput<edm4eic::ReconstructedParticle> m_in_rc_particles{this, "ReconstructedParticles"};
0023 
0024   // Declare outputs
0025   PodioOutput<edm4eic::ReconstructedParticle> m_out_reco_particles{this};
0026 
0027   // Declare parameters
0028   ParameterRef<double> m_min_energy_over_momentum{this, "minEnergyOverMomentum",
0029                                                   config().min_energy_over_momentum};
0030   ParameterRef<double> m_max_energy_over_momentum{this, "maxEnergyOverMomentum",
0031                                                   config().max_energy_over_momentum};
0032 
0033 public:
0034   void Configure() {
0035     // This is called when the factory is instantiated.
0036     // Use this callback to make sure the algorithm is configured.
0037     // The logger, parameters, and services have all been fetched before this is called
0038     m_algo = std::make_unique<AlgoT>(GetPrefix());
0039     m_algo->level(static_cast<algorithms::LogLevel>(logger()->level()));
0040 
0041     // Pass config object to algorithm
0042     m_algo->applyConfig(config());
0043 
0044     m_algo->init();
0045   }
0046 
0047   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0048     // This is called on every event.
0049     // Use this callback to call your Algorithm using all inputs and outputs
0050     // The inputs will have already been fetched for you at this point.
0051     m_algo->process({m_in_rc_particles()}, {m_out_reco_particles().get()});
0052 
0053     logger()->debug("Found {} reconstructed electron candidates", m_out_reco_particles()->size());
0054   }
0055 };
0056 } // namespace eicrecon