Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-05 09:25:27

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024 - 2025, Simon Gardner
0003 
0004 #pragma once
0005 
0006 #include "services/geometry/dd4hep/DD4hep_service.h"
0007 
0008 // Event Model related classes
0009 #include <edm4eic/MCRecoTrackerHitAssociationCollection.h>
0010 #include <edm4eic/MCRecoTrackParticleAssociationCollection.h>
0011 #include <edm4eic/TrackCollection.h>
0012 #include <edm4eic/Measurement2DCollection.h>
0013 #include <algorithms/fardetectors/FarDetectorLinearTracking.h>
0014 
0015 #include <extensions/jana/JOmniFactory.h>
0016 #include <spdlog/logger.h>
0017 
0018 namespace eicrecon {
0019 
0020 class FarDetectorLinearTracking_factory
0021     : public JOmniFactory<FarDetectorLinearTracking_factory, FarDetectorLinearTrackingConfig> {
0022 
0023 public:
0024   using AlgoT = eicrecon::FarDetectorLinearTracking;
0025 
0026 private:
0027   std::unique_ptr<AlgoT> m_algo;
0028 
0029   VariadicPodioInput<edm4eic::Measurement2D> m_hits_input{this};
0030   PodioInput<edm4eic::MCRecoTrackerHitAssociation> m_hits_association_input{this};
0031   PodioOutput<edm4eic::Track> m_tracks_output{this};
0032   PodioOutput<edm4eic::MCRecoTrackParticleAssociation> m_tracks_association_output{this};
0033 
0034   ParameterRef<std::size_t> n_layer{this, "numLayers", config().n_layer};
0035   ParameterRef<std::vector<double>> layer_weights{this, "layerWeights", config().layer_weights};
0036   ParameterRef<std::size_t> layer_hits_max{this, "layerHitsMax", config().layer_hits_max};
0037   ParameterRef<float> chi2_max{this, "chi2Max", config().chi2_max};
0038 
0039 public:
0040   void Configure() {
0041     m_algo = std::make_unique<AlgoT>(GetPrefix());
0042     m_algo->level(static_cast<algorithms::LogLevel>(logger()->level()));
0043     m_algo->applyConfig(config());
0044     m_algo->init();
0045   }
0046 
0047   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0048 
0049     try {
0050       std::vector<gsl::not_null<const edm4eic::Measurement2DCollection*>> hits;
0051       for (const auto& hit : m_hits_input()) {
0052         hits.push_back(gsl::not_null<const edm4eic::Measurement2DCollection*>{hit});
0053       }
0054 
0055       // Prepare the input tuple
0056       auto input = std::make_tuple(hits, m_hits_association_input());
0057 
0058       m_algo->process(input, {m_tracks_output().get(), m_tracks_association_output().get()});
0059     } catch (std::exception& e) {
0060       throw JException(e.what());
0061     }
0062   }
0063 };
0064 
0065 } // namespace eicrecon