diff --git a/src/algorithms/tracking/TrackerHitReconstruction.cc b/src/algorithms/tracking/TrackerHitReconstruction.cc index ba37ac094c..2a4de11247 100644 --- a/src/algorithms/tracking/TrackerHitReconstruction.cc +++ b/src/algorithms/tracking/TrackerHitReconstruction.cc @@ -1,15 +1,15 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck, Dmitry Romanov +// Copyright (C) 2022 - 2025 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck, Dmitry Romanov #include "TrackerHitReconstruction.h" #include #include #include +#include #include #include #include -#include #include #include #include @@ -27,21 +27,13 @@ namespace { } } // namespace -void TrackerHitReconstruction::init(const dd4hep::rec::CellIDPositionConverter* converter, - std::shared_ptr& logger) { - - m_log = logger; - - m_converter = converter; -} - -std::unique_ptr -TrackerHitReconstruction::process(const edm4eic::RawTrackerHitCollection& raw_hits) { +void TrackerHitReconstruction::process(const Input& input, const Output& output) const { using dd4hep::mm; - auto rec_hits{std::make_unique()}; + const auto [raw_hits] = input; + auto [rec_hits] = output; - for (const auto& raw_hit : raw_hits) { + for (const auto& raw_hit : *raw_hits) { auto id = raw_hit.getCellID(); @@ -50,12 +42,11 @@ TrackerHitReconstruction::process(const edm4eic::RawTrackerHitCollection& raw_hi auto dim = m_converter->cellDimensions(id); // >oO trace - if (m_log->level() == spdlog::level::trace) { - m_log->trace("position x={:.2f} y={:.2f} z={:.2f} [mm]: ", pos.x() / mm, pos.y() / mm, - pos.z() / mm); - m_log->trace("dimension size: {}", dim.size()); + if (level() == algorithms::LogLevel::kTrace) { + trace("position x={:.2f} y={:.2f} z={:.2f} [mm]: ", pos.x() / mm, pos.y() / mm, pos.z() / mm); + trace("dimension size: {}", dim.size()); for (std::size_t j = 0; j < std::size(dim); ++j) { - m_log->trace(" - dimension {:<5} size: {:.2}", j, dim[j]); + trace(" - dimension {:<5} size: {:.2}", j, dim[j]); } } @@ -81,8 +72,6 @@ TrackerHitReconstruction::process(const edm4eic::RawTrackerHitCollection& raw_hi 0.0F); // Error on the energy rec_hit.setRawHit(raw_hit); } - - return rec_hits; } } // namespace eicrecon diff --git a/src/algorithms/tracking/TrackerHitReconstruction.h b/src/algorithms/tracking/TrackerHitReconstruction.h index 138cd33f2f..d25142e5a6 100644 --- a/src/algorithms/tracking/TrackerHitReconstruction.h +++ b/src/algorithms/tracking/TrackerHitReconstruction.h @@ -1,45 +1,46 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck, Dmitry Romanov +// Copyright (C) 2022 - 2025 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck, Dmitry Romanov #pragma once #include +#include +#include #include #include -#include -#include +#include +#include +#include #include "TrackerHitReconstructionConfig.h" #include "algorithms/interfaces/WithPodConfig.h" namespace eicrecon { +using TrackerHitReconstructionAlgorithm = + algorithms::Algorithm, + algorithms::Output>; + /** - * Produces edm4eic::TrackerHit with geometric info from edm4eic::RawTrackerHit - */ -class TrackerHitReconstruction : public WithPodConfig { + * Produces edm4eic::TrackerHit with geometric info from edm4eic::RawTrackerHit + */ +class TrackerHitReconstruction : public TrackerHitReconstructionAlgorithm, + public WithPodConfig { public: + TrackerHitReconstruction(std::string_view name) + : TrackerHitReconstructionAlgorithm{ + name, {"inputRawHits"}, {"outputHits"}, "reconstruct raw hits into tracker hits."} {} + /// Once in a lifetime initialization - void init(const dd4hep::rec::CellIDPositionConverter* converter, - std::shared_ptr& logger); + void init() final{}; /// Processes RawTrackerHit and produces a TrackerHit - std::unique_ptr - process(const edm4eic::RawTrackerHitCollection& raw_hits); - - /// Set a configuration - eicrecon::TrackerHitReconstructionConfig& - applyConfig(eicrecon::TrackerHitReconstructionConfig& cfg) { - m_cfg = cfg; - return m_cfg; - } + void process(const Input&, const Output&) const final; private: - /** algorithm logger */ - std::shared_ptr m_log; - - /// Cell ID position converter - const dd4hep::rec::CellIDPositionConverter* m_converter; + const algorithms::GeoSvc& m_geo{algorithms::GeoSvc::instance()}; + const dd4hep::rec::CellIDPositionConverter* m_converter{m_geo.cellIDPositionConverter()}; }; + } // namespace eicrecon diff --git a/src/factories/tracking/TrackerHitReconstruction_factory.h b/src/factories/tracking/TrackerHitReconstruction_factory.h index 8d053ab604..ada9b0f8d3 100644 --- a/src/factories/tracking/TrackerHitReconstruction_factory.h +++ b/src/factories/tracking/TrackerHitReconstruction_factory.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2023 Wouter Deconinck +// Copyright (C) 2023 - 2025 Wouter Deconinck #pragma once @@ -12,7 +12,11 @@ namespace eicrecon { class TrackerHitReconstruction_factory : public JOmniFactory { - TrackerHitReconstruction m_algo; +public: + using AlgoT = eicrecon::TrackerHitReconstruction; + +private: + std::unique_ptr m_algo; PodioInput m_raw_hits_input{this}; PodioOutput m_rec_hits_output{this}; @@ -23,14 +27,15 @@ class TrackerHitReconstruction_factory public: void Configure() { - m_algo.applyConfig(config()); - m_algo.init(m_geoSvc().converter(), logger()); + m_algo = std::make_unique(GetPrefix()); + m_algo->applyConfig(config()); + m_algo->init(); } void ChangeRun(int32_t /* run_number */) {} void Process(int32_t /* run_number */, uint64_t /* event_number */) { - m_rec_hits_output() = m_algo.process(*m_raw_hits_input()); + m_algo->process({m_raw_hits_input()}, {m_rec_hits_output().get()}); } };