artdaq  v2_03_02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Static Public Attributes | List of all members
artdaq::EventStore Class Reference

The EventStore class collects Fragment objects, until it receives a complete event, at which point the event is handed over to the art thread. More...

#include <artdaq/DAQrate/EventStore.hh>

Public Types

enum  EventStoreInsertResult : int { EventStoreInsertResult::REJECT_QUEUEFULL, EventStoreInsertResult::SUCCESS, EventStoreInsertResult::SUCCESS_STOREFULL, EventStoreInsertResult::REJECT_STOREFULL }
 This enumeration contains possible status codes of insertion attempts. More...
 
typedef int( ART_CMDLINE_FCN )(int, char **)
 An art function that accepts standard C main arguments. More...
 
typedef int( ART_CFGSTRING_FCN )(const std::string &)
 An art function that accepts a fhicl::ParameterSet as a string. More...
 
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

 EventStore ()=delete
 Default Constructor is deleted.
 
 EventStore (EventStore const &)=delete
 Copy Constructor is deleted.
 
EventStoreoperator= (EventStore const &)=delete
 Copy Assignment operator is deleted. More...
 
 EventStore (const fhicl::ParameterSet &pset, size_t num_fragments_per_event, run_id_t run, size_t event_queue_depth, size_t max_incomplete_events)
 EventStore Constructor. More...
 
 EventStore (const fhicl::ParameterSet &pset, size_t num_fragments_per_event, run_id_t run, int argc, char *argv[], ART_CMDLINE_FCN *reader)
 EventStore Constructor. More...
 
 EventStore (const fhicl::ParameterSet &pset, size_t num_fragments_per_event, run_id_t run, const std::string &configString, ART_CFGSTRING_FCN *reader)
 EventStore Constructor. More...
 
virtual ~EventStore ()
 EventStore Destructor.
 
void insert (FragmentPtr pfrag, bool printWarningWhenFragmentIsDropped=true)
 Give ownership of the Fragment to the EventStore. More...
 
EventStoreInsertResult insert (FragmentPtr pfrag, FragmentPtr &rejectedFragment)
 Give ownership of the Fragment to the EventStore. More...
 
bool endOfData (int &readerReturnValue)
 Indicate that the end of input has been reached to the art thread. More...
 
void setSeqIDModulus (unsigned int seqIDModulus)
 Set the parameter that will be used to determine which sequence IDs get grouped together into events. More...
 
bool flushData ()
 Push any incomplete events onto the queue. More...
 
void startRun (run_id_t runID)
 Start a Run. More...
 
void startSubrun ()
 Start a new Subrun, incrementing the subrun number.
 
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 sendMetrics ()
 Send metrics to the MetricManager, if one has been instantiated in the application.
 
size_t incompleteEventCount () const
 Get the number of events currently being built in the EventStore. More...
 
void setRequestMode (detail::RequestMessageMode mode)
 Set the mode for RequestMessages. Used to indicate when EventStore should enter "EndOfRun" mode. More...
 

Static Public Attributes

static const std::string EVENT_RATE_STAT_KEY
 Key for the Event Rate MonitoredQuantity.
 
static const std::string INCOMPLETE_EVENT_STAT_KEY
 Key for the Incomplete Events MonitoredQuantity.
 

Detailed Description

The EventStore class collects Fragment objects, until it receives a complete event, at which point the event is handed over to the art thread.

Todo:
Make the art thread a separate process

An EventStore is given Fragments, which it collects until it finds it has a complete RawEvent. When a complete RawEvent is assembled, the EventStore puts it onto the global RawEvent queue. There should be only one EventStore per process; an MPI program can thus have multiple EventStores. By construction, each EventStore will only deal with events (and fragments) from a single run.

The EventStore is also responsible for starting the thread that will be popping events off the global queue. This is so that the EventStore is guaranteed to live long enough to allow the global queue to be drained. The current implementation uses only a free function as the 'thread function' for this thread.

A future enhancement of EventStore may make it be able to move from handling run X to handling run Y; such an enhancement will have to include how to deal with any incomplete events in storage at the time of the introduction of the new run.

