13#include <dqm/analysis/modules/DQMHistAutoCanvas.h>
33 addParam(
"IncludeFolders",
m_inclfolders,
"List of histograms to automatically create canvases, empty for all",
34 std::vector<std::string>());
35 addParam(
"ExcludeFolders",
m_exclfolders,
"List of folders to exclude from create canvases, empty for none, \"all\" for all",
36 std::vector<std::string>());
37 addParam(
"IncludeListFile",
m_listfile,
"List canvases to create canvases from, empty for using include/exclide folder parameter",
39 B2DEBUG(1,
"DQMHistAutoCanvas: Constructor done.");
48 if (!inputFile.is_open()) {
49 B2WARNING(
"cannot open histogram list file " <<
m_listfile);
55 while (std::getline(inputFile, line)) {
70 gStyle->SetOptStat(0);
71 gStyle->SetStatStyle(1);
72 gStyle->SetOptDate(22);
77 bool give_canvas =
false;
78 TString histoname = it.first;
81 auto split_result =
StringSplit(histoname.Data(),
'/');
82 if (split_result.size() <= 1)
continue;
83 auto dirname = split_result.at(0);
86 if (split_result.size() > 1) {
87 hname = split_result.at(1);
88 if ((dirname +
"/" + hname) ==
"softwaretrigger/skim") hname =
"skim_hlt";
89 cname = dirname +
"/c_" + hname;
91 hname = histoname.Data();
94 std::replace(cname.begin(), cname.end(),
'.',
'_');
107 bool in_excl_folder =
false;
109 in_excl_folder =
true;
112 if (excl_folder == dirname) {
113 in_excl_folder =
true;
119 if (in_excl_folder) {
121 B2DEBUG(1,
"==" << wanted_folder <<
"==" << dirname <<
"==");
122 if (wanted_folder == std::string(histoname)) {
134 B2DEBUG(1,
"Auto Hist->Canvas for " << histoname);
135 histoname.ReplaceAll(
"/",
"_");
136 std::string name = histoname.Data();
137 if (
m_cs.find(name) ==
m_cs.end()) {
139 TCanvas* c =
new TCanvas(cname.c_str(), (
"c_" + hname).c_str());
140 m_cs.insert(std::pair<std::string, std::unique_ptr<TCanvas>>(name, c));
141 B2DEBUG(1,
"DQMHistAutoCanvasModule: new canvas " << c->GetName());
144 TCanvas* c =
m_cs[name].get();
151 auto hist = it.second.getHist();
153 if (hist->GetDimension() == 1) {
155 if (hist->GetMinimum() > 0) hist->SetMinimum(0);
158 if (hist->Integral() != 0) {
161 if (refCopy and abs(refCopy->Integral()) > 0) {
163 if (refCopy->GetMaximum() > hist->GetMaximum())
164 hist->SetMaximum(1.1 * refCopy->GetMaximum());
166 refCopy->Draw(
"hist,same");
176 }
else if (hist->GetDimension() == 2) {
The base class for the histogram analysis module.
static TH1 * findRefHist(const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
Get referencehistogram from list (no other search).
std::vector< std::string > StringSplit(const std::string &s, const char delim)
Helper function for string token split.
static HistList & getHistList()
Get the list of the histograms.
@ c_RefScaleEntries
to number of entries (integral)
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
std::vector< std::string > m_inclfolders
The list of folders for which automatically generate canvases.
DQMHistAutoCanvasModule()
Constructor.
std::map< std::string, std::unique_ptr< TCanvas > > m_cs
The map of histogram names to canvas pointers for buffering.
void terminate() override final
This method is called at terminate.
void event() override final
This method is called for each event.
std::set< std::string > m_canvaslist
list of wanted canvas name if included as list file
void beginRun() override final
This method is called for each run.
std::vector< std::string > m_exclfolders
The list of folders which are excluded from automatically generate canvases.
std::string m_listfile
The filename of a list canvas names to auto generate.
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.