PandaTree
TreeEntry.h
1 #ifndef PandaTree_Interface_TreeEntry_h
2 #define PandaTree_Interface_TreeEntry_h
3 
4 #include "ReaderObject.h"
5 #include "IOUtils.h"
6 
7 #include "TTree.h"
8 
9 #include <vector>
10 
11 namespace panda {
12 
13  class CollectionBase;
14 
16 
19  class TreeEntry : public ReaderObject {
20  public:
21  TreeEntry() : ReaderObject() {}
22  TreeEntry(TreeEntry const& src) : ReaderObject (src) {}
23  virtual ~TreeEntry() {}
24  // Important to have this implemented - otherwise the TreeEntries will start copying the objects_ vectors!
25  TreeEntry& operator=(TreeEntry const&) { return *this; }
26 
27  void setStatus(TTree&, utils::BranchList const& blist) final;
28  utils::BranchList getStatus(TTree&) const final;
29  utils::BranchList getBranchNames(Bool_t = kTRUE, Bool_t direct = kFALSE) const final;
30  UInt_t setAddress(TTree&, utils::BranchList const& blist = {"*"}, Bool_t setStatus = kTRUE) final;
31  void book(TTree&, utils::BranchList const& blist = {"*"}) final;
33  Int_t getEntry(UInt_t, Long64_t entry, Bool_t localEntry = kFALSE) final;
34  Int_t fill(TTree&) final;
35  void init() final;
36  char const* getName() const final { return ""; }
37  void setName(char const*) final {}
38  void unlink(TTree&) final;
39 
40  protected:
41  virtual void doSetStatus_(TTree&, utils::BranchList const&) = 0;
42  virtual utils::BranchList doGetStatus_(TTree&) const = 0;
43  virtual utils::BranchList doGetBranchNames_() const = 0;
44  virtual void doSetAddress_(TTree& tree, utils::BranchList const&, Bool_t setStatus) = 0;
45  virtual void doBook_(TTree&, utils::BranchList const&) = 0;
46  virtual void doGetEntry_(TTree&) = 0;
47  virtual void doInit_() = 0;
48  virtual void doUnlink_(TTree&) = 0;
49 
50  std::vector<Object*> objects_{};
51  std::vector<CollectionBase*> collections_{};
52  };
53 
54 }
55 
56 #endif
void unlink(TTree &) final
Unlink from a tree.
Definition: TreeEntry.cc:107
Int_t getEntry(TTree &tree, Long64_t entry, Bool_t localEntry=kFALSE) final
Read an entry from an input tree.
Definition: ReaderObject.cc:21
void setStatus(TTree &, utils::BranchList const &blist) final
Set status of branches to true (matching branch) or false (vetoed branch)
Definition: TreeEntry.cc:5
void init() final
Reset the object state.
Definition: TreeEntry.cc:62
std::vector< Object * > objects_
list of object branches (containers and singlets)
Definition: TreeEntry.h:50
Int_t fill(TTree &) final
Fill a tree.
Definition: TreeEntry.cc:98
List of branch names.
Definition: IOUtils.h:64
void setName(char const *) final
Set object name.
Definition: TreeEntry.h:37
Int_t getEntry(UInt_t, Long64_t entry, Bool_t localEntry=kFALSE) final
Read an entry from an input tree.
Definition: TreeEntry.cc:71
utils::BranchList getBranchNames(Bool_t=kTRUE, Bool_t direct=kFALSE) const final
Get the full list of branch names.
Definition: TreeEntry.cc:27
char const * getName() const final
Name of this object.
Definition: TreeEntry.h:36
std::vector< CollectionBase * > collections_
list of collections (overlaps with objects_)
Definition: TreeEntry.h:51
utils::BranchList getStatus(TTree &) const final
Get status of branches in the tree.
Definition: TreeEntry.cc:14
void book(TTree &, utils::BranchList const &blist={"*"}) final
Book new branches bound to this object on the tree.
Definition: TreeEntry.cc:53
Base class for objects representing one full entry of a tree (e.g. Event).
Definition: TreeEntry.h:19
UInt_t setAddress(TTree &, utils::BranchList const &blist={"*"}, Bool_t setStatus=kTRUE) final
Bind the tree branches to the elements of this object.
Definition: TreeEntry.cc:42
Definition: Array.h:11
Base class for objects that can be linked to an input tree directly.
Definition: ReaderObject.h:10