8 #include <daq/dqm/DqmMasterCallback.h>
9 #include <daq/slc/system/LogFile.h>
10 #include <framework/pcore/EvtMessage.h>
11 #include <framework/pcore/MsgHandler.h>
22 int DqmMasterCallback::m_running = 0;
27 void* RunDqmMasterLogger(
void*)
32 DqmMasterCallback::DqmMasterCallback(
ConfigFile& config)
34 m_histodir = config.get(
"dqmmaster.histodir");
35 m_instance = config.get(
"dqmmaster.instance");
36 auto host = config.get(
"dqmmaster.host");
37 auto port = config.getInt(
"dqmmaster.port");
39 LogFile::info(
"DqmMasterCallback : instance = %s, histodir = %s", m_instance.c_str(), m_histodir.c_str());
45 DqmMasterCallback::~DqmMasterCallback()
50 void DqmMasterCallback::load(
const DBObject& ,
const std::string& runtype)
53 LogFile::info(
"LOAD: runtype %s", m_runtype.c_str());
56 void DqmMasterCallback::start(
int expno,
int runno)
64 TText rc_clear(0, 0,
"DQMRC:CLEAR");
65 hdl.add(&rc_clear,
"DQMRC:CLEAR");
67 TText subdir(0, 0,
"DQMInfo");
68 hdl.add(&subdir,
"SUBDIR:DQMInfo") ;
70 TH1F h_expno(
"expno", to_string(m_expno).c_str(), 1, 0, 1);
71 hdl.add(&h_expno,
"expno");
73 TH1F h_runno(
"runno", to_string(m_runno).c_str(), 1, 0, 1);
74 hdl.add(&h_runno,
"runno");
76 TH1F h_rtype(
"rtype", m_runtype.c_str(), 1, 0, 1);
77 hdl.add(&h_rtype,
"rtype");
79 TText command(0, 0,
"COMMAND:EXIT");
80 hdl.add(&command,
"SUBDIR:EXIT");
82 TText rc_merge(0, 0,
"DQMRC:MERGE");
83 hdl.add(&rc_merge,
"DQMRC:MERGE");
87 (msg->
header())->reserved[0] = 0;
88 (msg->
header())->reserved[1] = numobjs;
90 while (m_sock->send(msg) < 0) {
91 LogFile::error(
"Connection to histogramm server is missing in START: expno = %d, runno = %d, runtype %s", m_expno, m_runno,
93 m_sock->sock()->reconnect(10);
97 LogFile::info(
"START: expno = %d, runno = %d, runtype %s", m_expno, m_runno, m_runtype.c_str());
101 void DqmMasterCallback::stop(
void)
103 LogFile::info(
"STOP: expno = %d, runno = %d, runtype %s", m_expno, m_runno, m_runtype.c_str());
105 if (m_running == 0)
return;
114 snprintf(outfile,
sizeof(outfile),
"DQMRC:SAVE:%s/%sdqm_e%4.4dr%6.6d.root", m_histodir.c_str(), m_instance.c_str(), m_expno,
117 TText rc_save(0, 0, outfile);
118 hdl.add(&rc_save, outfile);
122 (msg->
header())->reserved[0] = 0;
123 (msg->
header())->reserved[1] = numobjs;
125 while (m_sock->send(msg) < 0) {
126 LogFile::error(
"Connection closed during STOP, file not saved: expno = %d, runno = %d, runtype %s", m_expno, m_runno,
128 m_sock->sock()->reconnect(10);
137 void DqmMasterCallback::abort(
void)
Class to manage streamed object.
EvtHeader * header()
Get pointer to EvtHeader.
A class to encode/decode an EvtMessage.
Abstract base class for different kinds of events.