Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 07:56:32

0001 // Copyright (C) 2022, 2023 Daniel Brandenburg
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
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 private:
0015   // Underlying algorithm
0016   std::unique_ptr<eicrecon::ElectronReconstruction> m_algo;
0017 
0018   // Declare inputs
0019   PodioInput<edm4eic::ReconstructedParticle> m_in_rc_particles{this, "ReconstructedParticles"};
0020 
0021   // Declare outputs
0022   PodioOutput<edm4eic::ReconstructedParticle> m_out_reco_particles{this};
0023 
0024   // Declare parameters
0025   ParameterRef<double> m_min_energy_over_momentum{this, "minEnergyOverMomentum",
0026                                                   config().min_energy_over_momentum};
0027   ParameterRef<double> m_max_energy_over_momentum{this, "maxEnergyOverMomentum",
0028                                                   config().max_energy_over_momentum};
0029 
0030   // Declare services here, e.g.
0031   // Service<DD4hep_service> m_geoSvc {this};
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<eicrecon::ElectronReconstruction>();
0039 
0040     // Pass config object to algorithm
0041     m_algo->applyConfig(config());
0042 
0043     // If we needed geometry, we'd obtain it like so
0044     // m_algo->init(m_geoSvc().detector(), m_geoSvc().converter(), logger());
0045 
0046     m_algo->init(logger());
0047   }
0048 
0049   void ChangeRun(int32_t /* run_number */) {
0050     // This is called whenever the run number is changed.
0051     // Use this callback to retrieve state that is keyed off of run number.
0052     // This state should usually be managed by a Service.
0053     // Note: You usually don't need this, because you can declare a Resource instead.
0054   }
0055 
0056   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0057     // This is called on every event.
0058     // Use this callback to call your Algorithm using all inputs and outputs
0059     // The inputs will have already been fetched for you at this point.
0060     auto output = m_algo->execute(m_in_rc_particles());
0061 
0062     logger()->debug("Found {} reconstructed electron candidates", output->size());
0063 
0064     m_out_reco_particles() = std::move(output);
0065     // JANA will take care of publishing the outputs for you.
0066   }
0067 };
0068 } // namespace eicrecon