Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright 2023, Wouter Deconinck
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 #pragma once
0005 
0006 #include <edm4eic/EDM4eicVersion.h>
0007 
0008 #include "algorithms/calorimetry/CalorimeterHitDigi.h"
0009 #include "services/algorithms_init/AlgorithmsInit_service.h"
0010 #include "extensions/jana/JOmniFactory.h"
0011 
0012 namespace eicrecon {
0013 
0014 class CalorimeterHitDigi_factory : public JOmniFactory<CalorimeterHitDigi_factory, CalorimeterHitDigiConfig> {
0015 
0016 public:
0017     using AlgoT = eicrecon::CalorimeterHitDigi;
0018 private:
0019     std::unique_ptr<AlgoT> m_algo;
0020 
0021     PodioInput<edm4hep::SimCalorimeterHit> m_hits_input {this};
0022     PodioOutput<edm4hep::RawCalorimeterHit> m_hits_output {this};
0023 #if EDM4EIC_VERSION_MAJOR >= 7
0024     PodioOutput<edm4eic::MCRecoCalorimeterHitAssociation> m_hit_assocs_output {this};
0025 #endif
0026 
0027     ParameterRef<std::vector<double>> m_energyResolutions {this, "energyResolutions", config().eRes};
0028     ParameterRef<double> m_timeResolution {this, "timeResolution", config().tRes};
0029     ParameterRef<unsigned int> m_capADC {this, "capacityADC", config().capADC};
0030     ParameterRef<double> m_dyRangeADC {this, "dynamicRangeADC", config().dyRangeADC};
0031     ParameterRef<unsigned int> m_pedMeanADC {this, "pedestalMean", config().pedMeanADC};
0032     ParameterRef<double> m_pedSigmaADC {this, "pedestalSigma", config().pedSigmaADC};
0033     ParameterRef<double> m_resolutionTDC {this, "resolutionTDC", config().resolutionTDC};
0034     ParameterRef<std::string> m_corrMeanScale {this, "scaleResponse", config().corrMeanScale};
0035     ParameterRef<std::vector<std::string>> m_fields {this, "signalSumFields", config().fields};
0036     ParameterRef<std::string> m_readout {this, "readoutClass", config().readout};
0037 
0038     Service<AlgorithmsInit_service> m_algorithmsInit {this};
0039 
0040 public:
0041     void Configure() {
0042         m_algo = std::make_unique<AlgoT>(GetPrefix());
0043         m_algo->level(static_cast<algorithms::LogLevel>(logger()->level()));
0044         m_algo->applyConfig(config());
0045         m_algo->init();
0046     }
0047 
0048     void ChangeRun(int64_t run_number) {
0049     }
0050 
0051     void Process(int64_t run_nr, uint64_t event_nr) {
0052 #if EDM4EIC_VERSION_MAJOR >= 7
0053         m_algo->process({m_hits_input()}, {m_hits_output().get(), m_hit_assocs_output().get()});
0054 #else
0055         m_algo->process({m_hits_input()}, {m_hits_output().get()});
0056 #endif
0057     }
0058 };
0059 
0060 } // eicrecon