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>

List of all members.

Public Types

enum  EventStoreInsertResult { REJECT_QUEUEFULL, SUCCESS, SUCCESS_STOREFULL, 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.
typedef int( ART_CFGSTRING_FCN )(const std::string &)
 An art function that accepts a fhicl::ParameterSet as a string.
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 ()
 Default Constructor is deleted.
 EventStore (EventStore const &)
 Copy Constructor is deleted.
EventStoreoperator= (EventStore const &)
 Copy Assignment operator is deleted.
 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.
 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.
 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.
virtual ~EventStore ()
 EventStore Destructor.
void insert (FragmentPtr pfrag, bool printWarningWhenFragmentIsDropped=true)
 Give ownership of the Fragment to the EventStore.
EventStoreInsertResult insert (FragmentPtr pfrag, FragmentPtr &rejectedFragment)
 Give ownership of the Fragment to the EventStore.
bool endOfData (int &readerReturnValue)
 Indicate that the end of input has been reached to the art thread.
void setSeqIDModulus (unsigned int seqIDModulus)
 Set the parameter that will be used to determine which sequence IDs get grouped together into events.
bool flushData ()
 Push any incomplete events onto the queue.
void startRun (run_id_t runID)
 Start a Run.
void startSubrun ()
 Start a new Subrun, incrementing the subrun 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 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.

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 48 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 61 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 55 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 74 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:
pset ParameterSet used to configured EventStore
num_fragments_per_event Number of fragments per event
run Run Number
event_queue_depth Default for the event_queue_depth, if not specified in pset
max_incomplete_events Default 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 26 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:
pset ParameterSet used to configured EventStore
num_fragments_per_event Number of fragments per event
run Run Number
argc Number of arguments
argv Array of arguments, as strings
reader art 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:
pset ParameterSet used to configured EventStore
num_fragments_per_event Number of fragments per event
run Run Number
configString fhicl::ParameterSet string for configuring art thread
reader art function to start

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

Definition at line 73 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] readerReturnValue Exit 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 247 of file EventStore.cc.

bool artdaq::EventStore::endRun (  ) 

Send an EndOfRunFragment to the art thread.

Returns:
True if enqueue successful

Definition at line 354 of file EventStore.cc.

bool artdaq::EventStore::endSubrun (  ) 

Send an EndOfSubRunFragment to the art thread.

Returns:
True if enqueue successful

Definition at line 370 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 267 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 273 of file EventStore.hh.

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

Give ownership of the Fragment to the EventStore.

Parameters:
pfrag Fragment to insert
[out] rejectedFragment If 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 205 of file EventStore.cc.

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

Give ownership of the Fragment to the EventStore.

Parameters:
pfrag Fragment to insert
printWarningWhenFragmentIsDropped Print 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 94 of file EventStore.cc.

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

Copy Assignment operator is deleted.

Returns:
EventStore copy
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:
seqIDModulus Sequence 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 262 of file EventStore.cc.

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

Start a Run.

Parameters:
runID Run number of the new run

Definition at line 305 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 250 of file EventStore.hh.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator

Generated on 23 May 2017 for artdaq by  doxygen 1.6.1