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 17/03/2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, 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_TEntryListFromFile
0013 #define ROOT_TEntryListFromFile
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 // TEntryListFromFile
0017 //
0018 // Manages entry lists from different files, when they are not loaded
0019 // in memory at the same time.
0020 //
0021 // This entry list should only be used when processing a TChain (see
0022 // TChain::SetEntryList() function). File naming convention:
0023 // - by default, filename_elist.root is used, where filename is the
0024 //   name of the chain element.
0025 // - xxx$xxx.root - $ sign is replaced by the name of the chain element
0026 // If the list name is not specified (by passing filename_elist.root/listname to
0027 // the TChain::SetEntryList() function, the first object of class TEntryList
0028 // in the file is taken.
0029 // It is assumed that there are as many lists, as there are chain elements,
0030 // and they are in the same order.
0031 //
0032 // If one of the list files can't be opened, or there is an error reading a list
0033 // from the file, this list is skipped and the entry loop continues on the next
0034 // list.
0035 
0036 #include "TEntryList.h"
0037 
0038 class TFile;
0039 
0040 class TEntryListFromFile: public TEntryList
0041 {
0042 protected:
0043    TString    fListFileName;  ///<  from this string names of all files can be found
0044    TString    fListName;      ///<  name of the list
0045    Int_t      fNFiles;        ///<  total number of files
0046    Long64_t   *fListOffset;   ///<[fNFiles] numbers of entries in ind. lists
0047    TFile      *fFile;         ///< currently open file
0048                               ///<  fCurrent points to the currently open list
0049    TObjArray *fFileNames;     ///<! points to the fFiles data member of the corresponding chain
0050 
0051    // Obsolete use TTree::kMaxEntries
0052    static constexpr auto kBigNumber = std::numeric_limits<Long64_t>::max();
0053 
0054 private:
0055    TEntryListFromFile(const TEntryListFromFile&);            // Not implemented.
0056    TEntryListFromFile &operator=(const TEntryListFromFile&); // Not implemented.
0057 
0058 public:
0059 
0060    TEntryListFromFile();
0061    TEntryListFromFile(const char *filename, const char *listname, Int_t nfiles);
0062    ~TEntryListFromFile() override;
0063    void        Add(const TEntryList * /* elist */) override {};
0064    Int_t       Contains(Long64_t /* entry */, TTree * /* tree = 0 */) override { return 0; };
0065    bool        Enter(Long64_t /* entry */, TTree * /* tree = 0 */) override { return false; };
0066    bool        Enter(Long64_t /* entry */, const char * /* treename */, const char * /* filename */) override { return false; };
0067    TEntryList *GetCurrentList() const override { return fCurrent; };
0068    TEntryList *GetEntryList(const char * /* treename */, const char * /* filename */, Option_t * /* opt="" */) override { return nullptr; };
0069 
0070    Long64_t    GetEntry(Long64_t index) override;
0071    Long64_t    GetEntryAndTree(Long64_t index, Int_t &treenum) override;
0072    virtual Long64_t    GetEntries();
0073    virtual Long64_t    GetEntriesFast() const { return fN; }
0074 
0075    Long64_t    GetN() const override { return fN; }
0076    const char *GetTreeName() const override { return fTreeName.Data(); }
0077    const char *GetFileName() const override { return fFileName.Data(); }
0078    Int_t       GetTreeNumber() const override { return fTreeNumber; }
0079 
0080    virtual Int_t       LoadList(Int_t listnumber);
0081 
0082    Int_t       Merge(TCollection * /*list*/) override{ return 0; }
0083 
0084    Long64_t    Next() override;
0085    void        OptimizeStorage() override {};
0086    bool        Remove(Long64_t /*entry*/, TTree * /*tree = nullptr */) override{ return false; }
0087 
0088    void        Print(const Option_t* option = "") const override;
0089 
0090    void        SetTree(const TTree * /*tree*/) override {}
0091    void        SetTree(const char * /*treename*/, const char * /*filename*/) override {}
0092    virtual void        SetFileNames(TObjArray *names) { fFileNames = names; }
0093    void        SetTreeNumber(Int_t index) override { fTreeNumber=index;  }
0094    virtual void        SetNFiles(Int_t nfiles) { fNFiles = nfiles; }
0095    void        Subtract(const TEntryList * /*elist*/) override {}
0096 
0097    ClassDefOverride(TEntryListFromFile, 1); //Manager for entry lists from different files
0098 };
0099 #endif