1 #ifndef artdaq_DAQrate_EventStore_hh
2 #define artdaq_DAQrate_EventStore_hh
4 #include "artdaq/DAQdata/Globals.hh"
5 #include "artdaq-core/Data/RawEvent.hh"
6 #include "artdaq-core/Core/GlobalQueue.hh"
7 #include "artdaq-utilities/Plugins/MetricManager.hh"
8 #include <fhiclcpp/ParameterSet.h>
16 #include <arpa/inet.h>
17 #include <netinet/in.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
66 typedef std::map<sequence_id_t, RawEvent_ptr>
EventMap;
130 size_t num_fragments_per_event,
run_id_t run,
131 size_t event_queue_depth,
size_t max_incomplete_events);
145 size_t num_fragments_per_event,
run_id_t run,
146 int argc,
char* argv[],
160 size_t num_fragments_per_event,
run_id_t run,
161 const std::string& configString,
183 void insert(FragmentPtr pfrag,
184 bool printWarningWhenFragmentIsDropped =
true);
278 size_t const num_fragments_per_event_;
279 size_t const max_queue_size_;
280 size_t const max_incomplete_count_;
284 RawEventQueue& queue_;
285 std::chrono::steady_clock::time_point reader_thread_launch_time_;
286 std::future<int> reader_thread_;
289 std::mutex request_mutex_;
290 std::map<Fragment::sequence_id_t, Fragment::timestamp_t> active_requests_;
292 size_t request_delay_;
294 struct sockaddr_in request_addr_;
295 std::string multicast_out_addr_;
297 unsigned int seqIDModulus_;
301 artdaq::detail::seconds
const enq_timeout_;
302 size_t enq_check_count_;
303 bool const printSummaryStats_;
305 int incomplete_event_report_interval_ms_;
306 std::chrono::steady_clock::time_point last_incomplete_event_report_time_;
308 bool send_routing_tokens_;
311 struct sockaddr_in token_addr_;
312 std::string token_address_;
314 int art_thread_wait_ms_;
317 void initStatistics_();
319 void reportStatistics_();
321 void setup_requests_(std::string trigger_addr);
323 void send_request_();
325 void do_send_request_();
327 void setup_tokens_();
329 void send_routing_token_(
int nSlots);
void insert(FragmentPtr pfrag, bool printWarningWhenFragmentIsDropped=true)
Give ownership of the Fragment to the EventStore.
static const std::string EVENT_RATE_STAT_KEY
Key for the Event Rate MonitoredQuantity.
bool endOfData(int &readerReturnValue)
Indicate that the end of input has been reached to the art thread.
EventStore & operator=(EventStore const &)=delete
Copy Assignment operator is deleted.
EventStoreInsertResult
This enumeration contains possible status codes of insertion attempts.
void startRun(run_id_t runID)
Start a Run.
Fragment::sequence_id_t sequence_id_t
Copy Fragment::sequence_id_t into local scope.
EventStore()=delete
Default Constructor is deleted.
virtual ~EventStore()
EventStore Destructor.
The Fragment was successfully inserted.
size_t incompleteEventCount() const
Get the number of events currently being built in the EventStore.
std::map< sequence_id_t, RawEvent_ptr > EventMap
An EventMap is a map of RawEvent_ptr objects, keyed by sequence ID.
void startSubrun()
Start a new Subrun, incrementing the subrun number.
RawEvent::subrun_id_t subrun_id_t
Copy RawEvent::subrun_id_t into local scope.
The EventStore class collects Fragment objects, until it receives a complete event, at which point the event is handed over to the art thread.
int( ART_CMDLINE_FCN)(int, char **)
An art function that accepts standard C main arguments.
static const std::string INCOMPLETE_EVENT_STAT_KEY
Key for the Incomplete Events MonitoredQuantity.
The EventStore is full, but the Fragment was accepted as it is for an already-open event...
subrun_id_t subrunID() const
Get the current subrun number.
void setSeqIDModulus(unsigned int seqIDModulus)
Set the parameter that will be used to determine which sequence IDs get grouped together into events...
void sendMetrics()
Send metrics to the MetricManager, if one has been instantiated in the application.
int( ART_CFGSTRING_FCN)(const std::string &)
An art function that accepts a fhicl::ParameterSet as a string.
bool flushData()
Push any incomplete events onto the queue.
RawEvent::run_id_t run_id_t
Copy RawEvent::run_id_t into local scope.
The EventStore is full, and the Fragment was rejected.
The Fragment was rejected, because the RawEventQueue is full.
bool endRun()
Send an EndOfRunFragment to the art thread.
bool endSubrun()
Send an EndOfSubRunFragment to the art thread.