Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:36

0001 // Copyright 2024, Jefferson Science Associates, LLC.
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 
0005 #include "JANA/JEventProcessor.h"
0006 #include <JANA/Topology/JEventMapArrow.h>
0007 
0008 #include <JANA/JEventSource.h>
0009 #include <JANA/JEventUnfolder.h>
0010 #include <JANA/JEvent.h>
0011 
0012 
0013 JEventMapArrow::JEventMapArrow(std::string name) {
0014     set_name(name);
0015     set_is_parallel(true);
0016     create_ports(1, 1);
0017 
0018 }
0019 
0020 void JEventMapArrow::add_source(JEventSource* source) {
0021     m_sources.push_back(source);
0022 }
0023 
0024 void JEventMapArrow::add_unfolder(JEventUnfolder* unfolder) {
0025     m_unfolders.push_back(unfolder);
0026 }
0027 
0028 void JEventMapArrow::add_processor(JEventProcessor* processor) {
0029     m_procs.push_back(processor);
0030 }
0031 
0032 void JEventMapArrow::fire(JEvent* event, OutputData& outputs, size_t& output_count, JArrow::FireResult& status) {
0033 
0034     LOG_DEBUG(m_logger) << "Executing arrow " << get_name() << " for event# " << event->GetEventNumber() << LOG_END;
0035     for (JEventSource* source : m_sources) {
0036         JCallGraphEntryMaker cg_entry(*event->GetJCallGraphRecorder(), source->GetTypeName()); // times execution until this goes out of scope
0037         source->Preprocess(*event);
0038     }
0039     for (JEventUnfolder* unfolder : m_unfolders) {
0040         JCallGraphEntryMaker cg_entry(*event->GetJCallGraphRecorder(), unfolder->GetTypeName()); // times execution until this goes out of scope
0041         unfolder->Preprocess(*event);
0042     }
0043     for (JEventProcessor* processor : m_procs) {
0044         JCallGraphEntryMaker cg_entry(*event->GetJCallGraphRecorder(), processor->GetTypeName()); // times execution until this goes out of scope
0045         if (processor->GetCallbackStyle() == JEventProcessor::CallbackStyle::LegacyMode) {
0046             processor->DoLegacyProcess(event->shared_from_this());
0047         }
0048         else {
0049             processor->DoMap(*event);
0050         }
0051     }
0052     LOG_DEBUG(m_logger) << "Executed arrow " << get_name() << " for event# " << event->GetEventNumber() << LOG_END;
0053     outputs[0] = {event, 1};
0054     output_count = 1;
0055     status = JArrow::FireResult::KeepGoing;
0056 }
0057 
0058 void JEventMapArrow::initialize() {
0059     LOG_DEBUG(m_logger) << "Initializing arrow '" << get_name() << "'" << LOG_END;
0060     for (auto processor : m_procs) {
0061         if (processor->GetCallbackStyle() == JEventProcessor::CallbackStyle::LegacyMode) {
0062             LOG_INFO(m_logger) << "Initializing JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END;
0063             processor->DoInitialize();
0064             LOG_INFO(m_logger) << "Initialized JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END;
0065         }
0066     }
0067     LOG_DEBUG(m_logger) << "Initialized arrow '" << get_name() << "'" << LOG_END;
0068 }
0069 
0070 void JEventMapArrow::finalize() {
0071     LOG_DEBUG(m_logger) << "Finalizing arrow '" << get_name() << "'" << LOG_END;
0072     for (auto processor : m_procs) {
0073         if (processor->GetCallbackStyle() == JEventProcessor::CallbackStyle::LegacyMode) {
0074             LOG_DEBUG(m_logger) << "Finalizing JEventProcessor " << processor->GetTypeName() << LOG_END;
0075             processor->DoFinalize();
0076             LOG_INFO(m_logger) << "Finalized JEventProcessor " << processor->GetTypeName() << LOG_END;
0077         }
0078     }
0079     LOG_DEBUG(m_logger) << "Finalized arrow " << get_name() << LOG_END;
0080 }
0081