Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include <vector>
28
29class TBranch;
30class TBranchElement;
31class TLeaf;
32
33namespace ROOT {
34namespace Internal {
35
37
38 /// 0 for the general case, 1 when this a split clases inside a TClonesArray,
39 /// 2 when this is a split classes inside an STL container.
40 enum ELocation { kOut=0, kClones, kSTL };
41
43 public:
45 ReaderType fType; ///< Type of the reader: Value or Array
46 TString fDataType; ///< Data type of reader
47 TString fName; ///< Reader name
48 TString fBranchName; ///< Branch corresponding to the reader
49
51 fType(type),
52 fDataType(dataType),
53 fName(name),
54 fBranchName(branchName) { }
55 };
56
57 class TBranchDescriptor : public TNamed {
58 public:
59 ELocation fIsClones; ///< Type of container
60 TString fContainerName; ///< Name of the container
61 TString fBranchName; ///< Name of the branch
62 TString fSubBranchPrefix;///< Prefix (e.g. if the branch name is "A." the prefix is "A"
63 TVirtualStreamerInfo *fInfo; ///< Streamer info
64 TBranchDescriptor *fParent; ///< Descriptor of the parent branch (NULL for topmost)
65
67 const char *branchname, const char *subBranchPrefix, ELocation isclones,
68 const TString &containerName, TBranchDescriptor *parent = nullptr) :
70 fIsClones(isclones),
71 fContainerName(containerName),
72 fBranchName(branchname),
73 fSubBranchPrefix(subBranchPrefix),
74 fInfo(info),
75 fParent(parent)
76 {
79 }
80 }
81
82 bool IsClones() const { return fIsClones == kClones; }
83
84 bool IsSTL() const { return fIsClones == kSTL; }
85 };
86
88 {
89 TString fClassname; ///< Class name of the selector
90 TList fListOfReaders; ///< List of readers
91 bool fIncludeAllLeaves; ///< Should all leaves be included
92 bool fIncludeAllTopmost; ///< Should all topmost branches be included
93 std::vector<TString> fIncludeLeaves; ///< Branches whose leaves should be included
94 std::vector<TString> fIncludeStruct; ///< Branches whom should be included
95
97 TString branchName, TBranchDescriptor *parent = nullptr, bool isLeaf = true);
101 UInt_t AnalyzeOldLeaf(TLeaf *leaf, Int_t nleaves);
102 bool BranchNeedsReader(TString branchName, TBranchDescriptor *parent, bool isLeaf);
103
104 void ParseOptions();
105 void AnalyzeTree(TTree *tree);
106 void WriteSelector();
107
108 public:
109 TTreeReaderGenerator(TTree* tree, const char *classname, Option_t *option);
110 };
111}
112}
113
114#endif
const char Option_t
Definition RtypesCore.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
TBranchDescriptor(const char *type, TVirtualStreamerInfo *info, const char *branchname, const char *subBranchPrefix, ELocation isclones, const TString &containerName, TBranchDescriptor *parent=nullptr)
TString fBranchName
Name of the branch.
TVirtualStreamerInfo * fInfo
Streamer info.
ELocation fIsClones
Type of container.
TBranchDescriptor * fParent
Descriptor of the parent branch (NULL for topmost)
TString fContainerName
Name of the container.
TString fSubBranchPrefix
Prefix (e.g. if the branch name is "A." the prefix is "A".
Base class for code generators like TTreeProxyGenerator and TTreeReaderGenerator.
TString fBranchName
Branch corresponding to the reader.
ReaderType fType
Type of the reader: Value or Array.
TTreeReaderDescriptor(ReaderType type, TString dataType, TString name, TString branchName)
std::vector< TString > fIncludeStruct
Branches whom should be included.
void AnalyzeTree(TTree *tree)
Analyze tree and extract readers.
TString fClassname
Class name of the selector.
std::vector< TString > fIncludeLeaves
Branches whose leaves should be included.
UInt_t AnalyzeBranches(TBranchDescriptor *desc, TBranchElement *branch, TVirtualStreamerInfo *info)
Analyse sub-branches of 'branch' recursively and extract readers.
void ParseOptions()
Parse the user options.
bool fIncludeAllTopmost
Should all topmost branches be included.
void AddReader(TTreeReaderDescriptor::ReaderType type, TString dataType, TString name, TString branchName, TBranchDescriptor *parent=nullptr, bool isLeaf=true)
Add a reader to the generated code.
bool BranchNeedsReader(TString branchName, TBranchDescriptor *parent, bool isLeaf)
Check whether a branch should have a corresponding reader added, depending on the options provided by...
bool fIncludeAllLeaves
Should all leaves be included.
UInt_t AnalyzeOldLeaf(TLeaf *leaf, Int_t nleaves)
Analyze the leaf and add the variables found.
UInt_t AnalyzeOldBranch(TBranch *branch)
Analyze branch and add the variables found.
void WriteSelector()
Generate code for selector class.
A Branch for the case of an object.
A TTree is a list of TBranches.
Definition TBranch.h:93
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
TString & Remove(Ssiz_t pos)
Definition TString.h:685
A TTree represents a columnar dataset.
Definition TTree.h:79
Abstract Interface class describing Streamer information for one class.
ELocation
0 for the general case, 1 when this a split clases inside a TClonesArray, 2 when this is a split clas...
TString GetCppName(TString name)
Convert a valid TTree branch name or filename into a valid C++ variable name.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...