Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEntryListFromFile.h
Go to the documentation of this file.
1// @(#)root/tree:$Id$
2// Author: Anna Kreshuk 17/03/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TEntryListFromFile
13#define ROOT_TEntryListFromFile
14
15//////////////////////////////////////////////////////////////////////////
16// TEntryListFromFile
17//
18// Manages entry lists from different files, when they are not loaded
19// in memory at the same time.
20//
21// This entry list should only be used when processing a TChain (see
22// TChain::SetEntryList() function). File naming convention:
23// - by default, filename_elist.root is used, where filename is the
24// name of the chain element.
25// - xxx$xxx.root - $ sign is replaced by the name of the chain element
26// If the list name is not specified (by passing filename_elist.root/listname to
27// the TChain::SetEntryList() function, the first object of class TEntryList
28// in the file is taken.
29// It is assumed that there are as many lists, as there are chain elements,
30// and they are in the same order.
31//
32// If one of the list files can't be opened, or there is an error reading a list
33// from the file, this list is skipped and the entry loop continues on the next
34// list.
35
36#include "TEntryList.h"
37
38class TFile;
39
41{
42protected:
43 TString fListFileName; ///< from this string names of all files can be found
44 TString fListName; ///< name of the list
45 Int_t fNFiles; ///< total number of files
46 Long64_t *fListOffset; ///<[fNFiles] numbers of entries in ind. lists
47 TFile *fFile; ///< currently open file
48 ///< fCurrent points to the currently open list
49 TObjArray *fFileNames; ///<! points to the fFiles data member of the corresponding chain
50
51 // Obsolete use TTree::kMaxEntries
52 static constexpr auto kBigNumber = std::numeric_limits<Long64_t>::max();
53
54private:
55 TEntryListFromFile(const TEntryListFromFile&); // Not implemented.
56 TEntryListFromFile &operator=(const TEntryListFromFile&); // Not implemented.
57
58public:
59
61 TEntryListFromFile(const char *filename, const char *listname, Int_t nfiles);
62 virtual ~TEntryListFromFile();
63 virtual void Add(const TEntryList * /*elist*/){};
64 virtual Int_t Contains(Long64_t /*entry*/, TTree * /*tree = 0*/) {return 0;};
65 virtual Bool_t Enter(Long64_t /*entry*/, TTree * /*tree = 0*/){return 0;};
66 virtual TEntryList *GetCurrentList() const { return fCurrent; };
67 virtual TEntryList *GetEntryList(const char * /*treename*/, const char * /*filename*/, Option_t * /*opt=""*/) {return 0;};
68
69 virtual Long64_t GetEntry(Long64_t index);
70 virtual Long64_t GetEntryAndTree(Long64_t index, Int_t &treenum);
71 virtual Long64_t GetEntries();
72 virtual Long64_t GetEntriesFast() const { return fN; };
73
74 virtual Long64_t GetN() const { return fN; }
75 virtual const char *GetTreeName() const { return fTreeName.Data(); }
76 virtual const char *GetFileName() const { return fFileName.Data(); }
77 virtual Int_t GetTreeNumber() const { return fTreeNumber; }
78
79 virtual Int_t LoadList(Int_t listnumber);
80
81 virtual Int_t Merge(TCollection * /*list*/){ return 0; };
82
83 virtual Long64_t Next();
84 virtual void OptimizeStorage() {};
85 virtual Bool_t Remove(Long64_t /*entry*/, TTree * /*tree = 0*/){ return 0; };
86
87 virtual void Print(const Option_t* option = "") const;
88
89 virtual void SetTree(const TTree * /*tree*/){};
90 virtual void SetTree(const char * /*treename*/, const char * /*filename*/){};
91 virtual void SetFileNames(TObjArray *names) { fFileNames = names; }
92 virtual void SetTreeNumber(Int_t index) { fTreeNumber=index; }
93 virtual void SetNFiles(Int_t nfiles) { fNFiles = nfiles; }
94 virtual void Subtract(const TEntryList * /*elist*/) {};
95
96 ClassDef(TEntryListFromFile, 1); //Manager for entry lists from different files
97};
98#endif
int Int_t
Definition RtypesCore.h:45
long long Long64_t
Definition RtypesCore.h:80
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
Collection abstract base class.
Definition TCollection.h:65
Manages entry lists from different files, when they are not loaded in memory at the same time.
virtual ~TEntryListFromFile()
d-tor
virtual Int_t Contains(Long64_t, TTree *)
TString fListName
name of the list
virtual Bool_t Enter(Long64_t, TTree *)
Add entry #entry to the list.
virtual void OptimizeStorage()
Checks if the array representation is more economical and if so, switches to it.
virtual Long64_t Next()
Returns the next entry in the list.
TEntryListFromFile & operator=(const TEntryListFromFile &)
virtual TEntryList * GetCurrentList() const
virtual Int_t LoadList(Int_t listnumber)
Loads the list #listnumber This is the only function that can modify fCurrent and fFile data members.
virtual Int_t Merge(TCollection *)
Merge this list with the lists from the collection.
virtual void SetTreeNumber(Int_t index)
virtual void SetNFiles(Int_t nfiles)
TFile * fFile
currently open file fCurrent points to the currently open list
virtual void SetFileNames(TObjArray *names)
Int_t fNFiles
total number of files
virtual TEntryList * GetEntryList(const char *, const char *, Option_t *)
Return the entry list, corresponding to treename and filename By default, the filename is first tried...
virtual void Print(const Option_t *option="") const
Print info about this list.
virtual Long64_t GetEntryAndTree(Long64_t index, Int_t &treenum)
Return the entry corresponding to the index parameter and the number of the tree, where this entry is...
virtual Long64_t GetEntries()
Returns the total number of entries in the list.
static constexpr auto kBigNumber
TEntryListFromFile(const TEntryListFromFile &)
virtual void SetTree(const char *, const char *)
If a list for a tree with such name and filename exists, sets it as the current sublist If not,...
virtual Bool_t Remove(Long64_t, TTree *)
Remove entry #entry from the list.
virtual void SetTree(const TTree *)
If a list for a tree with such name and filename exists, sets it as the current sublist If not,...
TString fListFileName
from this string names of all files can be found
virtual Long64_t GetN() const
TObjArray * fFileNames
! points to the fFiles data member of the corresponding chain
virtual void Subtract(const TEntryList *)
Remove all the entries of this entry list, that are contained in elist.
Long64_t * fListOffset
[fNFiles] numbers of entries in ind. lists
virtual const char * GetTreeName() const
virtual Long64_t GetEntriesFast() const
virtual Long64_t GetEntry(Long64_t index)
Returns entry #index See also Next() for a faster alternative.
virtual Int_t GetTreeNumber() const
virtual const char * GetFileName() const
virtual void Add(const TEntryList *)
Add 2 entry lists.
A List of entry numbers in a TTree or TChain.
Definition TEntryList.h:26
TString fFileName
name of the file, where the tree is
Definition TEntryList.h:39
Int_t fTreeNumber
! the index of the tree in the chain (used when the entry list is used as input (TTree::SetEntryList(...
Definition TEntryList.h:41
Long64_t fN
number of entries in the list
Definition TEntryList.h:36
TEntryList * fCurrent
! currently filled entry list
Definition TEntryList.h:32
TString fTreeName
name of the tree
Definition TEntryList.h:38
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
An array of TObjects.
Definition TObjArray.h:31
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
A TTree represents a columnar dataset.
Definition TTree.h:79