Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:03:06

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 
0011 namespace eicrecon {
0012 
0013 class ReconstructedElectrons_factory : public JOmniFactory<ReconstructedElectrons_factory, ElectronReconstructionConfig> {
0014 private:
0015 
0016     // Underlying algorithm
0017     std::unique_ptr<eicrecon::ElectronReconstruction> m_algo;
0018 
0019     // Declare inputs
0020     PodioInput<edm4eic::ReconstructedParticle> m_in_rc_particles {this, "ReconstructedParticles"};
0021 
0022 
0023     // Declare outputs
0024     PodioOutput<edm4eic::ReconstructedParticle> m_out_reco_particles {this};
0025 
0026     // Declare parameters
0027     ParameterRef<double> m_min_energy_over_momentum {this, "minEnergyOverMomentum", config().min_energy_over_momentum};
0028     ParameterRef<double> m_max_energy_over_momentum {this, "maxEnergyOverMomentum", 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(int64_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(int64_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(
0061           m_in_rc_particles()
0062         );
0063 
0064         logger()->debug( "Event {}: Found {} reconstructed electron candidates", event_number, output->size() );
0065 
0066         m_out_reco_particles() = std::move(output);
0067         // JANA will take care of publishing the outputs for you.
0068     }
0069 };
0070 } // namespace eicrecon