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.");
74 TH1::AddDirectory(
false);
85 const std::filesystem::file_time_type ftime = std::filesystem::last_write_time(
m_mempath);
88 B2INFO(
"File not updated! -> Sleep");
98 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
99 B2INFO(
"[" << mbstr <<
"] before Load File");
101 std::unique_ptr<TFile> pFile = std::unique_ptr<TFile> (
new TFile(
m_mempath.c_str(),
"READ"));
102 if (pFile->IsZombie()) {
103 B2WARNING(
"DQMHistAnalysisInput2: " <<
m_mempath +
" is Zombie -> Sleep");
110 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
111 B2INFO(
"[" << mbstr <<
"] after LoadFile");
113 const TDatime& mt = pFile->GetModificationDate();
114 TDatime mmt(mt.Convert());
115 std::string expno(
"UNKNOWN"), runno(
"UNKNOWN"), rtype(
"UNKNOWN");
118 TIter next(pFile->GetListOfKeys());
122 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
123 B2INFO(
"[" << mbstr <<
"] before input loop");
132 std::vector<TH1*> hs;
134 while ((key = (TKey*)next())) {
135 auto obj = key->ReadObj();
136 if (obj ==
nullptr)
continue;
137 if (!obj->IsA()->InheritsFrom(
"TH1")) {
148 TString a = h->GetName();
149 a.ReplaceAll(
":",
"");
151 B2DEBUG(1,
"DQMHistAnalysisInput2: get histo " << a.Data());
163 if (std::string(h->GetName()) == std::string(
"DQMInfo/expno")) expno = h->GetTitle();
164 if (std::string(h->GetName()) == std::string(
"DQMInfo/runno")) runno = h->GetTitle();
165 if (std::string(h->GetName()) == std::string(
"DQMInfo/rtype")) rtype = h->GetTitle();
169 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
170 B2INFO(
"[" << mbstr <<
"] before Close File");
176 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
177 B2INFO(
"[" << mbstr <<
"] before delete File");
181 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
182 B2INFO(
"[" << mbstr <<
"] after input loop");
184 if (expno == std::string(
"UNKNOWN") || runno == std::string(
"UNKNOWN")) {
185 B2WARNING(
"DQMHistAnalysisInput2: " <<
m_mempath +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated " +
188 for (
auto& h : hs)
delete h;
191 if (
m_c_info != NULL)
m_c_info->SetTitle((
m_mempath +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Changed "
193 + mmt.AsString() +
", Last DQM event " + std::string(mbstr)).c_str());
197 B2INFO(
"DQMHistAnalysisInput2: " <<
m_mempath +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated " +
218 anyupdate |=
addHist(
"", h->GetName(), h);
219 B2DEBUG(1,
"Found : " << h->GetName() <<
" : " << h->GetEntries());
235 B2DEBUG(1,
"DQMHistAnalysisInput2: endRun called");
240 B2DEBUG(1,
"DQMHistAnalysisInput2: terminate called");
251 time_t now = time(0);
252 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&now));
254 strftime(mbstr,
sizeof(mbstr),
"%F %T", localtime(&
m_last_event));
255 fprintf(fh,
"%s,", mbstr);
257 fprintf(fh,
"%s,", mbstr);
259 fprintf(fh,
"%s,", mbstr);
261 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.
static void clearRefList(void)
Clears the list of ref histograms.
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.