Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-25 08:23:32

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2025 Derek Anderson
0003 
0004 #pragma once
0005 
0006 #include <edm4eic/EDM4eicVersion.h>
0007 #include "algorithms/calorimetry/CalorimeterClusterShape.h"
0008 #include "extensions/jana/JOmniFactory.h"
0009 #include "services/algorithms_init/AlgorithmsInit_service.h"
0010 
0011 namespace eicrecon {
0012 
0013 class CalorimeterClusterShape_factory
0014     : public JOmniFactory<CalorimeterClusterShape_factory, CalorimeterClusterShapeConfig> {
0015 
0016 public:
0017   using AlgoT = eicrecon::CalorimeterClusterShape;
0018 
0019 private:
0020   // algorithm to run
0021   std::unique_ptr<AlgoT> m_algo;
0022 
0023   // input collections
0024   PodioInput<edm4eic::Cluster> m_clusters_input{this};
0025   PodioInput<edm4eic::MCRecoClusterParticleAssociation> m_assocs_input{this};
0026 
0027   // output collections
0028   PodioOutput<edm4eic::Cluster> m_clusters_output{this};
0029 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0030   PodioOutput<edm4eic::MCRecoClusterParticleLink> m_links_output{this};
0031 #endif
0032   PodioOutput<edm4eic::MCRecoClusterParticleAssociation> m_assocs_output{this};
0033 
0034   // parameter bindings
0035   ParameterRef<bool> m_longitudinalShowerInfoAvailable{this, "longitudinalShowerInfoAvailable",
0036                                                        config().longitudinalShowerInfoAvailable};
0037   ParameterRef<std::string> m_energyWeight{this, "energyWeight", config().energyWeight};
0038   ParameterRef<double> m_sampFrac{this, "sampFrac", config().sampFrac};
0039   ParameterRef<std::vector<double>> m_logWeightBaseCoeffs{this, "logWeightBaseCoeffs",
0040                                                           config().logWeightBaseCoeffs};
0041   ParameterRef<double> m_logWeightBase_Eref{this, "logWeightBase_Eref",
0042                                             config().logWeightBase_Eref};
0043   ParameterRef<double> m_logWeightBase{this, "logWeightBase", config().logWeightBase};
0044 
0045   // services
0046   Service<AlgorithmsInit_service> m_algoInitSvc{this};
0047 
0048 public:
0049   void Configure() {
0050     m_algo = std::make_unique<AlgoT>(GetPrefix());
0051     m_algo->level(static_cast<algorithms::LogLevel>(logger()->level()));
0052     m_algo->applyConfig(config());
0053     m_algo->init();
0054   }
0055 
0056   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0057     m_algo->process({m_clusters_input(), m_assocs_input()}, {m_clusters_output().get(),
0058 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0059                                                              m_links_output().get(),
0060 #endif
0061                                                              m_assocs_output().get()});
0062   }
0063 
0064 }; // end CalorimeterClusterShape_factory
0065 
0066 } // namespace eicrecon