Belle II Software development
Recorder Class Reference

Class to fill a tree from a set of variables. More...

#include <Recorder.h>

Classes

class  Impl
 Record the MVA variables. More...
 

Public Member Functions

 Recorder (const std::function< void(TTree &)> &setBranches, const std::string &rootFileName, const std::string &treeName="recorded_tree")
 Construct the Recorder opening the given ROOT file and create the underlying TTree and add let the given function setup branches.
 
 Recorder (const std::vector< Named< Float_t * > > &namedVariables, const std::string &rootFileName, const std::string &treeName="recorded_tree")
 Construct the Recorder opening the given ROOT file and create the underlying TTree and add variable names and values addresses as branches to it.
 
 ~Recorder ()
 Destructor writing the TTree and closing the ROOT File.
 
void write ()
 Write all captured variables to disk.
 
void capture ()
 Capture the registered variable values and write them out.
 

Private Attributes

std::unique_ptr< Implm_impl
 Pointer to implementation hiding the details.
 

Detailed Description

Class to fill a tree from a set of variables.

Definition at line 29 of file Recorder.h.

Constructor & Destructor Documentation

◆ Recorder() [1/2]

Recorder ( const std::function< void(TTree &)> &  setBranches,
const std::string &  rootFileName,
const std::string &  treeName = "recorded_tree" 
)

Construct the Recorder opening the given ROOT file and create the underlying TTree and add let the given function setup branches.

PImpl Interface.

Parameters
setBranchesFunction invoked with the underlying TTree as argument which is supposed create Branches and provide the value adresses.
rootFileNameName of ROOT file to which should be written.
treeNameName of the TTree in the ROOT file.

Definition at line 139 of file Recorder.cc.

142 : m_impl(std::make_unique<Impl>(setBranches, rootFileName, treeName))
143{
144}
std::unique_ptr< Impl > m_impl
Pointer to implementation hiding the details.
Definition: Recorder.h:71

◆ Recorder() [2/2]

Recorder ( const std::vector< Named< Float_t * > > &  namedVariables,
const std::string &  rootFileName,
const std::string &  treeName = "recorded_tree" 
)

Construct the Recorder opening the given ROOT file and create the underlying TTree and add variable names and values addresses as branches to it.

Parameters
namedVariablesA sequence of named values that are used as addresses of branches
rootFileNameName of ROOT file to which should be written.
treeNameName of the TTree in the ROOT file.

Definition at line 146 of file Recorder.cc.

148 :
149 Recorder([ & namedVariables](TTree & tree)
150{
151 for (const Named<Float_t*>& namedVariable : namedVariables) {
152 std::string name = namedVariable.getName();
153 Float_t* variable = namedVariable;
154 tree.Branch(name.c_str(), variable);
155 }
156},
157rootFileName,
158treeName)
159{
160}
A mixin class to attach a name to an object.
Definition: Named.h:23
Class to fill a tree from a set of variables.
Definition: Recorder.h:29

Member Function Documentation

◆ capture()

void capture ( )

Capture the registered variable values and write them out.

Definition at line 169 of file Recorder.cc.

170{
171 m_impl->capture();
172}

◆ write()

void write ( )

Write all captured variables to disk.

Definition at line 164 of file Recorder.cc.

165{
166 m_impl->write();
167}

Member Data Documentation

◆ m_impl

std::unique_ptr<Impl> m_impl
private

Pointer to implementation hiding the details.

Definition at line 71 of file Recorder.h.


The documentation for this class was generated from the following files: