Logo ROOT   6.10/09
Reference Guide
List of all members | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
TChain Class Reference

A chain is a collection of files containing TTree objects.

When the chain is created, the first parameter is the default name for the Tree to be processed later on.

Enter a new element in the chain via the TChain::Add function. Once a chain is defined, one can use the normal TTree functions to Draw,Scan,etc.

Use TChain::SetBranchStatus to activate one or more branches for all the trees in the chain.

Definition at line 33 of file TChain.h.

Public Types

enum  { kGlobalWeight = BIT(15), kAutoDelete = BIT(16), kProofUptodate = BIT(17), kProofLite = BIT(18) }
 
- Public Types inherited from TTree
enum  { kForceRead = BIT(11), kCircular = BIT(12) }
 
enum  { kSplitCollectionOfPointers = 100 }
 
enum  ESetBranchAddressStatus {
  kMissingBranch = -5, kInternalError = -4, kMissingCompiledCollectionProxy = -3, kMismatch = -2,
  kClassMismatch = -1, kMatch = 0, kMatchConversion = 1, kMatchConversionCollection = 2,
  kMakeClass = 3, kVoidPtr = 4, kNoCheck = 5
}
 
- Public Types inherited from TObject
enum  { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kBitMask = 0x00ffffff }
 
enum  { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) }
 
enum  EStatusBits {
  kCanDelete = BIT(0), kMustCleanup = BIT(3), kObjInCanvas = BIT(3), kIsReferenced = BIT(4),
  kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13)
}
 

Public Member Functions

 TChain ()
 Default constructor. More...
 
 TChain (const char *name, const char *title="")
 Create a chain. More...
 
virtual ~TChain ()
 Destructor. More...
 
virtual Int_t Add (TChain *chain)
 Add all files referenced by the passed chain to this chain. More...
 
virtual Int_t Add (const char *name, Long64_t nentries=TTree::kMaxEntries)
 Add a new file to this chain. More...
 
virtual Int_t AddFile (const char *name, Long64_t nentries=TTree::kMaxEntries, const char *tname="")
 Add a new file to this chain. More...
 
virtual Int_t AddFileInfoList (TCollection *list, Long64_t nfiles=TTree::kMaxEntries)
 Add all files referenced in the list to the chain. More...
 
virtual TFriendElementAddFriend (const char *chainname, const char *dummy="")
 Add a TFriendElement to the list of friends of this chain. More...
 
virtual TFriendElementAddFriend (const char *chainname, TFile *dummy)
 Add the whole chain or tree as a friend of this chain. More...
 
virtual TFriendElementAddFriend (TTree *chain, const char *alias="", Bool_t warn=kFALSE)
 Add the whole chain or tree as a friend of this chain. More...
 
virtual void Browse (TBrowser *)
 Browse the contents of the chain. More...
 
virtual void CanDeleteRefs (Bool_t flag=kTRUE)
 When closing a file during the chain processing, the file may be closed with option "R" if flag is set to kTRUE. More...
 
virtual void CreatePackets ()
 Initialize the packet descriptor string. More...
 
virtual void DirectoryAutoAdd (TDirectory *)
 Override the TTree::DirectoryAutoAdd behavior: we never auto add. More...
 
