The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built. More...
#include <artdaq/DAQrate/SharedMemoryEventManager.hh>
Classes | |
struct | Config |
Configuration of the SharedMemoryEventManager. May be used for parameter validation. More... | |
struct | MetricData |
Public Types | |
typedef RawEvent::run_id_t | run_id_t |
Copy RawEvent::run_id_t into local scope. | |
typedef RawEvent::subrun_id_t | subrun_id_t |
Copy RawEvent::subrun_id_t into local scope. | |
typedef Fragment::sequence_id_t | sequence_id_t |
Copy Fragment::sequence_id_t into local scope. | |
typedef std::map < sequence_id_t, RawEvent_ptr > | EventMap |
An EventMap is a map of RawEvent_ptr objects, keyed by sequence ID. | |
Public Member Functions | |
SharedMemoryEventManager (fhicl::ParameterSet pset, fhicl::ParameterSet art_pset) | |
SharedMemoryEventManager Constructor. | |
virtual | ~SharedMemoryEventManager () |
SharedMemoryEventManager Destructor. | |
bool | AddFragment (FragmentPtr frag, size_t timeout_usec, FragmentPtr &outfrag) |
Copy a Fragment into the SharedMemoryEventManager. | |
RawDataType * | WriteFragmentHeader (detail::RawFragmentHeader frag, bool dropIfNoBuffersAvailable=false) |
Get a pointer to a reserved memory area for the given Fragment header. | |
void | DoneWritingFragment (detail::RawFragmentHeader frag) |
Used to indicate that the given Fragment is now completely in the buffer. Will check for buffer completeness, and unset the pending flag. | |
size_t | GetIncompleteEventCount () |
Returns the number of buffers which contain data but are not yet complete. | |
size_t | GetPendingEventCount () |
Returns the number of events which are complete but waiting on lower sequenced events to finish. | |
size_t | GetLockedBufferCount () |
Returns the number of buffers currently owned by this manager. | |
size_t | GetArtEventCount () |
Returns the number of events sent to art this subrun. | |
size_t | GetFragmentCount (Fragment::sequence_id_t seqID, Fragment::type_t type=Fragment::InvalidFragmentType) |
Get the count of Fragments of a given type in an event. | |
size_t | GetFragmentCountInBuffer (int buffer, Fragment::type_t type=Fragment::InvalidFragmentType) |
Get the count of Fragments of a given type in a buffer. | |
void | RunArt (std::shared_ptr< art_config_file > config_file, std::shared_ptr< std::atomic< pid_t >> pid_out) |
Run an art instance, recording the return codes and restarting it until the end flag is raised. | |
void | StartArt () |
Start all the art processes. | |
pid_t | StartArtProcess (fhicl::ParameterSet pset) |
Start one art process. | |
void | ShutdownArtProcesses (std::set< pid_t > &pids) |
Shutdown a set of art processes. | |
void | ReconfigureArt (fhicl::ParameterSet art_pset, run_id_t newRun=0, int n_art_processes=-1) |
Restart all art processes, using the given fhicl code to configure the new art processes. | |
bool | endOfData () |
Indicate that the end of input has been reached to the art processes. | |
void | startRun (run_id_t runID) |
Start a Run. | |
void | startSubrun () |
Start a new Subrun, incrementing the subrun number. | |
run_id_t | runID () const |
Get the current Run number. | |
subrun_id_t | subrunID () const |
Get the current subrun number. | |
bool | endRun () |
Send an EndOfRunFragment to the art thread. | |
bool | endSubrun () |
Send an EndOfSubRunFragment to the art thread. | |
void | rolloverSubrun (sequence_id_t boundary) |
Rollover the subrun after the specified event. | |
void | sendMetrics () |
Send metrics to the MetricManager, if one has been instantiated in the application. | |
void | setRequestMode (detail::RequestMessageMode mode) |
Set the RequestMessageMode for all outgoing data requests. | |
void | setOverwrite (bool overwrite) |
Set the overwrite flag (non-reliable data transfer) for the Shared Memory. | |
void | SetInitFragment (FragmentPtr frag) |
Set the stored Init fragment, if one has not yet been set already. | |
uint32_t | GetBroadcastKey () |
Gets the shared memory key of the broadcast SharedMemoryManager. | |
RawDataType * | GetDroppedDataAddress (Fragment::fragment_id_t frag) |
Gets the address of the "dropped data" fragment. Used for testing. | |
void | UpdateArtConfiguration (fhicl::ParameterSet art_pset) |
Updates the internally-stored copy of the art configuration. | |
void | CheckPendingBuffers () |
Check for buffers which are ready to be marked incomplete and released to art and issue tokens for any buffers which are avaialble. |
The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built.
Definition at line 85 of file SharedMemoryEventManager.hh.
artdaq::SharedMemoryEventManager::SharedMemoryEventManager | ( | fhicl::ParameterSet | pset, | |
fhicl::ParameterSet | art_pset | |||
) |
SharedMemoryEventManager Constructor.
pset | ParameterSet used to configure SharedMemoryEventManager. See artdaq::SharedMemoryEventManager::Config for description of parameters | |
art_pset | ParameterSet used to configure art. See art::Config for description of expected document format |
Definition at line 14 of file SharedMemoryEventManager.cc.
bool artdaq::SharedMemoryEventManager::AddFragment | ( | FragmentPtr | frag, | |
size_t | timeout_usec, | |||
FragmentPtr & | outfrag | |||
) |
Copy a Fragment into the SharedMemoryEventManager.
frag | FragmentPtr object | |
timeout_usec | Timeout for adding Fragment to the Shared Memory | |
[out] | outfrag | Rejected Fragment if timeout occurs |
Definition at line 143 of file SharedMemoryEventManager.cc.
void artdaq::SharedMemoryEventManager::DoneWritingFragment | ( | detail::RawFragmentHeader | frag | ) |
Used to indicate that the given Fragment is now completely in the buffer. Will check for buffer completeness, and unset the pending flag.
frag | Fragment that is now completely in the buffer. |
Definition at line 231 of file SharedMemoryEventManager.cc.
bool artdaq::SharedMemoryEventManager::endOfData | ( | ) |
Indicate that the end of input has been reached to the art processes.
Put the end-of-data marker onto the RawEvent queue (if possible), wait for the reader function to exit, and fill in the reader return value. This scenario returns true. If the end-of-data marker can not be pushed onto the RawEvent queue, false is returned.
Definition at line 587 of file SharedMemoryEventManager.cc.
bool artdaq::SharedMemoryEventManager::endRun | ( | ) |
Send an EndOfRunFragment to the art thread.
Definition at line 737 of file SharedMemoryEventManager.cc.
bool artdaq::SharedMemoryEventManager::endSubrun | ( | ) |
Send an EndOfSubRunFragment to the art thread.
Definition at line 757 of file SharedMemoryEventManager.cc.
size_t artdaq::SharedMemoryEventManager::GetArtEventCount | ( | ) | [inline] |
Returns the number of events sent to art this subrun.
Definition at line 221 of file SharedMemoryEventManager.hh.
uint32_t artdaq::SharedMemoryEventManager::GetBroadcastKey | ( | ) | [inline] |
Gets the shared memory key of the broadcast SharedMemoryManager.
Definition at line 347 of file SharedMemoryEventManager.hh.
RawDataType* artdaq::SharedMemoryEventManager::GetDroppedDataAddress | ( | Fragment::fragment_id_t | frag | ) | [inline] |
Gets the address of the "dropped data" fragment. Used for testing.
Definition at line 353 of file SharedMemoryEventManager.hh.
size_t artdaq::SharedMemoryEventManager::GetFragmentCount | ( | Fragment::sequence_id_t | seqID, | |
Fragment::type_t | type = Fragment::InvalidFragmentType | |||
) |
Get the count of Fragments of a given type in an event.
seqID | Sequence ID of Fragments | |
type | Type of fragments to count. Use InvalidFragmentType to count all fragments (default) |
Definition at line 276 of file SharedMemoryEventManager.cc.
size_t artdaq::SharedMemoryEventManager::GetFragmentCountInBuffer | ( | int | buffer, | |
Fragment::type_t | type = Fragment::InvalidFragmentType | |||
) |
Get the count of Fragments of a given type in a buffer.
buffer | Buffer to count | |
type | Type of fragments to count. Use InvalidFragmentType to count all fragments (default) |
Definition at line 281 of file SharedMemoryEventManager.cc.
size_t artdaq::SharedMemoryEventManager::GetIncompleteEventCount | ( | ) | [inline] |
Returns the number of buffers which contain data but are not yet complete.
Definition at line 203 of file SharedMemoryEventManager.hh.
size_t artdaq::SharedMemoryEventManager::GetLockedBufferCount | ( | ) | [inline] |
Returns the number of buffers currently owned by this manager.
Definition at line 215 of file SharedMemoryEventManager.hh.
size_t artdaq::SharedMemoryEventManager::GetPendingEventCount | ( | ) | [inline] |
Returns the number of events which are complete but waiting on lower sequenced events to finish.
Definition at line 209 of file SharedMemoryEventManager.hh.
void artdaq::SharedMemoryEventManager::ReconfigureArt | ( | fhicl::ParameterSet | art_pset, | |
run_id_t | newRun = 0 , |
|||
int | n_art_processes = -1 | |||
) |
Restart all art processes, using the given fhicl code to configure the new art processes.
art_pset | ParameterSet used to configure art | |
newRun | New Run number for reconfigured art | |
n_art_processes | Number of art processes to start, -1 (default) leaves the number unchanged |
Definition at line 559 of file SharedMemoryEventManager.cc.
void artdaq::SharedMemoryEventManager::rolloverSubrun | ( | sequence_id_t | boundary | ) |
Rollover the subrun after the specified event.
boundary | sequence ID of the boundary (Event with seqID == boundary will be in new subrun) |
Definition at line 780 of file SharedMemoryEventManager.cc.
run_id_t artdaq::SharedMemoryEventManager::runID | ( | ) | const [inline] |
Get the current Run number.
Definition at line 295 of file SharedMemoryEventManager.hh.
void artdaq::SharedMemoryEventManager::setOverwrite | ( | bool | overwrite | ) | [inline] |
Set the overwrite flag (non-reliable data transfer) for the Shared Memory.
overwrite | Whether to allow the writer to overwrite data that has not yet been read |
Definition at line 336 of file SharedMemoryEventManager.hh.
void artdaq::SharedMemoryEventManager::setRequestMode | ( | detail::RequestMessageMode | mode | ) | [inline] |
Set the RequestMessageMode for all outgoing data requests.
mode | Mode to set |
Definition at line 330 of file SharedMemoryEventManager.hh.
void artdaq::SharedMemoryEventManager::ShutdownArtProcesses | ( | std::set< pid_t > & | pids | ) |
Shutdown a set of art processes.
pids | PIDs of the art processes |
Definition at line 453 of file SharedMemoryEventManager.cc.
pid_t artdaq::SharedMemoryEventManager::StartArtProcess | ( | fhicl::ParameterSet | pset | ) |
Start one art process.
pset | ParameterSet to send to this art process |
Definition at line 408 of file SharedMemoryEventManager.cc.
void artdaq::SharedMemoryEventManager::startRun | ( | run_id_t | runID | ) |
Start a Run.
runID | Run number of the new run |
Definition at line 695 of file SharedMemoryEventManager.cc.
subrun_id_t artdaq::SharedMemoryEventManager::subrunID | ( | ) | const [inline] |
Get the current subrun number.
Definition at line 301 of file SharedMemoryEventManager.hh.
void artdaq::SharedMemoryEventManager::UpdateArtConfiguration | ( | fhicl::ParameterSet | art_pset | ) |
Updates the internally-stored copy of the art configuration.
art_pset | ParameterSet used to configure art |
This method updates the internally-stored copy of the art configuration, but it does not restart art processes. So, if this method is called while art processes are running, it will have no effect until the next restart, such as the next Start of run. Typically, this method is intended to be called between runs, when no art processes are running.
Definition at line 1211 of file SharedMemoryEventManager.cc.
artdaq::RawDataType * artdaq::SharedMemoryEventManager::WriteFragmentHeader | ( | detail::RawFragmentHeader | frag, | |
bool | dropIfNoBuffersAvailable = false | |||
) |
Get a pointer to a reserved memory area for the given Fragment header.
frag | Fragment header (contains sequence ID and size information) | |
dropIfNoBuffersAvailable | Whether to drop the fragment (instead of returning nullptr) when no buffers are available (Default: false) |
Definition at line 163 of file SharedMemoryEventManager.cc.