Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-09 09:02:00

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/Topology/JTapArrow.h>
0006 #include <JANA/JEventProcessor.h>
0007 #include <JANA/JEventUnfolder.h>
0008 #include <JANA/JEvent.h>
0009 
0010 
0011 JTapArrow::JTapArrow(std::string name, JEventLevel level) {
0012     SetName(name);
0013     AddPort("in", level);
0014     AddPort("out", level);
0015 }
0016 
0017 void JTapArrow::AddProcessor(JEventProcessor* proc) {
0018     if (proc->IsOrderingEnabled()) {
0019         m_ports[EVENT_IN]->SetEnforcesOrdering(true);
0020     }
0021     m_procs.push_back(proc);
0022 }
0023 
0024 void JTapArrow::Fire(JEvent* event, OutputData& outputs, size_t& output_count, JArrow::FireResult& status) {
0025 
0026     LOG_DEBUG(m_logger) << "Executing arrow " << GetName() << " for event# " << event->GetEventNumber() << LOG_END;
0027     for (JEventProcessor* proc : m_procs) {
0028         JCallGraphEntryMaker cg_entry(*event->GetJCallGraphRecorder(), proc->GetTypeName()); // times execution until this goes out of scope
0029         if (proc->GetCallbackStyle() != JEventProcessor::CallbackStyle::LegacyMode) {
0030             proc->DoTap(*event);
0031         }
0032     }
0033     outputs[0] = {event, 1};
0034     output_count = 1;
0035     status = JArrow::FireResult::KeepGoing;
0036     LOG_DEBUG(m_logger) << "Executed arrow " << GetName() << " for event# " << event->GetEventNumber() << LOG_END;
0037 }
0038 
0039 void JTapArrow::Initialize() {
0040     LOG_DEBUG(m_logger) << "Initializing arrow '" << GetName() << "'" << LOG_END;
0041     for (auto processor : m_procs) {
0042         LOG_DEBUG(m_logger) << "Initializing JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END;
0043         processor->DoInit();
0044         LOG_INFO(m_logger) << "Initialized JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END;
0045     }
0046     LOG_DEBUG(m_logger) << "Initialized arrow '" << GetName() << "'" << LOG_END;
0047 }
0048 
0049 void JTapArrow::Finalize() {
0050     LOG_DEBUG(m_logger) << "Finalizing arrow '" << GetName() << "'" << LOG_END;
0051     for (auto processor : m_procs) {
0052         LOG_DEBUG(m_logger) << "Finalizing JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END;
0053         processor->DoFinalize();
0054         LOG_INFO(m_logger) << "Finalized JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END;
0055     }
0056     LOG_DEBUG(m_logger) << "Finalized arrow '" << GetName() << "'" << LOG_END;
0057 }
0058