Definition at line 49 of file EventStore.hh.

Member Typedef Documentation

typedef int( artdaq::EventStore::ART_CFGSTRING_FCN)(const std::string &)

An art function that accepts a fhicl::ParameterSet as a string.

Returns
Return code from art

Definition at line 62 of file EventStore.hh.

typedef int( artdaq::EventStore::ART_CMDLINE_FCN)(int, char **)

An art function that accepts standard C main arguments.

Returns
Return code from art

Definition at line 56 of file EventStore.hh.

Member Enumeration Documentation

This enumeration contains possible status codes of insertion attempts.

Enumerator
REJECT_QUEUEFULL 

The Fragment was rejected, because the RawEventQueue is full.

SUCCESS 

The Fragment was successfully inserted.

SUCCESS_STOREFULL 

The EventStore is full, but the Fragment was accepted as it is for an already-open event.

REJECT_STOREFULL 

The EventStore is full, and the Fragment was rejected.

Definition at line 75 of file EventStore.hh.

Constructor & Destructor Documentation

artdaq::EventStore::EventStore ( const fhicl::ParameterSet &  pset,
size_t  num_fragments_per_event,
run_id_t  run,
size_t  event_queue_depth,
size_t  max_incomplete_events 
)

EventStore Constructor.

Parameters
psetParameterSet used to configured EventStore
num_fragments_per_eventNumber of fragments per event
runRun Number
event_queue_depthDefault for the event_queue_depth, if not specified in pset
max_incomplete_eventsDefault for the max_incomplete_events, if not specified in pset

This constructor is not meant to be called directly; it handles all of the EventStore setup for the other constructors which merely start the art thread.

* EventStore accepts the following Parameters:
* "event_queue_depth" (Default: event_queue_depth): The size of the ConcurrentQueue to allocate
* "max_incomplete_events" (Default: max_incomplete_events): The maximum size of the EventStore
* "send_requests" (Default: false): Whether to send DataRequests when new sequence IDs are seen
* "request_port" (Default: 3001): Port to send DataRequests on
* "request_delay_ms" (Default: 10): How long to wait before sending new DataRequests
* "output_address" (Default: "localhost"): Use this hostname for multicast output (to assign to the proper NIC)
* "event_queue_wait_time" (Default: 5.0): 
* "event_queue_check_count" (Default: 5000):
* "print_event_store_stats" (Default: false):
* "incomplete_event_report_interval_ms" (Default: -1):
* "art_thread_wait_ms" (Default: 4000): Amount of time to wait for the art thread to start dequeuing events
* "request_address" (Default: "227.128.12.26"): Multicast address to send DataRequests to
* "routing_token_config" (Default: Empty table): FHiCL table containing RoutingToken configuration
*   "use_routing_master" (Default: false): Whether to send tokens to a RoutingMaster
*   "routing_token_port" (Default: 35555): Port to send tokens on
*   "routing_master_hostname" (Default: "localhost"): Hostname or IP of RoutingMaster
* 

Definition at line 25 of file EventStore.cc.

artdaq::EventStore::EventStore ( const fhicl::ParameterSet &  pset,
size_t  num_fragments_per_event,
run_id_t  run,
int  argc,
char *  argv[],
ART_CMDLINE_FCN reader 
)

EventStore Constructor.

Parameters
psetParameterSet used to configured EventStore
num_fragments_per_eventNumber of fragments per event
runRun Number
argcNumber of arguments
argvArray of arguments, as strings
readerart function to start

This constructor deletgates to the first constructor, with event_queue_depth and max_incomplete_events set to 50.

Definition at line 64 of file EventStore.cc.

artdaq::EventStore::EventStore ( const fhicl::ParameterSet &  pset,
size_t  num_fragments_per_event,
run_id_t  run,
const std::string &  configString,
ART_CFGSTRING_FCN reader 
)

EventStore Constructor.

Parameters
psetParameterSet used to configured EventStore
num_fragments_per_eventNumber of fragments per event
runRun Number
configStringfhicl::ParameterSet string for configuring art thread
readerart function to start

