Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:34:30

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