Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:34:29

0001 // Copyright 2023, Wouter Deconinck
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 //
0004 
0005 #pragma once
0006 
0007 #include <edm4eic/EDM4eicVersion.h>
0008 
0009 #include "algorithms/calorimetry/CalorimeterClusterRecoCoG.h"
0010 #include "services/algorithms_init/AlgorithmsInit_service.h"
0011 #include "extensions/jana/JOmniFactory.h"
0012 
0013 namespace eicrecon {
0014 
0015 class CalorimeterClusterRecoCoG_factory
0016     : public JOmniFactory<CalorimeterClusterRecoCoG_factory, CalorimeterClusterRecoCoGConfig> {
0017 
0018 public:
0019   using AlgoT = eicrecon::CalorimeterClusterRecoCoG;
0020 
0021 private:
0022   std::unique_ptr<AlgoT> m_algo;
0023 
0024   PodioInput<edm4eic::ProtoCluster> m_proto_input{this};
0025 #if EDM4EIC_VERSION_MAJOR >= 7
0026   PodioInput<edm4eic::MCRecoCalorimeterHitAssociation> m_mchitassocs_input{this};
0027 #else
0028   PodioInput<edm4hep::SimCalorimeterHit> m_mchits_input{this};
0029 #endif
0030 
0031   PodioOutput<edm4eic::Cluster> m_cluster_output{this};
0032   PodioOutput<edm4eic::MCRecoClusterParticleAssociation> m_assoc_output{this};
0033 
0034   ParameterRef<std::string> m_energyWeight{this, "energyWeight", config().energyWeight};
0035   ParameterRef<double> m_samplingFraction{this, "samplingFraction", config().sampFrac};
0036   ParameterRef<double> m_logWeightBase{this, "logWeightBase", config().logWeightBase};
0037   ParameterRef<std::vector<double>> m_logWeightBaseCoeffs{this, "logWeightBaseCoeffs",
0038                                                           config().logWeightBaseCoeffs};
0039   ParameterRef<double> m_logWeightBase_Eref{this, "logWeightBase_Eref",
0040                                             config().logWeightBase_Eref};
0041   ParameterRef<bool> m_enableEtaBounds{this, "enableEtaBounds", config().enableEtaBounds};
0042 
0043   Service<AlgorithmsInit_service> m_algorithmsInit{this};
0044 
0045 public:
0046   void Configure() {
0047     m_algo = std::make_unique<AlgoT>(GetPrefix());
0048     m_algo->level(static_cast<algorithms::LogLevel>(logger()->level()));
0049     m_algo->applyConfig(config());
0050     m_algo->init();
0051   }
0052 
0053   void ChangeRun(int32_t /* run_number */) {}
0054 
0055   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0056 #if EDM4EIC_VERSION_MAJOR >= 7
0057     m_algo->process({m_proto_input(), m_mchitassocs_input()},
0058 #else
0059     m_algo->process({m_proto_input(), m_mchits_input()},
0060 #endif
0061                     {m_cluster_output().get(), m_assoc_output().get()});
0062   }
0063 };
0064 
0065 } // namespace eicrecon