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>
22int DqmMasterCallback::m_running = 0;
27void* RunDqmMasterLogger(
void*)
32DqmMasterCallback::DqmMasterCallback(
ConfigFile& config)
34 m_histodir = config.get(
"dqmmaster.histodir");
35 m_tmpdir = config.get(
"dqmmaster.tmpdir");
36 m_instance = config.get(
"dqmmaster.instance");
37 auto host = config.get(
"dqmmaster.host");
38 auto port = config.getInt(
"dqmmaster.port");
40 LogFile::info(
"DqmMasterCallback : instance = %s, histodir = %s, tmpdir = %s", m_instance.c_str(), m_histodir.c_str(),
47DqmMasterCallback::~DqmMasterCallback()
52void DqmMasterCallback::load(
const DBObject& ,
const std::string& runtype)
55 LogFile::info(
"LOAD: runtype %s", m_runtype.c_str());
58 std::string filename = m_tmpdir +
"/dqm_" + m_instance +
"_runtype";
60 auto fh = fopen(filename.c_str(),
"wt+");
62 fprintf(fh,
"%s", m_runtype.c_str());
68void DqmMasterCallback::start(
int expno,
int runno)
75 std::string filename = m_tmpdir +
"/dqm_" + m_instance +
"_expnr";
77 auto fh = fopen(filename.c_str(),
"wt+");
79 fprintf(fh,
"%d", m_expno);
84 std::string filename = m_tmpdir +
"/dqm_" + m_instance +
"_runnr";
86 auto fh = fopen(filename.c_str(),
"wt+");
88 fprintf(fh,
"%d", m_runno);
96 TText rc_clear(0, 0,
"DQMRC:CLEAR");
97 hdl.add(&rc_clear,
"DQMRC:CLEAR");
99 TText subdir(0, 0,
"DQMInfo");
100 hdl.add(&subdir,
"SUBDIR:DQMInfo") ;
102 TH1F h_expno(
"expno", to_string(m_expno).c_str(), 1, 0, 1);
103 hdl.add(&h_expno,
"expno");
105 TH1F h_runno(
"runno", to_string(m_runno).c_str(), 1, 0, 1);
106 hdl.add(&h_runno,
"runno");
108 TH1F h_rtype(
"rtype", m_runtype.c_str(), 1, 0, 1);
109 hdl.add(&h_rtype,
"rtype");
111 TText command(0, 0,
"COMMAND:EXIT");
112 hdl.add(&command,
"SUBDIR:EXIT");
114 TText rc_merge(0, 0,
"DQMRC:MERGE");
115 hdl.add(&rc_merge,
"DQMRC:MERGE");
119 (msg->
header())->reserved[0] = 0;
120 (msg->
header())->reserved[1] = numobjs;
122 while (m_sock->send(msg) < 0) {
123 LogFile::error(
"Connection to histogramm server is missing in START: expno = %d, runno = %d, runtype %s", m_expno, m_runno,
125 m_sock->sock()->reconnect(10);
129 LogFile::info(
"START: expno = %d, runno = %d, runtype %s", m_expno, m_runno, m_runtype.c_str());
133void DqmMasterCallback::stop(
void)
135 LogFile::info(
"STOP: expno = %d, runno = %d, runtype %s", m_expno, m_runno, m_runtype.c_str());
137 if (m_running == 0)
return;
146 snprintf(outfile,
sizeof(outfile),
"DQMRC:SAVE:%s/%sdqm_e%4.4dr%6.6d.root", m_histodir.c_str(), m_instance.c_str(), m_expno,
149 TText rc_save(0, 0, outfile);
150 hdl.add(&rc_save, outfile);
154 (msg->
header())->reserved[0] = 0;
155 (msg->
header())->reserved[1] = numobjs;
157 while (m_sock->send(msg) < 0) {
158 LogFile::error(
"Connection closed during STOP, file not saved: expno = %d, runno = %d, runtype %s", m_expno, m_runno,
160 m_sock->sock()->reconnect(10);
169void 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.