![]() |
ATLAS Offline Software
|
A class that hopefully makes making a flat ntuple tree a bit easier since you don't need to worry about what type to make the branches and stuff. More...
#include <TreeManager.h>
Public Types | |
typedef std::function< int(top::TreeManager const *, std::string const &)> | BranchFilter |
function object type used for branch filters More... | |
Public Member Functions | |
TreeManager () | |
Default constructor - note need to initialize the class if you use this. More... | |
TreeManager (const std::string &name, TFile *outputFile, const int, const int, const int) | |
You need to construct this at the start (in the same way as for the plot manager. More... | |
TreeManager (const TreeManager &&rhs) | |
We do allow you to move it. More... | |
TreeManager (const TreeManager &)=delete | |
But not to copy it. More... | |
TreeManager & | operator= (TreeManager const &)=delete |
Or assign it. More... | |
void | initialize (const std::string &name, TFile *outputFile, const int, const int, const int) |
Initialize the class with a new output file. More... | |
void | fill () |
Calls TTree::Fill. More... | |
const std::string & | name () const |
name of the TTree More... | |
std::vector< BranchFilter > & | branchFilters () |
list of functions that control which variables are written out More... | |
std::vector< BranchFilter > const & | branchFilters () const |
list of functions that control which variables are written out More... | |
template<class T > | |
void | makeOutputVariable (T &obj, const std::string name) |
The idea is to simplify the creation of branches so that you don't have to write tree->Branch("blah", &blah, "blah/I") because the computer can figure out the "blah/I" bit for you. More... | |
Private Member Functions | |
const char * | RootType (const char *typeid_type) |
Stolen from SFrame code. More... | |
const char * | TypeidType (const char *root_type) |
Stolen from SFrame code. More... | |
Private Attributes | |
std::string | m_name |
name of the tree More... | |
TTree * | m_tree |
Pointer to the TTree, created by this class in the constructor. More... | |
std::list< void * > | m_outputVarPointers |
Stolen from SFrame code. More... | |
std::vector< BranchFilter > | m_branchFilters |
list of functions that control which variables are written out More... | |
int | m_basketSizePrimitive |
int | m_basketSizeVector |
A class that hopefully makes making a flat ntuple tree a bit easier since you don't need to worry about what type to make the branches and stuff.
Almost all this code is stolen from SFrame: http://sourceforge.net/p/sframe
Definition at line 26 of file TreeManager.h.
typedef std::function<int (top::TreeManager const*, std::string const&)> top::TreeManager::BranchFilter |
function object type used for branch filters
Definition at line 67 of file TreeManager.h.
top::TreeManager::TreeManager | ( | ) |
Default constructor - note need to initialize the class if you use this.
Definition at line 15 of file TreeManager.cxx.
top::TreeManager::TreeManager | ( | const std::string & | name, |
TFile * | outputFile, | ||
const int | nEventAutoFlush, | ||
const int | basketSizePrimitive, | ||
const int | basketSizeVector | ||
) |
You need to construct this at the start (in the same way as for the plot manager.
file | The file to write the tree to. |
name | The name of the tree (e.g. nominal, systematic1 etc). |
Definition at line 20 of file TreeManager.cxx.
top::TreeManager::TreeManager | ( | const TreeManager && | rhs | ) |
|
delete |
But not to copy it.
|
inline |
list of functions that control which variables are written out
The function objects are called in order, with the TreeManager instance and the variable name as parameters. A return value of 1 (0) tells the TreeManager that the variable should (not) be written to the n-tuple. If the function returns -1, the decision is left to the next function in the list. If there are no functions in the list, or all functions return -1, the variable is written to the n-tuple.
Definition at line 70 of file TreeManager.h.
|
inline |
list of functions that control which variables are written out
The function objects are called in order, with the TreeManager instance and the variable name as parameters. A return value of 1 (0) tells the TreeManager that the variable should (not) be written to the n-tuple. If the function returns -1, the decision is left to the next function in the list. If there are no functions in the list, or all functions return -1, the variable is written to the n-tuple.
Definition at line 73 of file TreeManager.h.
void top::TreeManager::fill | ( | ) |
void top::TreeManager::initialize | ( | const std::string & | name, |
TFile * | outputFile, | ||
const int | nEventAutoFlush, | ||
const int | basketSizePrimitive, | ||
const int | basketSizeVector | ||
) |
|
inline |
The idea is to simplify the creation of branches so that you don't have to write tree->Branch("blah", &blah, "blah/I") because the computer can figure out the "blah/I" bit for you.
Stolen from SFrame.
obj | The object that you would like to save in a branch. This can be a primitive type (e.g. int, unsigned int, etc.) or an object (e.g. std::vector<float>). |
name | The name you would like to give this branch. |
Definition at line 88 of file TreeManager.h.
const std::string & top::TreeManager::name | ( | ) | const |
|
delete |
Or assign it.
Stolen from SFrame code.
This is a tricky one. In SCycleBaseNTuple::DeclareVariable(...) the function automatically detects the type of the variable to be put into the output tree. Since ROOT uses a different naming scheme for the primitives than C++'s typeid call, the typeid names have to be translated for ROOT. This is the function doing that.
typeid_type | Primitive type name in the "typeid" format |
Definition at line 61 of file TreeManager.cxx.
Stolen from SFrame code.
This function is used internally to check whether the user tries to connect the correct type of primitive to the branches. ROOT can have some trouble identifying such code problems...
root_type | ROOT primitive type name |
Definition at line 131 of file TreeManager.cxx.
|
private |
Definition at line 172 of file TreeManager.h.
|
private |
Definition at line 173 of file TreeManager.h.
|
private |
list of functions that control which variables are written out
The function objects are called in order, with the TreeManager instance and the variable name as parameters. A return value of 1 (0) tells the TreeManager that the variable should (not) be written to the n-tuple. If the function returns -1, the decision is left to the next function in the list. If there are no functions in the list, or all functions return -1, the variable is written to the n-tuple.
Definition at line 169 of file TreeManager.h.
|
private |
name of the tree
Definition at line 110 of file TreeManager.h.
|
private |
Stolen from SFrame code.
We have to keep the pointers to the output variables defined by the user. ROOT keeps track of the objects by storing pointers to pointers to the objects. Since the user probably wants to use the output objects directly and not through pointers, the base class has to take care of this pointer issue by itself...
Definition at line 157 of file TreeManager.h.
|
private |
Pointer to the TTree, created by this class in the constructor.
Definition at line 146 of file TreeManager.h.