Logo ROOT   6.10/09
Reference Guide
TTreeReaderGenerator.h
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Akos Hajdu 22/06/2015
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers and al. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTreeReaderGenerator
13 #define ROOT_TTreeReaderGenerator
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TTreeReaderGenerator //
18 // //
19 // Generate a Selector using the TTreeReader interface //
20 // (TTreeReaderValue, TTreeReaderArray) to access the data in the tree. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TTreeGeneratorBase.h"
25 
26 #include "TNamed.h"
27 
28 class TBranch;
29 class TBranchElement;
30 class TLeaf;
31 
32 namespace ROOT {
33 namespace Internal {
34 
35  // 0 for the general case, 1 when this a split clases inside a TClonesArray,
36  // 2 when this is a split classes inside an STL container.
37  enum ELocation { kOut=0, kClones, kSTL };
38 
39  class TTreeReaderDescriptor : public TObject {
40  public:
42  ReaderType fType; // Type of the reader: Value or Array
43  TString fDataType; // Data type of reader
44  TString fName; // Reader name
45  TString fBranchName; // Branch corresponding to the reader
46 
48  fType(type),
49  fDataType(dataType),
50  fName(name),
51  fBranchName(branchName) { }
52  };
53 
54  class TBranchDescriptor : public TNamed {
55  public:
56  ELocation fIsClones; // Type of container
57  TString fContainerName; // Name of the container
58  TString fBranchName; // Name of the branch
59  TString fSubBranchPrefix;// Prefix (e.g. if the branch name is "A." the prefix is "A"
60  TVirtualStreamerInfo *fInfo; // Streamer info
61  TBranchDescriptor *fParent; // Descriptor of the parent branch (NULL for topmost)
62 
64  const char *branchname, const char *subBranchPrefix, ELocation isclones,
65  const TString &containerName, TBranchDescriptor *parent = 0) :
66  TNamed(type,type),
67  fIsClones(isclones),
68  fContainerName(containerName),
69  fBranchName(branchname),
70  fSubBranchPrefix(subBranchPrefix),
71  fInfo(info),
72  fParent(parent)
73  {
74  if (fSubBranchPrefix.Length() && fSubBranchPrefix[fSubBranchPrefix.Length() - 1] == '.') {
75  fSubBranchPrefix.Remove(fSubBranchPrefix.Length()-1);
76  }
77  }
78 
79  Bool_t IsClones() const { return fIsClones == kClones; }
80 
81  Bool_t IsSTL() const { return fIsClones == kSTL; }
82  };
83 
85  {
86  TString fClassname; // Class name of the selector
87  TList fListOfReaders; // List of readers
88  Bool_t fIncludeAllLeaves; // Should all leaves be included
89  Bool_t fIncludeAllTopmost; // Should all topmost branches be included
90  std::vector<TString> fIncludeLeaves; // Branches whose leaves should be included
91  std::vector<TString> fIncludeStruct; // Branches whom should be included
92 
93  void AddReader(TTreeReaderDescriptor::ReaderType type, TString dataType, TString name,
94  TString branchName, TBranchDescriptor *parent = 0, Bool_t isLeaf = kTRUE);
95  UInt_t AnalyzeBranches(TBranchDescriptor *desc, TBranchElement *branch, TVirtualStreamerInfo *info);
96  UInt_t AnalyzeBranches(TBranchDescriptor *desc, TIter &branches, TVirtualStreamerInfo *info);
97  UInt_t AnalyzeOldBranch(TBranch *branch);
98  UInt_t AnalyzeOldLeaf(TLeaf *leaf, Int_t nleaves);
99  Bool_t BranchNeedsReader(TString branchName, TBranchDescriptor *parent, Bool_t isLeaf);
100 
101  void ParseOptions();
102  void AnalyzeTree(TTree *tree);
103  void WriteSelector();
104 
105  public:
106  TTreeReaderGenerator(TTree* tree, const char *classname, Option_t *option);
107  };
108 }
109 }
110 
111 #endif
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:32
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
const char Option_t
Definition: RtypesCore.h:62
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TTreeReaderDescriptor(ReaderType type, TString dataType, TString name, TString branchName)
A doubly linked list.
Definition: TList.h:43
TBranchDescriptor(const char *type, TVirtualStreamerInfo *info, const char *branchname, const char *subBranchPrefix, ELocation isclones, const TString &containerName, TBranchDescriptor *parent=0)
unsigned int UInt_t
Definition: RtypesCore.h:42
Ssiz_t Length() const
Definition: TString.h:388
A Branch for the case of an object.
TString & Remove(Ssiz_t pos)
Definition: TString.h:621
int type
Definition: TGX11.cxx:120
Mother of all ROOT objects.
Definition: TObject.h:37
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:78
A TTree is a list of TBranches.
Definition: TBranch.h:57
Abstract Interface class describing Streamer information for one class.
const Bool_t kTRUE
Definition: RtypesCore.h:91