Belle II Software  release-05-02-19
RbTuple.h
1 //+
2 // File : RbTuple.h
3 // Description : Collect ROOT histogram/Ntuples from event processes
4 //
5 // Author : Ryosuke Itoh, IPNS, KEK
6 // Date : 16 - Apr - 2009
7 // Modified : 27 - Jul - 2010, for pbasf2
8 //-
9 
10 #pragma once
11 
12 #include <vector>
13 #include <string>
14 
15 class TFile;
16 
17 namespace Belle2 {
22  class Module;
23 
25  /*
26  Modules with histogram definitions are supposed to be derived from
27  HistoModule class and histograms are defined in HistoModule::defineHisto() function.
28  It is supposed to be hooked by register_module(*this) function.
29  */
31  public:
32 
33  // Constructor and destructor are private for singleton access
35  ~RbTupleManager();
36 
38  RbTupleManager(int nprocess, const char* filename, const char* workdir = ".");
39 
41  static RbTupleManager& Instance();
42 
44  void init(int nprocess, const char* filename, const char* workdir = ".");
45 
47  // void define ( void (*func)( void ) );
48  void register_module(Module*);
49 
50 
52  int begin(int pid);
53 
55  int terminate();
56 
57  // Functions to collect histograms from event processing on the fly
58  // int collect ();
59 
61  int dump();
62 
64  int hadd(bool deleteflag = true);
65 
67  const std::vector<Module*>& getHistDefiningModules() const
68  {
69  return m_histdefs;
70  }
71 
72  private:
75  std::vector<Module*> m_histdefs;
76  int m_nproc{0};
77  std::string m_filename;
78  std::string m_workdir;
79  TFile* m_root{nullptr};
80  };
81 
83 } // Belle2 namespace
Belle2::RbTupleManager::init
void init(int nprocess, const char *filename, const char *workdir=".")
Global initialization.
Definition: RbTuple.cc:49
Belle2::RbTupleManager::s_instance
static RbTupleManager * s_instance
singleton instance.
Definition: RbTuple.h:73
Belle2::RbTupleManager::register_module
void register_module(Module *)
Functions called by analysis modules in mother process.
Definition: RbTuple.cc:82
Belle2::RbTupleManager::dump
int dump()
Function to dump histograms/tuples to the file.
Definition: RbTuple.cc:126
Belle2::RbTupleManager::getHistDefiningModules
const std::vector< Module * > & getHistDefiningModules() const
Return the list of modules that have defined histograms.
Definition: RbTuple.h:67
Belle2::RbTupleManager::begin
int begin(int pid)
Function called by HistoManager module for the first event.
Definition: RbTuple.cc:88
Belle2::RbTupleManager
Class to manage histograms defined in registered modules.
Definition: RbTuple.h:30
Belle2::RbTupleManager::m_nproc
int m_nproc
Number of parallel processes.
Definition: RbTuple.h:76
Belle2::RbTupleManager::m_histdefs
std::vector< Module * > m_histdefs
registered HistoModules.
Definition: RbTuple.h:75
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RbTupleManager::m_root
TFile * m_root
Histogram output file.
Definition: RbTuple.h:79
Belle2::RbTupleManager::Instance
static RbTupleManager & Instance()
Access to singleton.
Definition: RbTuple.cc:40
Belle2::RbTupleManager::hadd
int hadd(bool deleteflag=true)
Functions to add up all histogram files.
Definition: RbTuple.cc:135
Belle2::RbTupleManager::m_filename
std::string m_filename
Name of histogram output file.
Definition: RbTuple.h:77
Belle2::RbTupleManager::terminate
int terminate()
Function called by HistoManager module at the end.
Definition: RbTuple.cc:115
Belle2::RbTupleManager::m_workdir
std::string m_workdir
Name of working directory.
Definition: RbTuple.h:78