File indexing completed on 2025-01-18 10:12:30
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
0037
0038 enum ELocation { kOut=0, kClones, kSTL };
0039
0040 class TTreeReaderDescriptor : public TObject {
0041 public:
0042 enum ReaderType { kValue, kArray };
0043 ReaderType fType;
0044 TString fDataType;
0045 TString fName;
0046 TString fBranchName;
0047
0048 TTreeReaderDescriptor(ReaderType type, TString dataType, TString name, TString branchName) :
0049 fType(type),
0050 fDataType(dataType),
0051 fName(name),
0052 fBranchName(branchName) { }
0053 };
0054
0055 class TBranchDescriptor : public TNamed {
0056 public:
0057 ELocation fIsClones;
0058 TString fContainerName;
0059 TString fBranchName;
0060 TString fSubBranchPrefix;
0061 TVirtualStreamerInfo *fInfo;
0062 TBranchDescriptor *fParent;
0063
0064 TBranchDescriptor(const char *type, TVirtualStreamerInfo *info,
0065 const char *branchname, const char *subBranchPrefix, ELocation isclones,
0066 const TString &containerName, TBranchDescriptor *parent = nullptr) :
0067 TNamed(type,type),
0068 fIsClones(isclones),
0069 fContainerName(containerName),
0070 fBranchName(branchname),
0071 fSubBranchPrefix(subBranchPrefix),
0072 fInfo(info),
0073 fParent(parent)
0074 {
0075 if (fSubBranchPrefix.Length() && fSubBranchPrefix[fSubBranchPrefix.Length() - 1] == '.') {
0076 fSubBranchPrefix.Remove(fSubBranchPrefix.Length()-1);
0077 }
0078 }
0079
0080 bool IsClones() const { return fIsClones == kClones; }
0081
0082 bool IsSTL() const { return fIsClones == kSTL; }
0083 };
0084
0085 class TTreeReaderGenerator : public TTreeGeneratorBase
0086 {
0087 TString fClassname;
0088 TList fListOfReaders;
0089 bool fIncludeAllLeaves;
0090 bool fIncludeAllTopmost;
0091 std::vector<TString> fIncludeLeaves;
0092 std::vector<TString> fIncludeStruct;
0093
0094 void AddReader(TTreeReaderDescriptor::ReaderType type, TString dataType, TString name,
0095 TString branchName, TBranchDescriptor *parent = nullptr, bool isLeaf = true);
0096 UInt_t AnalyzeBranches(TBranchDescriptor *desc, TBranchElement *branch, TVirtualStreamerInfo *info);
0097 UInt_t AnalyzeBranches(TBranchDescriptor *desc, TIter &branches, TVirtualStreamerInfo *info);
0098 UInt_t AnalyzeOldBranch(TBranch *branch);
0099 UInt_t AnalyzeOldLeaf(TLeaf *leaf, Int_t nleaves);
0100 bool BranchNeedsReader(TString branchName, TBranchDescriptor *parent, bool isLeaf);
0101
0102 void ParseOptions();
0103 void AnalyzeTree(TTree *tree);
0104 void WriteSelector();
0105
0106 public:
0107 TTreeReaderGenerator(TTree* tree, const char *classname, Option_t *option);
0108 };
0109 }
0110 }
0111
0112 #endif