9#include <dqm/analysis/modules/DQMHistReferenceModule.h>
31 B2DEBUG(1,
"DQMHistReference: Constructor done.");
39 B2DEBUG(1,
"DQMHistReference: initialized.");
44 B2DEBUG(1,
"DQMHistReference: beginRun called.");
51 TH1::AddDirectory(
false);
53 B2DEBUG(1,
"DQMHistReference: reading references from input root file");
56 if (run_type ==
"") run_type =
"default";
58 B2INFO(
"DQMHistReference: run_type " << run_type);
62 if (refFile->IsZombie()) {
63 B2INFO(
"DQMHistReference: reference file " <<
m_referenceFileName <<
" does not exist. No references will be used!");
71 TIter nextkey(refFile->GetListOfKeys());
73 while ((key = (TKey*)nextkey())) {
74 if (key->IsFolder() &&
string(key->GetName()) ==
string(
"ref")) {
75 TDirectory* refdir = (TDirectory*)key->ReadObj();
76 TIter nextDetDir(refdir->GetListOfKeys());
79 while ((detDir = (TKey*)nextDetDir())) {
80 if (!detDir->IsFolder())
continue;
81 TIter nextTypeDir(((TDirectory*)detDir->ReadObj())->GetListOfKeys());
83 TDirectory* foundDir = NULL;
85 while ((typeDir = (TKey*)nextTypeDir())) {
86 if (!typeDir->IsFolder())
continue;
87 if (
string(typeDir->GetName()) == run_type) {
88 foundDir = (TDirectory*)typeDir->ReadObj();
91 if (
string(typeDir->GetName()) ==
"default") foundDir = (TDirectory*)typeDir->ReadObj();
93 string dirname = detDir->GetName();
95 B2INFO(
"No run type specific or default references available for " << dirname);
97 B2INFO(
"Reading reference histograms for " << dirname <<
" from run type folder: " << foundDir->GetName());
99 TIter next(foundDir->GetListOfKeys());
102 while ((hh = (TKey*)next())) {
103 if (hh->IsFolder())
continue;
104 TObject* obj = hh->ReadObj();
105 if (obj->IsA()->InheritsFrom(
"TH1")) {
107 string histname = h->GetName();
108 std::string name = dirname +
"/" + histname;
110 n.m_orghist_name = name;
111 n.m_refhist_name =
"ref/" + name;
112 h->SetName((n.m_refhist_name).c_str());
115 n.setRefCopy(
nullptr);
116 n.setCanvas(
nullptr);
128 B2INFO(
"DQMHistReference: read references done");
135 B2DEBUG(1,
"DQMHistReference: event called");
140 B2DEBUG(1,
"DQMHistReference: endRun called");
145 B2DEBUG(1,
"DQMHistReference: terminate called");
The base class for the histogram analysis module.
static const std::string & getRunType(void)
Get the Run Type.
static RefList & getRefList()
Get the list of the reference histograms.
void initialize() override final
Initializer.
~DQMHistReferenceModule()
Destructor.
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.