10 #include <tracking/trackFindingCDC/mva/Recorder.h>
13 #include <framework/datastore/StoreObjPtr.h>
14 #include <framework/pcore/RootMergeable.h>
27 namespace TrackFindingCDC {
37 Impl(
const std::function<
void(TTree&)>& setBranches,
38 const std::string& rootFileName,
39 const std::string& treeName =
"recorded_tree");
62 #include <framework/datastore/DataStore.h>
63 #include <framework/pcore/ProcHandler.h>
69 using namespace TrackFindingCDC;
72 const std::string& rootFileName,
73 const std::string& treeName)
75 , m_tTree(treeName,
DataStore::c_Persistent)
77 TDirectory* ptrSavedCurrentTDirectory = gDirectory;
79 m_tFile =
new TFile(rootFileName.c_str(),
"RECREATE");
83 m_tTree.construct(treeName.c_str(), treeName.c_str());
89 if (ptrSavedCurrentTDirectory) {
90 ptrSavedCurrentTDirectory->cd();
100 m_tTree->get().SetDirectory(
nullptr);
114 TDirectory* ptrSavedCurrentTDirectory = gDirectory;
116 TFile* tFile = m_tTree->get().GetCurrentFile();
120 m_tTree->get().Write(
"", TObject::kOverwrite);
121 m_tTree->get().SetDirectory(
nullptr);
124 if (ptrSavedCurrentTDirectory) {
125 ptrSavedCurrentTDirectory->cd();
136 m_tTree->get().Fill();
142 const std::string& rootFileName,
143 const std::string& treeName)
144 :
m_impl(std::make_unique<
Impl>(setBranches, rootFileName, treeName))
149 const std::string& rootFileName,
150 const std::string& treeName) :
151 Recorder([ & namedVariables](TTree & tree)
154 std::string name = namedVariable.getName();
155 Float_t* variable = namedVariable;
156 tree.Branch(name.c_str(), variable);