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
15#include <TH1D.h>
16#include <TFile.h>
17
18namespace Belle2 {
23 template<class T> class RootMergeable;
25}
26
27namespace Belle2::VariablePersistenceManager {
28
39 public:
44
55 void initialize(const std::string& fileName,
56 const std::string& directory,
57 Variables& variables) override;
58
65 void addEntry(const EvaluatedVariables& evaluatedVariables) override;
66
73 void store() override;
74
75 private:
79 std::string m_fileName;
80
84 std::string m_directory;
85
89 Variables m_variables;
90
94 std::shared_ptr<TFile> m_file{nullptr};
95
99 std::map<std::string, std::unique_ptr<StoreObjPtr<RootMergeable<TH1D>>>> m_histograms;
100
107 void openFileWithGuards();
108
115 void registerHistograms();
116 };
117
118} // namespace Belle2::VariablePersistenceManager
Wrap a root histogram or TNtuple to make it mergeable.
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.
Abstract base class for different kinds of events.