ROOT logo
// @(#)root/tree:$Id: TEntryListFromFile.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Anna Kreshuk 17/03/2007

/*************************************************************************
 * Copyright (C) 1995-2007, 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_TEntryListFromFile
#define ROOT_TEntryListFromFile

//////////////////////////////////////////////////////////////////////////
// TEntryListFromFile
//
// Manages entry lists from different files, when they are not loaded
// in memory at the same time. 
//
// This entry list should only be used when processing a TChain (see
// TChain::SetEntryList() function). 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 lists, as there are chain elements,
// and they are in the same order.
//
// If one of the list files can't be opened, or there is an error reading a list
// from the file, this list is skipped and the entry loop continues on the next
// list.

#include "TEntryList.h"

class TFile;

class TEntryListFromFile: public TEntryList 
{
 protected:
   TString    fListFileName;  //from this string names of all files can be found
   TString    fListName;      //name of the list
   Int_t      fNFiles;        //total number of files
   Long64_t   *fListOffset;   //[fNFiles] numbers of entries in ind. lists
   TFile      *fFile;         //currently open file
                              //fCurrent points to the currently open list
   TObjArray *fFileNames;     //! points to the fFiles data member of the corresponding chain
   
 public:

   enum {
      kBigNumber = 1234567890
   };

   TEntryListFromFile();
   TEntryListFromFile(const char *filename, const char *listname, Int_t nfiles);
   virtual ~TEntryListFromFile();
   virtual void        Add(const TEntryList * /*elist*/){};
   virtual Int_t       Contains(Long64_t /*entry*/, TTree * /*tree = 0*/)  {return 0;};
   virtual Bool_t      Enter(Long64_t /*entry*/, TTree * /*tree = 0*/){return 0;};
   virtual TEntryList *GetCurrentList() const { return fCurrent; };
   virtual TEntryList *GetEntryList(const char * /*treename*/, const char * /*filename*/, Option_t * /*opt=""*/) {return 0;};
   
   virtual Long64_t    GetEntry(Int_t index);
   virtual Long64_t    GetEntryAndTree(Int_t index, Int_t &treenum);
   virtual Long64_t    GetEntries();
   virtual Long64_t    GetEntriesFast() const { return fN; };
   
   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 Int_t       LoadList(Int_t listnumber);
   
   virtual Int_t       Merge(TCollection * /*list*/){ return 0; };
   
   virtual Long64_t    Next();
   virtual void        OptimizeStorage() {};
   virtual Bool_t      Remove(Long64_t /*entry*/, TTree * /*tree = 0*/){ return 0; };
   
   virtual void        Print(const Option_t* option = "") const;

   virtual void        SetTree(const TTree * /*tree*/){};
   virtual void        SetTree(const char * /*treename*/, const char * /*filename*/){};
   virtual void        SetFileNames(TObjArray *names) { fFileNames = names; }
   virtual void        SetTreeNumber(Int_t index) { fTreeNumber=index;  }
   virtual void        SetNFiles(Int_t nfiles) { fNFiles = nfiles; }
   virtual void        Subtract(const TEntryList * /*elist*/) {};
   
   ClassDef(TEntryListFromFile, 1); //Manager for entry lists from different files
};
#endif
 TEntryListFromFile.h:1
 TEntryListFromFile.h:2
 TEntryListFromFile.h:3
 TEntryListFromFile.h:4
 TEntryListFromFile.h:5
 TEntryListFromFile.h:6
 TEntryListFromFile.h:7
 TEntryListFromFile.h:8
 TEntryListFromFile.h:9
 TEntryListFromFile.h:10
 TEntryListFromFile.h:11
 TEntryListFromFile.h:12
 TEntryListFromFile.h:13
 TEntryListFromFile.h:14
 TEntryListFromFile.h:15
 TEntryListFromFile.h:16
 TEntryListFromFile.h:17
 TEntryListFromFile.h:18
 TEntryListFromFile.h:19
 TEntryListFromFile.h:20
 TEntryListFromFile.h:21
 TEntryListFromFile.h:22
 TEntryListFromFile.h:23
 TEntryListFromFile.h:24
 TEntryListFromFile.h:25
 TEntryListFromFile.h:26
 TEntryListFromFile.h:27
 TEntryListFromFile.h:28
 TEntryListFromFile.h:29
 TEntryListFromFile.h:30
 TEntryListFromFile.h:31
 TEntryListFromFile.h:32
 TEntryListFromFile.h:33
 TEntryListFromFile.h:34
 TEntryListFromFile.h:35
 TEntryListFromFile.h:36
 TEntryListFromFile.h:37
 TEntryListFromFile.h:38
 TEntryListFromFile.h:39
 TEntryListFromFile.h:40
 TEntryListFromFile.h:41
 TEntryListFromFile.h:42
 TEntryListFromFile.h:43
 TEntryListFromFile.h:44
 TEntryListFromFile.h:45
 TEntryListFromFile.h:46
 TEntryListFromFile.h:47
 TEntryListFromFile.h:48
 TEntryListFromFile.h:49
 TEntryListFromFile.h:50
 TEntryListFromFile.h:51
 TEntryListFromFile.h:52
 TEntryListFromFile.h:53
 TEntryListFromFile.h:54
 TEntryListFromFile.h:55
 TEntryListFromFile.h:56
 TEntryListFromFile.h:57
 TEntryListFromFile.h:58
 TEntryListFromFile.h:59
 TEntryListFromFile.h:60
 TEntryListFromFile.h:61
 TEntryListFromFile.h:62
 TEntryListFromFile.h:63
 TEntryListFromFile.h:64
 TEntryListFromFile.h:65
 TEntryListFromFile.h:66
 TEntryListFromFile.h:67
 TEntryListFromFile.h:68
 TEntryListFromFile.h:69
 TEntryListFromFile.h:70
 TEntryListFromFile.h:71
 TEntryListFromFile.h:72
 TEntryListFromFile.h:73
 TEntryListFromFile.h:74
 TEntryListFromFile.h:75
 TEntryListFromFile.h:76
 TEntryListFromFile.h:77
 TEntryListFromFile.h:78
 TEntryListFromFile.h:79
 TEntryListFromFile.h:80
 TEntryListFromFile.h:81
 TEntryListFromFile.h:82
 TEntryListFromFile.h:83
 TEntryListFromFile.h:84
 TEntryListFromFile.h:85
 TEntryListFromFile.h:86
 TEntryListFromFile.h:87
 TEntryListFromFile.h:88
 TEntryListFromFile.h:89
 TEntryListFromFile.h:90
 TEntryListFromFile.h:91
 TEntryListFromFile.h:92
 TEntryListFromFile.h:93
 TEntryListFromFile.h:94
 TEntryListFromFile.h:95