14 #include <dqm/analysis/modules/DQMHistAnalysisInput.h>
16 #include <daq/slc/base/StringUtil.h>
37 addParam(
"HistMemoryPath", m_mempath,
"Path to Input Hist memory", std::string(
""));
38 addParam(
"HistMemorySize", m_memsize,
"Size of Input Hist memory", 10000000);
39 addParam(
"HistMemoryName", m_memname,
"Name of Input Hist memory", std::string(
""));
40 addParam(
"ShmId", m_shm_id,
"ID of shared memory", 0);
41 addParam(
"SemId", m_sem_id,
"ID of semaphore", 0);
42 addParam(
"RefreshInterval", m_interval,
"Refresh interval of histograms", 10);
43 addParam(
"AutoCanvas", m_autocanvas,
"Automatic creation of canvas",
true);
44 addParam(
"AutoCanvasFolders", m_acfolders,
"List of histograms to automatically create canvases, empty for all",
45 std::vector<std::string>());
46 addParam(
"ExcludeFolders", m_exclfolders,
"List of folders to exclude from create canvases, empty for none, \"all\" for all",
47 std::vector<std::string>());
48 addParam(
"RemoveEmpty", m_remove_empty,
"Remove empty histograms",
false);
49 addParam(
"EnableRunInfo", m_enable_run_info,
"Enable Run Info",
false);
50 B2DEBUG(1,
"DQMHistAnalysisInput: Constructor done.");
64 m_c_info =
new TCanvas(
"DQMInfo/c_info",
"");
70 B2INFO(
"DQMHistAnalysisInput: initialized.");
76 B2INFO(
"DQMHistAnalysisInput: beginRun called.");
86 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
87 B2INFO(
"[" << mbstr <<
"] before LoadMemFile");
89 TMemFile* file =
m_memory->LoadMemFile();
92 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
93 B2INFO(
"[" << mbstr <<
"] after LoadMemFile");
95 const TDatime& mt = file->GetModificationDate();
96 TDatime mmt(mt.Convert());
97 std::string expno(
"UNKNOWN"), runno(
"UNKNOWN"), rtype(
"UNKNOWN");
100 TIter next(file->GetListOfKeys());
104 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
105 B2INFO(
"[" << mbstr <<
"] before input loop");
107 while ((key = (TKey*)next())) {
108 TH1* h = (TH1*)key->ReadObj();
109 if (h == NULL)
continue;
112 TString a = h->GetName();
113 a.ReplaceAll(
":",
"");
115 B2DEBUG(1,
"DQMHistAnalysisInput: get histo " << a.Data());
117 if (StringUtil::split(a.Data(),
'/').size() <= 1)
continue;
119 std::string dir_name = StringUtil::split(a.Data(),
'/')[0];
122 if (std::string(h->GetName()) == std::string(
"DQMInfo/expno")) expno = h->GetTitle();
123 if (std::string(h->GetName()) == std::string(
"DQMInfo/runno")) runno = h->GetTitle();
124 if (std::string(h->GetName()) == std::string(
"DQMInfo/rtype")) rtype = h->GetTitle();
126 StringList s = StringUtil::split(a.Data(),
'/');
128 bool give_canvas =
false;
132 bool in_excl_folder =
false;
134 in_excl_folder =
true;
137 if (excl_folder == s[0]) {
138 in_excl_folder =
true;
144 if (in_excl_folder) {
146 B2DEBUG(1,
"==" << wanted_folder <<
"==" << s[0] <<
"==");
147 if (wanted_folder == std::string(h->GetName())) {
158 B2DEBUG(1,
"Auto Hist->Canvas for " << a);
159 a.ReplaceAll(
"/",
"_");
160 std::string name = a.Data();
161 if (
m_cs.find(name) ==
m_cs.end()) {
163 std::string dirname = s[0];
164 std::string hname = s[1];
165 if ((dirname +
"/" + hname) ==
"softwaretrigger/skim") hname =
"skim_hlt";
166 TCanvas* c =
new TCanvas((dirname +
"/c_" + hname).c_str(), (
"c_" + hname).c_str());
167 m_cs.insert(std::pair<std::string, TCanvas*>(name, c));
169 std::string hname = a.Data();
170 TCanvas* c =
new TCanvas((
"c_" + hname).c_str(), (
"c_" + hname).c_str());
171 m_cs.insert(std::pair<std::string, TCanvas*>(name, c));
174 TCanvas* c =
m_cs[name];
175 B2DEBUG(1,
"DQMHistAnalysisInput: new canvas " << c->GetName());
177 if (h->GetDimension() == 1) {
178 if (h->GetMinimum() > 0) h->SetMinimum(0);
180 }
else if (h->GetDimension() == 2) {
189 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
190 B2INFO(
"[" << mbstr <<
"] after input loop");
192 if (expno == std::string(
"UNKNOWN") || runno == std::string(
"UNKNOWN")) {
195 if (
m_c_info != NULL)
m_c_info->SetTitle((
m_memname +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated "
196 + mmt.AsString()).c_str());
200 B2INFO(
"DQMHistAnalysisInput: " <<
m_memname +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated " +
204 for (
size_t i = 0; i < hs.size(); i++) {
207 B2DEBUG(1,
"Found : " << h->GetName() <<
" : " << h->GetEntries());
220 B2INFO(
"DQMHistAnalysisInput : endRun called");
222 TIter nextckey(gROOT->GetListOfCanvases());
223 TObject* cobj = NULL;
225 while ((cobj =
dynamic_cast<TObject*
>(nextckey()))) {
226 if (cobj->IsA()->InheritsFrom(
"TCanvas")) {
227 (
dynamic_cast<TCanvas*
>(cobj))->Clear();
235 B2INFO(
"terminate called");
The base class for the histogram analysis module.
static void addHist(const std::string &dirname, const std::string &histname, TH1 *h)
Add histogram.
static void resetHist()
Clear and reset the list of histograms.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.