Belle II Software  release-05-01-25
HLTDQM2ZMQ.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <framework/core/Module.h>
13 
14 #include <daq/hbasf2/utils/HLTStreamHelper.h>
15 #include <framework/pcore/zmq/connections/ZMQConfirmedConnection.h>
16 
17 #include <framework/pcore/zmq/utils/ZMQParent.h>
18 #include <framework/datastore/StoreObjPtr.h>
19 #include <framework/dataobjects/EventMetaData.h>
20 
21 #include <memory>
22 #include <chrono>
23 #include <zmq.hpp>
24 
25 namespace Belle2 {
43  class HLTDQM2ZMQModule : public Module {
44  public:
47 
56  void event() override;
57 
59  void endRun() override;
60 
62  void beginRun() override;
63 
65  void terminate() override;
66 
67  private:
69  std::string m_param_output;
71  unsigned int m_param_sendOutInterval = 30;
72 
74  std::shared_ptr<ZMQParent> m_parent;
76  std::unique_ptr<ZMQConfirmedOutput> m_output;
77 
83  bool m_firstEvent = true;
85  bool m_histogramsDefined = false;
87  std::chrono::system_clock::time_point m_start;
88 
90  void sendOutHistograms();
91  };
93 }
Belle2::HLTDQM2ZMQModule::sendOutHistograms
void sendOutHistograms()
Helper function to serialize and send out the histograms.
Definition: HLTDQM2ZMQ.cc:125
Belle2::HLTStreamHelper
Helper class for data store serialization.
Definition: HLTStreamHelper.h:52
Belle2::HLTDQM2ZMQModule::m_output
std::unique_ptr< ZMQConfirmedOutput > m_output
Confirmed connection to the histogram server.
Definition: HLTDQM2ZMQ.h:84
Belle2::HLTDQM2ZMQModule::m_parent
std::shared_ptr< ZMQParent > m_parent
ZMQ Parent needed for the connections.
Definition: HLTDQM2ZMQ.h:82
Belle2::HLTDQM2ZMQModule::beginRun
void beginRun() override
Call the defineHisto function of all histogram modules registered at the RbTupleManager singleton.
Definition: HLTDQM2ZMQ.cc:64
Belle2::HLTDQM2ZMQModule::terminate
void terminate() override
Stream the histograms one last time and send out a terminate message. We rely on all histogram module...
Definition: HLTDQM2ZMQ.cc:104
Belle2::HLTDQM2ZMQModule::m_param_output
std::string m_param_output
Module parameter: histogram server address.
Definition: HLTDQM2ZMQ.h:77
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::HLTDQM2ZMQModule::m_streamHelper
HLTStreamHelper m_streamHelper
Streamer utility. TODO: in principle we do not need this, could be static!
Definition: HLTDQM2ZMQ.h:87
Belle2::HLTDQM2ZMQModule::endRun
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:80
Belle2::HLTDQM2ZMQModule::HLTDQM2ZMQModule
HLTDQM2ZMQModule()
Register the module parameters.
Definition: HLTDQM2ZMQ.cc:11
Belle2::HLTDQM2ZMQModule::m_param_sendOutInterval
unsigned int m_param_sendOutInterval
Module parameter: send out interval in seconds.
Definition: HLTDQM2ZMQ.h:79
Belle2::HLTDQM2ZMQModule::event
void event() override
On the first event, initialize the connection and the streamer.
Definition: HLTDQM2ZMQ.cc:35
Belle2::HLTDQM2ZMQModule::m_firstEvent
bool m_firstEvent
Are we still in the first event?
Definition: HLTDQM2ZMQ.h:91
Belle2::HLTDQM2ZMQModule::m_start
std::chrono::system_clock::time_point m_start
Point in time when the current interval counting started.
Definition: HLTDQM2ZMQ.h:95
Belle2::HLTDQM2ZMQModule::m_eventMetaData
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:89
Belle2::HLTDQM2ZMQModule::m_histogramsDefined
bool m_histogramsDefined
Are the histograms already defined (e.g. defineHisto is called)? TODO: should we reset this after the...
Definition: HLTDQM2ZMQ.h:93