virtual Long64_t Draw (const char *varexp, const TCut &selection, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Draw expression varexp for selected entries. More...
 
virtual Long64_t Draw (const char *varexp, const char *selection, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Process all entries in this chain and draw histogram corresponding to expression varexp. More...
 
virtual void Draw (Option_t *opt)
 Default Draw method for all objects. More...
 
virtual Int_t Fill ()
 Fill all branches. More...
 
virtual TBranchFindBranch (const char *name)
 See TTree::GetReadEntry(). More...
 
virtual TLeafFindLeaf (const char *name)
 See TTree::GetReadEntry(). More...
 
virtual const char * GetAlias (const char *aliasName) const
 Returns the expanded value of the alias. Search in the friends if any. More...
 
virtual TBranchGetBranch (const char *name)
 Return pointer to the branch name in the current tree. More...
 
virtual Bool_t GetBranchStatus (const char *branchname) const
 See TTree::GetReadEntry(). More...
 
virtual Long64_t GetCacheSize () const
 
virtual Long64_t GetChainEntryNumber (Long64_t entry) const
 Return absolute entry number in the chain. More...
 
virtual TClusterIterator GetClusterIterator (Long64_t firstentry)
 Return an iterator over the cluster of baskets starting at firstentry. More...
 
virtual Long64_t GetEntries () const
 Return the total number of entries in the chain. More...
 
virtual Long64_t GetEntries (const char *sel)
 Return the number of entries matching the selection. More...
 
virtual Int_t GetEntry (Long64_t entry=0, Int_t getall=0)
 Get entry from the file to memory. More...
 
virtual Long64_t GetEntryNumber (Long64_t entry) const
 Return entry number corresponding to entry. More...
 
virtual Int_t GetEntryWithIndex (Int_t major, Int_t minor=0)
 Return entry corresponding to major and minor number. More...
 
TFileGetFile () const
 Return a pointer to the current file. More...
 
virtual TLeafGetLeaf (const char *branchname, const char *leafname)
 Return a pointer to the leaf name in the current tree. More...
 
virtual TLeafGetLeaf (const char *name)
 Return a pointer to the leaf name in the current tree. More...
 
virtual TObjArrayGetListOfBranches ()
 Return a pointer to the list of branches of the current tree. More...
 
TObjArrayGetListOfFiles () const
 
virtual TObjArrayGetListOfLeaves ()
 Return a pointer to the list of leaves of the current tree. More...
 
virtual Double_t GetMaximum (const char *columname)
 Return maximum of column with name columname. More...
 
virtual Double_t GetMinimum (const char *columname)
 Return minimum of column with name columname. More...
 
virtual Int_t GetNbranches ()
 Return the number of branches of the current tree. More...
 
Int_t GetNtrees () const
 
virtual Long64_t GetReadEntry () const
 See TTree::GetReadEntry(). More...
 
TListGetStatus () const
 
virtual TTreeGetTree () const
 
virtual Int_t GetTreeNumber () const
 
Long64_tGetTreeOffset () const
 
Int_t GetTreeOffsetLen () const
 
virtual Double_t GetWeight () const
 Return the chain weight. More...
 
virtual Int_t LoadBaskets (Long64_t maxmemory)
 Dummy function. More...
 
virtual Long64_t LoadTree (Long64_t entry)
 Find the tree which contains entry, and set it as the current tree. More...
 
void Lookup (Bool_t force=kFALSE)
 Check / locate the files in the chain. More...
 
virtual void Loop (Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Loop on nentries of this chain starting at firstentry. (NOT IMPLEMENTED) More...
 
virtual void ls (Option_t *option="") const
 List the chain. More...
 
virtual Long64_t Merge (const char *name, Option_t *option="")
 Merge all the entries in the chain into a new tree in a new file. More...
 
virtual Long64_t Merge (TCollection *list, Option_t *option="")
 Merge all chains in the collection. (NOT IMPLEMENTED) More...
 
virtual Long64_t Merge (TCollection *list, TFileMergeInfo *info)
 Merge all chains in the collection. (NOT IMPLEMENTED) More...
 
virtual Long64_t Merge (TFile *file, Int_t basketsize, Option_t *option="")
 Merge all the entries in the chain into a new tree in the current file. More...
 
virtual void Print (Option_t *option="") const
 Print the header information of each tree in the chain. More...
 
virtual Long64_t Process (const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Process all entries in this chain, calling functions in filename. More...
 
virtual Long64_t Process (TSelector *selector, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Process this chain executing the code in selector. More...
 
virtual void RecursiveRemove (TObject *obj)
 Make sure that obj (which is being deleted or will soon be) is no longer referenced by this TTree. More...
 
virtual void RemoveFriend (TTree *)
 Remove a friend from the list of friends. More...
 
virtual void Reset (Option_t *option="")
 Resets the state of this chain. More...
 
virtual void ResetAfterMerge (TFileMergeInfo *)
 Resets the state of this chain after a merge (keep the customization but forget the data). More...
 
virtual void ResetBranchAddress (TBranch *)
 Reset the addresses of the branch. More...
 
virtual void ResetBranchAddresses ()
 Reset the addresses of the branches. More...
 
virtual Long64_t Scan (const char *varexp="", const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Loop on tree and print entries passing selection. More...
 
virtual void SetAutoDelete (Bool_t autodel=kTRUE)
 Set the global branch kAutoDelete bit. More...
 
virtual Int_t SetBranchAddress (const char *bname, void *add, TBranch **ptr=0)
 Set branch address. More...
 
virtual Int_t SetBranchAddress (const char *bname, void *add, TBranch **ptr, TClass *realClass, EDataType datatype, Bool_t isptr)
 Check if bname is already in the status list, and if not, create a TChainElement object and set its address. More...
 
virtual Int_t SetBranchAddress (const char *bname, void *add, TClass *realClass, EDataType datatype, Bool_t isptr)
 Check if bname is already in the status list, and if not, create a TChainElement object and set its address. More...
 
template<class T >
Int_t SetBranchAddress (const char *bname, T **add, TBranch **ptr=0)
 
template<class T >
Int_t SetBranchAddress (const char *bname, T *add, TBranch **ptr=0)
 
virtual void SetBranchStatus (const char *bname, Bool_t status=1, UInt_t *found=0)
 Set branch status to Process or DoNotProcess. More...
 
virtual Int_t SetCacheSize (Long64_t cacheSize=-1)
 Set maximum size of the file cache . More...
 
virtual void SetDirectory (TDirectory *dir)
 Remove reference to this chain from current directory and add reference to new directory dir. More...
 
virtual void SetEntryList (TEntryList *elist, Option_t *opt="")
 Set the input entry list (processing the entries of the chain will then be limited to the entries in the list) This function finds correspondance between the sub-lists of the TEntryList and the trees of the TChain By default (opt=""), both the file names of the chain elements and the file names of the TEntryList sublists are expanded to full path name. More...
 
virtual void SetEntryListFile (const char *filename="", Option_t *opt="")
 Set the input entry list (processing the entries of the chain will then be limited to the entries in the list). More...
 
virtual void SetEventList (TEventList *evlist)
 This function transfroms the given TEventList into a TEntryList. More...
 
virtual void SetMakeClass (Int_t make)
 Set all the branches in this TTree to be in decomposed object mode (also known as MakeClass mode). More...
 
virtual void SetPacketSize (Int_t size=100)
 Set number of entries per packet for parallel root. More...
 
virtual void SetProof (Bool_t on=kTRUE, Bool_t refresh=kFALSE, Bool_t gettreeheader=kFALSE)
 Enable/Disable PROOF processing on the current default Proof (gProof). More...
 
virtual void SetWeight (Double_t w=1, Option_t *option="")
 Set chain weight. More...
 
virtual void UseCache (Int_t maxCacheSize=10, Int_t pageSize=0)
 Dummy function kept for back compatibility. More...
 
- Public Member Functions inherited from TTree
 TTree ()
 Default constructor and I/O constructor. More...
 
 TTree (const char *name, const char *title, Int_t splitlevel=99)
 Normal tree constructor. More...
 
virtual ~TTree ()
 Destructor. More...
 
virtual Int_t AddBranchToCache (const char *bname, Bool_t subbranches=kFALSE)
 Add branch with name bname to the Tree cache. More...
 
virtual Int_t AddBranchToCache (TBranch *branch, Bool_t subbranches=kFALSE)
 Add branch b to the Tree cache. More...
 
void AddClone (TTree *)
 Add a cloned tree to our list of trees to be notified whenever we change our branch addresses or when we are deleted. More...
 
virtual void AddTotBytes (Int_t tot)
 
virtual void AddZipBytes (Int_t zip)
 
virtual Long64_t AutoSave (Option_t *option="")
 AutoSave tree header every fAutoSave bytes. More...
 
virtual Int_t Branch (TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
 Create one branch for each element in the collection. More...
 
virtual Int_t Branch (TList *list, Int_t bufsize=32000, Int_t splitlevel=99)
 Deprecated function. Use next function instead. More...
 
virtual Int_t Branch (const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
 Create one branch for each element in the folder. More...
 
virtual TBranchBranch (const char *name, void *address, const char *leaflist, Int_t bufsize=32000)
 Create a new TTree Branch. More...
 
TBranchBranch (const char *name, char *address, const char *leaflist, Int_t bufsize=32000)
 
TBranchBranch (const char *name, Long_t address, const char *leaflist, Int_t bufsize=32000)
 
TBranchBranch (const char *name, int address, const char *leaflist, Int_t bufsize=32000)
 
virtual TBranchBranch (const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
 Create a new branch with the object of class classname at address addobj. More...
 
template<class T >
TBranchBranch (const char *name, const char *classname, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
 
template<class T >
TBranchBranch (const char *name, const char *classname, T **addobj, Int_t bufsize=32000, Int_t splitlevel=99)
 
template<class T >
TBranchBranch (const char *name, T **addobj, Int_t bufsize=32000, Int_t splitlevel=99)
 
template<class T >
TBranchBranch (const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
 
virtual TBranchBranchOld (const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1)
 Create a new TTree BranchObject. More...
 
virtual TBranchBranchRef ()
 Build the optional branch supporting the TRefTable. More...
 
virtual TBranchBronch (const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
 Create a new TTree BranchElement. More...
 
virtual Int_t BuildIndex (const char *majorname, const char *minorname="0")
 Build a Tree Index (default is TTreeIndex). More...
 
TStreamerInfoBuildStreamerInfo (TClass *cl, void *pointer=0, Bool_t canOptimize=kTRUE)
 Build StreamerInfo for class cl. More...
 
virtual TFileChangeFile (TFile *file)
 Called by TTree::Fill() when file has reached its maximum fgMaxTreeSize. More...
 
virtual TTreeCloneTree (Long64_t nentries=-1, Option_t *option="")
 Create a clone of this tree and copy nentries. More...
 
virtual void CopyAddresses (TTree *, Bool_t undo=kFALSE)
 Set branch addresses of passed tree equal to ours. More...
 
virtual Long64_t CopyEntries (TTree *tree, Long64_t nentries=-1, Option_t *option="")
 Copy nentries from given tree to this tree. More...
 
virtual TTreeCopyTree (const char *selection, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Copy a tree with selection. More...
 
virtual TBasketCreateBasket (TBranch *)
 Create a basket for this tree and given branch. More...
 
Int_t Debug () const
 
virtual void Delete (Option_t *option="")
 Delete this tree from memory or/and disk. More...
 
virtual void DropBaskets ()
 Remove some baskets from memory. More...
 
virtual Int_t DropBranchFromCache (const char *bname, Bool_t subbranches=kFALSE)
 Remove the branch with name 'bname' from the Tree cache. More...
 
virtual Int_t DropBranchFromCache (TBranch *branch, Bool_t subbranches=kFALSE)
 Remove the branch b from the Tree cache. More...
 
virtual void DropBuffers (Int_t nbytes)
 Drop branch buffers to accommodate nbytes below MaxVirtualsize. More...
 
virtual Int_t Fit (const char *funcname, const char *varexp, const char *selection="", Option_t *option="", Option_t *goption="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Fit a projected item(s) from a tree. More...
 
virtual Int_t FlushBaskets () const
 Write to disk all the basket that have not yet been individually written. More...
 
virtual Long64_t GetAutoFlush () const
 
virtual Long64_t GetAutoSave () const
 
virtual TBranchRefGetBranchRef () const
 
virtual Long64_t GetChainOffset () const
 
TFileGetCurrentFile () const
 Return pointer to the current file. More...
 
Long64_t GetDebugMax () const
 
Long64_t GetDebugMin () const
 
Int_t GetDefaultEntryOffsetLen () const
 
TDirectoryGetDirectory () const
 
virtual Long64_t GetEntriesFast () const
 
virtual Long64_t GetEntriesFriend () const
 Return pointer to the 1st Leaf named name in any Branch of this Tree or any branch in the list of friend trees. More...
 
virtual TEntryListGetEntryList ()
 Returns the entry list, set to this tree. More...
 
virtual Long64_t GetEntryNumberWithBestIndex (Long64_t major, Long64_t minor=0) const
 Return entry number corresponding to major and minor number. More...
 
virtual Long64_t GetEntryNumberWithIndex (Long64_t major, Long64_t minor=0) const
 Return entry number corresponding to major and minor number. More...
 
virtual Long64_t GetEstimate () const
 
Int_t GetEvent (Long64_t entry=0, Int_t getall=0)
 
TEventListGetEventList () const
 
virtual Int_t GetFileNumber () const
 
virtual TTreeGetFriend (const char *) const
 Return a pointer to the TTree friend whose name or alias is 'friendname. More...
 
virtual const char * GetFriendAlias (TTree *) const
 If the 'tree' is a friend, this method returns its alias name. More...
 
TH1GetHistogram ()
 
virtual Bool_t GetImplicitMT ()
 
virtual Int_tGetIndex ()
 
virtual Double_tGetIndexValues ()
 
virtual TIteratorGetIteratorOnAllLeaves (Bool_t dir=kIterForward)
 Creates a new iterator that will go through all the leaves on the tree itself and its friend. More...
 
virtual TListGetListOfAliases () const
 
virtual TListGetListOfClones ()
 
virtual TListGetListOfFriends () const
 
Int_t GetMakeClass () const
 
virtual Long64_t GetMaxEntryLoop () const
 
virtual Long64_t GetMaxVirtualSize () const
 
TObjectGetNotify () const
 
virtual Int_t GetPacketSize () const
 
virtual TVirtualPerfStatsGetPerfStats () const
 
TVirtualTreePlayerGetPlayer ()
 Load the TTreePlayer (if not already done). More...
 
virtual Long64_t GetReadEvent () const
 
virtual Int_t GetScanField () const
 
TTreeFormulaGetSelect ()
 
virtual Long64_t GetSelectedRows ()
 
virtual Int_t GetTimerInterval () const
 
virtual Long64_t GetTotBytes () const
 
TBufferGetTransientBuffer (Int_t size)
 Returns the transient buffer currently used by this TTree for reading/writing baskets. More...
 
virtual TVirtualIndexGetTreeIndex () const
 
virtual Int_t GetUpdate () const
 
virtual TListGetUserInfo ()
 Return a pointer to the list containing user objects associated to this tree. More...
 
virtual Double_tGetV1 ()
 
virtual Double_tGetV2 ()
 
virtual Double_tGetV3 ()
 
virtual Double_tGetV4 ()
 
virtual Double_tGetVal (Int_t i)
 
TTreeFormulaGetVar (Int_t i)
 
TTreeFormulaGetVar1 ()
 
TTreeFormulaGetVar2 ()
 
TTreeFormulaGetVar3 ()
 
TTreeFormulaGetVar4 ()
 
virtual Double_tGetW ()
 
virtual Long64_t GetZipBytes () const
 
virtual void IncrementTotalBuffers (Int_t nbytes)
 
Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More...
 
virtual Long64_t LoadTreeFriend (Long64_t entry, TTree *T)
 Load entry on behalf of our master tree, we may use an index. More...
 
virtual Int_t MakeClass (const char *classname=0, Option_t *option="")
 Generate a skeleton analysis class for this tree. More...
 
virtual Int_t MakeCode (const char *filename=0)
 Generate a skeleton function for this tree. More...
 
virtual Int_t MakeProxy (const char *classname, const char *macrofilename=0, const char *cutfilename=0, const char *option=0, Int_t maxUnrolling=3)
 Generate a skeleton analysis class for this Tree using TBranchProxy. More...
 
virtual Int_t MakeSelector (const char *selector=0, Option_t *option="")
 Generate skeleton selector class for this tree. More...
 
Bool_t MemoryFull (Int_t nbytes)
 Check if adding nbytes to memory we are still below MaxVirtualsize. More...
 
virtual Bool_t Notify ()
 Function called when loading a new class library. More...
 
virtual void OptimizeBaskets (ULong64_t maxMemory=10000000, Float_t minComp=1.1, Option_t *option="")
 This function may be called after having filled some entries in a Tree. More...
 
TPrincipalPrincipal (const char *varexp="", const char *selection="", Option_t *option="np", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Interface to the Principal Components Analysis class. More...
 
virtual void PrintCacheStats (Option_t *option="") const
 Print statistics about the TreeCache for this tree. More...
 
virtual Long64_t Project (const char *hname, const char *varexp, const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Make a projection of a tree using selections. More...
 
virtual TSQLResultQuery (const char *varexp="", const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Loop over entries and return a TSQLResult object containing entries following selection. More...
 
virtual Long64_t ReadFile (const char *filename, const char *branchDescriptor="", char delimiter=' ')
 Create or simply read branches from filename. More...
 
virtual Long64_t ReadStream (std::istream &inputStream, const char *branchDescriptor="", char delimiter=' ')
 Create or simply read branches from an input stream. More...
 
virtual void Refresh ()
 Refresh contents of this tree and its branches from the current status on disk. More...
 
virtual Bool_t SetAlias (const char *aliasName, const char *aliasFormula)
 Set a tree variable alias. More...
 
virtual void SetAutoFlush (Long64_t autof=-30000000)
 This function may be called at the start of a program to change the default value for fAutoFlush. More...
 
virtual void SetAutoSave (Long64_t autos=-300000000)
 This function may be called at the start of a program to change the default value for fAutoSave (and for SetAutoSave) is -300000000, ie 300 MBytes. More...
 
virtual void SetBasketSize (const char *bname, Int_t buffsize=16000)
 Set a branch's basket size. More...
 
template<class T >
Int_t SetBranchAddress (const char *bname, T **add, TBranch **ptr=0)
 
template<class T >
Int_t SetBranchAddress (const char *bname, T *add, TBranch **ptr=0)
 
virtual Int_t SetCacheEntryRange (Long64_t first, Long64_t last)
 interface to TTreeCache to set the cache entry range More...
 
virtual void SetCacheLearnEntries (Int_t n=10)
 Interface to TTreeCache to set the number of entries for the learning phase. More...
 
virtual void SetChainOffset (Long64_t offset=0)
 
virtual void SetCircular (Long64_t maxEntries)
 Enable/Disable circularity for this tree. More...
 
virtual void SetDebug (Int_t level=1, Long64_t min=0, Long64_t max=9999999)
 Set the debug level and the debug range. More...
 
virtual void SetDefaultEntryOffsetLen (Int_t newdefault, Bool_t updateExisting=kFALSE)
 Update the default value for the branch's fEntryOffsetLen. More...
 
virtual Long64_t SetEntries (Long64_t n=-1)
 Change number of entries in the tree. More...
 
virtual void SetEstimate (Long64_t nentries=1000000)
 Set number of entries to estimate variable limits. More...
 
virtual void SetFileNumber (Int_t number=0)
 Set fFileNumber to number. More...
 
virtual void SetImplicitMT (Bool_t enabled)
 
virtual void SetMaxEntryLoop (Long64_t maxev=kMaxEntries)
 
virtual void SetMaxVirtualSize (Long64_t size=0)
 
virtual void SetName (const char *name)
 Change the name of this tree. More...
 
virtual void SetNotify (TObject *obj)
 Sets the address of the object to be notified when the tree is loaded. More...
 
virtual void SetObject (const char *name, const char *title)
 Change the name and title of this tree. More...
 
virtual void SetParallelUnzip (Bool_t opt=kTRUE, Float_t RelSize=-1)
 Enable or disable parallel unzipping of Tree buffers. More...
 
virtual void SetPerfStats (TVirtualPerfStats *perf)
 Set perf stats. More...
 
virtual void SetScanField (Int_t n=50)
 
virtual void SetTimerInterval (Int_t msec=333)
 
virtual void SetTreeIndex (TVirtualIndex *index)
 The current TreeIndex is replaced by the new index. More...
 
virtual void SetUpdate (Int_t freq=0)
 
virtual void Show (Long64_t entry=-1, Int_t lenmax=20)
 Print values of all active leaves for entry. More...
 
virtual void StartViewer ()
 Start the TTreeViewer on this tree. More...
 
virtual Int_t StopCacheLearningPhase ()
 Stop the cache learning phase. More...
 
virtual Int_t UnbinnedFit (const char *funcname, const char *varexp, const char *selection="", Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
 Unbinned fit of one or more variable(s) from a tree. More...
 
void UseCurrentStyle ()
 Replace current attributes by current style. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory. More...
 
- Public Member Functions inherited from TNamed
 TNamed ()
 
 TNamed (const char *name, const char *title)
 
 TNamed (const TString &name, const TString &title)
 
 TNamed (const TNamed &named)
 TNamed copy ctor. More...
 
virtual ~TNamed ()
 
virtual void Clear (Option_t *option="")
 Set name and title to empty strings (""). More...
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility. More...
 
virtual Int_t Compare (const TObject *obj) const
 Compare two TNamed objects. More...
 
virtual void Copy (TObject &named) const
 Copy this to obj. More...
 
virtual void FillBuffer (char *&buffer)
 Encode TNamed into output buffer. More...
 
virtual const char * GetName () const
 Returns name of object. More...
 
virtual const char * GetTitle () const
 Returns title of object. More...
 
virtual ULong_t Hash () const
 Return hash value for this object. More...
 
virtual Bool_t IsSortable () const
 
TNamedoperator= (const TNamed &rhs)
 TNamed assignment operator. More...
 
virtual void SetNameTitle (const char *name, const char *title)
 Set all the TNamed parameters (name and title). More...
 
virtual void SetTitle (const char *title="")
 Set the title of the TNamed. More...
 
virtual Int_t Sizeof () const
 Return size of the TNamed part of the TObject. More...
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor. More...
 
 TObject (const TObject &object)
 TObject copy ctor. More...
 
virtual ~TObject ()
 TObject destructor. More...
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract. More...
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad. More...
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs. More...
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object. More...
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs. More...
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad). More...
 
virtual void Dump () const
 Dump contents of object on stdout. More...
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message. More...
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g. More...
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray. More...
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py). More...
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message. More...
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes. More...
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes. More...
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object. More...
 
virtual const char * GetIconName () const
 Returns mime type name of object. More...
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py). More...
 
virtual Option_tGetOption () const
 
virtual UInt_t GetUniqueID () const
 Return the unique object id. More...
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out. More...
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message. More...
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname". More...
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl. More...
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas. More...
 
void InvertBit (UInt_t f)
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory). More...
 
Bool_t IsOnHeap () const
 
Bool_t IsZombie () const
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More...
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete. More...
 
void operator delete (void *ptr)
 Operator delete. More...
 
void operator delete[] (void *ptr)
 Operator delete []. More...
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator. More...
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself. More...
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list. More...
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory. More...
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename. More...
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out". More...
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f. More...
 
void SetBit (UInt_t f)
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object. More...
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id. More...
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message. More...
 
Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message. More...
 
- Public Member Functions inherited from TAttLine
 TAttLine ()
 AttLine default constructor. More...
 
 TAttLine (Color_t lcolor, Style_t lstyle, Width_t lwidth)
 AttLine normal constructor. More...
 
virtual ~TAttLine ()
 AttLine destructor. More...
 
void Copy (TAttLine &attline) const
 Copy this line attributes to a new TAttLine. More...
 
Int_t DistancetoLine (Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
 Compute distance from point px,py to a line. More...
 
virtual Color_t GetLineColor () const
 Return the line color. More...
 
virtual Style_t GetLineStyle () const
 Return the line style. More...
 
virtual Width_t GetLineWidth () const
 Return the line width. More...
 
virtual void Modify ()
 Change current line attributes if necessary. More...
 
virtual void ResetAttLine (Option_t *option="")
 Reset this line attributes to default values. More...
 
virtual void SaveLineAttributes (std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
 Save line attributes as C++ statement(s) on output stream out. More...
 
virtual void SetLineAttributes ()
 Invoke the DialogCanvas Line attributes. More...
 
virtual void SetLineColor (Color_t lcolor)
 Set the line color. More...
 
virtual void SetLineColorAlpha (Color_t lcolor, Float_t lalpha)
 Set a transparent line color. More...
 
virtual void SetLineStyle (Style_t lstyle)
 Set the line style. More...
 
virtual void SetLineWidth (Width_t lwidth)
 Set the line width. More...
 
- Public Member Functions inherited from TAttFill
 TAttFill ()
 AttFill default constructor. More...
 
 TAttFill (Color_t fcolor, Style_t fstyle)
 AttFill normal constructor. More...
 
virtual ~TAttFill ()
 AttFill destructor. More...
 
void Copy (TAttFill &attfill) const
 Copy this fill attributes to a new TAttFill. More...
 
virtual Color_t GetFillColor () const
 Return the fill area color. More...
 
virtual Style_t GetFillStyle () const
 Return the fill area style. More...
 
virtual Bool_t IsTransparent () const
 
virtual void Modify ()
 Change current fill area attributes if necessary. More...
 
virtual void ResetAttFill (Option_t *option="")
 Reset this fill attributes to default values. More...
 
virtual void SaveFillAttributes (std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
 Save fill attributes as C++ statement(s) on output stream out. More...
 
virtual void SetFillAttributes ()
 Invoke the DialogCanvas Fill attributes. More...
 
virtual void SetFillColor (Color_t fcolor)
 Set the fill area color. More...
 
virtual void SetFillColorAlpha (Color_t fcolor, Float_t falpha)
 Set a transparent fill color. More...
 
virtual void SetFillStyle (Style_t fstyle)
 Set the fill area style. More...
 
- Public Member Functions inherited from TAttMarker
 TAttMarker ()
 TAttMarker default constructor. More...
 
 TAttMarker (Color_t color, Style_t style, Size_t msize)
 TAttMarker normal constructor. More...
 
virtual ~TAttMarker ()
 TAttMarker destructor. More...
 
void Copy (TAttMarker &attmarker) const
 Copy this marker attributes to a new TAttMarker. More...
 
virtual Color_t GetMarkerColor () const
 Return the marker color. More...
 
virtual Size_t GetMarkerSize () const
 Return the marker size. More...
 
virtual Style_t GetMarkerStyle () const
 Return the marker style. More...
 
virtual void Modify ()
 Change current marker attributes if necessary. More...
 
virtual void ResetAttMarker (Option_t *toption="")
 Reset this marker attributes to the default values. More...
 
virtual void SaveMarkerAttributes (std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
 Save line attributes as C++ statement(s) on output stream out. More...
 
virtual void SetMarkerAttributes ()
 Invoke the DialogCanvas Marker attributes. More...
 
virtual void SetMarkerColor (Color_t mcolor=1)
 Set the marker color. More...
 
virtual void SetMarkerColorAlpha (Color_t mcolor, Float_t malpha)
 Set a transparent marker color. More...
 
virtual void SetMarkerSize (Size_t msize=1)
 Set the marker size. More...
 
virtual void SetMarkerStyle (Style_t mstyle=1)
 Set the marker style. More...
 

Static Public Attributes

static constexpr auto kBigNumber = TTree::kMaxEntries
 
- Static Public Attributes inherited from TTree
static constexpr Long64_t kMaxEntries = TVirtualTreePlayer::kMaxEntries
 

Protected Member Functions

void InvalidateCurrentTree ()
 Set the TTree to be reloaded as soon as possible. More...
 
void ReleaseChainProof ()
 
- Protected Member Functions inherited from TTree
virtual TBranchBranchImp (const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel)
 Same as TTree::Branch() with added check that addobj matches className. More...
 
virtual TBranchBranchImp (const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel)
 Same as TTree::Branch but automatic detection of the class name. More...
 
virtual TBranchBranchImpRef (const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel)
 Same as TTree::Branch but automatic detection of the class name. More...
 
virtual TBranchBranchImpRef (const char *branchname, TClass *ptrClass, EDataType datatype, void *addobj, Int_t bufsize, Int_t splitlevel)
 Same as TTree::Branch but automatic detection of the class name. More...
 
virtual TBranchBronchExec (const char *name, const char *classname, void *addobj, Bool_t isptrptr, Int_t bufsize, Int_t splitlevel)
 Helper function implementing TTree::Bronch and TTree::Branch(const char *name, T &obj);. More...
 
virtual Int_t CheckBranchAddressType (TBranch *branch, TClass *ptrClass, EDataType datatype, Bool_t ptr)
 Check whether or not the address described by the last 3 parameters matches the content of the branch. More...
 
Long64_t GetCacheAutoSize (Bool_t withDefault=kFALSE) const
 Used for automatic sizing of the cache. More...
 
virtual TLeafGetLeafImpl (const char *branchname, const char *leafname)
 Return pointer to the 1st Leaf named name in any Branch of this Tree or any branch in the list of friend trees. More...
 
char GetNewlineValue (std::istream &inputStream)
 Determine which newline this file is using. More...
 
TTreeCacheGetReadCache (TFile *file, Bool_t create=kFALSE)
 Find and return the TTreeCache registered with the file and which may contain branches for us. More...
 
void ImportClusterRanges (TTree *fromtree)
 Appends the cluster range information stored in 'fromtree' to this tree, including the value of fAutoFlush. More...
 
virtual void KeepCircular ()
 Keep a maximum of fMaxEntries in memory. More...
 
void MoveReadCache (TFile *src, TDirectory *dir)
 Move a cache from a file to the current file in dir. More...
 
Int_t SetBranchAddressImp (TBranch *branch, void *addr, TBranch **ptr)
 Change branch address, dealing with clone trees properly. More...
 
Int_t SetCacheSizeAux (Bool_t autocache=kTRUE, Long64_t cacheSize=0)
 Set the size of the file cache and create it if possible. More...
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected). More...
 
void MakeZombie ()
 

Protected Attributes

Bool_t fCanDeleteRefs
 ! If true, TProcessIDs are deleted when closing a file More...
 
TFilefFile
 ! Pointer to current file (We own the file). More...
 
TObjArrayfFiles
 -> List of file names containing the trees (TChainElement, owned) More...
 
Int_t fNtrees
 Number of trees. More...
 
TChainfProofChain
 ! chain proxy when going to be processed by PROOF More...
 
TListfStatus
 -> List of active/inactive branches (TChainElement, owned) More...
 
TTreefTree
 ! Pointer to current tree (Note: We do not own this tree.) More...
 
Int_t fTreeNumber
 ! Current Tree number in fTreeOffset table More...
 
Long64_tfTreeOffset
 [fTreeOffsetLen] Array of variables More...
 
Int_t fTreeOffsetLen
 Current size of fTreeOffset array. More...
 
- Protected Attributes inherited from TTree
TListfAliases
 List of aliases for expressions based on the tree branches. More...
 
Long64_t fAutoFlush
 Auto-flush tree when fAutoFlush entries written or -fAutoFlush (compressed) bytes produced. More...
 
Long64_t fAutoSave
 Autosave tree when fAutoSave entries written or -fAutoSave (compressed) bytes produced. More...
 
TObjArray fBranches
 List of Branches. More...
 
TBranchReffBranchRef
 Branch supporting the TRefTable (if any) More...
 
Bool_t fCacheDoAutoInit
 ! true if cache auto creation or resize check is needed More...
 
Long64_t fCacheSize
 ! Maximum size of file buffers More...
 
Bool_t fCacheUserSet
 ! true if the cache setting was explicitly given by user More...
 
Long64_t fChainOffset
 ! Offset of 1st entry of this Tree in a TChain More...
 
TListfClones
 ! List of cloned trees which share our addresses More...
 
Long64_tfClusterRangeEnd
 [fNClusterRange] Last entry of a cluster range. More...
 
Long64_tfClusterSize
 [fNClusterRange] Number of entries in each cluster for a given range. More...
 
Int_t fDebug
 ! Debug level More...
 
Long64_t fDebugMax
 ! Last entry number to debug More...
 
Long64_t fDebugMin
 ! First entry number to debug More...
 
Int_t fDefaultEntryOffsetLen
 Initial Length of fEntryOffset table in the basket buffers. More...
 
TDirectoryfDirectory
 ! Pointer to directory holding this tree More...
 
Long64_t fEntries
 Number of entries. More...
 
TEntryListfEntryList
 ! Pointer to event selection list (if one) More...
 
Long64_t fEstimate
 Number of entries to estimate histogram limits. More...
 
TEventListfEventList
 ! Pointer to event selection list (if one) More...
 
Int_t fFileNumber
 ! current file number (if file extensions) More...
 
Long64_t fFlushedBytes
 Number of auto-flushed bytes. More...
 
UInt_t fFriendLockStatus
 ! Record which method is locking the friend recursion More...
 
TListfFriends
 pointer to list of friend elements More...
 
Bool_t fIMTEnabled
 ! true if implicit multi-threading is enabled for this tree More...
 
TArrayI fIndex
 Index of sorted values. More...
 
TArrayD fIndexValues
 Sorted index values. More...
 
TObjArray fLeaves
 Direct pointers to individual branch leaves. More...
 
Int_t fMakeClass
 ! not zero when processing code generated by MakeClass More...
 
Int_t fMaxClusterRange
 ! Memory allocated for the cluster range. More...
 
Long64_t fMaxEntries
 Maximum number of entries in case of circular buffers. More...
 
Long64_t fMaxEntryLoop
 Maximum number of entries to process. More...
 
Long64_t fMaxVirtualSize
 Maximum total size of buffers kept in memory. More...
 
Int_t fNClusterRange
 Number of Cluster range in addition to the one defined by 'AutoFlush'. More...
 
UInt_t fNEntriesSinceSorting
 ! Number of entries processed since the last re-sorting of branches More...
 
Int_t fNfill
 ! Local for EntryLoop More...
 
TObjectfNotify
 ! Object to be notified when loading a Tree More...
 
Int_t fPacketSize
 ! Number of entries in one packet for parallel root More...
 
TVirtualPerfStatsfPerfStats
 ! pointer to the current perf stats object More...
 
TVirtualTreePlayerfPlayer
 ! Pointer to current Tree player More...
 
Long64_t fReadEntry
 ! Number of the entry being processed More...
 
Long64_t fSavedBytes
 Number of autosaved bytes. More...
 
Int_t fScanField
 Number of runs before prompting in Scan. More...
 
std::vector< TBranch * > fSeqBranches
 ! Branches to be processed sequentially when IMT is on More...
 
std::vector< std::pair< Long64_t, TBranch * > > fSortedBranches
 ! Branches to be processed in parallel when IMT is on, sorted by average task time More...
 
Int_t fTimerInterval
 Timer interval in milliseconds. More...
 
std::atomic< Long64_tfTotalBuffers
 ! Total number of bytes in branch buffers More...
 
Long64_t fTotBytes
 Total number of bytes in all branches before compression. More...
 
TBufferfTransientBuffer
 ! Pointer to the current transient buffer. More...
 
TVirtualIndexfTreeIndex
 Pointer to the tree Index (if any) More...
 
Int_t fUpdate
 Update frequency for EntryLoop. More...
 
TListfUserInfo
 pointer to a list of user objects associated to this Tree More...
 
Double_t fWeight
 Tree weight (see TTree::SetWeight) More...
 
Long64_t fZipBytes
 Total number of bytes in all branches after compression. More...
 
- Protected Attributes inherited from TNamed
TString fName
 
TString fTitle
 
- Protected Attributes inherited from TAttLine
Color_t fLineColor
 Line color. More...
 
Style_t fLineStyle
 Line style. More...
 
Width_t fLineWidth
 Line width. More...
 
- Protected Attributes inherited from TAttFill
Color_t fFillColor
 Fill area color. More...
 
Style_t fFillStyle
 Fill area style. More...
 
- Protected Attributes inherited from TAttMarker
Color_t fMarkerColor
 Marker color. More...
 
Size_t fMarkerSize
 Marker size. More...
 
Style_t fMarkerStyle
 Marker style. More...
 

Private Member Functions

 TChain (const TChain &)
 
TChainoperator= (const TChain &)
 
void ParseTreeFilename (const char *name, TString &filename, TString &treename, TString &query, TString &suffix, Bool_t wildcards) const
 Get the tree url or filename and other information from the name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from TTree
static Int_t GetBranchStyle ()
 Static function returning the current branch style. More...
 
static Long64_t GetMaxTreeSize ()
 Static function which returns the tree file size limit in bytes. More...
 
static TTreeMergeTrees (TList *list, Option_t *option="")
 Static function merging the trees in the TList into a new tree. More...
 
static void SetBranchStyle (Int_t style=1)
 Set the current branch style. More...
 
static void SetMaxTreeSize (Long64_t maxsize=100000000000LL)
 Set the maximum size in bytes of a Tree file (static function). More...
 
- Static Public Member Functions inherited from TObject
static Long_t GetDtorOnly ()
 Return destructor only flag. More...
 
static Bool_t GetObjectStat ()
 Get status of object stat flag. More...
 
static void SetDtorOnly (void *obj)
 Set destructor only flag. More...
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable. More...
 
- Protected Types inherited from TTree
enum  ELockStatusBits {
  kFindBranch = BIT(0), kFindLeaf = BIT(1), kGetAlias = BIT(2), kGetBranch = BIT(3),
  kGetEntry = BIT(4), kGetEntryWithIndex = BIT(5), kGetFriend = BIT(6), kGetFriendAlias = BIT(7),
  kGetLeaf = BIT(8), kLoadTree = BIT(9), kPrint = BIT(10), kRemoveFriend = BIT(11),
  kSetBranchStatus = BIT(12)
}
 
- Static Protected Attributes inherited from TTree
static Int_t fgBranchStyle = 1
 Old/New branch style. More...
 
static Long64_t fgMaxTreeSize = 100000000000LL
 Maximum size of a file containing a Tree. More...
 

#include <TChain.h>

Inheritance diagram for TChain:
[legend]

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kGlobalWeight 
kAutoDelete 
kProofUptodate 
kProofLite 

Definition at line 58 of file TChain.h.

Constructor & Destructor Documentation

◆ TChain() [1/3]

TChain::TChain ( const TChain )
private

◆ TChain() [2/3]

TChain::TChain ( )

Default constructor.

Definition at line 63 of file TChain.cxx.

◆ TChain() [3/3]

TChain::TChain ( const char *  name,
const char *  title = "" 
)

Create a chain.

A TChain is a collection of TFile objects. the first parameter "name" is the name of the TTree object in the files added with Add. Use TChain::Add to add a new element to this chain.

In case the Tree is in a subdirectory, do, eg:

TChain ch("subdir/treename");

Example: Suppose we have 3 files f1.root, f2.root and f3.root. Each file contains a TTree object named "T".

TChain ch("T"); creates a chain to process a Tree called "T"
ch.Add("f1.root");
ch.Add("f2.root");
ch.Add("f3.root");
ch.Draw("x");

The Draw function above will process the variable "x" in Tree "T" reading sequentially the 3 files in the chain ch.

The TChain data structure:

Each TChainElement has a name equal to the tree name of this TChain and a title equal to the file name. So, to loop over the TFiles that have been added to this chain:

TObjArray *fileElements=chain->GetListOfFiles();
TIter next(fileElements);
TChainElement *chEl=0;
while (( chEl=(TChainElement*)next() )) {
TFile f(chEl->GetTitle());
... do something with f ...
}

Definition at line 137 of file TChain.cxx.

◆ ~TChain()

TChain::~TChain ( )
virtual

Destructor.

Definition at line 177 of file TChain.cxx.

Member Function Documentation

◆ Add() [1/2]

Int_t TChain::Add ( TChain chain)
virtual

Add all files referenced by the passed chain to this chain.

The function returns the total number of files connected.

Definition at line 220 of file TChain.cxx.

◆ Add() [2/2]

Int_t TChain::Add ( const char *  name,
Long64_t  nentries = TTree::kMaxEntries 
)
virtual

Add a new file to this chain.

Argument name may have either of two formats. The first:

[//machine]/path/file_name.root[/tree_name]

If tree_name is missing the chain name will be assumed. Wildcard treatment is triggered by the any of the special characters []*? which may be used in the file name, eg. specifying "xxx*.root" adds all files starting with xxx in the current file system directory.

Alternatively name may have the format of a url, eg.

root://machine/path/file_name.root
or root://machine/path/file_name.root/tree_name
or root://machine/path/file_name.root/tree_name?query

where "query" is to be interpreted by the remote server. Wildcards may be supported in urls, depending on the protocol plugin and the remote server. http or https urls can contain a query identifier without tree_name, but generally urls can not be written with them because of ambiguity with the wildcard character. (Also see the documentation for TChain::AddFile, which does not support wildcards but allows the url to contain query)

NB. To add all the files of a TChain to a chain, use Add(TChain *chain).

A. if nentries <= 0, the file is connected and the tree header read in memory to get the number of entries.

B. if (nentries > 0, the file is not connected, nentries is assumed to be the number of entries in the file. In this case, no check is made that the file exists and the Tree existing in the file. This second mode is interesting in case the number of entries in the file is already stored in a run data base for example.

C. if (nentries == TTree::kMaxEntries) (default), the file is not connected. the number of entries in each file will be read only when the file will need to be connected to read an entry. This option is the default and very efficient if one process the chain sequentially. Note that in case TChain::GetEntry(entry) is called and entry refers to an entry in the 3rd file, for example, this forces the Tree headers in the first and second file to be read to find the number of entries in these files. Note that if one calls TChain::GetEntriesFast() after having created a chain with this default, GetEntriesFast will return TTree::kMaxEntries! TChain::GetEntries will force of the Tree headers in the chain to be read to read the number of entries in each Tree.

D. The TChain data structure Each TChainElement has a name equal to the tree name of this TChain and a title equal to the file name. So, to loop over the TFiles that have been added to this chain:

TObjArray *fileElements=chain->GetListOfFiles();
TIter next(fileElements);
TChainElement *chEl=0;
while (( chEl=(TChainElement*)next() )) {
TFile f(chEl->GetTitle());
... do something with f ...
}

Return value:

  • If nentries>0 (including the default of TTree::kMaxEntries) and no wildcarding is used, ALWAYS returns 1 without regard to whether the file exists or contains the correct tree.
  • If wildcarding is used, regardless of the value of nentries, returns the number of files matching the name without regard to whether they contain the correct tree.
  • If nentries<=0 and wildcarding is not used, return 1 if the file exists and contains the correct tree and 0 otherwise.

Definition at line 335 of file TChain.cxx.

◆ AddFile()

Int_t TChain::AddFile ( const char *  name,
Long64_t  nentries = TTree::kMaxEntries,
const char *  tname = "" 
)
virtual

Add a new file to this chain.

Filename formats are similar to TChain::Add. Wildcards are not applied. urls may also contain query and fragment identifiers where the tree name can be specified in the url fragment.

eg.

root://machine/path/file_name.root?query#tree_name

If tree_name is given as a part of the file name it is used to as the name of the tree to load from the file. Otherwise if tname argument is specified the chain will load the tree named tname from the file, otherwise the original treename specified in the TChain constructor will be used.

A. If nentries <= 0, the file is opened and the tree header read into memory to get the number of entries.

B. If nentries > 0, the file is not opened, and nentries is assumed to be the number of entries in the file. In this case, no check is made that the file exists nor that the tree exists in the file. This second mode is interesting in case the number of entries in the file is already stored in a run database for example.

C. If nentries == TTree::kMaxEntries (default), the file is not opened. The number of entries in each file will be read only when the file is opened to read an entry. This option is the default and very efficient if one processes the chain sequentially. Note that in case GetEntry(entry) is called and entry refers to an entry in the third file, for example, this forces the tree headers in the first and second file to be read to find the number of entries in those files. Note that if one calls GetEntriesFast() after having created a chain with this default, GetEntriesFast() will return TTree::kMaxEntries! Using the GetEntries() function instead will force all of the tree headers in the chain to be read to read the number of entries in each tree.

D. The TChain data structure Each TChainElement has a name equal to the tree name of this TChain and a title equal to the file name. So, to loop over the TFiles that have been added to this chain:

TObjArray *fileElements=chain->GetListOfFiles();
TIter next(fileElements);
TChainElement *chEl=0;
while (( chEl=(TChainElement*)next() )) {
TFile f(chEl->GetTitle());
... do something with f ...
}

The function returns 1 if the file is successfully connected, 0 otherwise.

Definition at line 443 of file TChain.cxx.

◆ AddFileInfoList()

Int_t TChain::AddFileInfoList ( TCollection filelist,
Long64_t  nfiles = TTree::kMaxEntries 
)
virtual

Add all files referenced in the list to the chain.

The object type in the list must be either TFileInfo or TObjString or TUrl . The function return 1 if successful, 0 otherwise.

Definition at line 540 of file TChain.cxx.

◆ AddFriend() [1/3]

TFriendElement * TChain::AddFriend ( const char *  chain,
const char *  dummy = "" 
)
virtual

Add a TFriendElement to the list of friends of this chain.

A TChain has a list of friends similar to a tree (see TTree::AddFriend). You can add a friend to a chain with the TChain::AddFriend method, and you can retrieve the list of friends with TChain::GetListOfFriends. This example has four chains each has 20 ROOT trees from 20 ROOT files.

TChain ch("t"); // a chain with 20 trees from 20 files
TChain ch1("t1");
TChain ch2("t2");
TChain ch3("t3");

Now we can add the friends to the first chain.

ch.AddFriend("t1")
ch.AddFriend("t2")
ch.AddFriend("t3")
tchain_friend.png

The parameter is the name of friend chain (the name of a chain is always the name of the tree from which it was created). The original chain has access to all variable in its friends. We can use the TChain::Draw method as if the values in the friends were in the original chain. To specify the chain to use in the Draw method, use the syntax:

<chainname>.<branchname>.<varname>

If the variable name is enough to uniquely identify the variable, you can leave out the chain and/or branch name. For example, this generates a 3-d scatter plot of variable "var" in the TChain ch versus variable v1 in TChain t1 versus variable v2 in TChain t2.

ch.Draw("var:t1.v1:t2.v2");

When a TChain::Draw is executed, an automatic call to TTree::AddFriend connects the trees in the chain. When a chain is deleted, its friend elements are also deleted.

The number of entries in the friend must be equal or greater to the number of entries of the original chain. If the friend has fewer entries a warning is given and the resulting histogram will have missing entries. For additional information see TTree::AddFriend.

Reimplemented from TTree.

Definition at line 630 of file TChain.cxx.

◆ AddFriend() [2/3]

TFriendElement * TChain::AddFriend ( const char *  chainname,
TFile dummy 
)
virtual

Add the whole chain or tree as a friend of this chain.

Reimplemented from TTree.

Definition at line 659 of file TChain.cxx.

◆ AddFriend() [3/3]

TFriendElement * TChain::AddFriend ( TTree chain,
const char *  alias = "",
Bool_t  warn = kFALSE 
)
virtual

Add the whole chain or tree as a friend of this chain.

Reimplemented from TTree.

Definition at line 686 of file TChain.cxx.

◆ Browse()

void TChain::Browse ( TBrowser b)
virtual

Browse the contents of the chain.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 712 of file TChain.cxx.

◆ CanDeleteRefs()

void TChain::CanDeleteRefs ( Bool_t  flag = kTRUE)
virtual

When closing a file during the chain processing, the file may be closed with option "R" if flag is set to kTRUE.

by default flag is kTRUE. When closing a file with option "R", all TProcessIDs referenced by this file are deleted. Calling TFile::Close("R") might be necessary in case one reads a long list of files having TRef, writing some of the referenced objects or TRef to a new file. If the TRef or referenced objects of the file being closed will not be referenced again, it is possible to minimize the size of the TProcessID data structures in memory by forcing a delete of the unused TProcessID.

Definition at line 730 of file TChain.cxx.

◆ CreatePackets()

void TChain::CreatePackets ( )
virtual

Initialize the packet descriptor string.

Definition at line 738 of file TChain.cxx.

◆ DirectoryAutoAdd()

void TChain::DirectoryAutoAdd ( TDirectory )
virtual

Override the TTree::DirectoryAutoAdd behavior: we never auto add.

Reimplemented from TTree.

Definition at line 751 of file TChain.cxx.

◆ Draw() [1/3]

Long64_t TChain::Draw ( const char *  varexp,
const TCut selection,
Option_t option = "",
Long64_t  nentries = kMaxEntries,
Long64_t  firstentry = 0 
)
virtual

Draw expression varexp for selected entries.

Returns -1 in case of error or number of selected events in case of success.

This function accepts TCut objects as arguments. Useful to use the string operator +, example: ntuple.Draw("x",cut1+cut2+cut3);

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 764 of file TChain.cxx.

◆ Draw() [2/3]

Long64_t TChain::Draw ( const char *  varexp,
const char *  selection,
Option_t option = "",
Long64_t  nentries = kMaxEntries,
Long64_t  firstentry = 0 
)
virtual

Process all entries in this chain and draw histogram corresponding to expression varexp.

Returns -1 in case of error or number of selected events in case of success.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 784 of file TChain.cxx.

◆ Draw() [3/3]

virtual void TChain::Draw ( Option_t option)
inlinevirtual

Default Draw method for all objects.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 86 of file TChain.h.

◆ Fill()

virtual Int_t TChain::Fill ( )
inlinevirtual

Fill all branches.

This function loops on all the branches of this tree. For each branch, it copies to the branch buffer (basket) the current values of the leaves data types. If a leaf is a simple data type, a simple conversion to a machine independent format has to be done.

This machine independent version of the data is copied into a basket (each branch has its own basket). When a basket is full (32k worth of data by default), it is then optionally compressed and written to disk (this operation is also called committing or 'flushing' the basket). The committed baskets are then immediately removed from memory.

The function returns the number of bytes committed to the individual branches.

If a write error occurs, the number of bytes returned is -1.

If no data are written, because, e.g., the branch is disabled, the number of bytes returned is 0.

The baskets are flushed and the Tree header saved at regular intervals

At regular intervals, when the amount of data written so far is greater than fAutoFlush (see SetAutoFlush) all the baskets are flushed to disk. This makes future reading faster as it guarantees that baskets belonging to nearby entries will be on the same disk region. When the first call to flush the baskets happen, we also take this opportunity to optimize the baskets buffers. We also check if the amount of data written is greater than fAutoSave (see SetAutoSave). In this case we also write the Tree header. This makes the Tree recoverable up to this point in case the program writing the Tree crashes. The decisions to FlushBaskets and Auto Save can be made based either on the number of bytes written (fAutoFlush and fAutoSave negative) or on the number of entries written (fAutoFlush and fAutoSave positive). Note that the user can decide to call FlushBaskets and AutoSave in her event loop base on the number of events written instead of the number of bytes written.

Note that calling FlushBaskets too often increases the IO time.

Note that calling AutoSave too often increases the IO time and also the file size.

Reimplemented from TTree.

Definition at line 87 of file TChain.h.

◆ FindBranch()

TBranch * TChain::FindBranch ( const char *  name)
virtual

See TTree::GetReadEntry().

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 803 of file TChain.cxx.

◆ FindLeaf()

TLeaf * TChain::FindLeaf ( const char *  name)
virtual

See TTree::GetReadEntry().

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 824 of file TChain.cxx.

◆ GetAlias()

const char * TChain::GetAlias ( const char *  aliasName) const
virtual

Returns the expanded value of the alias. Search in the friends if any.

Reimplemented from TTree.

Definition at line 845 of file TChain.cxx.

◆ GetBranch()

TBranch * TChain::GetBranch ( const char *  name)
virtual

Return pointer to the branch name in the current tree.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 864 of file TChain.cxx.

◆ GetBranchStatus()

Bool_t TChain::GetBranchStatus ( const char *  branchname) const
virtual

See TTree::GetReadEntry().

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 885 of file TChain.cxx.

◆ GetCacheSize()

virtual Long64_t TChain::GetCacheSize ( ) const
inlinevirtual

Reimplemented from TTree.

Definition at line 92 of file TChain.h.

◆ GetChainEntryNumber()

Long64_t TChain::GetChainEntryNumber ( Long64_t  entry) const
virtual

Return absolute entry number in the chain.

The input parameter entry is the entry number in the current tree of this chain.

Reimplemented from TTree.

Definition at line 913 of file TChain.cxx.

◆ GetClusterIterator()

TTree::TClusterIterator TChain::GetClusterIterator ( Long64_t  firstentry)
virtual

Return an iterator over the cluster of baskets starting at firstentry.

This iterator is not yet supported for TChain object.

Reimplemented from TTree.

Definition at line 902 of file TChain.cxx.

◆ GetEntries() [1/2]

Long64_t TChain::GetEntries ( ) const
virtual

Return the total number of entries in the chain.

In case the number of entries in each tree is not yet known, the offset table is computed.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 923 of file TChain.cxx.

◆ GetEntries() [2/2]

virtual Long64_t TChain::GetEntries ( const char *  selection)
inlinevirtual

Return the number of entries matching the selection.

Return -1 in case of errors.

If the selection uses any arrays or containers, we return the number of entries where at least one element match the selection. GetEntries is implemented using the selector class TSelectorEntries, which can be used directly (see code in TTreePlayer::GetEntries) for additional option. If SetEventList was used on the TTree or TChain, only that subset of entries will be considered.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 97 of file TChain.h.

◆ GetEntry()

Int_t TChain::GetEntry ( Long64_t  entry = 0,
Int_t  getall = 0 
)
virtual

Get entry from the file to memory.

  • getall = 0 : get only active branches
  • getall = 1 : get all branches

Return the total number of bytes read, 0 bytes read indicates a failure.

Reimplemented from TTree.

Definition at line 947 of file TChain.cxx.

◆ GetEntryNumber()

Long64_t TChain::GetEntryNumber ( Long64_t  entry) const
virtual

Return entry number corresponding to entry.

if no TEntryList set returns entry else returns entry #entry from this entry list and also computes the global entry number (loads all tree headers)

Reimplemented from TTree.

Definition at line 966 of file TChain.cxx.

◆ GetEntryWithIndex()

Int_t TChain::GetEntryWithIndex ( Int_t  major,
Int_t  minor = 0 
)
virtual

Return entry corresponding to major and minor number.

The function returns the total number of bytes read. If the Tree has friend trees, the corresponding entry with the index values (major,minor) is read. Note that the master Tree and its friend may have different entry serial numbers corresponding to (major,minor).

Reimplemented from TTree.

Definition at line 999 of file TChain.cxx.

◆ GetFile()

TFile * TChain::GetFile ( ) const

Return a pointer to the current file.

If no file is connected, the first file is automatically loaded.

Definition at line 1010 of file TChain.cxx.

◆ GetLeaf() [1/2]

TLeaf * TChain::GetLeaf ( const char *  branchname,
const char *  leafname 
)
virtual

Return a pointer to the leaf name in the current tree.

Reimplemented from TTree.

Definition at line 1023 of file TChain.cxx.

◆ GetLeaf() [2/2]

TLeaf * TChain::GetLeaf ( const char *  name)
virtual

Return a pointer to the leaf name in the current tree.

Reimplemented from TTree.

Definition at line 1044 of file TChain.cxx.

◆ GetListOfBranches()

TObjArray * TChain::GetListOfBranches ( )
virtual

Return a pointer to the list of branches of the current tree.

Warning: If there is no current TTree yet, this routine will open the first in the chain.

Returns 0 on failure.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 1070 of file TChain.cxx.

◆ GetListOfFiles()

TObjArray* TChain::GetListOfFiles ( ) const
inline

Definition at line 107 of file TChain.h.

◆ GetListOfLeaves()

TObjArray * TChain::GetListOfLeaves ( )
virtual

Return a pointer to the list of leaves of the current tree.

Warning: May set the current tree!

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 1093 of file TChain.cxx.

◆ GetMaximum()

Double_t TChain::GetMaximum ( const char *  columname)
virtual

Return maximum of column with name columname.

Reimplemented from TTree.

Definition at line 1114 of file TChain.cxx.

◆ GetMinimum()

Double_t TChain::GetMinimum ( const char *  columname)
virtual

Return minimum of column with name columname.

Reimplemented from TTree.

Definition at line 1131 of file TChain.cxx.

◆ GetNbranches()

Int_t TChain::GetNbranches ( )
virtual

Return the number of branches of the current tree.

Warning: May set the current tree!

Reimplemented from TTree.

Definition at line 1150 of file TChain.cxx.

◆ GetNtrees()

Int_t TChain::GetNtrees ( ) const
inline

Definition at line 95 of file TChain.h.

◆ GetReadEntry()

Long64_t TChain::GetReadEntry ( ) const
virtual

See TTree::GetReadEntry().

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 1165 of file TChain.cxx.

◆ GetStatus()

TList* TChain::GetStatus ( ) const
inline

Definition at line 114 of file TChain.h.

◆ GetTree()

virtual TTree* TChain::GetTree ( ) const
inlinevirtual

Reimplemented from TTree.

Definition at line 115 of file TChain.h.

◆ GetTreeNumber()

virtual Int_t TChain::GetTreeNumber ( ) const
inlinevirtual

Reimplemented from TTree.

Definition at line 116 of file TChain.h.

◆ GetTreeOffset()

Long64_t* TChain::GetTreeOffset ( ) const
inline

Definition at line 117 of file TChain.h.

◆ GetTreeOffsetLen()

Int_t TChain::GetTreeOffsetLen ( ) const
inline

Definition at line 118 of file TChain.h.

◆ GetWeight()

Double_t TChain::GetWeight ( ) const
virtual

Return the chain weight.

By default the weight is the weight of the current tree. However, if the weight has been set in TChain::SetWeight() with the option "global", then that weight will be returned.

Warning: May set the current tree!

Reimplemented from TTree.

Definition at line 1186 of file TChain.cxx.

◆ InvalidateCurrentTree()

void TChain::InvalidateCurrentTree ( )
protected

Set the TTree to be reloaded as soon as possible.

In particular this is needed when adding a Friend.

If the tree has clones, copy them into the chain clone list so we can change their branch addresses when necessary.

This is to support the syntax:

TTree* clone = chain->GetTree()->CloneTree(0);

Definition at line 1215 of file TChain.cxx.

◆ LoadBaskets()

Int_t TChain::LoadBaskets ( Long64_t  maxmemory)
virtual

Dummy function.

It could be implemented and load all baskets of all trees in the chain. For the time being use TChain::Merge and TTree::LoadBasket on the resulting tree.

Reimplemented from TTree.

Definition at line 1233 of file TChain.cxx.

◆ LoadTree()

Long64_t TChain::LoadTree ( Long64_t  entry)
virtual

Find the tree which contains entry, and set it as the current tree.

Returns the entry number in that tree.

The input argument entry is the entry serial number in the whole chain.

In case of error, LoadTree returns a negative number:

  • -1: The chain is empty.
  • -2: The requested entry number is less than zero or too large for the chain. or too large for the large TTree.
  • -3: The file corresponding to the entry could not be correctly open
  • -4: The TChainElement corresponding to the entry is missing or the TTree is missing from the file.
  • -5: Internal error, please report the circumstance when this happen as a ROOT issue.

Note: This is the only routine which sets the value of fTree to a non-zero pointer.

Reimplemented from TTree.

Definition at line 1259 of file TChain.cxx.

◆ Lookup()

void TChain::Lookup ( Bool_t  force = kFALSE)

Check / locate the files in the chain.

By default only the files not yet looked up are checked. Use force = kTRUE to check / re-check every file.

Definition at line 1677 of file TChain.cxx.

◆ Loop()

void TChain::Loop ( Option_t option = "",
Long64_t  nentries = kMaxEntries,
Long64_t  firstentry = 0 
)
virtual

Loop on nentries of this chain starting at firstentry. (NOT IMPLEMENTED)

Definition at line 1747 of file TChain.cxx.

◆ ls()

void TChain::ls ( Option_t option = "") const
virtual

List the chain.

Reimplemented from TNamed.

Definition at line 1791 of file TChain.cxx.

◆ Merge() [1/4]

Long64_t TChain::Merge ( const char *  name,
Option_t option = "" 
)
virtual

Merge all the entries in the chain into a new tree in a new file.

See important note in the following function Merge().

If the chain is expecting the input tree inside a directory, this directory is NOT created by this routine.

So in a case where we have:

TChain ch("mydir/mytree");
ch.Merge("newfile.root");

The resulting file will have not subdirectory. To recreate the directory structure do:

TFile* file = TFile::Open("newfile.root", "RECREATE");
file->mkdir("mydir")->cd();
ch.Merge(file);

Definition at line 1824 of file TChain.cxx.

◆ Merge() [2/4]

Long64_t TChain::Merge ( TCollection list,
Option_t option = "" 
)
virtual

Merge all chains in the collection. (NOT IMPLEMENTED)

Reimplemented from TTree.

Definition at line 1833 of file TChain.cxx.

◆ Merge() [3/4]

Long64_t TChain::Merge ( TCollection list,
TFileMergeInfo info 
)
virtual

Merge all chains in the collection. (NOT IMPLEMENTED)

Reimplemented from TTree.

Definition at line 1842 of file TChain.cxx.

◆ Merge() [4/4]

Long64_t TChain::Merge ( TFile file,
Int_t  basketsize,
Option_t option = "" 
)
virtual

Merge all the entries in the chain into a new tree in the current file.

Note: The "file" parameter is not the file where the new tree will be inserted. The new tree is inserted into gDirectory, which is usually the most recently opened file, or the directory most recently cd()'d to.

If option = "C" is given, the compression level for all branches in the new Tree is set to the file compression level. By default, the compression level of all branches is the original compression level in the old trees.

If basketsize > 1000, the basket size for all branches of the new tree will be set to basketsize.

Example using the file generated in $ROOTSYS/test/Event merge two copies of Event.root

gSystem.Load("libEvent");
TChain ch("T");
ch.Add("Event1.root");
ch.Add("Event2.root");
ch.Merge("all.root");

If the chain is expecting the input tree inside a directory, this directory is NOT created by this routine.

So if you do:

TChain ch("mydir/mytree");
ch.Merge("newfile.root");

The resulting file will not have subdirectories. In order to preserve the directory structure do the following instead:

TFile* file = TFile::Open("newfile.root", "RECREATE");
file->mkdir("mydir")->cd();
ch.Merge(file);

If 'option' contains the word 'fast' the merge will be done without unzipping or unstreaming the baskets (i.e., a direct copy of the raw bytes on disk).

When 'fast' is specified, 'option' can also contains a sorting order for the baskets in the output file.

There is currently 3 supported sorting order:

SortBasketsByOffset (the default)
SortBasketsByBranch
SortBasketsByEntry

When using SortBasketsByOffset the baskets are written in the output file in the same order as in the original file (i.e. the basket are sorted on their offset in the original file; Usually this also means that the baskets are sorted on the index/number of the last entry they contain)

When using SortBasketsByBranch all the baskets of each individual branches are stored contiguously. This tends to optimize reading speed when reading a small number (1->5) of branches, since all their baskets will be clustered together instead of being spread across the file. However it might decrease the performance when reading more branches (or the full entry).

When using SortBasketsByEntry the baskets with the lowest starting entry are written first. (i.e. the baskets are sorted on the index/number of the first entry they contain). This means that on the file the baskets will be in the order in which they will be needed when reading the whole tree sequentially.

IMPORTANT Note 1: AUTOMATIC FILE OVERFLOW

When merging many files, it may happen that the resulting file reaches a size > TTree::fgMaxTreeSize (default = 100 GBytes). In this case the current file is automatically closed and a new file started. If the name of the merged file was "merged.root", the subsequent files will be named "merged_1.root", "merged_2.root", etc. fgMaxTreeSize may be modified via the static function TTree::SetMaxTreeSize. When in fast mode, the check and switch is only done in between each input file.

IMPORTANT Note 2: The output file is automatically closed and deleted.

This is required because in general the automatic file overflow described above may happen during the merge. If only the current file is produced (the file passed as first argument), one can instruct Merge to not close and delete the file by specifying the option "keep".

The function returns the total number of files produced. To check that all files have been merged use something like:

if (newchain->GetEntries()!=oldchain->GetEntries()) {
... not all the file have been copied ...
}

Definition at line 1950 of file TChain.cxx.

◆ operator=()

TChain& TChain::operator= ( const TChain )
private

◆ ParseTreeFilename()

void TChain::ParseTreeFilename ( const char *  name,
TString filename,
TString treename,
TString query,
TString suffix,
Bool_t  wildcards 
) const
private

Get the tree url or filename and other information from the name.

A treename and a url's query section is split off from name. The splitting depends on whether the resulting filename is to be subsequently treated for wildcards or not, since the question mark is both the url query identifier and a wildcard. Wildcard matching is not done in this method itself.

[xxx://host]/a/path/file.root[/treename]
[xxx://host]/a/path/file.root[/treename][?query]
[xxx://host]/a/path/file.root[?query[#treename]]

Note that in a case like this

[xxx://host]/a/path/file#treename

i.e. anchor but no options (query), the filename will be the full path, as the ancho may be the internal file name of an archive.

Parameters
[in]nameis the original name
[in]wildcardsindicates if the resulting filename will be treated for wildcards. For backwards compatibility, with most protocols this flag suppresses the search for the url fragment identifier and limits the query identifier search to cases where the tree name is given as a trailing slash-separated string at the end of the file name.
[out]filenamethe url or filename to be opened or matched
[out]treenamethe treename, which may be found as a trailing part of the name or in a url fragment section. If not found this will be empty.
[out]queryis the url query section, including the leading question mark. If not found or the query section is only followed by a fragment this will be empty.
[out]suffixthe portion of name which was removed to form filename.

Definition at line 2086 of file TChain.cxx.

◆ Print()

void TChain::Print ( Option_t option = "") const
virtual

Print the header information of each tree in the chain.

See TTree::Print for a list of options.

Reimplemented from TTree.

Definition at line 2135 of file TChain.cxx.

◆ Process() [1/2]

Long64_t TChain::Process ( const char *  filename,
Option_t option = "",
Long64_t  nentries = kMaxEntries,
Long64_t  firstentry = 0 
)
virtual

Process all entries in this chain, calling functions in filename.

The return value is -1 in case of error and TSelector::GetStatus() in in case of success. See TTree::Process.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 2158 of file TChain.cxx.

◆ Process() [2/2]

Long64_t TChain::Process ( TSelector selector,
Option_t option = "",
Long64_t  nentries = kMaxEntries,
Long64_t  firstentry = 0 
)
virtual

Process this chain executing the code in selector.

The return value is -1 in case of error and TSelector::GetStatus() in in case of success.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 2180 of file TChain.cxx.

◆ RecursiveRemove()

void TChain::RecursiveRemove ( TObject obj)
virtual

Make sure that obj (which is being deleted or will soon be) is no longer referenced by this TTree.

Reimplemented from TTree.

Definition at line 2198 of file TChain.cxx.

◆ ReleaseChainProof()

void TChain::ReleaseChainProof ( )
protected

◆ RemoveFriend()

void TChain::RemoveFriend ( TTree oldFriend)
virtual

Remove a friend from the list of friends.

Reimplemented from TTree.

Definition at line 2217 of file TChain.cxx.

◆ Reset()

void TChain::Reset ( Option_t option = "")
virtual

Resets the state of this chain.

Reimplemented from TTree.

Definition at line 2240 of file TChain.cxx.

◆ ResetAfterMerge()

void TChain::ResetAfterMerge ( TFileMergeInfo info)
virtual

Resets the state of this chain after a merge (keep the customization but forget the data).

Reimplemented from TTree.

Definition at line 2262 of file TChain.cxx.

◆ ResetBranchAddress()

void TChain::ResetBranchAddress ( TBranch branch)
virtual

Reset the addresses of the branch.

Reimplemented from TTree.

Definition at line 2330 of file TChain.cxx.

◆ ResetBranchAddresses()

void TChain::ResetBranchAddresses ( )
virtual

Reset the addresses of the branches.

Reimplemented from TTree.

Definition at line 2344 of file TChain.cxx.

◆ Scan()

Long64_t TChain::Scan ( const char *  varexp = "",
const char *  selection = "",
Option_t option = "",
Long64_t  nentries = kMaxEntries,
Long64_t  firstentry = 0 
)
virtual

Loop on tree and print entries passing selection.

  • If varexp is 0 (or "") then print only first 8 columns.
  • If varexp = "*" print all columns.
  • Otherwise a columns selection can be made using "var1:var2:var3". See TTreePlayer::Scan for more information.

Reimplemented from TTree.

Definition at line 2281 of file TChain.cxx.

◆ SetAutoDelete()

void TChain::SetAutoDelete ( Bool_t  autodelete = kTRUE)
virtual

Set the global branch kAutoDelete bit.

When LoadTree loads a new Tree, the branches for which the address is set will have the option AutoDelete set For more details on AutoDelete, see TBranch::SetAutoDelete.

Definition at line 2296 of file TChain.cxx.

◆ SetBranchAddress() [1/5]

Int_t TChain::SetBranchAddress ( const char *  bname,
void add,
TBranch **  ptr = 0 
)
virtual

Set branch address.

Parameters
[in]bnameis the name of a branch.
[in]addis the address of the branch.
[in]ptrNote: See the comments in TBranchElement::SetAddress() for a more detailed discussion of the meaning of the add parameter.

IMPORTANT REMARK:

In case TChain::SetBranchStatus is called, it must be called BEFORE calling this function.

See TTree::CheckBranchAddressType for the semantic of the return value.

Reimplemented from TTree.

Definition at line 2373 of file TChain.cxx.

◆ SetBranchAddress() [2/5]

Int_t TChain::SetBranchAddress ( const char *  bname,
void add,
TBranch **  ptr,
TClass realClass,
EDataType  datatype,
Bool_t  isptr 
)
virtual

Check if bname is already in the status list, and if not, create a TChainElement object and set its address.

See TTree::CheckBranchAddressType for the semantic of the return value.

Note: See the comments in TBranchElement::SetAddress() for a more detailed discussion of the meaning of the add parameter.

Reimplemented from TTree.

Definition at line 2438 of file TChain.cxx.

◆ SetBranchAddress() [3/5]

Int_t TChain::SetBranchAddress ( const char *  bname,
void add,
TClass realClass,
EDataType  datatype,
Bool_t  isptr 
)
virtual

Check if bname is already in the status list, and if not, create a TChainElement object and set its address.

See TTree::CheckBranchAddressType for the semantic of the return value.

Note: See the comments in TBranchElement::SetAddress() for a more detailed discussion of the meaning of the add parameter.

Reimplemented from TTree.

Definition at line 2426 of file TChain.cxx.

◆ SetBranchAddress() [4/5]

template<class T >
Int_t TChain::SetBranchAddress ( const char *  bname,
T **  add,
TBranch **  ptr = 0 
)
inline

Definition at line 143 of file TChain.h.

◆ SetBranchAddress() [5/5]

template<class T >
Int_t TChain::SetBranchAddress ( const char *  bname,
T *  add,
TBranch **  ptr = 0 
)
inline

Definition at line 149 of file TChain.h.

◆ SetBranchStatus()

void TChain::SetBranchStatus ( const char *  bname,
Bool_t  status = 1,
UInt_t found = 0 
)
virtual

Set branch status to Process or DoNotProcess.

Parameters
[in]bnameis the name of a branch. if bname="*", apply to all branches.
[in]status= 1 branch will be processed, = 0 branch will not be processed
[out]foundSee IMPORTANT REMARKS in TTree::SetBranchStatus and TChain::SetBranchAddress

If found is not 0, the number of branch(es) found matching the regular expression is returned in *found AND the error message 'unknown branch' is suppressed.

Reimplemented from TTree.

Definition at line 2468 of file TChain.cxx.

◆ SetCacheSize()

Int_t TChain::SetCacheSize ( Long64_t  cacheSize = -1)
virtual

Set maximum size of the file cache .

  • if cachesize = 0 the existing cache (if any) is deleted.
  • if cachesize = -1 (default) it is set to the AutoFlush value when writing the Tree (default is 30 MBytes).

Returns:

  • 0 size set, cache was created if possible
  • -1 on error

Reimplemented from TTree.

Definition at line 2305 of file TChain.cxx.

◆ SetDirectory()

void TChain::SetDirectory ( TDirectory dir)
virtual

Remove reference to this chain from current directory and add reference to new directory dir.

dir can be 0 in which case the chain does not belong to any directory.

Reimplemented from TTree.

Definition at line 2495 of file TChain.cxx.

◆ SetEntryList()

void TChain::SetEntryList ( TEntryList elist,
Option_t opt = "" 
)
virtual

Set the input entry list (processing the entries of the chain will then be limited to the entries in the list) This function finds correspondance between the sub-lists of the TEntryList and the trees of the TChain By default (opt=""), both the file names of the chain elements and the file names of the TEntryList sublists are expanded to full path name.

If opt = "ne", the file names are taken as they are and not expanded

Reimplemented from TTree.

Definition at line 2517 of file TChain.cxx.

◆ SetEntryListFile()

void TChain::SetEntryListFile ( const char *  filename = "",
Option_t opt = "" 
)
virtual

Set the input entry list (processing the entries of the chain will then be limited to the entries in the list).

This function creates a special kind of entry list (TEntryListFromFile object) that loads lists, corresponding to the chain elements, one by one, so that only one list is in memory at a time.

If there is an error opening one of the files, this file is skipped and the next file is loaded

File naming convention:

  • by default, filename_elist.root is used, where filename is the name of the chain element
  • xxx$xxx.root - $ sign is replaced by the name of the chain element

If the list name is not specified (by passing filename_elist.root/listname to the TChain::SetEntryList() function, the first object of class TEntryList in the file is taken.

It is assumed, that there are as many list files, as there are elements in the chain and they are in the same order

Definition at line 2612 of file TChain.cxx.

◆ SetEventList()

void TChain::SetEventList ( TEventList evlist)
virtual

This function transfroms the given TEventList into a TEntryList.

NOTE, that this function loads all tree headers, because the entry numbers in the TEventList are global and have to be recomputed, taking into account the number of entries in each tree.

The new TEntryList is owned by the TChain and gets deleted when the chain is deleted. This TEntryList is returned by GetEntryList() function, and after GetEntryList() function is called, the TEntryList is not owned by the chain any more and will not be deleted with it.

Reimplemented from TTree.

Reimplemented in TProofChain.

Definition at line 2658 of file TChain.cxx.

◆ SetMakeClass()

virtual void TChain::SetMakeClass ( Int_t  make)
inlinevirtual

Set all the branches in this TTree to be in decomposed object mode (also known as MakeClass mode).

Reimplemented from TTree.

Definition at line 160 of file TChain.h.

◆ SetPacketSize()

void TChain::SetPacketSize ( Int_t  size = 100)
virtual

Set number of entries per packet for parallel root.

Definition at line 2733 of file TChain.cxx.

◆ SetProof()

void TChain::SetProof ( Bool_t  on = kTRUE,
Bool_t  refresh = kFALSE,
Bool_t  gettreeheader = kFALSE 
)
virtual

Enable/Disable PROOF processing on the current default Proof (gProof).

"Draw" and "Processed" commands will be handled by PROOF. The refresh and gettreeheader are meaningful only if on == kTRUE. If refresh is kTRUE the underlying fProofChain (chain proxy) is always rebuilt (even if already existing). If gettreeheader is kTRUE the header of the tree will be read from the PROOF cluster: this is only needed for browsing and should be used with care because it may take a long time to execute.

Definition at line 2754 of file TChain.cxx.

◆ SetWeight()

void TChain::SetWeight ( Double_t  w = 1,
Option_t option = "" 
)
virtual

Set chain weight.

The weight is used by TTree::Draw to automatically weight each selected entry in the resulting histogram. For example the equivalent of

chain.Draw("x","w")

is

chain.SetWeight(w,"global");
chain.Draw("x");

By default the weight used will be the weight of each Tree in the TChain. However, one can force the individual weights to be ignored by specifying the option "global". In this case, the TChain global weight will be used for all Trees.

Reimplemented from TTree.

Definition at line 2801 of file TChain.cxx.

◆ UseCache()

void TChain::UseCache ( Int_t  maxCacheSize = 10,
Int_t  pageSize = 0 
)
virtual

Dummy function kept for back compatibility.

The cache is now activated automatically when processing TTrees/TChain.

Definition at line 2857 of file TChain.cxx.

Member Data Documentation

◆ fCanDeleteRefs

Bool_t TChain::fCanDeleteRefs
protected

! If true, TProcessIDs are deleted when closing a file

Definition at line 40 of file TChain.h.

◆ fFile

TFile* TChain::fFile
protected

! Pointer to current file (We own the file).

Definition at line 42 of file TChain.h.

◆ fFiles

TObjArray* TChain::fFiles
protected

-> List of file names containing the trees (TChainElement, owned)

Definition at line 43 of file TChain.h.

◆ fNtrees

Int_t TChain::fNtrees
protected

Number of trees.

Definition at line 37 of file TChain.h.

◆ fProofChain

TChain* TChain::fProofChain
protected

! chain proxy when going to be processed by PROOF

Definition at line 45 of file TChain.h.

◆ fStatus

TList* TChain::fStatus
protected

-> List of active/inactive branches (TChainElement, owned)

Definition at line 44 of file TChain.h.

◆ fTree

TTree* TChain::fTree
protected

! Pointer to current tree (Note: We do not own this tree.)

Definition at line 41 of file TChain.h.

◆ fTreeNumber

Int_t TChain::fTreeNumber
protected

! Current Tree number in fTreeOffset table

Definition at line 38 of file TChain.h.

◆ fTreeOffset

Long64_t* TChain::fTreeOffset
protected

[fTreeOffsetLen] Array of variables

Definition at line 39 of file TChain.h.

◆ fTreeOffsetLen

Int_t TChain::fTreeOffsetLen
protected

Current size of fTreeOffset array.

Definition at line 36 of file TChain.h.

◆ kBigNumber

constexpr auto TChain::kBigNumber = TTree::kMaxEntries
static

Definition at line 66 of file TChain.h.


The documentation for this class was generated from the following files: