File indexing completed on 2025-09-17 09:22:17
0001
0002
0003
0004
0005 #pragma once
0006
0007
0008
0009
0010
0011
0012
0013 #include "JANA/Services/JParameterManager.h"
0014 #include "JANA/Utils/JEventLevel.h"
0015 #include <JANA/JEvent.h>
0016 #include <JANA/JMultifactory.h>
0017 #include <JANA/JVersion.h>
0018
0019 #include <string>
0020 #include <vector>
0021
0022 namespace jana::components {
0023
0024 struct EmptyConfig {};
0025
0026 template <typename AlgoT, typename ConfigT=EmptyConfig>
0027 class JOmniFactory : public JMultifactory {
0028 private:
0029
0030 ConfigT m_config;
0031
0032 public:
0033
0034 inline void PreInit(std::string tag,
0035 JEventLevel level,
0036 std::vector<std::string> input_collection_names,
0037 std::vector<JEventLevel> input_collection_levels,
0038 std::vector<std::vector<std::string>> variadic_input_collection_names,
0039 std::vector<JEventLevel> variadic_input_collection_levels,
0040 std::vector<std::string> output_collection_names,
0041 std::vector<std::vector<std::string>> variadic_output_collection_names
0042 ) {
0043
0044 m_prefix = (this->GetPluginName().empty()) ? tag : this->GetPluginName() + ":" + tag;
0045 m_level = level;
0046
0047
0048 m_logger = m_app->GetService<JParameterManager>()->GetLogger(m_prefix);
0049
0050
0051
0052 m_app->SetDefaultParameter(m_prefix + ":InputTags", input_collection_names, "Input collection names");
0053 m_app->SetDefaultParameter(m_prefix + ":OutputTags", output_collection_names, "Output collection names");
0054
0055 WireInputs(level, input_collection_levels, input_collection_names, variadic_input_collection_levels, variadic_input_collection_names);
0056 WireOutputs(level, output_collection_names, variadic_output_collection_names, false);
0057
0058
0059
0060
0061
0062 }
0063
0064 void Init() override {
0065 static_cast<AlgoT*>(this)->Configure();
0066 }
0067
0068 void ChangeRun(const std::shared_ptr<const JEvent>& event) override {
0069 static_cast<AlgoT*>(this)->ChangeRun(event->GetRunNumber());
0070 }
0071
0072 void ChangeRun(int32_t) override {};
0073
0074 void Process(const std::shared_ptr<const JEvent> &event) override {
0075 static_cast<AlgoT*>(this)->Execute(event->GetRunNumber(), event->GetEventNumber());
0076 }
0077
0078 using ConfigType = ConfigT;
0079
0080
0081
0082 JLogger& logger() { return m_logger; }
0083
0084
0085 ConfigT& config() { return m_config; }
0086
0087
0088
0089 void Summarize(JComponentSummary& summary) const override {
0090
0091 auto* mfs = new JComponentSummary::Component(
0092 "OmniFactory", GetPrefix(), GetTypeName(), GetLevel(), GetPluginName());
0093
0094 SummarizeInputs(*mfs);
0095 SummarizeOutputs(*mfs);
0096 summary.Add(mfs);
0097 }
0098
0099 };
0100
0101 }
0102
0103 using jana::components::JOmniFactory;
0104
0105