ROOT logo
// @(#)root/tree:$Id$
// Author: Anna Kreshuk 27/10/2006

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TEntryList
#define ROOT_TEntryList

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

class TTree;
class TDirectory;
class TObjArray;
class TString;

class TList;
class TCollection;

class TEntryList: public TNamed 
{
 private:
   TEntryList& operator=(const TEntryList&); // Not implemented

 protected:
   TList      *fLists;   //a list of underlying entry lists for each tree of a chain
   TEntryList *fCurrent; //! currently filled entry list

   Int_t            fNBlocks;   //number of TEntryListBlocks
   TObjArray       *fBlocks;    //blocks with indices of passing events (TEntryListBlocks)
   Long64_t         fN;         //number of entries in the list
   Long64_t         fEntriesToProcess; //used on proof to set the number of entries to process in a packet
   TString          fTreeName;  //name of the tree
   TString          fFileName;  //name of the file, where the tree is
   ULong_t          fStringHash;//! Hash value of a string of treename and filename
   Int_t            fTreeNumber;//! the index of the tree in the chain (used when the entry
                                //list is used as input (TTree::SetEntryList())

   Long64_t         fLastIndexQueried; //! used to optimize GetEntry() function from a loop 
   Long64_t         fLastIndexReturned; //! used to optimize GetEntry() function from a loop
   Bool_t           fShift;            //! true when some sub-lists don't correspond to trees
                                       //(when the entry list is used as input in TChain)
   TDirectory      *fDirectory;   //! Pointer to directory holding this tree
   Bool_t           fReapply;     //  If true, TTree::Draw will 'reapply' the original cut

   void             GetFileName(const char *filename, TString &fn, Bool_t * = 0);

 public:
   enum {kBlockSize = 64000}; //number of entries in each block (not the physical size).

   TEntryList();
   TEntryList(const char *name, const char *title);
   TEntryList(const char *name, const char *title, const TTree *tree);
   TEntryList(const char *name, const char *title, const char *treename, const char *filename);
   TEntryList(const TTree *tree);
   TEntryList(const TEntryList& elist);
   virtual ~TEntryList();

   virtual void        Add(const TEntryList *elist);
   virtual Int_t       Contains(Long64_t entry, TTree *tree = 0);
   virtual void        DirectoryAutoAdd(TDirectory *);
   virtual Bool_t      Enter(Long64_t entry, TTree *tree = 0);
   virtual TEntryList *GetCurrentList() const { return fCurrent; };
   virtual TEntryList *GetEntryList(const char *treename, const char *filename, Option_t *opt="");
   virtual Long64_t    GetEntry(Int_t index);
   virtual Long64_t    GetEntryAndTree(Int_t index, Int_t &treenum);
   virtual Long64_t    GetEntriesToProcess() const {return fEntriesToProcess;}
   virtual TList      *GetLists() const { return fLists; }
   virtual TDirectory *GetDirectory() const { return fDirectory; }
   virtual Long64_t    GetN() const { return fN; }
   virtual const char *GetTreeName() const { return fTreeName.Data(); }
   virtual const char *GetFileName() const { return fFileName.Data(); }
   virtual Int_t       GetTreeNumber() const { return fTreeNumber; }
   virtual Bool_t      GetReapplyCut() const { return fReapply; };
   virtual Int_t       Merge(TCollection *list);
   
   virtual Long64_t    Next();
   virtual void        OptimizeStorage();
   virtual Int_t       RelocatePaths(const char *newloc, const char *oldloc = 0);
   virtual Bool_t      Remove(Long64_t entry, TTree *tree = 0);
   virtual void        Reset();
   virtual Int_t       ScanPaths(TList *roots, Bool_t notify = kTRUE);

   virtual void        Print(const Option_t* option = "") const;
   virtual void        SetDirectory(TDirectory *dir);
   virtual void        SetEntriesToProcess(Long64_t nen) { fEntriesToProcess = nen; }
   virtual void        SetShift(Bool_t shift) { fShift = shift; };
   virtual void        SetTree(const TTree *tree);
   virtual void        SetTree(const char *treename, const char *filename);
   virtual void        SetTreeName(const char *treename){ fTreeName = treename; };
   virtual void        SetFileName(const char *filename){ fFileName = filename; };
   virtual void        SetTreeNumber(Int_t index) { fTreeNumber=index;  }
   virtual void        SetReapplyCut(Bool_t apply = kFALSE) {fReapply = apply;}; // *TOGGLE*
   virtual void        Subtract(const TEntryList *elist);