This constructor deletgates to the first constructor, with event_queue_depth and max_incomplete_events set to 20.

Definition at line 75 of file EventStore.cc.

Member Function Documentation

bool artdaq::EventStore::endOfData ( int &  readerReturnValue)

Indicate that the end of input has been reached to the art thread.

Parameters
[out]readerReturnValueExit status code of the art thread
Returns
True if the end proceeded correctly

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 259 of file EventStore.cc.

bool artdaq::EventStore::endRun ( )

Send an EndOfRunFragment to the art thread.

Returns
True if enqueue successful

Definition at line 366 of file EventStore.cc.

bool artdaq::EventStore::endSubrun ( )

Send an EndOfSubRunFragment to the art thread.

Returns
True if enqueue successful

Definition at line 382 of file EventStore.cc.

bool artdaq::EventStore::flushData ( )

Push any incomplete events onto the queue.

Returns
Returns true if all stale events were flushed, false if one or more events could not be flushed because the queue was full.

Definition at line 279 of file EventStore.cc.

size_t artdaq::EventStore::incompleteEventCount ( ) const
inline

Get the number of events currently being built in the EventStore.

Returns
The number of events currently being built in the EventStore

Definition at line 274 of file EventStore.hh.

void artdaq::EventStore::insert ( FragmentPtr  pfrag,
bool  printWarningWhenFragmentIsDropped = true 
)

Give ownership of the Fragment to the EventStore.

Parameters
pfragFragment to insert
printWarningWhenFragmentIsDroppedPrint a warning if the Fragment is dopped (data loss) Default = true

Give ownership of the Fragment to the EventStore. The pointer we are given must NOT be null, and the Fragment to which it points must NOT be empty; the Fragment must at least contain the necessary header information. -> this instance of the insert method discards completed events if they can't be pushed onto the event queue within the specified timeout. This is a rather severe response, so this method should only be used in special cases.

Definition at line 98 of file EventStore.cc.

EventStore::EventStoreInsertResult artdaq::EventStore::insert ( FragmentPtr  pfrag,
FragmentPtr &  rejectedFragment 
)

Give ownership of the Fragment to the EventStore.

Parameters
pfragFragment to insert
[out]rejectedFragmentIf the Fragment could not be inserted, it will be returned here
Returns
EventStoreInsertResult detailing the status of the EventStore insertion operation

Give ownership of the Fragment to the EventStore. The pointer we are given must NOT be null, and the Fragment to which it points must NOT be empty; the Fragment must at least contain the necessary header information. -> this instance of the insert method returns an EventStoreInsertResult, and returns the fragment to the caller, if there is no room to push events onto the event queue, within the timeout that was specified at construction time.

Definition at line 217 of file EventStore.cc.

EventStore& artdaq::EventStore::operator= ( EventStore const &  )
delete

Copy Assignment operator is deleted.

Returns
EventStore copy
void artdaq::EventStore::setRequestMode ( detail::RequestMessageMode  mode)
inline

Set the mode for RequestMessages. Used to indicate when EventStore should enter "EndOfRun" mode.

Parameters
modeMode to set

Definition at line 280 of file EventStore.hh.

void artdaq::EventStore::setSeqIDModulus ( unsigned int  seqIDModulus)

Set the parameter that will be used to determine which sequence IDs get grouped together into events.

Parameters
seqIDModulusSequence ID grouping parameter

Set the parameter that will be used to determine which sequence IDs get grouped together into events. This defaults to 1 which is the case where fragments with the same sequence ID will get grouped together. The other use case is for the aggregator which will group together fragments with different sequence IDs.

Definition at line 274 of file EventStore.cc.

void artdaq::EventStore::startRun ( run_id_t  runID)

Start a Run.

Parameters
runIDRun number of the new run

Definition at line 317 of file EventStore.cc.

subrun_id_t artdaq::EventStore::subrunID ( ) const
inline

Get the current subrun number.

Returns
The current subrun number

Definition at line 251 of file EventStore.hh.


The documentation for this class was generated from the following files: