![]() |
Belle II Software development
|
A PersistenceManager that writes variables to ROOT histograms (TH1D). More...
#include <ConcreteVariablesToHistogramPersistenceManager.h>
Public Member Functions | |
| ConcreteVariablesToHistogramPersistenceManager () | |
| Default constructor. | |
| void | initialize (const std::string &fileName, const std::string &directory, Variables &variables) override |
| Initializes the manager by opening a ROOT file and creating histograms. | |
| void | addEntry (const EvaluatedVariables &evaluatedVariables) override |
| Fills histograms with the current set of evaluated variables. | |
| void | store () override |
| Writes histogram data to disk. | |
Private Member Functions | |
| void | openFileWithGuards () |
Safely opens the ROOT file specified by m_fileName. | |
| void | registerHistograms () |
Registers (books) the histograms based on m_variables. | |
Private Attributes | |
| std::string | m_fileName |
| Name of the ROOT file where histograms will be written. | |
| std::string | m_directory |
| Name of the directory (folder) within the ROOT file where histograms are stored. | |
| Variables | m_variables |
| A list of variables associated with the histograms. | |
| std::shared_ptr< TFile > | m_file {nullptr} |
| Pointer to the ROOT file object. | |
| std::map< std::string, std::unique_ptr< StoreObjPtr< RootMergeable< TH1D > > > > | m_histograms |
| A map of histogram names to their respective objects (wrapped in RootMergeable). | |
A PersistenceManager that writes variables to ROOT histograms (TH1D).
This class creates and manages one-dimensional histograms for a set of variables. It handles opening a ROOT file, booking the histograms, and filling them with user-supplied data each event. The histograms can be merged in a multi-process environment through the RootMergeable mechanism.
Definition at line 38 of file ConcreteVariablesToHistogramPersistenceManager.h.
Default constructor.
Definition at line 20 of file ConcreteVariablesToHistogramPersistenceManager.cc.
|
overridevirtual |
Fills histograms with the current set of evaluated variables.
| evaluatedVariables | A map of variable names to their current values. |
Each call updates the corresponding histogram with the provided variable values.
Implements PersistenceManager.
Definition at line 34 of file ConcreteVariablesToHistogramPersistenceManager.cc.
|
overridevirtual |
Initializes the manager by opening a ROOT file and creating histograms.
| fileName | The name of the ROOT file to create or update. |
| directory | The directory (folder) within the ROOT file where histograms will be placed. |
| variables | A list of variables that will be associated with the histograms. |
This method configures the persistence manager with file/directory names and prepares the memory structures for histogram creation. It does not fill any data yet; that is handled by addEntry().
Implements PersistenceManager.
Definition at line 22 of file ConcreteVariablesToHistogramPersistenceManager.cc.
|
private |
Safely opens the ROOT file specified by m_fileName.
Throws an exception if the file cannot be opened for writing or if any other file-related error occurs.
Definition at line 62 of file ConcreteVariablesToHistogramPersistenceManager.cc.
|
private |
Registers (books) the histograms based on m_variables.
For each variable that is defined as "binned" (i.e., has bin information), a TH1D histogram is created in m_histograms.
Definition at line 76 of file ConcreteVariablesToHistogramPersistenceManager.cc.
|
overridevirtual |
Writes histogram data to disk.
After filling the histograms through addEntry(), this function ensures the data is written (or merged) into the ROOT file.
Implements PersistenceManager.
Definition at line 43 of file ConcreteVariablesToHistogramPersistenceManager.cc.
|
private |
Name of the directory (folder) within the ROOT file where histograms are stored.
Definition at line 84 of file ConcreteVariablesToHistogramPersistenceManager.h.
|
private |
Pointer to the ROOT file object.
Definition at line 94 of file ConcreteVariablesToHistogramPersistenceManager.h.
|
private |
Name of the ROOT file where histograms will be written.
Definition at line 79 of file ConcreteVariablesToHistogramPersistenceManager.h.
|
private |
A map of histogram names to their respective objects (wrapped in RootMergeable).
Definition at line 99 of file ConcreteVariablesToHistogramPersistenceManager.h.
|
private |
A list of variables associated with the histograms.
Definition at line 89 of file ConcreteVariablesToHistogramPersistenceManager.h.