End-of-data and EndSubRun handling in BRs and EBs

12-Apr-2016, KAB

It's not always clear what messages are sent within an artdaq process, and between processes, at end-run time, so I wanted to make some notes. We'll see if these turn out to be useful.


Within the BoardReader, the Stop request from Run Control is passed down to the stop() method in BoardReaderCore, which sets its internal "stop_requested_" attribute to true (not relevant here) and calls the FragmentGenereator StopCmd() method. The FragmentGenerator[CommandableFragmentGenerator] has a separate "should_stop_" attribute that gets set to true in StopCmd(), and StopCmd() calls the FragmentGenerator stop() method. The FragmentGenerator stop() method may, or may not, do anything, but in principle it tells the upstream hardware to stop sending data.

Once the FragmentGenerator getNext_() method notices that a stop has been requested (by checking should_stop_), it drains any remaining data out of the pipeline (possibly in multiple calls) and then returns false. When the BoardReaderCore::process_fragments() method receives the false return code from FragmentGenerator::getNext(), it stops executing its loop, and the process_fragments() method naturally exits. When that method exits, the artdaq::SHandles instance that was being used to send data to the EventBuilders is destructed, and in the SHandles destructor, an EOD (end-of-data) fragment is sent to each of the EventBuilders.

For reference, the SHandles instance in the BoardReaderCore::process_fragments method is created early in the execution of that method. And, that method starts executing whenever a Start (begin-run) or Resume message is received from Run Control.


With the EventBuilder, the Stop request from Run Control is passed down to the EventBuilderCore::stop() method, which sets its internal "stop_requested_" attribute to true, calls EventStore::endSubrun() (if a run is going), and calls EventStore::endRun(). The EventStore endSubrun() method puts an EndOfSubrun fragment on the RawEventQueue, and the endRun() method puts an EndRun fragment on the RawEventQueue.

The NetMonInput_source receives these fragments and constructs the appropriate Run and SubRun Principals.