Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TChain.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 03/02/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
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_TChain
13 #define ROOT_TChain
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TChain //
19 // //
20 // A chain of TTrees. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TTree.h"
25 #include <iosfwd>
26 
27 class TFile;
28 class TBrowser;
29 class TCut;
30 class TEntryList;
31 class TEventList;
32 class TCollection;
33 
34 class TChain : public TTree {
35 
36 protected:
37  Int_t fTreeOffsetLen; ///< Current size of fTreeOffset array
38  Int_t fNtrees; ///< Number of trees
39  Int_t fTreeNumber; ///<! Current Tree number in fTreeOffset table
40  Long64_t *fTreeOffset; ///<[fTreeOffsetLen] Array of variables
41  Bool_t fCanDeleteRefs; ///<! If true, TProcessIDs are deleted when closing a file
42  TTree *fTree; ///<! Pointer to current tree (Note: We do *not* own this tree.)
43  TFile *fFile; ///<! Pointer to current file (We own the file).
44  TObjArray *fFiles; ///< -> List of file names containing the trees (TChainElement, owned)
45  TList *fStatus; ///< -> List of active/inactive branches (TChainElement, owned)
46  TChain *fProofChain; ///<! chain proxy when going to be processed by PROOF
47 
48 private:
49  TChain(const TChain&); // not implemented
50  TChain& operator=(const TChain&); // not implemented
51  void ParseTreeFilename(const char *name, TString &filename, TString &treename, TString &query, TString &suffix, Bool_t wildcards) const;
52 
53 protected:
54  void InvalidateCurrentTree();
55  void ReleaseChainProof();
56 
57 public:
58  // TChain constants
59  enum EStatusBits {
60  kGlobalWeight = BIT(15),
61  kAutoDelete = BIT(16),
62  kProofUptodate = BIT(17),
63  kProofLite = BIT(18)
64  };
65 
66  // This used to be 1234567890, if user code hardcoded this number, the user code will need to change.
67  static constexpr auto kBigNumber = TTree::kMaxEntries;
68 
69 public:
70  TChain();
71  TChain(const char* name, const char* title = "");
72  virtual ~TChain();
73 
74  virtual Int_t Add(TChain* chain);
75  virtual Int_t Add(const char* name, Long64_t nentries = TTree::kMaxEntries);
76  virtual Int_t AddFile(const char* name, Long64_t nentries = TTree::kMaxEntries, const char* tname = "");
77  virtual Int_t AddFileInfoList(TCollection* list, Long64_t nfiles = TTree::kMaxEntries);
78  virtual TFriendElement *AddFriend(const char* chainname, const char* dummy = "");
79  virtual TFriendElement *AddFriend(const char* chainname, TFile* dummy);
80  virtual TFriendElement *AddFriend(TTree* chain, const char* alias = "", Bool_t warn = kFALSE);
81  virtual void Browse(TBrowser*);
82  virtual void CanDeleteRefs(Bool_t flag = kTRUE);
83  virtual void CreatePackets();
84  virtual void DirectoryAutoAdd(TDirectory *);
85  virtual Long64_t Draw(const char* varexp, const TCut& selection, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0);
86  virtual Long64_t Draw(const char* varexp, const char* selection, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0); // *MENU*
87  virtual void Draw(Option_t* opt) { Draw(opt, "", "", kMaxEntries, 0); }
88  virtual Int_t Fill() { MayNotUse("Fill()"); return -1; }
89  virtual TBranch *FindBranch(const char* name);
90  virtual TLeaf *FindLeaf(const char* name);
91  virtual TBranch *GetBranch(const char* name);
92  virtual Bool_t GetBranchStatus(const char* branchname) const;
93  virtual Long64_t GetCacheSize() const { return fTree ? fTree->GetCacheSize() : fCacheSize; }
94  virtual Long64_t GetChainEntryNumber(Long64_t entry) const;
95  virtual TClusterIterator GetClusterIterator(Long64_t firstentry);
96  Int_t GetNtrees() const { return fNtrees; }
97  virtual Long64_t GetEntries() const;
98  virtual Long64_t GetEntries(const char *sel) { return TTree::GetEntries(sel); }
99  virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0);
100  virtual Long64_t GetEntryNumber(Long64_t entry) const;
101  virtual Int_t GetEntryWithIndex(Int_t major, Int_t minor=0);
102  TFile *GetFile() const;
103  virtual TLeaf *GetLeaf(const char* branchname, const char* leafname);
104  virtual TLeaf *GetLeaf(const char* name);
105  virtual TObjArray *GetListOfBranches();
106  // Warning, GetListOfFiles returns the list of TChainElements (not the list of files)
107  // see TChain::AddFile to see how to get the corresponding TFile objects
108  TObjArray *GetListOfFiles() const {return fFiles;}
109  virtual TObjArray *GetListOfLeaves();
110  virtual const char *GetAlias(const char *aliasName) const;
111  virtual Double_t GetMaximum(const char *columname);
112  virtual Double_t GetMinimum(const char *columname);
113  virtual Int_t GetNbranches();
114  virtual Long64_t GetReadEntry() const;
115  TList *GetStatus() const { return fStatus; }
116  virtual TTree *GetTree() const { return fTree; }
117  virtual Int_t GetTreeNumber() const { return fTreeNumber; }
118  Long64_t *GetTreeOffset() const { return fTreeOffset; }
119  Int_t GetTreeOffsetLen() const { return fTreeOffsetLen; }
120  virtual Double_t GetWeight() const;
121  virtual Int_t LoadBaskets(Long64_t maxmemory);
122  virtual Long64_t LoadTree(Long64_t entry);
123  void Lookup(Bool_t force = kFALSE);
124  virtual void Loop(Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0); // *MENU*
125  virtual void ls(Option_t *option="") const;
126  virtual Long64_t Merge(const char *name, Option_t *option = "");
127  virtual Long64_t Merge(TCollection *list, Option_t *option = "");
128  virtual Long64_t Merge(TCollection *list, TFileMergeInfo *info);
129  virtual Long64_t Merge(TFile *file, Int_t basketsize, Option_t *option="");
130  virtual void Print(Option_t *option="") const;
131  virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0); // *MENU*
132  virtual Long64_t Process(TSelector* selector, Option_t* option = "", Long64_t nentries = kMaxEntries, Long64_t firstentry = 0);
133  virtual void RecursiveRemove(TObject *obj);
134  virtual void RemoveFriend(TTree*);
135  virtual void Reset(Option_t *option="");
136  virtual void ResetAfterMerge(TFileMergeInfo *);
137  virtual void ResetBranchAddress(TBranch *);
138  virtual void ResetBranchAddresses();
139  virtual void SavePrimitive (std::ostream &out, Option_t *option="");
140  virtual Long64_t Scan(const char *varexp="", const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0); // *MENU*
141  virtual void SetAutoDelete(Bool_t autodel=kTRUE);
142  virtual Int_t SetBranchAddress(const char *bname,void *add, TBranch **ptr = 0);
143  virtual Int_t SetBranchAddress(const char *bname,void *add, TBranch **ptr, TClass *realClass, EDataType datatype, Bool_t isptr);
144  virtual Int_t SetBranchAddress(const char *bname,void *add, TClass *realClass, EDataType datatype, Bool_t isptr);
145  template <class T> Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr = 0) {
146  return TTree::SetBranchAddress<T>(bname, add, ptr);
147  }
148 #ifndef R__NO_CLASS_TEMPLATE_SPECIALIZATION
149  // This can only be used when the template overload resolution can distringuish between
150  // T* and T**
151  template <class T> Int_t SetBranchAddress(const char *bname, T *add, TBranch **ptr = 0) {
152  return TTree::SetBranchAddress<T>(bname, add, ptr);
153  }
154 #endif
155 
156  virtual void SetBranchStatus(const char *bname, Bool_t status=1, UInt_t *found=0);
157  virtual Int_t SetCacheSize(Long64_t cacheSize = -1);
158  virtual void SetDirectory(TDirectory *dir);
159  virtual void SetEntryList(TEntryList *elist, Option_t *opt="");
160  virtual void SetEntryListFile(const char *filename="", Option_t *opt="");
161  virtual void SetEventList(TEventList *evlist);
162  virtual void SetMakeClass(Int_t make) { TTree::SetMakeClass(make); if (fTree) fTree->SetMakeClass(make);}
163  virtual void SetName(const char *name);
164  virtual void SetPacketSize(Int_t size = 100);
165  virtual void SetProof(Bool_t on = kTRUE, Bool_t refresh = kFALSE, Bool_t gettreeheader = kFALSE);
166  virtual void SetWeight(Double_t w=1, Option_t *option="");
167  virtual void UseCache(Int_t maxCacheSize = 10, Int_t pageSize = 0);
168 
169  ClassDef(TChain,5) //A chain of TTrees
170 };
171 
172 #endif // ROOT_TChain