9#include <daq/dqm/modules/DqmHistoManagerModule.h>
11#include <framework/core/Environment.h>
12#include <framework/pcore/ProcHandler.h>
13#include <framework/pcore/RbTuple.h>
38 addParam(
"histoFileName",
m_histfile,
"Name of histogram output file.",
string(
"histofile.root"));
40 addParam(
"HostName",
m_hostname,
"Name of host to send histograms",
string(
"localhost"));
41 addParam(
"Port", m_port,
"Socket port number to connect", DQM_SOCKET);
42 addParam(
"DumpInterval", m_interval,
"Interval to dump histos", 1000);
43 addParam(
"WriteInterval", m_dumpinterval,
"Interval to write file", 10000);
46DqmHistoManagerModule::~DqmHistoManagerModule()
89 (m_sock->sock())->sock());
100 m_initialized =
true;
106 if (!m_initialized) {
110 m_initialized =
true;
116 if (!m_initialized) {
120 m_initialized =
true;
123 time_t ctime = time(NULL);
126 if ((ctime - m_ptime) > m_interval) {
132 StreamHistograms(gDirectory, m_msg);
137 printf(
"DqmHistoManger(proc:%d): dumping histos.....%d histos\n",
141 (msg->
header())->reserved[0] = 0;
142 (msg->
header())->reserved[1] = m_nobjs;
143 (msg->
header())->reserved[2] = 0;
151 if ((ctime - m_dtime) > m_dumpinterval) {
171 StreamHistograms(gDirectory, m_msg);
173 printf(
"terminate : m_nobjs = %d\n", m_nobjs);
175 (msg->
header())->reserved[0] = 0;
176 (msg->
header())->reserved[1] = m_nobjs;
177 (msg->
header())->reserved[2] = 0;
192int DqmHistoManagerModule::StreamHistograms(TDirectory* curdir,
MsgHandler* msg)
194 TList* keylist = curdir->GetList();
197 TIter nextkey(keylist);
199 int nkeys [[maybe_unused]] = 0;
200 int nobjs [[maybe_unused]] = 0;
201 while ((key = (TKey*)nextkey())) {
203 TObject* obj = curdir->FindObject(key->GetName());
204 if (obj->IsA()->InheritsFrom(
"TH1")) {
205 TH1* h1 = (TH1*) obj;
208 m_msg->
add(h1, h1->GetName());
212 }
else if (obj->IsA()->InheritsFrom(TDirectory::Class())) {
214 TDirectory* tdir = (TDirectory*) obj;
216 TText subdir(0, 0, tdir->GetName());
217 m_msg->
add(&subdir,
"SUBDIR:" +
string(obj->GetName())) ;
221 StreamHistograms(tdir, msg);
222 TText command(0, 0,
"COMMAND:EXIT");
223 m_msg->
add(&command,
"SUBDIR:EXIT");
std::string m_histfile
Name of histogram output file.
void initialize() override
module functions
void event() override
This method is the core of the module.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
std::string m_workdir
Name of working directory.
void beginRun() override
Called when entering a new run.
bool m_initmain
True if initialize() was called.
std::string m_hostname
Host name to send histograms.
DqmHistoManagerModule()
Constructor and Destructor.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Class to manage streamed object.
EvtHeader * header()
Get pointer to EvtHeader.
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_HistogramManager
This module is used to manage histograms accumulated by other modules.
A class to encode/decode an EvtMessage.
virtual void add(const TObject *, const std::string &name)
Add an object to be streamed.
virtual EvtMessage * encode_msg(ERecordType rectype)
Stream object list into an EvtMessage.
virtual void clear()
Clear object list.
static int EvtProcID()
Return ID of the current process.
static int numEventProcesses()
Return number of worker processes (configured value, not current)
static RbTupleManager & Instance()
Access to singleton.
void init(int nprocess, const char *filename, const char *workdir=".")
Global initialization.
int begin(int pid)
Function called by HistoManager module for the first event.
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.