Belle II Software  release-05-02-19
HistoManagerModule.cc
1 //+
2 // File : HistoManager.cc
3 // Description : A module to manager histograms/ntuples/ttrees; implementation
4 //
5 // Author : Ryosuke Itoh, IPNS, KEK
6 // Date : 27 - Jul - 2010
7 //-
8 
9 #include <framework/modules/histomanager/HistoManagerModule.h>
10 
11 #include <framework/core/Environment.h>
12 #include <framework/pcore/ProcHandler.h>
13 #include <framework/pcore/RbTuple.h>
14 
15 using namespace Belle2;
16 using namespace std;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
27 // Implementations
28 HistoManagerModule::HistoManagerModule() : Module(), m_initmain(false), m_tupleManagerInitialized(false)
29 {
30  // Module description
31  setDescription("Manage histograms/Ntuples/TTrees for modules inheriting from the HistoModule class. See https://confluence.desy.de/display/BI/Software+HistogramManagement for details.");
32  setPropertyFlags(Module::c_HistogramManager);
33 
34  // Parameters
35  addParam("histoFileName", m_histoFileName, "Name of histogram output file.", string("histofile.root"));
36  addParam("workDirName", m_workdir, "Name of working directory.", string("."));
37 
38 }
39 
40 HistoManagerModule::~HistoManagerModule() = default;
41 
43 {
44  RbTupleManager::Instance().init(Environment::Instance().getNumberProcesses(), m_histoFileName.c_str(), m_workdir.c_str());
45 
46  m_initmain = true;
47  // cout << "HistoManager::initialization done" << endl;
48 
49 }
50 
52 {
53  if (!m_tupleManagerInitialized) {
54  // cout << "HistoManager:: first pass in beginRun() : proc="
55  // << ProcHandler::EvtProcID() << endl;
57  m_tupleManagerInitialized = true;
58  }
59 }
60 
62 {
63  if (!m_tupleManagerInitialized) {
64  // cout << "HistoManager:: first pass in endRun(): proc="
65  // << ProcHandler::EvtProcID() << endl;
67  m_tupleManagerInitialized = true;
68  }
69 }
70 
72 {
73  if (!m_tupleManagerInitialized) {
74  // cout << "HistoManager:: first pass in event() : proc="
75  // << ProcHandler::EvtProcID() << endl;
77  m_tupleManagerInitialized = true;
78  }
79 }
80 
82 {
83  if (m_tupleManagerInitialized) {
84  // cout << "HistoManager::terminating event process : PID=" << ProcHandler::EvtProcID() << endl;
86  }
87 }
Belle2::RbTupleManager::init
void init(int nprocess, const char *filename, const char *workdir=".")
Global initialization.
Definition: RbTuple.cc:49
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::RbTupleManager::begin
int begin(int pid)
Function called by HistoManager module for the first event.
Definition: RbTuple.cc:88
Belle2::HistoManagerModule::initialize
virtual void initialize() override
module functions
Definition: HistoManagerModule.cc:42
Belle2::HistoManager
Definition: HistoManager.h:24
Belle2::HistoManagerModule::event
virtual void event() override
This method is the core of the module.
Definition: HistoManagerModule.cc:71
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::HistoManagerModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: HistoManagerModule.cc:51
Belle2::HistoManagerModule
Class definition of HistoManager module.
Definition: HistoManagerModule.h:24
Belle2::Module::c_HistogramManager
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Definition: Module.h:83
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RbTupleManager::Instance
static RbTupleManager & Instance()
Access to singleton.
Definition: RbTuple.cc:40
Belle2::ProcHandler::EvtProcID
static int EvtProcID()
Return ID of the current process.
Definition: ProcHandler.cc:243
Belle2::HistoManagerModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: HistoManagerModule.cc:81
Belle2::HistoManagerModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: HistoManagerModule.cc:61
Belle2::Environment::Instance
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:31
Belle2::RbTupleManager::terminate
int terminate()
Function called by HistoManager module at the end.
Definition: RbTuple.cc:115