Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-02 08:32:55

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023 - 2025, Simon Gardner
0003 
0004 #pragma once
0005 
0006 #include "algorithms/fardetectors/FarDetectorTrackerCluster.h"
0007 #include "services/geometry/dd4hep/DD4hep_service.h"
0008 #include "extensions/jana/JOmniFactory.h"
0009 
0010 namespace eicrecon {
0011 
0012 class FarDetectorTrackerCluster_factory
0013     : public JOmniFactory<FarDetectorTrackerCluster_factory, FarDetectorTrackerClusterConfig> {
0014 
0015 public:
0016   using AlgoT = eicrecon::FarDetectorTrackerCluster;
0017 
0018 private:
0019   std::unique_ptr<AlgoT> m_algo;
0020 
0021   VariadicPodioInput<edm4eic::TrackerHit> m_raw_hits_input{this};
0022   VariadicPodioOutput<edm4eic::Measurement2D> m_clustered_hits_output{this};
0023 
0024   Service<AlgorithmsInit_service> m_algorithmsInit{this};
0025 
0026   ParameterRef<std::string> m_readout{this, "readoutClass", config().readout};
0027   ParameterRef<std::string> m_x_field{this, "xField", config().x_field};
0028   ParameterRef<std::string> m_y_field{this, "yField", config().y_field};
0029   ParameterRef<double> m_hit_time_limit{this, "hitTimeLimit", config().hit_time_limit};
0030 
0031 public:
0032   /** One time initialization **/
0033   void Configure() {
0034 
0035     m_algo = std::make_unique<AlgoT>(GetPrefix());
0036     m_algo->level(static_cast<algorithms::LogLevel>(logger()->level()));
0037     // Setup algorithm
0038     m_algo->applyConfig(config());
0039     m_algo->init();
0040   }
0041 
0042   void ChangeRun(int32_t /* run_number */) {}
0043 
0044   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0045     std::vector<gsl::not_null<edm4eic::Measurement2DCollection*>> clustered_collections;
0046     for (const auto& clustered : m_clustered_hits_output()) {
0047       clustered_collections.push_back(
0048           gsl::not_null<edm4eic::Measurement2DCollection*>(clustered.get()));
0049     }
0050 
0051     auto in1 = m_raw_hits_input();
0052     std::vector<gsl::not_null<const edm4eic::TrackerHitCollection*>> in2;
0053     std::copy(in1.cbegin(), in1.cend(), std::back_inserter(in2));
0054 
0055     m_algo->process(in2, clustered_collections);
0056   }
0057 };
0058 
0059 } // namespace eicrecon