14 #include <dqm/analysis/modules/DQMHistAnalysisOutputFile.h>
32 DQMHistAnalysisOutputFileModule::DQMHistAnalysisOutputFileModule()
35 setDescription(
"Module to save histograms from DQMHistAnalysisModules");
38 addParam(
"HistoFile",
m_filename,
"Output Histogram Filename", std::string(
"histo.root"));
43 B2DEBUG(20,
"DQMHistAnalysisOutputFile: Constructor done.");
51 B2DEBUG(20,
"DQMHistAnalysisOutputFile: initialized.");
57 B2DEBUG(20,
"DQMHistAnalysisOutputFile: beginRun called.");
63 B2DEBUG(20,
"DQMHistAnalysisOutputFile: event called.");
68 B2INFO(
"DQMHistAnalysisOutputFile: endRun called");
74 TDirectory* oldDir = gDirectory;
81 seq = gROOT->GetListOfCanvases() ;
83 B2INFO(
"found canvases");
87 while ((obj = (TObject*)next())) {
88 if (obj->InheritsFrom(
"TCanvas")) {
89 B2INFO(
"Canvas name: " << obj->GetName() <<
" title " << obj->GetTitle());
92 B2INFO(
"Others name: " << obj->GetName() <<
" title " << obj->GetTitle());
98 TSeqCollection* files;
99 files = gROOT->GetListOfFiles() ;
101 B2INFO(
"found keys");
102 TIter nextfile(files) ;
105 while ((file = (TObject*)nextfile())) {
106 if (file->InheritsFrom(
"TFile")) {
107 B2INFO(
"File name: " << file->GetName() <<
" title " << file->GetTitle());
108 if (file == &f || file->GetName() ==
m_filename)
continue;
110 TList* list = ((TFile*)file)->GetListOfKeys() ;
116 while ((key = (TKey*)next())) {
117 TString skey(key->GetClassName());
118 if (skey.BeginsWith(TString(
"Belle2::")))
continue;
119 TClass clkey(key->GetClassName());
120 if (clkey.InheritsFrom(
"TH1")) {
121 obj = key->ReadObj() ;
122 B2INFO(
"Histo name: " << obj->GetName() <<
" title " << obj->GetTitle());
124 d = old = gDirectory;
125 TString myl = obj->GetName();
132 while (myl.Tokenize(tok, from,
"/")) {
136 if (myl.Tokenize(dummy, fr,
"/")) {
137 auto e = d->GetDirectory(tok);
150 ((TH1*)obj)->SetName(tok);
157 B2INFO(
"Others name: " << file->GetName() <<
" title " << file->GetTitle());
172 B2INFO(
"DQMHistAnalysisOutputFile: terminate called");
The base class for the histogram analysis module.
bool m_saveCanvases
Write all Canvases to file.
void initialize() override final
Initializer.
bool m_saveHistos
Write all Histos to file.
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.
std::string m_histogramDirectoryName
Directory name within root file where to place things.
void endRun() override final
This method is called if the current run ends.
std::string m_filename
file name of root file
void beginRun() override final
Called when entering a new run.
~DQMHistAnalysisOutputFileModule()
Destructor.
void setDescription(const std::string &description)
Sets the description of the module.
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.