10 #include <dqm/analysis/modules/DQMHistAnalysisInput.h>
12 #include <daq/slc/base/StringUtil.h>
33 addParam(
"HistMemoryPath", m_mempath,
"Path to Input Hist memory", std::string(
""));
34 addParam(
"HistMemorySize", m_memsize,
"Size of Input Hist memory", 10000000);
35 addParam(
"HistMemoryName", m_memname,
"Name of Input Hist memory", std::string(
""));
36 addParam(
"ShmId", m_shm_id,
"ID of shared memory", 0);
37 addParam(
"SemId", m_sem_id,
"ID of semaphore", 0);
38 addParam(
"RefreshInterval", m_interval,
"Refresh interval of histograms", 10);
39 addParam(
"AutoCanvas", m_autocanvas,
"Automatic creation of canvas",
true);
40 addParam(
"AutoCanvasFolders", m_acfolders,
"List of histograms to automatically create canvases, empty for all",
41 std::vector<std::string>());
42 addParam(
"ExcludeFolders", m_exclfolders,
"List of folders to exclude from create canvases, empty for none, \"all\" for all",
43 std::vector<std::string>());
44 addParam(
"RemoveEmpty", m_remove_empty,
"Remove empty histograms",
false);
45 addParam(
"EnableRunInfo", m_enable_run_info,
"Enable Run Info",
false);
46 B2DEBUG(1,
"DQMHistAnalysisInput: Constructor done.");
50 DQMHistAnalysisInputModule::~DQMHistAnalysisInputModule() { }
60 m_c_info =
new TCanvas(
"DQMInfo/c_info",
"");
66 B2INFO(
"DQMHistAnalysisInput: initialized.");
72 B2INFO(
"DQMHistAnalysisInput: beginRun called.");
82 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
83 B2INFO(
"[" << mbstr <<
"] before LoadMemFile");
85 TMemFile* file =
m_memory->LoadMemFile();
88 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
89 B2INFO(
"[" << mbstr <<
"] after LoadMemFile");
91 const TDatime& mt = file->GetModificationDate();
92 TDatime mmt(mt.Convert());
93 std::string expno(
"UNKNOWN"), runno(
"UNKNOWN"), rtype(
"UNKNOWN");
96 TIter next(file->GetListOfKeys());
100 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
101 B2INFO(
"[" << mbstr <<
"] before input loop");
103 while ((key = (TKey*)next())) {
104 TH1* h = (TH1*)key->ReadObj();
105 if (h == NULL)
continue;
108 TString a = h->GetName();
109 a.ReplaceAll(
":",
"");
111 B2DEBUG(1,
"DQMHistAnalysisInput: get histo " << a.Data());
113 if (StringUtil::split(a.Data(),
'/').size() <= 1)
continue;
115 std::string dir_name = StringUtil::split(a.Data(),
'/')[0];
118 if (std::string(h->GetName()) == std::string(
"DQMInfo/expno")) expno = h->GetTitle();
119 if (std::string(h->GetName()) == std::string(
"DQMInfo/runno")) runno = h->GetTitle();
120 if (std::string(h->GetName()) == std::string(
"DQMInfo/rtype")) rtype = h->GetTitle();
122 StringList s = StringUtil::split(a.Data(),
'/');
124 bool give_canvas =
false;
128 bool in_excl_folder =
false;
130 in_excl_folder =
true;
133 if (excl_folder == s[0]) {
134 in_excl_folder =
true;
140 if (in_excl_folder) {
142 B2DEBUG(1,
"==" << wanted_folder <<
"==" << s[0] <<
"==");
143 if (wanted_folder == std::string(h->GetName())) {
154 B2DEBUG(1,
"Auto Hist->Canvas for " << a);
155 a.ReplaceAll(
"/",
"_");
156 std::string name = a.Data();
157 if (
m_cs.find(name) ==
m_cs.end()) {
159 std::string dirname = s[0];
160 std::string hname = s[1];
161 if ((dirname +
"/" + hname) ==
"softwaretrigger/skim") hname =
"skim_hlt";
162 TCanvas* c =
new TCanvas((dirname +
"/c_" + hname).c_str(), (
"c_" + hname).c_str());
163 m_cs.insert(std::pair<std::string, TCanvas*>(name, c));
165 std::string hname = a.Data();
166 TCanvas* c =
new TCanvas((
"c_" + hname).c_str(), (
"c_" + hname).c_str());
167 m_cs.insert(std::pair<std::string, TCanvas*>(name, c));
170 TCanvas* c =
m_cs[name];
171 B2DEBUG(1,
"DQMHistAnalysisInput: new canvas " << c->GetName());
173 if (h->GetDimension() == 1) {
174 if (h->GetMinimum() > 0) h->SetMinimum(0);
176 }
else if (h->GetDimension() == 2) {
185 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
186 B2INFO(
"[" << mbstr <<
"] after input loop");
188 if (expno == std::string(
"UNKNOWN") || runno == std::string(
"UNKNOWN")) {
191 if (
m_c_info != NULL)
m_c_info->SetTitle((
m_memname +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated "
192 + mmt.AsString()).c_str());
196 B2INFO(
"DQMHistAnalysisInput: " <<
m_memname +
": Exp " + expno +
", Run " + runno +
", RunType " + rtype +
", Last Updated " +
200 for (
size_t i = 0; i < hs.size(); i++) {
203 B2DEBUG(1,
"Found : " << h->GetName() <<
" : " << h->GetEntries());
204 std::string vname = h->GetName();
206 if (h->GetDimension() == 1) {
211 }
else if (h->GetDimension() == 2) {
233 B2INFO(
"DQMHistAnalysisInput : endRun called");
235 TIter nextckey(gROOT->GetListOfCanvases());
236 TObject* cobj = NULL;
238 while ((cobj =
dynamic_cast<TObject*
>(nextckey()))) {
239 if (cobj->IsA()->InheritsFrom(
"TCanvas")) {
240 (
dynamic_cast<TCanvas*
>(cobj))->Clear();
248 B2INFO(
"terminate called");