   static  Int_t       Relocate(const char *fn,
                                const char *newroot, const char *oldroot = 0, const char *enlnm = 0);
   static  Int_t       Scan(const char *fn, TList *roots);

// Preventing warnings with -Weffc++ in GCC since the overloading of the || operator was a design choice.
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
   friend TEntryList operator||(TEntryList& elist1, TEntryList& elist2);
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
#pragma GCC diagnostic pop
#endif

   ClassDef(TEntryList, 2);  //A list of entries in a TTree
};
#endif
 TEntryList.h:1
 TEntryList.h:2
 TEntryList.h:3
 TEntryList.h:4
 TEntryList.h:5
 TEntryList.h:6
 TEntryList.h:7
 TEntryList.h:8
 TEntryList.h:9
 TEntryList.h:10
 TEntryList.h:11
 TEntryList.h:12
 TEntryList.h:13
 TEntryList.h:14
 TEntryList.h:15
 TEntryList.h:16
 TEntryList.h:17
 TEntryList.h:18
 TEntryList.h:19
 TEntryList.h:20
 TEntryList.h:21
 TEntryList.h:22
 TEntryList.h:23
 TEntryList.h:24
 TEntryList.h:25
 TEntryList.h:26
 TEntryList.h:27
 TEntryList.h:28
 TEntryList.h:29
 TEntryList.h:30
 TEntryList.h:31
 TEntryList.h:32
 TEntryList.h:33
 TEntryList.h:34
 TEntryList.h:35
 TEntryList.h:36
 TEntryList.h:37
 TEntryList.h:38
 TEntryList.h:39
 TEntryList.h:40
 TEntryList.h:41
 TEntryList.h:42
 TEntryList.h:43
 TEntryList.h:44
 TEntryList.h:45
 TEntryList.h:46
 TEntryList.h:47
 TEntryList.h:48
 TEntryList.h:49
 TEntryList.h:50
 TEntryList.h:51
 TEntryList.h:52
 TEntryList.h:53
 TEntryList.h:54
 TEntryList.h:55
 TEntryList.h:56
 TEntryList.h:57
 TEntryList.h:58
 TEntryList.h:59
 TEntryList.h:60
 TEntryList.h:61
 TEntryList.h:62
 TEntryList.h:63
 TEntryList.h:64
 TEntryList.h:65
 TEntryList.h:66
 TEntryList.h:67
 TEntryList.h:68
 TEntryList.h:69
 TEntryList.h:70
 TEntryList.h:71
 TEntryList.h:72
 TEntryList.h:73
 TEntryList.h:74
 TEntryList.h:75
 TEntryList.h:76
 TEntryList.h:77
 TEntryList.h:78
 TEntryList.h:79
 TEntryList.h:80
 TEntryList.h:81
 TEntryList.h:82
 TEntryList.h:83
 TEntryList.h:84
 TEntryList.h:85
 TEntryList.h:86
 TEntryList.h:87
 TEntryList.h:88
 TEntryList.h:89
 TEntryList.h:90
 TEntryList.h:91
 TEntryList.h:92
 TEntryList.h:93
 TEntryList.h:94
 TEntryList.h:95
 TEntryList.h:96
 TEntryList.h:97
 TEntryList.h:98
 TEntryList.h:99
 TEntryList.h:100
 TEntryList.h:101
 TEntryList.h:102
 TEntryList.h:103
 TEntryList.h:104
 TEntryList.h:105
 TEntryList.h:106
 TEntryList.h:107
 TEntryList.h:108
 TEntryList.h:109
 TEntryList.h:110
 TEntryList.h:111
 TEntryList.h:112
 TEntryList.h:113
 TEntryList.h:114
 TEntryList.h:115
 TEntryList.h:116
 TEntryList.h:117
 TEntryList.h:118
 TEntryList.h:119