14#include <dqm/analysis/modules/DQMHistAnalysisInput2.h>
36 addParam(
"HistMemoryPath",
m_mempath,
"Path to Input Hist memory", std::string(
""));
41 B2DEBUG(1,
"DQMHistAnalysisInput2: Constructor done.");
47 m_c_info =
new TCanvas(
"DQMInfo/c_info",
"");
51 B2DEBUG(1,
"DQMHistAnalysisInput2: initialized.");
57 B2DEBUG(1,
"DQMHistAnalysisInput2: beginRun called.");
73 TH1::AddDirectory(
false);
84 const std::filesystem::file_time_type ftime = std::filesystem::last_write_time(
m_mempath);
87 B2INFO(
"File not updated! -> Sleep");
97 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
98 B2INFO(
"[" << mbstr <<
"] before Load File");
100 std::unique_ptr<TFile> pFile = std::unique_ptr<TFile> (
new TFile(
m_mempath.c_str(),
"READ"));
101 if (pFile->IsZombie()) {
102 B2WARNING(
"DQMHistAnalysisInput2: " <<
m_mempath +
" is Zombie -> Sleep");
109 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
110 B2INFO(
"[" << mbstr <<
"] after LoadFile");
112 const TDatime& mt = pFile->GetModificationDate();
113 TDatime mmt(mt.Convert());
114 std::string expno(
"UNKNOWN"), runno(
"UNKNOWN"), rtype(
"UNKNOWN");
117 TIter next(pFile->GetListOfKeys());
121 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
122 B2INFO(
"[" << mbstr <<
"] before input loop");
131 std::vector<TH1*> hs;
133 while ((key = (TKey*)next())) {
134 auto obj = key->ReadObj();
135 if (obj ==
nullptr)
continue;
136 if (!obj->IsA()->InheritsFrom(
"TH1")) {
147 TString a = h->GetName();
148 a.ReplaceAll(
":",
"");
150 B2DEBUG(1,
"DQMHistAnalysisInput2: get histo " << a.Data());
162 if (std::string(h->GetName()) == std::string(
"DQMInfo/expno")) expno = h->GetTitle();
163 if (std::string(h->GetName()) == std::string(
"DQMInfo/runno")) runno = h->GetTitle();
164 if (std::string(h->GetName()) == std::string(
"DQMInfo/rtype")) rtype = h->GetTitle();
168 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
169 B2INFO(
"[" << mbstr <<
"] before Close File");
175 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
176 B2INFO(
"[" << mbstr <<
"] before delete File");
180 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
181 B2INFO(
"[" << mbstr <<
"] after input loop");
183 if (expno == std::string(
"UNKNOWN") || runno == std::string(
"UNKNOWN")) {
184 B2WARNING(
"DQMHistAnalysisInput2: " <<
m_mempath +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated " +
187 for (
auto& h : hs)
delete h;
190 if (
m_c_info != NULL)
m_c_info->SetTitle((
m_mempath +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Changed "
192 + mmt.AsString() +
", Last DQM event " + std::string(mbstr)).c_str());
196 B2INFO(
"DQMHistAnalysisInput2: " <<
m_mempath +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated " +
217 anyupdate |=
addHist(
"", h->GetName(), h);
218 B2DEBUG(1,
"Found : " << h->GetName() <<
" : " << h->GetEntries());
234 B2DEBUG(1,
"DQMHistAnalysisInput2: endRun called");
239 B2DEBUG(1,
"DQMHistAnalysisInput2: terminate called");
250 time_t now = time(0);
251 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
253 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&
m_last_event));
254 fprintf(fh,
"%s,", mbstr);
256 fprintf(fh,
"%s,", mbstr);
258 fprintf(fh,
"%s,", mbstr);
260 fprintf(fh,
"%s\n", mbstr);
The base class for the histogram analysis module.
void clearlist(void)
Clear all static global lists.
static void clearHistList(void)
Clears the list of histograms.
std::vector< std::string > StringSplit(const std::string &s, const char delim)
Helper function for string token split.
void setRunType(std::string &t)
Set the Run Type.
static bool addHist(const std::string &dirname, const std::string &histname, TH1 *h)
Add histogram.
void clearCanvases(void)
Clear content of all Canvases.
static int getEventProcessed(void)
Get the number of processed events.
static void initHistListBeforeEvent(void)
Reset the list of histograms.
void ExtractEvent(std::vector< TH1 * > &hs)
Extract event processed from daq histogram, called from input module.
void resetDeltaList(void)
Reset Delta.
void setReturnValue(int value)
Sets the return value for this module as integer.
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.