diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index b94a8558fe..77bc6b9915 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -57,12 +56,13 @@ template <> struct hash { // Hash for tuple // --> not yet supported by any compiler at the moment -template <> struct hash> { - size_t operator()(const std::tuple& key) const noexcept { - const auto& [particle, cellID] = key; - size_t h1 = hash{}(particle); - size_t h2 = hash{}(cellID); - return h1 ^ (h2 << 1); +template <> struct hash> { + size_t operator()(const std::tuple& key) const noexcept { + const auto& [particle, cellID, timeID] = key; + size_t h1 = hash{}(particle); + size_t h2 = hash{}(cellID); + size_t h3 = hash{}(timeID); + return ((h1 ^ (h2 << 1)) >> 1) ^ (h3 << 1); } }; @@ -173,7 +173,7 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input // (hence modify) contributions which is not supported for PodIO VectorMembers. Using // reasonable contribution merging, at least the intermediary structure should be // quite a bit smaller than the original hit collection. - using HitIndex = std::tuple; + using HitIndex = std::tuple; std::unordered_map> hit_map; @@ -184,21 +184,22 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input (ih.getCellID() & m_hit_id_mask.value() & m_contribution_id_mask.value()); // the cell ID of this particular contribution (we are using contributions to store // the hits making up this "superhit" with more segmentation) - const uint64_t newcontrib_cellID = (ih.getCellID() & m_hit_id_mask.value()); + const uint64_t newcontrib_cellID = (ih.getCellID() & m_contribution_id_mask.value()); // Optional attenuation const double attFactor = m_attenuationReferencePosition ? get_attenuation(ih.getPosition().z) : 1.; // Use primary particle (traced back through parents) to group contributions for (const auto& contrib : ih.getContributions()) { edm4hep::MCParticle primary = lookup_primary(contrib); - auto& hit_accum = hit_map[{primary, newhit_cellID}][newcontrib_cellID]; const double propagationTime = m_attenuationReferencePosition ? std::abs(m_attenuationReferencePosition.value() - ih.getPosition().z) * m_cfg.inversePropagationSpeed : 0.; - hit_accum.add(contrib.getEnergy() * attFactor, - contrib.getTime() + propagationTime + m_cfg.fixedTimeDelay, ih.getPosition()); + const double totalTime = contrib.getTime() + propagationTime + m_cfg.fixedTimeDelay; + const int newhit_timeID = std::floor(totalTime / m_cfg.timeWindow); + auto& hit_accum = hit_map[{primary, newhit_cellID, newhit_timeID}][newcontrib_cellID]; + hit_accum.add(contrib.getEnergy() * attFactor, totalTime, ih.getPosition()); } } @@ -208,7 +209,7 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input auto out_hit = out_hits->create(); - const auto& [particle, cellID] = hit_idx; + const auto& [particle, cellID, timeID] = hit_idx; HitContributionAccumulator new_hit; for (const auto& [contrib_idx, contrib] : contribs) { // Aggregate contributions to for the global hit diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h b/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h index eb25a30998..b6797df737 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h @@ -5,6 +5,7 @@ #include #include +#include namespace eicrecon { @@ -27,6 +28,8 @@ struct SimCalorimeterHitProcessorConfig { double inversePropagationSpeed{}; // detector-related time delay (e.g., scintillation) double fixedTimeDelay{}; + // time window for grouping contributions + double timeWindow{100 * edm4eic::unit::ns}; }; } // namespace eicrecon diff --git a/src/algorithms/digi/SiliconPulseGeneration.cc b/src/algorithms/digi/PulseGeneration.cc similarity index 72% rename from src/algorithms/digi/SiliconPulseGeneration.cc rename to src/algorithms/digi/PulseGeneration.cc index 5f3fa42573..b2212b5537 100644 --- a/src/algorithms/digi/SiliconPulseGeneration.cc +++ b/src/algorithms/digi/PulseGeneration.cc @@ -1,22 +1,27 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2024-2025 Simon Gardner, Chun Yuen Tsang, Prithwish Tribedy +// Copyright (C) 2024-2025 Simon Gardner, Chun Yuen Tsang, Prithwish Tribedy, +// Minho Kim, Sylvester Joosten, Wouter Deconinck, Dmitry Kalinkin // // Convert energy deposition into ADC pulses // ADC pulses are assumed to follow the shape of landau function -#include "SiliconPulseGeneration.h" +#include "PulseGeneration.h" #include #include #include -#include +#include +#include #include +#include +#include +#include #include #include #include #include -#include #include +#include #include #include @@ -127,7 +132,37 @@ class PulseShapeFactory { } }; -void SiliconPulseGeneration::init() { +std::tuple +HitAdapter::getPulseSources(const edm4hep::SimTrackerHit& hit) { + return {hit.getTime(), hit.getEDep()}; +} + +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) +void HitAdapter::addRelations(MutablePulseType& pulse, + const edm4hep::SimTrackerHit& hit) { + pulse.addToTrackerHits(hit); + pulse.addToParticles(hit.getParticle()); +} +#endif + +std::tuple +HitAdapter::getPulseSources(const edm4hep::SimCalorimeterHit& hit) { + const auto& contribs = hit.getContributions(); + auto earliest_contrib = + std::min_element(contribs.begin(), contribs.end(), + [](const auto& a, const auto& b) { return a.getTime() < b.getTime(); }); + return {earliest_contrib->getTime(), hit.getEnergy()}; +} + +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) +void HitAdapter::addRelations(MutablePulseType& pulse, + const edm4hep::SimCalorimeterHit& hit) { + pulse.addToCalorimeterHits(hit); + pulse.addToParticles(hit.getContributions(0).getParticle()); +} +#endif + +template void PulseGeneration::init() { m_pulse = PulseShapeFactory::createPulseShape(m_cfg.pulse_shape_function, m_cfg.pulse_shape_params); m_min_sampling_time = m_cfg.min_sampling_time; @@ -137,17 +172,15 @@ void SiliconPulseGeneration::init() { } } -void SiliconPulseGeneration::process(const SiliconPulseGeneration::Input& input, - const SiliconPulseGeneration::Output& output) const { +template +void PulseGeneration::process( + const typename PulseGenerationAlgorithm::Input& input, + const typename PulseGenerationAlgorithm::Output& output) const { const auto [simhits] = input; auto [rawPulses] = output; for (const auto& hit : *simhits) { - - auto cellID = hit.getCellID(); - double time = hit.getTime(); - double charge = hit.getEDep(); - + const auto [time, charge] = HitAdapter::getPulseSources(hit); // Calculate nearest timestep to the hit time rounded down (assume clocks aligned with time 0) double signal_time = m_cfg.timestep * std::floor(time / m_cfg.timestep); @@ -178,7 +211,7 @@ void SiliconPulseGeneration::process(const SiliconPulseGeneration::Input& input, } auto time_series = rawPulses->create(); - time_series.setCellID(cellID); + time_series.setCellID(hit.getCellID()); time_series.setInterval(m_cfg.timestep); time_series.setTime(signal_time + skip_bins * m_cfg.timestep); @@ -190,11 +223,13 @@ void SiliconPulseGeneration::process(const SiliconPulseGeneration::Input& input, time_series.setIntegral(integral); time_series.setPosition( edm4hep::Vector3f(hit.getPosition().x, hit.getPosition().y, hit.getPosition().z)); - time_series.addToTrackerHits(hit); - time_series.addToParticles(hit.getParticle()); + HitAdapter::addRelations(time_series, hit); #endif } -} // SiliconPulseGeneration:process +} // PulseGeneration:process + +template class PulseGeneration; +template class PulseGeneration; } // namespace eicrecon diff --git a/src/algorithms/digi/PulseGeneration.h b/src/algorithms/digi/PulseGeneration.h new file mode 100644 index 0000000000..4e5ad0848d --- /dev/null +++ b/src/algorithms/digi/PulseGeneration.h @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024-2025 Simon Gardner, Chun Yuen Tsang, Prithwish Tribedy, +// Minho Kim, Sylvester Joosten, Wouter Deconinck, Dmitry Kalinkin +// +// Convert energy deposition into analog pulses + +#pragma once + +#include +#include +#include +#include +#include +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) +#include +#else +#include +#endif +#include +#include +#include +#include + +#include "algorithms/digi/PulseGenerationConfig.h" +#include "algorithms/interfaces/WithPodConfig.h" + +namespace eicrecon { + +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) +using PulseType = edm4eic::SimPulse; +using MutablePulseType = edm4eic::MutableSimPulse; +#else +using PulseType = edm4hep::TimeSeries; +using MutablePulseType = edm4hep::MutableTimeSeries; +#endif + +template struct HitAdapter; + +template <> struct HitAdapter { + static std::tuple getPulseSources(const edm4hep::SimTrackerHit& hit); +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) + static void addRelations(MutablePulseType& pulse, const edm4hep::SimTrackerHit& hit); +#endif +}; + +template <> struct HitAdapter { + static std::tuple getPulseSources(const edm4hep::SimCalorimeterHit& hit); +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) + static void addRelations(MutablePulseType& pulse, const edm4hep::SimCalorimeterHit& hit); +#endif +}; + +template +using PulseGenerationAlgorithm = + algorithms::Algorithm, + algorithms::Output>; + +class SignalPulse; + +template +class PulseGeneration : public PulseGenerationAlgorithm, + public WithPodConfig { + +public: + PulseGeneration(std::string_view name) + : PulseGenerationAlgorithm{name, {"RawHits"}, {"OutputPulses"}, {}} {} + void init() final; + void process(const typename PulseGenerationAlgorithm::Input&, + const typename PulseGenerationAlgorithm::Output&) const final; + +private: + std::shared_ptr m_pulse; + float m_min_sampling_time = 0 * edm4eic::unit::ns; +}; + +} // namespace eicrecon diff --git a/src/algorithms/digi/SiliconPulseGenerationConfig.h b/src/algorithms/digi/PulseGenerationConfig.h similarity index 94% rename from src/algorithms/digi/SiliconPulseGenerationConfig.h rename to src/algorithms/digi/PulseGenerationConfig.h index 6e4614cf15..7b716e3cc3 100644 --- a/src/algorithms/digi/SiliconPulseGenerationConfig.h +++ b/src/algorithms/digi/PulseGenerationConfig.h @@ -7,7 +7,7 @@ namespace eicrecon { -struct SiliconPulseGenerationConfig { +struct PulseGenerationConfig { // Parameters of Silicon signal generation std::string pulse_shape_function = "LandauPulse"; // Pulse shape function std::vector pulse_shape_params = {1.0, 0.1}; // Parameters of the pulse shape function diff --git a/src/algorithms/digi/SiliconPulseGeneration.h b/src/algorithms/digi/SiliconPulseGeneration.h deleted file mode 100644 index 35b221f6e2..0000000000 --- a/src/algorithms/digi/SiliconPulseGeneration.h +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2024-2025 Simon Gardner, Chun Yuen Tsang, Prithwish Tribedy -// -// Convert energy deposition into analog pulses - -#pragma once - -#include -#include -#include -#include -#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) -#include -#else -#include -#endif -#include -#include -#include - -#include "algorithms/digi/SiliconPulseGenerationConfig.h" -#include "algorithms/interfaces/WithPodConfig.h" - -namespace eicrecon { - -#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) -using PulseType = edm4eic::SimPulse; -#else -using PulseType = edm4hep::TimeSeries; -#endif - -using SiliconPulseGenerationAlgorithm = - algorithms::Algorithm, - algorithms::Output>; - -class SignalPulse; - -class SiliconPulseGeneration : public SiliconPulseGenerationAlgorithm, - public WithPodConfig { - -public: - SiliconPulseGeneration(std::string_view name) - : SiliconPulseGenerationAlgorithm{name, {"RawHits"}, {"OutputPulses"}, {}} {} - void init() final; - void process(const Input&, const Output&) const final; - -private: - std::shared_ptr m_pulse; - float m_min_sampling_time = 0 * edm4eic::unit::ns; -}; - -} // namespace eicrecon diff --git a/src/detectors/BEMC/BEMC.cc b/src/detectors/BEMC/BEMC.cc index 05eb55c831..f35938b388 100644 --- a/src/detectors/BEMC/BEMC.cc +++ b/src/detectors/BEMC/BEMC.cc @@ -2,10 +2,14 @@ // Copyright (C) 2022 - 2025 Whitney Armstrong, Sylvester Joosten, Chao Peng, David Lawrence, Thomas Britton, Wouter Deconinck, Maria Zurek, Akshaya Vijay, Nathan Brei, Dmitry Kalinkin, Derek Anderson, Minho Kim #include +#include #include #include #include +#include #include +#include +#include #include #include #include @@ -13,6 +17,7 @@ #include "algorithms/calorimetry/CalorimeterHitDigiConfig.h" #include "algorithms/calorimetry/ImagingTopoClusterConfig.h" #include "algorithms/calorimetry/SimCalorimeterHitProcessorConfig.h" +#include "algorithms/digi/PulseGenerationConfig.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h" #include "factories/calorimetry/CalorimeterClusterShape_factory.h" @@ -24,6 +29,7 @@ #include "factories/calorimetry/ImagingTopoCluster_factory.h" #include "factories/calorimetry/SimCalorimeterHitProcessor_factory.h" #include "factories/calorimetry/TruthEnergyPositionClusterMerger_factory.h" +#include "factories/digi/PulseGeneration_factory.h" extern "C" { void InitPlugin(JApplication* app) { @@ -43,6 +49,15 @@ void InitPlugin(JApplication* app) { EcalBarrelScFi_inversePropagationSpeed = {(1. / 160) * edm4eic::unit::ns / edm4eic::unit::mm}; decltype(SimCalorimeterHitProcessorConfig::fixedTimeDelay) EcalBarrelScFi_fixedTimeDelay = { 2 * edm4eic::unit::ns}; + decltype(SimCalorimeterHitProcessorConfig::timeWindow) EcalBarrelScFi_timeWindow = { + 100 * edm4eic::unit::ns}; + + decltype(PulseGenerationConfig::pulse_shape_function) EcalBarrelScFi_pulse_shape_function = { + "LandauPulse"}; + decltype(PulseGenerationConfig::pulse_shape_params) EcalBarrelScFi_pulse_shape_params = { + 1.0, 2 * edm4eic::unit::ns}; + decltype(PulseGenerationConfig::ignore_thres) EcalBarrelScFi_ignore_thres = {1.0e-5}; + decltype(PulseGenerationConfig::timestep) EcalBarrelScFi_timestep = {0.5 * edm4eic::unit::ns}; // Make sure digi and reco use the same value decltype(CalorimeterHitDigiConfig::capADC) EcalBarrelScFi_capADC = 16384; //16384, 14bit ADC @@ -62,6 +77,7 @@ void InitPlugin(JApplication* app) { .contributionMergeFields = EcalBarrelScFi_contributionMergeFields, .inversePropagationSpeed = EcalBarrelScFi_inversePropagationSpeed, .fixedTimeDelay = EcalBarrelScFi_fixedTimeDelay, + .timeWindow = EcalBarrelScFi_timeWindow, }, app // TODO: Remove me once fixed )); @@ -76,6 +92,27 @@ void InitPlugin(JApplication* app) { .contributionMergeFields = EcalBarrelScFi_contributionMergeFields, .inversePropagationSpeed = EcalBarrelScFi_inversePropagationSpeed, .fixedTimeDelay = EcalBarrelScFi_fixedTimeDelay, + .timeWindow = EcalBarrelScFi_timeWindow, + }, + app // TODO: Remove me once fixed + )); + app->Add(new JOmniFactoryGeneratorT>( + "EcalBarrelScFiPPulses", {"EcalBarrelScFiPAttenuatedHits"}, {"EcalBarrelScFiPPulses"}, + { + .pulse_shape_function = EcalBarrelScFi_pulse_shape_function, + .pulse_shape_params = EcalBarrelScFi_pulse_shape_params, + .ignore_thres = EcalBarrelScFi_ignore_thres, + .timestep = EcalBarrelScFi_timestep, + }, + app // TODO: Remove me once fixed + )); + app->Add(new JOmniFactoryGeneratorT>( + "EcalBarrelScFiNPulses", {"EcalBarrelScFiNAttenuatedHits"}, {"EcalBarrelScFiNPulses"}, + { + .pulse_shape_function = EcalBarrelScFi_pulse_shape_function, + .pulse_shape_params = EcalBarrelScFi_pulse_shape_params, + .ignore_thres = EcalBarrelScFi_ignore_thres, + .timestep = EcalBarrelScFi_timestep, }, app // TODO: Remove me once fixed )); diff --git a/src/detectors/BTOF/BTOF.cc b/src/detectors/BTOF/BTOF.cc index e883e360c6..38b39354c4 100644 --- a/src/detectors/BTOF/BTOF.cc +++ b/src/detectors/BTOF/BTOF.cc @@ -6,11 +6,15 @@ // Copyright (C) 2024, Dmitry Kalinkin #include +#include #include #include #include #include +#include #include +#include +#include #include #include @@ -18,9 +22,9 @@ #include "extensions/jana/JOmniFactoryGeneratorT.h" #include "factories/digi/CFDROCDigitization_factory.h" #include "factories/digi/PulseCombiner_factory.h" +#include "factories/digi/PulseGeneration_factory.h" #include "factories/digi/SiliconChargeSharing_factory.h" #include "factories/digi/SiliconPulseDiscretization_factory.h" -#include "factories/digi/SiliconPulseGeneration_factory.h" #include "factories/digi/SiliconTrackerDigi_factory.h" #include "factories/tracking/TrackerHitReconstruction_factory.h" @@ -72,7 +76,7 @@ void InitPlugin(JApplication* app) { // gain is negative as LGAD voltage is always negative const double gain = -adc_range / Vm / landau_min * sigma_analog; const int offset = 3; - app->Add(new JOmniFactoryGeneratorT( + app->Add(new JOmniFactoryGeneratorT>( "LGADPulseGeneration", {"TOFBarrelSharedHits"}, {"TOFBarrelSmoothPulses"}, { .pulse_shape_function = "LandauPulse", diff --git a/src/detectors/LOWQ2/LOWQ2.cc b/src/detectors/LOWQ2/LOWQ2.cc index 59e9ec8dab..7310799f0d 100644 --- a/src/detectors/LOWQ2/LOWQ2.cc +++ b/src/detectors/LOWQ2/LOWQ2.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include // IWYU pragma: keep #include @@ -25,9 +26,9 @@ #include "algorithms/meta/SubDivideFunctors.h" #include "extensions/jana/JOmniFactoryGeneratorT.h" #include "factories/digi/PulseCombiner_factory.h" +#include "factories/digi/PulseGeneration_factory.h" #include "factories/digi/PulseNoise_factory.h" #include "factories/digi/SiliconChargeSharing_factory.h" -#include "factories/digi/SiliconPulseGeneration_factory.h" #include "factories/digi/SiliconTrackerDigi_factory.h" #include "factories/fardetectors/FarDetectorLinearProjection_factory.h" #include "factories/fardetectors/FarDetectorLinearTracking_factory.h" @@ -62,7 +63,7 @@ void InitPlugin(JApplication* app) { }, app)); // Generate signal pulse from hits - app->Add(new JOmniFactoryGeneratorT( + app->Add(new JOmniFactoryGeneratorT>( "TaggerTrackerPulseGeneration", {"TaggerTrackerSharedHits"}, {"TaggerTrackerHitPulses"}, { .pulse_shape_function = "LandauPulse", diff --git a/src/factories/calorimetry/SimCalorimeterHitProcessor_factory.h b/src/factories/calorimetry/SimCalorimeterHitProcessor_factory.h index 8872d58324..847a56786e 100644 --- a/src/factories/calorimetry/SimCalorimeterHitProcessor_factory.h +++ b/src/factories/calorimetry/SimCalorimeterHitProcessor_factory.h @@ -34,6 +34,7 @@ class SimCalorimeterHitProcessor_factory ParameterRef m_inversePropagationSpeed{this, "inversePropagationSpeed", config().inversePropagationSpeed}; ParameterRef m_fixedTimeDelay{this, "fixedTimeDelay", config().fixedTimeDelay}; + ParameterRef m_timeWindow{this, "timeWindow", config().timeWindow}; Service m_algorithmsInit{this}; diff --git a/src/factories/digi/PulseGeneration_factory.h b/src/factories/digi/PulseGeneration_factory.h new file mode 100644 index 0000000000..5c2b4bd818 --- /dev/null +++ b/src/factories/digi/PulseGeneration_factory.h @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2024-2025 Simon Gardner, Chun Yuen Tsang, Prithwish Tribedy +// Minho Kim, Sylvester Joosten, Wouter Deconinck, Dmitry Kalinkin +// + +#pragma once + +#include "algorithms/digi/PulseGeneration.h" +#include "services/algorithms_init/AlgorithmsInit_service.h" +#include "extensions/jana/JOmniFactory.h" + +namespace eicrecon { + +template +class PulseGeneration_factory + : public JOmniFactory, PulseGenerationConfig> { +public: + using AlgoT = eicrecon::PulseGeneration; + using FactoryT = JOmniFactory, PulseGenerationConfig>; + +private: + std::unique_ptr m_algo; + + typename FactoryT::template PodioInput m_in_sim_hits{this}; +#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) + typename FactoryT::template PodioOutput m_out_pulses{this}; +#else + typename FactoryT::template PodioOutput m_out_pulses{this}; +#endif + + typename FactoryT::template ParameterRef m_pulse_shape_function{ + this, "pulseShapeFunction", this->config().pulse_shape_function}; + typename FactoryT::template ParameterRef> m_pulse_shape_params{ + this, "pulseShapeParams", this->config().pulse_shape_params}; + typename FactoryT::template ParameterRef m_timestep{this, "timestep", + this->config().timestep}; + typename FactoryT::template ParameterRef m_ignore_thres{this, "ignoreThreshold", + this->config().ignore_thres}; + typename FactoryT::template ParameterRef m_min_sampling_time{ + this, "minSamplingTime", this->config().min_sampling_time}; + typename FactoryT::template ParameterRef m_max_time_bins{this, "maxTimeBins", + this->config().max_time_bins}; + + typename FactoryT::template Service m_algorithmsInit{this}; + +public: + void Configure() { + m_algo = std::make_unique(this->GetPrefix()); + m_algo->level(static_cast(this->logger()->level())); + m_algo->applyConfig(this->config()); + m_algo->init(); + } + + void Process(int32_t /* run_number */, uint64_t /* event_number */) { + m_algo->process({m_in_sim_hits()}, {m_out_pulses().get()}); + } +}; + +} // namespace eicrecon diff --git a/src/factories/digi/SiliconPulseGeneration_factory.h b/src/factories/digi/SiliconPulseGeneration_factory.h deleted file mode 100644 index 9a6b946fd5..0000000000 --- a/src/factories/digi/SiliconPulseGeneration_factory.h +++ /dev/null @@ -1,52 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2024-2025 Simon Gardner, Chun Yuen Tsang, Prithwish Tribedy -// - -#pragma once - -#include "algorithms/digi/SiliconPulseGeneration.h" -#include "services/algorithms_init/AlgorithmsInit_service.h" -#include "extensions/jana/JOmniFactory.h" - -namespace eicrecon { - -class SiliconPulseGeneration_factory - : public JOmniFactory { -public: - using AlgoT = eicrecon::SiliconPulseGeneration; - -private: - std::unique_ptr m_algo; - - PodioInput m_in_sim_hits{this}; -#if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) - PodioOutput m_out_pulses{this}; -#else - PodioOutput m_out_pulses{this}; -#endif - - ParameterRef m_pulse_shape_function{this, "pulseShapeFunction", - config().pulse_shape_function}; - ParameterRef> m_pulse_shape_params{this, "pulseShapeParams", - config().pulse_shape_params}; - ParameterRef m_timestep{this, "timestep", config().timestep}; - ParameterRef m_ignore_thres{this, "ignoreThreshold", config().ignore_thres}; - ParameterRef m_min_sampling_time{this, "minSamplingTime", config().min_sampling_time}; - ParameterRef m_max_time_bins{this, "maxTimeBins", config().max_time_bins}; - - Service m_algorithmsInit{this}; - -public: - void Configure() { - m_algo = std::make_unique(GetPrefix()); - m_algo->level(static_cast(logger()->level())); - m_algo->applyConfig(config()); - m_algo->init(); - } - - void Process(int32_t /* run_number */, uint64_t /* event_number */) { - m_algo->process({m_in_sim_hits()}, {m_out_pulses().get()}); - } -}; - -} // namespace eicrecon diff --git a/src/tests/algorithms_test/CMakeLists.txt b/src/tests/algorithms_test/CMakeLists.txt index c1790951d2..c44e51858e 100644 --- a/src/tests/algorithms_test/CMakeLists.txt +++ b/src/tests/algorithms_test/CMakeLists.txt @@ -12,8 +12,8 @@ add_executable( calorimetry_CalorimeterClusterRecoCoG.cc calorimetry_CalorimeterClusterShape.cc calorimetry_HEXPLIT.cc - digi_SiliconPulseGeneration.cc digi_EICROCDigitization.cc + digi_PulseGeneration.cc pid_MergeTracks.cc pid_MergeParticleID.cc pid_lut_PIDLookup.cc) diff --git a/src/tests/algorithms_test/digi_SiliconPulseGeneration.cc b/src/tests/algorithms_test/digi_PulseGeneration.cc similarity index 87% rename from src/tests/algorithms_test/digi_SiliconPulseGeneration.cc rename to src/tests/algorithms_test/digi_PulseGeneration.cc index cf811c08dc..94201fbdcf 100644 --- a/src/tests/algorithms_test/digi_SiliconPulseGeneration.cc +++ b/src/tests/algorithms_test/digi_PulseGeneration.cc @@ -19,8 +19,8 @@ #include #include -#include "algorithms/digi/SiliconPulseGeneration.h" -#include "algorithms/digi/SiliconPulseGenerationConfig.h" +#include "algorithms/digi/PulseGeneration.h" +#include "algorithms/digi/PulseGenerationConfig.h" #if EDM4EIC_VERSION_MAJOR > 8 || (EDM4EIC_VERSION_MAJOR == 8 && EDM4EIC_VERSION_MINOR >= 1) using PulseType = edm4eic::SimPulse; @@ -28,10 +28,10 @@ using PulseType = edm4eic::SimPulse; using PulseType = edm4hep::TimeSeries; #endif -TEST_CASE("SiliconPulseGeneration generates correct number of pulses", "[SiliconPulseGeneration]") { +TEST_CASE("PulseGeneration generates correct number of pulses", "[PulseGeneration]") { - eicrecon::SiliconPulseGeneration algo("SiliconPulseGeneration"); - eicrecon::SiliconPulseGenerationConfig cfg; + eicrecon::PulseGeneration algo("PulseGeneration"); + eicrecon::PulseGenerationConfig cfg; cfg.pulse_shape_function = "LandauPulse"; // Example pulse shape cfg.pulse_shape_params = {1.0, 1.0}; // Example parameters for the pulse shape cfg.ignore_thres = 1; @@ -66,11 +66,10 @@ TEST_CASE("SiliconPulseGeneration generates correct number of pulses", "[Silicon } } -TEST_CASE("Test the EvaluatorSvc pulse generation with a square pulse", - "[SiliconPulseGeneration]") { +TEST_CASE("Test the EvaluatorSvc pulse generation with a square pulse", "[PulseGeneration]") { - eicrecon::SiliconPulseGeneration algo("SiliconPulseGeneration"); - eicrecon::SiliconPulseGenerationConfig cfg; + eicrecon::PulseGeneration algo("PulseGeneration"); + eicrecon::PulseGenerationConfig cfg; // Square wave expression std::string expression = "(time >= param0 && time < param1) ? charge : 0";