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 "artdaq/DAQrate/detail/RequestMessage.hh"
9 #include "fhiclcpp/ParameterSet.h"
17 #include <arpa/inet.h>
18 #include <netinet/in.h>
19 #include <sys/types.h>
20 #include <sys/socket.h>
67 typedef std::map<sequence_id_t, RawEvent_ptr>
EventMap;
131 size_t num_fragments_per_event,
run_id_t run,
132 size_t event_queue_depth,
size_t max_incomplete_events);
146 size_t num_fragments_per_event,
run_id_t run,
147 int argc,
char* argv[],
161 size_t num_fragments_per_event,
run_id_t run,
162 const std::string& configString,
184 void insert(FragmentPtr pfrag,
185 bool printWarningWhenFragmentIsDropped =
true);
285 size_t const num_fragments_per_event_;
286 size_t const max_queue_size_;
287 size_t const max_incomplete_count_;
291 RawEventQueue& queue_;
292 std::chrono::steady_clock::time_point reader_thread_launch_time_;
293 std::future<int> reader_thread_;
296 std::mutex request_mutex_;
297 std::map<Fragment::sequence_id_t, Fragment::timestamp_t> active_requests_;
299 size_t request_delay_;
301 struct sockaddr_in request_addr_;
302 std::string multicast_out_addr_;
303 detail::RequestMessageMode request_mode_;
305 unsigned int seqIDModulus_;
309 artdaq::detail::seconds
const enq_timeout_;
310 size_t enq_check_count_;
311 bool const printSummaryStats_;
313 int incomplete_event_report_interval_ms_;
314 std::chrono::steady_clock::time_point last_incomplete_event_report_time_;
316 bool send_routing_tokens_;
319 struct sockaddr_in token_addr_;
320 std::string token_address_;
322 int art_thread_wait_ms_;
325 void initStatistics_();
327 void reportStatistics_();
329 void setup_requests_(std::string trigger_addr);
331 void send_request_();
333 void do_send_request_();
335 void setup_tokens_();
337 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.
void setRequestMode(detail::RequestMessageMode mode)
Set the mode for RequestMessages. Used to indicate when EventStore should enter "EndOfRun" mode...
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.