Belle II Software development
HistoManagerModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
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
15using namespace Belle2;
16using namespace std;
17
18//-----------------------------------------------------------------
19// Register the Module
20//-----------------------------------------------------------------
22
23//-----------------------------------------------------------------
24// Implementation
25//-----------------------------------------------------------------
26
27// Implementations
28HistoManagerModule::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.");
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
40HistoManagerModule::~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{
54 // cout << "HistoManager:: first pass in beginRun() : proc="
55 // << ProcHandler::EvtProcID() << endl;
58 }
59}
60
62{
64 // cout << "HistoManager:: first pass in endRun(): proc="
65 // << ProcHandler::EvtProcID() << endl;
68 }
69}
70
72{
74 // cout << "HistoManager:: first pass in event() : proc="
75 // << ProcHandler::EvtProcID() << endl;
78 }
79}
80
82{
84 // cout << "HistoManager::terminating event process : PID=" << ProcHandler::EvtProcID() << endl;
86 }
87}
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
virtual void initialize() override
module functions
virtual void event() override
This method is the core of the module.
HistoManagerModule()
Constructor and Destructor.
virtual void endRun() override
This method is called if the current run ends.
virtual void terminate() override
This method is called at the end of the event processing.
std::string m_workdir
Name of working directory.
virtual void beginRun() override
Called when entering a new run.
std::string m_histoFileName
Name of histogram output file.
bool m_tupleManagerInitialized
True if RbTupleManager was initialized.
bool m_initmain
True if initialize() was called.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Definition: Module.h:81
static int EvtProcID()
Return ID of the current process.
Definition: ProcHandler.cc:248
static RbTupleManager & Instance()
Access to singleton.
Definition: RbTuple.cc:40
int terminate()
Function called by HistoManager module at the end.
Definition: RbTuple.cc:118
void init(int nprocess, const char *filename, const char *workdir=".")
Global initialization.
Definition: RbTuple.cc:49
int begin(int pid)
Function called by HistoManager module for the first event.
Definition: RbTuple.cc:89
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.