Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:39

0001 // @(#)root/tree:$Id$
0002 // Author: Anna Kreshuk 27/10/2006
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TEntryList
0013 #define ROOT_TEntryList
0014 
0015 #include "TNamed.h"
0016 
0017 class TTree;
0018 class TDirectory;
0019 class TObjArray;
0020 class TString;
0021 
0022 class TList;
0023 class TCollection;
0024 
0025 class TEntryList: public TNamed
0026 {
0027  private:
0028    TEntryList& operator=(const TEntryList&); // Not implemented
0029 
0030  protected:
0031    TList      *fLists;                  ///<  a list of underlying entry lists for each tree of a chain
0032    TEntryList *fCurrent;                ///<! currently filled entry list
0033 
0034    Int_t            fNBlocks;           ///<  number of TEntryListBlocks
0035    TObjArray       *fBlocks;            ///<  blocks with indices of passing events (TEntryListBlocks)
0036    Long64_t         fN;                 ///<  number of entries in the list
0037    Long64_t         fEntriesToProcess;  ///<  used on proof to set the number of entries to process in a packet
0038    TString          fTreeName;          ///<  name of the tree
0039    TString          fFileName;          ///<  name of the file, where the tree is
0040    ULong_t          fStringHash;        ///<! Hash value of a string of treename and filename
0041    Int_t            fTreeNumber;        ///<! the index of the tree in the chain (used when the entry
0042                                         ///<  list is used as input (TTree::SetEntryList())
0043 
0044    Long64_t         fLastIndexQueried;  ///<! used to optimize GetEntry() function from a loop
0045    Long64_t         fLastIndexReturned; ///<! used to optimize GetEntry() function from a loop
0046    bool             fShift;             ///<! true when some sub-lists don't correspond to trees
0047                                         ///<  (when the entry list is used as input in TChain)
0048    TDirectory      *fDirectory;         ///<! Pointer to directory holding this tree
0049    bool             fReapply;           ///<  If true, TTree::Draw will 'reapply' the original cut
0050 
0051    void             GetFileName(const char *filename, TString &fn, bool * = nullptr);
0052 
0053  public:
0054    enum {kBlockSize = 64000}; //number of entries in each block (not the physical size).
0055 
0056    TEntryList();
0057    TEntryList(const char *name, const char *title);
0058    TEntryList(const char *name, const char *title, const TTree *tree);
0059    TEntryList(const char *name, const char *title, const char *treename, const char *filename);
0060    TEntryList(const TTree *tree);
0061    TEntryList(const TEntryList& elist);
0062    ~TEntryList() override;
0063 
0064    virtual void        Add(const TEntryList *elist);
0065    void                AddSubList(TEntryList *elist);
0066    virtual Int_t       Contains(Long64_t entry, TTree *tree = nullptr);
0067    virtual void        DirectoryAutoAdd(TDirectory *);
0068    virtual bool        Enter(Long64_t entry, TTree *tree = nullptr);
0069    virtual bool        Enter(Long64_t localentry, const char *treename, const char *filename);
0070    void                EnterRange(Long64_t start, Long64_t end, TTree *tree = nullptr, UInt_t step = 1U);
0071    virtual TEntryList *GetCurrentList() const { return fCurrent; };
0072    virtual TEntryList *GetEntryList(const char *treename, const char *filename, Option_t *opt="");
0073    virtual Long64_t    GetEntry(Long64_t index);
0074    virtual Long64_t    GetEntryAndTree(Long64_t index, Int_t &treenum);
0075    virtual Long64_t    GetEntriesToProcess() const {return fEntriesToProcess;}
0076    virtual TList      *GetLists() const { return fLists; }
0077    virtual TDirectory *GetDirectory() const { return fDirectory; }
0078    virtual Long64_t    GetN() const { return fN; }
0079    virtual const char *GetTreeName() const { return fTreeName.Data(); }
0080    virtual const char *GetFileName() const { return fFileName.Data(); }
0081    virtual Int_t       GetTreeNumber() const { return fTreeNumber; }
0082    virtual bool        GetReapplyCut() const { return fReapply; };
0083 
0084    bool IsValid() const
0085    {
0086       if ((fLists || fBlocks)) return true;
0087       return false;
0088    }
0089 
0090    virtual Int_t       Merge(TCollection *list);
0091 
0092    virtual Long64_t    Next();
0093    virtual void        OptimizeStorage();
0094    virtual Int_t       RelocatePaths(const char *newloc, const char *oldloc = nullptr);
0095    virtual bool        Remove(Long64_t entry, TTree *tree = nullptr);
0096    virtual void        Reset();
0097    virtual Int_t       ScanPaths(TList *roots, bool notify = true);
0098 
0099    void                Print(const Option_t* option = "") const override;
0100    virtual void        SetDirectory(TDirectory *dir);
0101    virtual void        SetEntriesToProcess(Long64_t nen) { fEntriesToProcess = nen; }
0102    virtual void        SetShift(bool shift) { fShift = shift; };
0103    virtual void        SetTree(const TTree *tree);
0104    virtual void        SetTree(const char *treename, const char *filename);
0105    virtual void        SetTreeName(const char *treename){ fTreeName = treename; };
0106    virtual void        SetFileName(const char *filename){ fFileName = filename; };
0107    virtual void        SetTreeNumber(Int_t index) { fTreeNumber=index;  }
0108    virtual void        SetReapplyCut(bool apply = false) {fReapply = apply;}; // *TOGGLE* *GETTER=GetReapplyCut
0109    virtual void        Subtract(const TEntryList *elist);
0110 
0111    static  Int_t       Relocate(const char *fn,
0112                                 const char *newroot, const char *oldroot = nullptr, const char *enlnm = nullptr);
0113    static  Int_t       Scan(const char *fn, TList *roots);
0114 
0115 // Preventing warnings with -Weffc++ in GCC since the overloading of the || operator was a design choice.
0116 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
0117 #pragma GCC diagnostic push
0118 #pragma GCC diagnostic ignored "-Weffc++"
0119 #endif
0120    friend TEntryList operator||(TEntryList& elist1, TEntryList& elist2);
0121 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
0122 #pragma GCC diagnostic pop
0123 #endif
0124 
0125    ClassDefOverride(TEntryList, 2);  //A list of entries in a TTree
0126 };
0127 #endif