Belle II Software prerelease-10-00-00a
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
29{
30 // Module description
31 setDescription("Manage histograms/Ntuples/TTrees for modules inheriting from the HistoModule class. See https://xwiki.desy.de/xwiki/rest/p/297bb 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.
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.
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
Module()
Constructor.
Definition Module.cc:30
@ 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.
static RbTupleManager & Instance()
Access to singleton.
Definition RbTuple.cc:38
int terminate()
Function called by HistoManager module at the end.
Definition RbTuple.cc:116
void init(int nprocess, const char *filename, const char *workdir=".")
Global initialization.
Definition RbTuple.cc:47
int begin(int pid)
Function called by HistoManager module for the first event.
Definition RbTuple.cc:87
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.