TreeBranch.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "TClonesArray.h"
6 
7 class TTree;
8 
9 namespace boca
10 {
11 
13 {
14 
15 public:
16 
17  TreeBranch(char const* name, TClass* cl, TTree* tree = nullptr);
18 
19  TreeBranch(std::string const& name, TClass& cl, TTree& tree);
20 
21  TreeBranch(std::string const& name, TClass& cl);
22 
23  TObject* NewEntry();
24 
25  template<typename Branch_>
26  Branch_& AddEntry() {
27  return static_cast<Branch_&>(*NewEntry());
28  }
29 
30  template<typename Branch_>
31  void AddEntry(Branch_ const& branch) {
32  AddEntry<Branch_>() = branch;
33  }
34 
35  void Clear();
36 
37 private:
38 
39  void SetClonesArray(std::string const& name);
40 
41  void SetTree(TTree& tree, std::string const& name);
42 
43  void CheckCapacity();
44 
45  int position_ = 0;
46 
47  int size_ = 1;
48 
49  TClonesArray clones_array_;
50 
51 };
52 
53 }
54 
void AddEntry(Branch_ const &branch)
Definition: TreeBranch.hh:31
Definition: TreeBranch.hh:12
TObject * NewEntry()
Definition: TreeBranch.cpp:48
Boosted Collider Analysis.
Definition: Analysis.hh:15
Branch_ & AddEntry()
Definition: TreeBranch.hh:26
void Clear()
Definition: TreeBranch.cpp:67
TreeBranch(char const *name, TClass *cl, TTree *tree=nullptr)
Definition: TreeBranch.cpp:10