artdaq
v3_02_00
|
The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built. More...
#include <artdaq/DAQrate/SharedMemoryEventManager.hh>
Classes | |
struct | Config |
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. More... | |
virtual | ~SharedMemoryEventManager () |
SharedMemoryEventManager Destructor. | |
bool | AddFragment (FragmentPtr frag, size_t timeout_usec, FragmentPtr &outfrag) |
Copy a Fragment into the SharedMemoryEventManager. More... | |
RawDataType * | WriteFragmentHeader (detail::RawFragmentHeader frag, bool dropIfNoBuffersAvailable=false) |
Get a pointer to a reserved memory area for the given Fragment header. More... | |
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. More... | |
size_t | GetIncompleteEventCount () |
Returns the number of buffers which contain data but are not yet complete. More... | |
size_t | GetPendingEventCount () |
Returns the number of events which are complete but waiting on lower sequenced events to finish. More... | |
size_t | GetLockedBufferCount () |
Returns the number of buffers currently owned by this manager. More... | |
size_t | GetArtEventCount () |
Returns the number of events sent to art this subrun. More... | |
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. More... | |
size_t | GetFragmentCountInBuffer (int buffer, Fragment::type_t type=Fragment::InvalidFragmentType) |
Get the count of Fragments of a given type in a buffer. More... | |
void | RunArt (std::shared_ptr< art_config_file > config_file, 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. More... | |
void | ShutdownArtProcesses (std::set< pid_t > pids) |
Shutdown a set of art processes. More... | |
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. More... | |
bool | endOfData () |
Indicate that the end of input has been reached to the art processes. More... | |
void | startRun (run_id_t runID) |
Start a Run. More... | |
void | startSubrun () |
Start a new Subrun, incrementing the subrun number. | |
run_id_t | runID () const |
Get the current Run number. More... | |
subrun_id_t | subrunID () const |
Get the current subrun number. More... | |
bool | endRun () |
Send an EndOfRunFragment to the art thread. More... | |
bool | endSubrun () |
Send an EndOfSubRunFragment to the art thread. More... | |
void | rolloverSubrun (sequence_id_t boundary) |
Rollover the subrun after the specified event. More... | |
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. More... | |
void | setOverwrite (bool overwrite) |
Set the overwrite flag (non-reliable data transfer) for the Shared Memory. More... | |
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. More... | |
RawDataType * | GetDroppedDataAddress () |
Gets the address of the "dropped data" fragment. Used for testing. More... | |
The SharedMemoryEventManager is a SharedMemoryManger which tracks events as they are built.
Definition at line 72 of file SharedMemoryEventManager.hh.
artdaq::SharedMemoryEventManager::SharedMemoryEventManager | ( | fhicl::ParameterSet | pset, |
fhicl::ParameterSet | art_pset | ||
) |
SharedMemoryEventManager Constructor.
pset | ParameterSet used to configure SharedMemoryEventManager |
art_pset | ParameterSet used to configure art |
* SharedMemoryEventManager accepts the following Parameters: * * "shared_memory_key" (Default 0xBEE70000 + PID): Key to use for shared memory access * "buffer_count" REQUIRED: Number of events in the Shared Memory (incomplete + pending art) * "max_event_size_bytes" REQUIRED: Maximum event size (all Fragments), in bytes * OR "max_fragment_size_bytes" REQURIED: Maximum Fragment size, in bytes * "stale_buffer_timeout_usec" (Default: event_queue_wait_time * 1,000,000): Maximum amount of time elapsed before a buffer is marked as abandoned. Time is reset each time an operation is performed on the buffer. * "event_queue_wait_time" (Default: 5): Amount of time (in seconds) an event can exist in shared memory before being released to art. Used as input to default parameter of "stale_buffer_timeout_usec". * "restart_crashed_art_processes" (Default: true): Whether to automatically restart art processes that fail for any reason * "broadcast_mode" (Default: false): When true, buffers are not marked Empty when read, but return to Full state. Buffers are overwritten in order received. * "art_analyzer_count" (Default: 1): Number of art procceses to start * "expected_fragments_per_event" (REQUIRED): Number of Fragments to expect per event * "update_run_ids_on_new_fragment" (Default: true): Whether the run and subrun ID of an event should be updated whenever a Fragment is added. * "use_art" (Default: true): Whether to start and manage art threads (Sets art_analyzer count to 0 and overwrite_mode to true when false) * "overwite_mode" (Default: false): Whether new data is allowed to overwrite buffers in the "Full" state * "send_init_fragments" (Default: true): Whether Init Fragments are expected to be sent to art. If true, a Warning message is printed when an Init Fragment is requested but none are available. * "incomplete_event_report_interval_ms" (Default: -1): Interval at which an incomplete event report should be written * A "Broadcast shared memory segment" is used for all system-level fragments, such as Init, Start/End Run, Start/End Subrun and EndOfData * "fragment_broadcast_timeout_ms" (Default: 3000): Amount of time broadcast fragments should live in the broadcast shared memory segment * "broadcast_shared_memory_key" (Default: 0xCEE7000 + PID): Key to use for broadcast shared memory access * "broadcast_buffer_count" (Default: 10): Buffers in the broadcast shared memory segment * "broadcast_buffer_size" (Default: 0x100000): Size of the buffers in the broadcast shared memory segment * "minimum_art_lifetime_s" (Default: 2 seconds): Amount of time that an art process should run to not be considered "DOA" * "expected_art_event_processing_time_us" (Default: 100000 us): During shutdown, SMEM will wait for this amount of time while it is checking that the art threads are done reading buffers. (TUNING: Should be slightly longer than the mean art processing time, but not so long that the Stop transition times out) *
Definition at line 11 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 133 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 193 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 499 of file SharedMemoryEventManager.cc.
bool artdaq::SharedMemoryEventManager::endRun | ( | ) |
Send an EndOfRunFragment to the art thread.
Definition at line 627 of file SharedMemoryEventManager.cc.
bool artdaq::SharedMemoryEventManager::endSubrun | ( | ) |
Send an EndOfSubRunFragment to the art thread.
Definition at line 646 of file SharedMemoryEventManager.cc.
|
inline |
Returns the number of events sent to art this subrun.
Definition at line 204 of file SharedMemoryEventManager.hh.
|
inline |
Gets the shared memory key of the broadcast SharedMemoryManager.
Definition at line 330 of file SharedMemoryEventManager.hh.
|
inline |
Gets the address of the "dropped data" fragment. Used for testing.
Definition at line 336 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 228 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 233 of file SharedMemoryEventManager.cc.
|
inline |
Returns the number of buffers which contain data but are not yet complete.
Definition at line 186 of file SharedMemoryEventManager.hh.
|
inline |
Returns the number of buffers currently owned by this manager.
Definition at line 198 of file SharedMemoryEventManager.hh.
|
inline |
Returns the number of events which are complete but waiting on lower sequenced events to finish.
Definition at line 192 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 471 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 669 of file SharedMemoryEventManager.cc.
|
inline |
Get the current Run number.
Definition at line 278 of file SharedMemoryEventManager.hh.
|
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 319 of file SharedMemoryEventManager.hh.
|
inline |
Set the RequestMessageMode for all outgoing data requests.
mode | Mode to set |
Definition at line 313 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 365 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 327 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 593 of file SharedMemoryEventManager.cc.
|
inline |
Get the current subrun number.
Definition at line 284 of file SharedMemoryEventManager.hh.
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 153 of file SharedMemoryEventManager.cc.