File indexing completed on 2025-09-17 09:16:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TTreeReaderGenerator
0013 #define ROOT_TTreeReaderGenerator
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "TTreeGeneratorBase.h"
0025
0026 #include "TNamed.h"
0027 #include <vector>
0028
0029 class TBranch;
0030 class TBranchElement;
0031 class TLeaf;
0032
0033 namespace ROOT {
0034 namespace Internal {
0035
0036 TString GetCppName(TString name);
0037
0038
0039
0040 enum ELocation { kOut=0, kClones, kSTL };
0041
0042 class TTreeReaderDescriptor : public TObject {
0043 public:
0044 enum ReaderType { kValue, kArray };
0045 ReaderType fType;
0046 TString fDataType;
0047 TString fName;
0048 TString fBranchName;
0049
0050 TTreeReaderDescriptor(ReaderType type, TString dataType, TString name, TString branchName) :
0051 fType(type),
0052 fDataType(dataType),
0053 fName(name),
0054 fBranchName(branchName) { }
0055 };
0056
0057 class TBranchDescriptor : public TNamed {
0058 public:
0059 ELocation fIsClones;
0060 TString fContainerName;
0061 TString fBranchName;
0062 TString fSubBranchPrefix;
0063 TVirtualStreamerInfo *fInfo;
0064 TBranchDescriptor *fParent;
0065
0066 TBranchDescriptor(const char *type, TVirtualStreamerInfo *info,
0067 const char *branchname, const char *subBranchPrefix, ELocation isclones,
0068 const TString &containerName, TBranchDescriptor *parent = nullptr) :
0069 TNamed(type,type),
0070 fIsClones(isclones),
0071 fContainerName(containerName),
0072 fBranchName(branchname),
0073 fSubBranchPrefix(subBranchPrefix),
0074 fInfo(info),
0075 fParent(parent)
0076 {
0077 if (fSubBranchPrefix.Length() && fSubBranchPrefix[fSubBranchPrefix.Length() - 1] == '.') {
0078 fSubBranchPrefix.Remove(fSubBranchPrefix.Length()-1);
0079 }
0080 }
0081
0082 bool IsClones() const { return fIsClones == kClones; }
0083
0084 bool IsSTL() const { return fIsClones == kSTL; }
0085 };
0086
0087 class TTreeReaderGenerator : public TTreeGeneratorBase
0088 {
0089 TString fClassname;
0090 TList fListOfReaders;
0091 bool fIncludeAllLeaves;
0092 bool fIncludeAllTopmost;
0093 std::vector<TString> fIncludeLeaves;
0094 std::vector<TString> fIncludeStruct;
0095
0096 void AddReader(TTreeReaderDescriptor::ReaderType type, TString dataType, TString name,
0097 TString branchName, TBranchDescriptor *parent = nullptr, bool isLeaf = true);
0098 UInt_t AnalyzeBranches(TBranchDescriptor *desc, TBranchElement *branch, TVirtualStreamerInfo *info);
0099 UInt_t AnalyzeBranches(TBranchDescriptor *desc, TIter &branches, TVirtualStreamerInfo *info);
0100 UInt_t AnalyzeOldBranch(TBranch *branch);
0101 UInt_t AnalyzeOldLeaf(TLeaf *leaf, Int_t nleaves);
0102 bool BranchNeedsReader(TString branchName, TBranchDescriptor *parent, bool isLeaf);
0103
0104 void ParseOptions();
0105 void AnalyzeTree(TTree *tree);
0106 void WriteSelector();
0107
0108 public:
0109 TTreeReaderGenerator(TTree* tree, const char *classname, Option_t *option);
0110 };
0111 }
0112 }
0113
0114 #endif