9#include <dqm/analysis/modules/DQMHistReferenceModule.h>
30 B2DEBUG(1,
"DQMHistReference: Constructor done.");
35 B2DEBUG(1,
"DQMHistReference: initialized.");
40 B2DEBUG(1,
"DQMHistReference: beginRun called.");
47 TH1::AddDirectory(
false);
49 B2DEBUG(1,
"DQMHistReference: reading references from input root file");
52 if (run_type ==
"") run_type =
"default";
54 B2INFO(
"DQMHistReference: run_type " << run_type);
58 if (refFile->IsZombie()) {
59 B2INFO(
"DQMHistReference: reference file " <<
m_referenceFileName <<
" does not exist. No references will be used!");
67 TIter nextRefDirKey(refFile->GetListOfKeys());
69 while ((refDirKey =
dynamic_cast<TKey*
>(nextRefDirKey()))) {
70 if (refDirKey->IsFolder() &&
string(refDirKey->GetName()) ==
string(
"ref")) {
71 TDirectory* refDir =
static_cast<TDirectory*
>(refDirKey->ReadObj());
72 TIter nextDetDirKey(refDir->GetListOfKeys());
75 while ((detDirKey =
dynamic_cast<TKey*
>(nextDetDirKey()))) {
76 if (!detDirKey->IsFolder())
continue;
77 TDirectory* detDir = ((TDirectory*)detDirKey->ReadObj());
78 TIter nextRunTypeDirKey(detDir->GetListOfKeys());
80 TDirectory* runtypeDir =
nullptr;
82 while ((runtypeDirKey = (TKey*)nextRunTypeDirKey())) {
83 if (!runtypeDirKey->IsFolder())
continue;
84 if (
string(runtypeDirKey->GetName()) == run_type) {
85 if (runtypeDir)
delete runtypeDir;
86 runtypeDir = (TDirectory*)runtypeDirKey->ReadObj();
90 if (
string(runtypeDirKey->GetName()) ==
"default") runtypeDir = (TDirectory*)runtypeDirKey->ReadObj();
92 string detName = detDir->GetName();
95 B2INFO(
"No run type specific or default references available for " << detName);
97 B2INFO(
"Reading reference histograms for " << detName <<
" from run type folder: " << runtypeDir->GetName());
99 TIter nextHistkey(runtypeDir->GetListOfKeys());
102 while ((histKey = (TKey*)nextHistkey())) {
103 if (histKey->IsFolder())
continue;
104 if (gROOT->GetClass(histKey->GetClassName())->InheritsFrom(
"TH1")) {
105 auto h =
dynamic_cast<TH1*
>(histKey->ReadObj());
117 B2INFO(
"DQMHistReference: read references done");
124 B2DEBUG(1,
"DQMHistReference: event called");
129 B2DEBUG(1,
"DQMHistReference: endRun called");
134 B2DEBUG(1,
"DQMHistReference: terminate called");
static void addRefHist(const std::string &dirname, TH1 *hist)
Add reference histogram.
static const std::string & getRunType(void)
Get the list of the reference histograms.
DQMHistAnalysisModule()
Constructor / Destructor.
void initialize() override final
Initializer.
void loadReferenceHistos()
Reads reference histograms from input root file.
DQMHistReferenceModule()
Constructor.
void terminate() override final
This method is called at the end of the event processing.
void event() override final
This method is called for each event.
void endRun() override final
This method is called if the current run ends.
void beginRun() override final
Called when entering a new run.
std::string m_referenceFileName
Reference Histogram Root file name.
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.