Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:13:08

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2024 Simon Gardner
0003 
0004 #pragma once
0005 
0006 #include "extensions/jana/JOmniFactory.h"
0007 #include "algorithms/meta/CollectionCollector.h"
0008 
0009 namespace eicrecon {
0010 
0011 template <class T, bool IsOptional = false>
0012 class CollectionCollector_factory
0013     : public JOmniFactory<CollectionCollector_factory<T, IsOptional>, NoConfig> {
0014 public:
0015   using AlgoT = eicrecon::CollectionCollector<typename T::collection_type>;
0016 
0017 private:
0018   std::unique_ptr<AlgoT> m_algo;
0019 
0020   typename JOmniFactory<CollectionCollector_factory<T, IsOptional>,
0021                         NoConfig>::template VariadicPodioInput<T, IsOptional>
0022       m_inputs{this};
0023   typename JOmniFactory<CollectionCollector_factory<T, IsOptional>,
0024                         NoConfig>::template PodioOutput<T>
0025       m_output{this};
0026 
0027 public:
0028   void Configure() {
0029     m_algo = std::make_unique<AlgoT>(this->GetPrefix());
0030     m_algo->level(static_cast<algorithms::LogLevel>(this->logger()->level()));
0031     m_algo->applyConfig(this->config());
0032     m_algo->init();
0033   }
0034 
0035   void Process(int32_t /* run_number */, uint64_t /* event_number */) {
0036     std::vector<gsl::not_null<const typename T::collection_type*>> in_collections;
0037     for (const auto& in_collection : m_inputs()) {
0038       in_collections.push_back(gsl::not_null<const typename T::collection_type*>{in_collection});
0039     }
0040     typename T::collection_type* merged_collection = m_output().get();
0041     m_algo->process(in_collections, merged_collection);
0042   };
0043 };
0044 
0045 } // namespace eicrecon