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>
34 setDescription(
"Module to manage histograms/Ntuples/TTrees");
38 addParam(
"histoFileName", m_histfile,
"Name of histogram output file.",
string(
"histofile.root"));
39 addParam(
"workDirName", m_workdir,
"Name of working directory",
string(
"."));
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);
46 DqmHistoManagerModule::~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);
134 EvtMessage* msg = m_msg->encode_msg(MSG_EVENT);
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);
174 EvtMessage* msg = m_msg->encode_msg(MSG_EVENT);
175 (msg->
header())->reserved[0] = 0;
176 (msg->
header())->reserved[1] = m_nobjs;
177 (msg->
header())->reserved[2] = 0;
192 int DqmHistoManagerModule::StreamHistograms(TDirectory* curdir,
MsgHandler* msg)
194 TList* keylist = curdir->GetList();
197 TIter nextkey(keylist);
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");
Class definition of DqmHistoManager module.
virtual void event()
This method is the core of the module.
virtual void initialize()
module functions
virtual void beginRun()
Called when entering a new run.
virtual void terminate()
This method is called at the end of the event processing.
virtual void endRun()
This method is called if the current run ends.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Class to manage streamed object.
EvtHeader * header()
Get pointer to EvtHeader.
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
A class to encode/decode an EvtMessage.
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.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.