RAPIDO
Repeatable Analysis Programming for Interpretability, Durability, and Organization
Loading...
Searching...
No Matches
arbol.h
1#ifndef ARBOL_H
2#define ARBOL_H
3
4#include <iostream>
5#include <functional>
6#include <string>
7#include <vector>
8#include <map>
9
10#include "TString.h"
11#include "TTree.h"
12#include "TFile.h"
13#include "TObject.h"
14
15#include "hepcli.h"
16#include "utilities.h"
17
22template<typename Type>
23class Branch : public Utilities::Variable<Type>
24{
25private:
27 TBranch* branch;
28public:
40 Branch(TTree* ttree, TString new_branch_name);
41};
42
46class Arbol
47{
48protected:
50 std::map<TString, Utilities::Dynamic*> branches;
52 std::map<TString, std::function<void()>> branch_resetters;
59 template<typename Type>
60 Branch<Type>* getBranch(TString branch_name);
61public:
63 TTree* ttree;
65 TFile* tfile;
66
78 Arbol(TFile* tfile, TString ttree_name = "tree");
85 Arbol(TString tfile_name, TString ttree_name = "tree");
96 virtual ~Arbol();
103 template<typename Type>
104 void newBranch(TString new_branch_name);
112 template<typename Type>
113 void newBranch(TString new_branch_name, Type new_reset_value);
121 template<typename Type>
122 void setBranchResetValue(TString branch_name, Type new_reset_value);
129 template<typename Type>
130 Type getLeaf(TString branch_name);
138 template<typename Type>
139 void setLeaf(TString branch_name, Type new_value);
147 template<typename Type>
148 void newVecBranch(TString new_branch_name);
157 template<typename Type>
158 void newVecBranch(TString new_branch_name, std::vector<Type> new_reset_vector);
167 template<typename Type>
168 void setVecBranchResetValue(TString branch_name, std::vector<Type> new_reset_vector);
176 template<typename Type>
177 std::vector<Type> getVecLeaf(TString branch_name);
186 template<typename Type>
187 void setVecLeaf(TString branch_name, std::vector<Type> new_vector);
188
196 template<typename Type>
197 void appendToVecLeaf(TString branch_name, Type new_value);
205 template<typename Type>
206 void prependToVecLeaf(TString branch_name, Type new_value);
215 template<typename Type>
216 void insertIntoVecLeaf(TString branch_name, Type new_value, int index);
224 template<typename Type>
225 void sortVecLeaf(TString branch_name, std::function<bool(Type, Type)> &lambda);
236 virtual void fill();
242 virtual void write(bool close = true);
243};
244
245#include "arbol.icc"
246
247#endif
Definition arbol.h:47
virtual void fill()
void setBranchResetValue(TString branch_name, Type new_reset_value)
void setVecBranchResetValue(TString branch_name, std::vector< Type > new_reset_vector)
void prependToVecLeaf(TString branch_name, Type new_value)
void resetBranches()
void newBranch(TString new_branch_name)
void newVecBranch(TString new_branch_name)
Arbol(TString tfile_name, TString ttree_name="tree")
void newBranch(TString new_branch_name, Type new_reset_value)
Branch< Type > * getBranch(TString branch_name)
void setLeaf(TString branch_name, Type new_value)
void insertIntoVecLeaf(TString branch_name, Type new_value, int index)
void appendToVecLeaf(TString branch_name, Type new_value)
virtual void write(bool close=true)
Type getLeaf(TString branch_name)
void sortVecLeaf(TString branch_name, std::function< bool(Type, Type)> &lambda)
std::map< TString, Utilities::Dynamic * > branches
Definition arbol.h:50
void setVecLeaf(TString branch_name, std::vector< Type > new_vector)
virtual ~Arbol()
Arbol(TFile *tfile, TString ttree_name="tree")
TTree * ttree
Definition arbol.h:63
Arbol(HEPCLI &cli)
TFile * tfile
Definition arbol.h:65
void newVecBranch(TString new_branch_name, std::vector< Type > new_reset_vector)
std::vector< Type > getVecLeaf(TString branch_name)
std::map< TString, std::function< void()> > branch_resetters
Definition arbol.h:52
Definition arbol.h:24
Branch(TTree *ttree, TString new_branch_name)
Definition hepcli.h:16
Definition utilities.h:159