LDMX Software
NtupleManager.cxx
1
2#include "Framework/NtupleManager.h"
3
4namespace framework {
5
7
9 // Create an instance of the NtupleManager if needed
10 static NtupleManager instance;
11 return instance;
12}
13
14void NtupleManager::create(const std::string& name) {
15 // Check if a tree named 'name' has already been created. If so
16 // throw an exception.
17 if (trees_.count(name) != 0)
18 EXCEPTION_RAISE("NtupleManager",
19 "A tree with name " + name + " has already been created.");
20
21 // Create a tree with the given name and add it to the list of trees.
22 trees_[name] = new TTree{name.c_str(), name.c_str()};
23}
24
25void NtupleManager::fill() {
26 // Loop over all the trees and fill them
27 for (const auto& [name, tree] : trees_) tree->Fill();
28}
29
31
33 // we assume that ROOT handles clean-up
34 // of the TTrees when they are written to the output histogram file
35 trees_.clear();
37}
38
39} // namespace framework
void clear()
Reset the objects carried by the passengers.
Definition Bus.h:126
void everybodyOff()
Kicks all of the passengers off the bus and therefore destroys any objects they are carrying.
Definition Bus.h:140
Singleton class used to manage the creation and pooling of ntuples.
NtupleManager()
Private constructor to prevent instantiation.
void create(const std::string &tname)
Create a ROOT tree to hold the ntuple variables (ROOT leaves).
framework::Bus bus_
Container for buffering variables.
void clear()
Reset all of the variables to their limits.
static NtupleManager & getInstance()
void reset()
Reset NtupleManager to blank state.
std::unordered_map< std::string, TTree * > trees_
Container for output ROOT trees.
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45