Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-27 09:06:28

0001 // Copyright 2023, Jefferson Science Associates, LLC.
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 // Created by Nathan Brei
0004 
0005 #pragma once
0006 
0007 /**
0008  * Omnifactories are a lightweight layer connecting JANA to generic algorithms
0009  * It is assumed multiple input data (controlled by input tags)
0010  * which might be changed by user parameters.
0011  */
0012 
0013 #include <JANA/JEvent.h>
0014 #include <JANA/JFactory.h>
0015 
0016 namespace jana::components {
0017 
0018 struct EmptyConfig {};
0019 
0020 template <typename FacT, typename ConfigT=EmptyConfig>
0021 class JOmniFactory : public JFactory {
0022 private:
0023 
0024     ConfigT m_config;
0025 
0026 public:
0027 
0028     JOmniFactory() {
0029         SetCallbackStyle(CallbackStyle::LegacyMode);
0030     }
0031 
0032     void Init() override {
0033         static_cast<FacT*>(this)->Configure();
0034     }
0035 
0036     void BeginRun(const std::shared_ptr<const JEvent>& event) override {
0037         // UserFac::ChangeRun() called from BeginRun() to avoid overloaded-virtual warning
0038         static_cast<FacT*>(this)->ChangeRun(event->GetRunNumber());
0039     }
0040 
0041     void Process(const std::shared_ptr<const JEvent>& event) override {
0042         static_cast<FacT*>(this)->Execute(event->GetRunNumber(), event->GetEventNumber());
0043     }
0044 
0045     // This is more hackery to suppress the overloaded-virtual warning
0046     // Has to virtual simply because EICrecon already declares it as override
0047     using JFactory::ChangeRun;
0048     void ChangeRun(int32_t) {}; 
0049 
0050 
0051     using ConfigType = ConfigT;
0052 
0053     /// Retrieve reference to already-configured logger
0054     //std::shared_ptr<spdlog::logger> &logger() { return m_logger; }
0055     JLogger& logger() { return m_logger; }
0056 
0057     /// Retrieve reference to embedded config object
0058     ConfigT& config() { return m_config; }
0059 
0060 
0061     /// Generate summary for UI, inspector
0062     void Summarize(JComponentSummary& summary) const override {
0063 
0064         auto* mfs = new JComponentSummary::Component(
0065             "OmniFactory", GetPrefix(), GetTypeName(), GetLevel(), GetPluginName());
0066 
0067         SummarizeInputs(*mfs);
0068         SummarizeOutputs(*mfs);
0069         summary.Add(mfs);
0070     }
0071 
0072 };
0073 
0074 } // namespace jana::components
0075 
0076 using jana::components::JOmniFactory;
0077 
0078