Belle II Software development
ConcreteVariablesToHistogramPersistenceManager.h
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#pragma once
10
11#include <reconstruction/persistenceManager/PersistenceManager.h>
12
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/pcore/RootMergeable.h>
15
16namespace Belle2::VariablePersistenceManager {
17
28 public:
33
44 void initialize(const std::string& fileName,
45 const std::string& directory,
46 Variables& variables) override;
47
54 void addEntry(const EvaluatedVariables& evaluatedVariables) override;
55
62 void store() override;
63
64 private:
68 std::string m_fileName;
69
73 std::string m_directory;
74
78 Variables m_variables;
79
83 std::shared_ptr<TFile> m_file{nullptr};
84
88 std::map<std::string, std::unique_ptr<StoreObjPtr<RootMergeable<TH1D>>>> m_histograms;
89
96 void openFileWithGuards();
97
104 void registerHistograms();
105 };
106
107} // namespace Belle2::VariablePersistenceManager
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.
std::map< std::string, std::unique_ptr< StoreObjPtr< RootMergeable< TH1D > > > > m_histograms
A map of histogram names to their respective objects (wrapped in RootMergeable).
void initialize(const std::string &fileName, const std::string &directory, Variables &variables) override
Initializes the manager by opening a ROOT file and creating histograms.
Abstract base class defining the interface for persisting variables.