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);
84 std::string hname = split_result.at(1);
85 if ((dirname +
"/" + hname) ==
"softwaretrigger/skim") hname =
"skim_hlt";
86 std::string cname = dirname +
"/c_" + hname;
87 std::replace(cname.begin(), cname.end(),
'.',
'_');
100 bool in_excl_folder =
false;
102 in_excl_folder =
true;
105 if (excl_folder == dirname) {
106 in_excl_folder =
true;
112 if (in_excl_folder) {
114 B2DEBUG(1,
"==" << wanted_folder <<
"==" << dirname <<
"==");
115 if (wanted_folder == std::string(histoname)) {
127 B2DEBUG(1,
"Auto Hist->Canvas for " << histoname);
128 histoname.ReplaceAll(
"/",
"_");
129 std::string name = histoname.Data();
130 if (
m_cs.find(name) ==
m_cs.end()) {
132 TCanvas* c =
new TCanvas(cname.c_str(), (
"c_" + hname).c_str());
133 m_cs.insert(std::pair<std::string, std::unique_ptr<TCanvas>>(name, c));
134 B2DEBUG(1,
"DQMHistAutoCanvasModule: new canvas " << c->GetName());
137 TCanvas* c =
m_cs[name].get();
144 auto hist = it.second.getHist();
146 if (hist->GetDimension() == 1) {
148 if (hist->GetMinimum() > 0) hist->SetMinimum(0);
151 if (hist->Integral() != 0) {
154 if (refCopy and abs(refCopy->Integral()) > 0) {
156 if (refCopy->GetMaximum() > hist->GetMaximum())
157 hist->SetMaximum(1.1 * refCopy->GetMaximum());
159 refCopy->Draw(
"hist,same");
169 }
else if (hist->GetDimension() == 2) {
static TH1 * findRefHist(const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
Get referencehistogram from list (no other search).
static void UpdateCanvas(const std::string &name, bool updated=true)
Mark canvas as updated (or not)
static std::vector< std::string > StringSplit(const std::string &s, const char delim)
Helper function for string token split.
DQMHistAnalysisModule()
Constructor / Destructor.
static HistList & getHistList()
Get the list of the histograms.
@ c_RefScaleEntries
to number of entries (integral)
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.