58            Warning(
"TTreeReaderGenerator::AddReader", 
"Ignored branch %s because type is unsupported.", branchName.
Data());
 
   66               Warning(
"AddReader", 
"Ignored branch %s because a branch with the same name already exists. " 
   67                                    "TTreeReader requires an unique name for the branches. You may need to " 
   68                                    "put a dot at the end of the name of top-level branches.", branchName.
Data());
 
   72         name.ReplaceAll(
'.', 
'_'); 
 
   74         while (
name.Index(
'[') >= 0 && 
name.Index(
']') >= 0 && 
name.Index(
']') > 
name.Index(
'[')) {
 
   86      if (info==0) info = branch->
GetInfo();
 
  106         TIter peek = branches;
 
  110            containerName = 
"TClonesArray";
 
  111         } 
else if (desc && desc->
IsSTL()) {
 
  112            outer_isclones = 
kSTL;
 
  117               containerName = 
"TClonesArray";
 
  119               outer_isclones = 
kSTL;
 
  137            subBranchPrefix = mom->
GetName();
 
  138            if (subBranchPrefix[subBranchPrefix.
Length()-1]==
'.') {
 
  141               subBranchPrefix = 
"";
 
  159         TIter peek = branches;     
 
  166               Error(
"AnalyzeBranches",
"Ran out of branches when looking in branch %s, class %s",
 
  169               Error(
"AnalyzeBranches",
"Ran out of branches when looking in class %s, element %s",
 
  170                     info->
GetName(), element->GetName());
 
  179         if (element->GetType() == -1) {
 
  188            if (leaf && outer_isclones == 
kOut 
  190            else branchEndName = branch->
GetName();
 
  192            pos = branchEndName.
Index(
".");
 
  194               if (subBranchPrefix.
Length() && branchEndName.
BeginsWith(subBranchPrefix)) {
 
  205         switch(element->GetType()) {
 
  274               readerType = TTreeReaderDescriptor::ReaderType::kArray;
 
  282               TClass *cl = element->GetClassPointer();
 
  288                  containerName = 
"TClonesArray";
 
  289                  if (outer_isclones != 
kOut) { 
 
  290                     isclones = outer_isclones;
 
  291                     dataType = 
"TClonesArray";
 
  293                     readerType = TTreeReaderDescriptor::ReaderType::kArray;
 
  299                  if (outer_isclones != 
kOut || containerName.
EqualTo(
"vector<bool>")) {
 
  305                     isclones = outer_isclones;
 
  308                     readerType = TTreeReaderDescriptor::ReaderType::kArray;
 
  311                        dataType = valueClass->
GetName();
 
  315                        if (valueClassBuiltIn) dataType = valueClassBuiltIn->
GetName();
 
  316                        else Error(
"AnalyzeBranches", 
"Could not get type from collection %s in branch %s", cl->
GetName(), branch->
GetName());
 
  340               if (element->IsBase()) { 
 
  349                  if (branchEndName == element->GetName()) { 
 
  360                                                      isclones, containerName, desc);
 
  378                                                    isclones, containerName, desc);
 
  386                  if (branchEndName == element->GetName()) { 
 
  391                        if (isclones != 
kOut) {
 
  397                                                      isclones, containerName, desc);
 
  404                     if (local_prefix.
Length()) local_prefix += 
".";
 
  405                     local_prefix += element->GetName();
 
  411                     if (isclones != 
kOut) {
 
  417                                                   isclones, containerName, desc);
 
  429               Error(
"AnalyzeBranch", 
"Unsupported type for %s (%d).", branch->
GetName(), element->GetType());
 
  432         if (!isBase && !skipped) { 
 
  433            if (outer_isclones != 
kOut && readerType == TTreeReaderDescriptor::ReaderType::kArray) {
 
  434               Error(
"AnalyzeBranch", 
"Arrays inside collections are not supported yet (branch: %s).", branch->
GetName());
 
  436               if (outer_isclones != 
kOut || isclones != 
kOut) {
 
  437                  readerType = TTreeReaderDescriptor::ReaderType::kArray;
 
  468      for(
int l=0;
l<nleaves;
l++) {
 
  473      return extraLookedAt;
 
  482         Error(
"AnalyzeOldLeaf",
"TLeafObject not supported yet");
 
  492      std::vector<Int_t> maxDim;
 
  496      pos = temp.
Index(
"[");
 
  498         if (pos) temp.
Remove(0, pos);
 
  502      pos = temp.
Index(
"[");
 
  504         if (pos) temp.
Remove(0, pos);
 
  511         const char *current = dimensions.
Data();
 
  517            if (current[0] == 
']') {
 
  518               maxDim.push_back(-1); 
 
  520               scanindex = sscanf(current,
"%d",&index);
 
  522                  maxDim.push_back(index); 
 
  524                  maxDim.push_back(-2); 
 
  528            current = (
char*)strstr( current, 
"[" );
 
  541            dataType = leafTypeName;
 
  545            type = TTreeReaderDescriptor::ReaderType::kArray;
 
  546            dataType = leafTypeName;
 
  625            if ( token.
Length() == 0 || (token.
Length() == 1 && token[0] == 
'@') ) {
 
  626               Warning(
"ParseOptions", 
"Ignored empty branch name in option string.");
 
  627            } 
else if (token[0] == 
'@') { 
 
  650      while ( (branch = (
TBranch*)next()) ) {
 
  653         const char *branchName = branch->
GetName();
 
  658         if (branchClassName && strlen(branchClassName)) {
 
  671               containerName = 
"TClonesArray";
 
  681                           "Introspection of TClonesArray in older file not implemented yet.");
 
  697                           "Introspection of TClonesArray for %s failed.",branch->
GetName());
 
  712                  if (containerName.
EqualTo(
"vector<bool>")) {
 
  717                     AddReader(TTreeReaderDescriptor::ReaderType::kArray,
 
  738                            : TTreeReaderDescriptor::ReaderType::kArray,
 
  752                            : TTreeReaderDescriptor::ReaderType::kArray,
 
  766                  Error(
"AnalyzeTree", 
"Cannot analyze branch %s because it is not a TBranchElement.", branchName);
 
  771                            : TTreeReaderDescriptor::ReaderType::kArray,
 
  791         treefile = 
"Memory Directory";
 
  804      std::ofstream ofs (thead, std::ofstream::out);
 
  806         Error(
"WriteSelector",
"cannot open output file %s", thead.
Data());
 
  812R
"CODE(////////////////////////////////////////////////////////// 
  813// This class has been automatically generated on 
  814// )CODE" << td.AsString() << R"CODE( by ROOT version )CODE" << gROOT->GetVersion() << std::endl; 
  817             << 
"// found on file: " << treefile << std::endl;
 
  822R
"CODE(////////////////////////////////////////////////////////// 
  831      if (isHbook) ofs << 
"#include <THbookFile.h>" << std::endl;
 
  833R
"CODE(#include <TSelector.h> 
  834#include <TTreeReader.h> 
  835#include <TTreeReaderValue.h> 
  836#include <TTreeReaderArray.h> 
  838// Headers needed by this particular selector 
  843      while ( (header = next()) ) {
 
  844         ofs << header->
GetTitle() << std::endl;
 
  846      ofs << std::endl << std::endl;
 
  850R
"CODE(class )CODE" << fClassname << R"CODE( : public TSelector { 
  852   TTreeReader     fReader;  //!the tree reader 
  853   TTree          *fChain = 0;   //!pointer to the analyzed TTree or TChain 
  855   // Readers to access the data (delete the ones you do not need). 
  862                                 << 
"> " << descriptor->
fName 
  863                                 << 
" = {fReader, \"" << descriptor->
fBranchName << 
"\"};" << std::endl;
 
  869   )CODE" << fClassname << R"CODE((TTree * /*tree*/ =0) { } 
  870   virtual ~)CODE" << fClassname << R"CODE(() { } 
  871   virtual Int_t   Version() const { return 2; } 
  872   virtual void    Begin(TTree *tree); 
  873   virtual void    SlaveBegin(TTree *tree); 
  874   virtual void    Init(TTree *tree); 
  875   virtual Bool_t  Notify(); 
  876   virtual Bool_t  Process(Long64_t entry); 
  877   virtual Int_t   GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; } 
  878   virtual void    SetOption(const char *option) { fOption = option; } 
  879   virtual void    SetObject(TObject *obj) { fObject = obj; } 
  880   virtual void    SetInputList(TList *input) { fInput = input; } 
  881   virtual TList  *GetOutputList() const { return fOutput; } 
  882   virtual void    SlaveTerminate(); 
  883   virtual void    Terminate(); 
  892void )CODE" << fClassname << R"CODE(::Init(TTree *tree) 
  894   // The Init() function is called when the selector needs to initialize 
  895   // a new tree or chain. Typically here the reader is initialized. 
  896   // It is normally not necessary to make changes to the generated 
  897   // code, but the routine can be extended by the user if needed. 
  898   // Init() will be called many times when running on PROOF 
  899   // (once per file to be processed). 
  901   fReader.SetTree(tree); 
  904Bool_t )CODE" << fClassname << R"CODE(::Notify() 
  906   // The Notify() function is called when a new file is opened. This 
  907   // can be either for a new TTree in a TChain or when when a new TTree 
  908   // is started when using PROOF. It is normally not necessary to make changes 
  909   // to the generated code, but the routine can be extended by the 
  910   // user if needed. The return value is currently not used. 
  916#endif // #ifdef )CODE" << fClassname << R"CODE(_cxx 
  923      std::ofstream ofsc (tcimp, std::ofstream::out);
 
  925         Error(
"WriteSelector",
"cannot open output file %s", tcimp.
Data());
 
  930R
"CODE(#define )CODE" << fClassname << R"CODE(_cxx 
  931// The class definition in )CODE" << fClassname << R"CODE(.h has been generated automatically 
  932// by the ROOT utility TTree::MakeSelector(). This class is derived 
  933// from the ROOT class TSelector. For more information on the TSelector 
  934// framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. 
  937// The following methods are defined in this file: 
  938//    Begin():        called every time a loop on the tree starts, 
  939//                    a convenient place to create your histograms. 
  940//    SlaveBegin():   called after Begin(), when on PROOF called only on the 
  942//    Process():      called for each event, in this function you decide what 
  943//                    to read and fill your histograms. 
  944//    SlaveTerminate: called at the end of the loop on the tree, when on PROOF 
  945//                    called only on the slave servers. 
  946//    Terminate():    called at the end of the loop on the tree, 
  947//                    a convenient place to draw/fit your histograms. 
  949// To use this file, try the following session on your Tree T: 
  951// root> T->Process(")CODE" << fClassname << R"CODE(.C") 
  952// root> T->Process(")CODE" << fClassname << R"CODE(.C","some options") 
  953// root> T->Process(")CODE" << fClassname << R"CODE(.C+") 
  957#include ")CODE" << thead << R"CODE(" 
  961void )CODE" << fClassname << R"CODE(::Begin(TTree * /*tree*/) 
  963   // The Begin() function is called at the start of the query. 
  964   // When running with PROOF Begin() is only called on the client. 
  965   // The tree argument is deprecated (on PROOF 0 is passed). 
  967   TString option = GetOption(); 
  970void )CODE" << fClassname << R"CODE(::SlaveBegin(TTree * /*tree*/) 
  972   // The SlaveBegin() function is called after the Begin() function. 
  973   // When running with PROOF SlaveBegin() is called on each slave server. 
  974   // The tree argument is deprecated (on PROOF 0 is passed). 
  976   TString option = GetOption(); 
  980Bool_t )CODE" << fClassname << R"CODE(::Process(Long64_t entry) 
  982   // The Process() function is called for each entry in the tree (or possibly 
  983   // keyed object in the case of PROOF) to be processed. The entry argument 
  984   // specifies which entry in the currently loaded tree is to be processed. 
  985   // When processing keyed objects with PROOF, the object is already loaded 
  986   // and is available via the fObject pointer. 
  988   // This function should contain the \"body\" of the analysis. It can contain 
  989   // simple or elaborate selection criteria, run algorithms on the data 
  990   // of the event and typically fill histograms. 
  992   // The processing can be stopped by calling Abort(). 
  994   // Use fStatus to set the return value of TTree::Process(). 
  996   // The return value is currently not used. 
  998   fReader.SetLocalEntry(entry); 
 1003void )CODE" << fClassname << R"CODE(::SlaveTerminate() 
 1005   // The SlaveTerminate() function is called after all entries or objects 
 1006   // have been processed. When running with PROOF SlaveTerminate() is called 
 1007   // on each slave server. 
 1011void )CODE" << fClassname << R"CODE(::Terminate() 
 1013   // The Terminate() function is the last function to be called during 
 1014   // a query. It always runs on the client, it can be used to present 
 1015   // the results graphically or save the results to file. 
void Error(const char *location, const char *msgfmt,...)
 
void Warning(const char *location, const char *msgfmt,...)
 
TBranchDescriptor * fParent
 
void AddHeader(TClass *cl)
Add a header inclusion request.
 
TVirtualStreamerInfo * GetStreamerInfo(TBranch *branch, TIter current, TClass *cl)
Return the correct TStreamerInfo of class 'cl' in the list of branches (current) [Assuming these bran...
 
TVirtualStreamerInfo * GetBaseClass(TStreamerElement *element)
Check if element is a base class and if yes, return the base class.
 
TString GetContainedClassName(TBranchElement *branch, TStreamerElement *element, Bool_t ispointer)
Get name of class inside a container.
 
std::vector< TString > fIncludeStruct
 
void AnalyzeTree(TTree *tree)
Analyze tree and extract readers.
 
std::vector< TString > fIncludeLeaves
 
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_t fIncludeAllTopmost
 
TTreeReaderGenerator(TTree *tree, const char *classname, Option_t *option)
Constructor. Analyzes the tree and writes selector.
 
void AddReader(TTreeReaderDescriptor::ReaderType type, TString dataType, TString name, TString branchName, TBranchDescriptor *parent=0, Bool_t isLeaf=kTRUE)
Add a reader to the generated code.
 
Bool_t BranchNeedsReader(TString branchName, TBranchDescriptor *parent, Bool_t isLeaf)
Check whether a branch should have a corresponding reader added, depending on the options provided by...
 
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.
 
TBranchElement * GetBranchCount() const
 
TStreamerInfo * GetInfo() const
Get streamer info for the branch class.
 
A TTree is a list of TBranches.
 
virtual const char * GetClassName() const
Return the name of the user class whose content is stored in this branch, if any.
 
virtual char * GetAddress() const
 
TObjArray * GetListOfBranches()
 
Int_t GetSplitLevel() const
 
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
 
TBranch * GetSubBranch(const TBranch *br) const
Find the parent branch of child.
 
virtual void SetAddress(void *add)
Set address of this branch.
 
TObjArray * GetListOfLeaves()
 
TBranch * GetMother() const
Get our top-level parent branch in the tree.
 
TClass instances represent classes, structs and namespaces in the ROOT type system.
 
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
 
Bool_t CanIgnoreTObjectStreamer()
 
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
 
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
 
An array of clone (identical) objects.
 
TClass * GetClass() const
 
Basic data type descriptor (datatype information is obtained from CINT).
 
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
 
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
 
const char * AsString() const
Return the date & time as a string (ctime() format).
 
virtual TFile * GetFile() const
 
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
 
virtual const char * GetTypeName() const
 
TBranch * GetBranch() const
 
virtual void Add(TObject *obj)
 
virtual const char * GetTitle() const
Returns title of object.
 
virtual const char * GetName() const
Returns name of object.
 
Int_t GetEntriesFast() const
 
Int_t GetEntries() const
Return the number of objects in array (i.e.
 
TObject * UncheckedAt(Int_t i) const
 
TObject * At(Int_t idx) const
 
Collectable string class.
 
Mother of all ROOT objects.
 
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
 
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
 
virtual const char * GetTitle() const
Returns title of object.
 
const char * Data() const
 
Bool_t EqualTo(const char *cs, ECaseCompare cmp=kExact) const
 
Ssiz_t Last(char c) const
Find last occurrence of a character c.
 
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
 
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
 
TString & Remove(Ssiz_t pos)
 
TString & Append(const char *cs)
 
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
 
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
 
A TTree represents a columnar dataset.
 
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
 
TDirectory * GetDirectory() const
 
virtual EDataType GetType() const =0
 
virtual TClass * GetValueClass() const =0
 
Abstract Interface class describing Streamer information for one class.
 
virtual TObjArray * GetElements() const =0
 
virtual TClass * GetClass() const =0