Belle II Software development
HLTDQM2ZMQ.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <framework/core/Module.h>
11
12#include <daq/hbasf2/utils/HLTStreamHelper.h>
13#include <framework/pcore/zmq/connections/ZMQConfirmedConnection.h>
14
15#include <framework/pcore/zmq/utils/ZMQParent.h>
16#include <framework/datastore/StoreObjPtr.h>
17#include <framework/dataobjects/EventMetaData.h>
18
19#include <memory>
20#include <chrono>
21#include <zmq.hpp>
22
23namespace Belle2 {
41 class HLTDQM2ZMQModule : public Module {
42 public:
45
54 void event() override;
55
57 void endRun() override;
58
60 void beginRun() override;
61
63 void terminate() override;
64
65 private:
67 std::string m_param_output;
69 unsigned int m_param_sendOutInterval = 30;
70
72 std::shared_ptr<ZMQParent> m_parent;
74 std::unique_ptr<ZMQConfirmedOutput> m_output;
75
81 bool m_firstEvent = true;
83 bool m_histogramsDefined = false;
85 std::chrono::system_clock::time_point m_start;
86
88 void sendOutHistograms();
89 };
91}
Module to collect DQM histograms (written out by HistoModules) and send them every time period to a r...
Definition: HLTDQM2ZMQ.h:41
bool m_firstEvent
Are we still in the first event?
Definition: HLTDQM2ZMQ.h:81
std::string m_param_output
Module parameter: histogram server address.
Definition: HLTDQM2ZMQ.h:67
void sendOutHistograms()
Helper function to serialize and send out the histograms.
Definition: HLTDQM2ZMQ.cc:132
void event() override
On the first event, initialize the connection and the streamer.
Definition: HLTDQM2ZMQ.cc:42
void endRun() override
Stream the histograms one last time and send out a run end message. We rely on all histogram modules ...
Definition: HLTDQM2ZMQ.cc:87
std::shared_ptr< ZMQParent > m_parent
ZMQ Parent needed for the connections.
Definition: HLTDQM2ZMQ.h:72
void terminate() override
Stream the histograms one last time and send out a terminate message. We rely on all histogram module...
Definition: HLTDQM2ZMQ.cc:111
HLTDQM2ZMQModule()
Register the module parameters.
Definition: HLTDQM2ZMQ.cc:18
StoreObjPtr< EventMetaData > m_eventMetaData
Reference to the event meta data in the data store for sending out the run and experiment number.
Definition: HLTDQM2ZMQ.h:79
void beginRun() override
Call the defineHisto function of all histogram modules registered at the RbTupleManager singleton.
Definition: HLTDQM2ZMQ.cc:71
bool m_histogramsDefined
Are the histograms already defined (e.g. defineHisto is called)? TODO: should we reset this after the...
Definition: HLTDQM2ZMQ.h:83
HLTStreamHelper m_streamHelper
Streamer utility. TODO: in principle we do not need this, could be static!
Definition: HLTDQM2ZMQ.h:77
std::unique_ptr< ZMQConfirmedOutput > m_output
Confirmed connection to the histogram server.
Definition: HLTDQM2ZMQ.h:74
unsigned int m_param_sendOutInterval
Module parameter: send out interval in seconds.
Definition: HLTDQM2ZMQ.h:69
std::chrono::system_clock::time_point m_start
Point in time when the current interval counting started.
Definition: HLTDQM2ZMQ.h:85
Helper class for data store serialization.
Base class for Modules.
Definition: Module.h:72
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.