11#include <reconstruction/persistenceManager/PersistenceManager.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/pcore/RootMergeable.h>
16namespace Belle2::VariablePersistenceManager {
45 const std::string& directory,
46 Variables& variables)
override;
54 void addEntry(
const EvaluatedVariables& evaluatedVariables)
override;
62 void store()
override;
83 std::shared_ptr<TFile>
m_file{
nullptr};
88 std::map<std::string, std::unique_ptr<StoreObjPtr<RootMergeable<TH1D>>>>
m_histograms;
Variables m_variables
A list of variables associated with the histograms.
void store() override
Writes histogram data to disk.
std::string m_directory
Name of the directory (folder) within the ROOT file where histograms are stored.
void addEntry(const EvaluatedVariables &evaluatedVariables) override
Fills histograms with the current set of evaluated variables.
void registerHistograms()
Registers (books) the histograms based on m_variables.
std::string m_fileName
Name of the ROOT file where histograms will be written.
void openFileWithGuards()
Safely opens the ROOT file specified by m_fileName.
std::map< std::string, std::unique_ptr< StoreObjPtr< RootMergeable< TH1D > > > > m_histograms
A map of histogram names to their respective objects (wrapped in RootMergeable).
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.
std::shared_ptr< TFile > m_file
Pointer to the ROOT file object.
Abstract base class defining the interface for persisting variables.