Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:29:35

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 #include <limits>
0039 
0040 class TFile;
0041 
0042 class TEntryListFromFile: public TEntryList
0043 {
0044 protected:
0045    TString    fListFileName;  ///<  from this string names of all files can be found
0046    TString    fListName;      ///<  name of the list
0047    Int_t      fNFiles;        ///<  total number of files
0048    Long64_t   *fListOffset;   ///<[fNFiles] numbers of entries in ind. lists
0049    TFile      *fFile;         ///< currently open file
0050                               ///<  fCurrent points to the currently open list
0051    TObjArray *fFileNames;     ///<! points to the fFiles data member of the corresponding chain
0052 
0053    // Obsolete use TTree::kMaxEntries
0054    static constexpr auto kBigNumber = std::numeric_limits<Long64_t>::max();
0055 
0056 private:
0057    TEntryListFromFile(const TEntryListFromFile&);            // Not implemented.
0058    TEntryListFromFile &operator=(const TEntryListFromFile&); // Not implemented.
0059 
0060 public:
0061 
0062    TEntryListFromFile();
0063    TEntryListFromFile(const char *filename, const char *listname, Int_t nfiles);
0064    ~TEntryListFromFile() override;
0065    void        Add(const TEntryList * /* elist */) override {};
0066    Int_t       Contains(Long64_t /* entry */, TTree * /* tree = 0 */) override { return 0; };
0067    bool        Enter(Long64_t /* entry */, TTree * /* tree = 0 */) override { return false; };
0068    bool        Enter(Long64_t /* entry */, const char * /* treename */, const char * /* filename */) override { return false; };
0069    TEntryList *GetCurrentList() const override { return fCurrent; };
0070    TEntryList *GetEntryList(const char * /* treename */, const char * /* filename */, Option_t * /* opt="" */) override { return nullptr; };
0071 
0072    Long64_t    GetEntry(Long64_t index) override;
0073    Long64_t    GetEntryAndTree(Long64_t index, Int_t &treenum) override;
0074    virtual Long64_t    GetEntries();
0075    virtual Long64_t    GetEntriesFast() const { return fN; }
0076 
0077    Long64_t    GetN() const override { return fN; }
0078    const char *GetTreeName() const override { return fTreeName.Data(); }
0079    const char *GetFileName() const override { return fFileName.Data(); }
0080    Int_t       GetTreeNumber() const override { return fTreeNumber; }
0081 
0082    virtual Int_t       LoadList(Int_t listnumber);
0083 
0084    Int_t       Merge(TCollection * /*list*/) override{ return 0; }
0085 
0086    Long64_t    Next() override;
0087    void        OptimizeStorage() override {};
0088    bool        Remove(Long64_t /*entry*/, TTree * /*tree = nullptr */) override{ return false; }
0089 
0090    void        Print(const Option_t* option = "") const override;
0091 
0092    void        SetTree(const TTree * /*tree*/) override {}
0093    void        SetTree(const char * /*treename*/, const char * /*filename*/) override {}
0094    virtual void        SetFileNames(TObjArray *names) { fFileNames = names; }
0095    void        SetTreeNumber(Int_t index) override { fTreeNumber=index;  }
0096    virtual void        SetNFiles(Int_t nfiles) { fNFiles = nfiles; }
0097    void        Subtract(const TEntryList * /*elist*/) override {}
0098 
0099    ClassDefOverride(TEntryListFromFile, 1); //Manager for entry lists from different files
0100 };
0101 #endif