1 #include <daq/hbasf2/modules/HLTDs2ZMQ.h>
2 #include <framework/pcore/zmq/messages/ZMQMessageFactory.h>
12 "On every event, serialize the data store and send the binary data out to "
13 "the connected ZMQ application (most likely a collector or final collector). "
14 "The sending is handled via a confirmed connection (output in this case), "
15 "so all the typical behaviour applies. Also sends out end run and termination "
16 "messages. Depending on the module setting, can send out events in "
17 "raw format (with send header and trailer and a serialized event message as buffer) "
18 "or only as normal ROOT serialized stream (evt message). "
19 "The former is the typical use case when talking with e.g. storage, the "
20 "latter can be used for local tests or when sending full events e.g. to the event display. "
21 "Please note that the environment setting of the stream objects heavily "
22 "influences the time spent in this module (because serialization needs time). "
23 "This module is only useful in the HLT context or for testing it and it optimized to be used "
24 "together with the HLTEventProcessor. Please note the special handling of the first event in the "
25 "HLTEventProcessor (therefore we do not stream the first event)"
27 setPropertyFlags(EModulePropFlags::c_Output | EModulePropFlags::c_ParallelProcessingCertified);
29 addParam(
"output", m_param_output,
"The ZMQ address of the connected application (to receive the messages).");
30 addParam(
"raw", m_param_raw,
"Send out raw data with send header and trailer around the evtmessage instead of just the evtmessage. "
31 "The former is the typical use case when talking with e.g. storage, "
32 "the latter can be used for local tests or when sending full events e.g. to the event display.");
35 void HLTDs2ZMQModule::event()
39 m_streamHelper.initialize();
48 auto zmqMessage = m_streamHelper.streamRaw();
49 m_output->handleEvent(std::move(zmqMessage));
51 auto zmqMessage = m_streamHelper.stream(
false,
false);
52 m_output->handleEvent(std::move(zmqMessage));
54 }
catch (zmq::error_t& error) {
55 if (error.num() == EINTR) {
57 B2DEBUG(10,
"Received an signal interrupt during the event call. Will return");
61 B2ERROR(
"ZMQ Error while calling the event: " << error.num());
65 void HLTDs2ZMQModule::endRun()
68 B2DEBUG(10,
"Sending out old run message");
69 auto message = ZMQMessageFactory::createMessage(EMessageTypes::c_lastEventMessage);
70 m_output->handleEvent(std::move(message));
71 }
catch (zmq::error_t& error) {
72 if (error.num() == EINTR) {
74 B2DEBUG(10,
"Received an signal interrupt during the event call. Will return");
78 B2ERROR(
"ZMQ Error while calling the event: " << error.num());
82 void HLTDs2ZMQModule::terminate()
85 B2DEBUG(10,
"Sending out terminate message");
86 auto message = ZMQMessageFactory::createMessage(EMessageTypes::c_terminateMessage);
87 m_output->handleEvent(std::move(message));
88 }
catch (zmq::error_t& error) {
89 if (error.num() == EINTR) {
91 B2DEBUG(10,
"Received an signal interrupt during the event call. Will return");
95 B2ERROR(
"ZMQ Error while calling the event: " << error.num());