8#include <daq/hbasf2/modules/HLTDQM2ZMQ.h>
9#include <framework/pcore/zmq/messages/ZMQMessageFactory.h>
10#include <framework/pcore/RbTuple.h>
11#include <framework/core/HistoModule.h>
21 "Module to collect DQM histograms (written out by HistoModules) and "
22 "send them every time period to a running ZMQ DQM server "
23 "(either a finalhistoserver or a proxyhistorver). "
24 "The address as well as the send interval are module parameters. "
25 "As the old DQM module, this module works by streaming everything in the current ROOT main "
26 "directory, which is either a TDirectory or a TH1. For the specific implementation on how "
27 "the streaming is done, please see the HLTStreamHelper class. "
28 "The histogram sending is handled via a confirmed connection (output in this case), "
29 "so all the usual conventions for a confirmed connection apply. "
30 "This module does only makes sense to run on the HLT, it is not useful for local "
37 "Please note that the full stack of DQM histo servers"
38 "could delay this, as each of them have a timeout.",
49 m_start = std::chrono::system_clock::now();
54 auto currentTime = std::chrono::system_clock::now();
55 auto timeDifference = std::chrono::duration_cast<std::chrono::seconds>(currentTime -
m_start).count();
58 m_start = std::chrono::system_clock::now();
60 }
catch (zmq::error_t& error) {
61 if (error.num() == EINTR) {
63 B2DEBUG(10,
"Received an signal interrupt during the event call. Will return");
67 B2ERROR(
"ZMQ Error while calling the event: " << error.num());
77 for (
const auto& module : modules) {
78 B2INFO(module->getName() <<
" is a histo module");
79 auto* histoModule =
dynamic_cast<HistoModule*
>(module);
80 B2ASSERT(
"The added module is not a histogram module!", histoModule);
81 histoModule->defineHisto();
94 B2DEBUG(10,
"Sending out old run message");
97 m_output->handleEvent(std::move(message),
false, 1000);
98 }
catch (zmq::error_t& error) {
99 if (error.num() == EINTR) {
101 B2DEBUG(10,
"Received an signal interrupt during the event call. Will return");
105 B2ERROR(
"ZMQ Error while calling the event: " << error.num());
118 B2DEBUG(10,
"Sending out terminate message");
120 m_output->handleEvent(std::move(message));
121 }
catch (zmq::error_t& error) {
122 if (error.num() == EINTR) {
124 B2DEBUG(10,
"Received an signal interrupt during the event call. Will return");
128 B2ERROR(
"ZMQ Error while calling the event: " << error.num());
139 m_output->handleEvent(std::move(msg),
false, 1000);
bool m_firstEvent
Are we still in the first event?
std::string m_param_output
Module parameter: histogram server address.
void sendOutHistograms()
Helper function to serialize and send out the histograms.
void event() override
On the first event, initialize the connection and the streamer.
void endRun() override
Stream the histograms one last time and send out a run end message. We rely on all histogram modules ...
std::shared_ptr< ZMQParent > m_parent
ZMQ Parent needed for the connections.
void terminate() override
Stream the histograms one last time and send out a terminate message. We rely on all histogram module...
HLTDQM2ZMQModule()
Register the module parameters.
void beginRun() override
Call the defineHisto function of all histogram modules registered at the RbTupleManager singleton.
bool m_histogramsDefined
Are the histograms already defined (e.g. defineHisto is called)? TODO: should we reset this after the...
HLTStreamHelper m_streamHelper
Streamer utility. TODO: in principle we do not need this, could be static!
std::unique_ptr< ZMQConfirmedOutput > m_output
Confirmed connection to the histogram server.
unsigned int m_param_sendOutInterval
Module parameter: send out interval in seconds.
std::chrono::system_clock::time_point m_start
Point in time when the current interval counting started.
std::unique_ptr< ZMQNoIdMessage > streamHistograms(bool compressed=true)
Stream all objects derived from TH1 into a message. Only the last subfolder is streamed by prefixing ...
void initialize()
Initialize this class. Call this e.g. in the first event.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
static RbTupleManager & Instance()
Access to singleton.
const std::vector< Module * > & getHistDefiningModules() const
Return the list of modules that have defined histograms.
Output part of a confirmed connection.
static auto createMessage(const std::string &msgIdentity, const EMessageTypes msgType, const std::unique_ptr< EvtMessage > &eventMessage)
Create an ID Message out of an identity, the type and an event message.
A helper class for creating ZMQ sockets keeping track of the ZMQ context and terminating it if needed...
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.