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 ~TEntryListFromFile() override;
63 void Add(const TEntryList * /* elist */) override {};
64 Int_t Contains(Long64_t /* entry */, TTree * /* tree = 0 */) override { return 0; };
65 bool Enter(Long64_t /* entry */, TTree * /* tree = 0 */) override { return false; };
66 bool Enter(Long64_t /* entry */, const char * /* treename */, const char * /* filename */) override { return false; };
67 TEntryList *GetCurrentList() const override { return fCurrent; };
68 TEntryList *GetEntryList(const char * /* treename */, const char * /* filename */, Option_t * /* opt="" */) override { return nullptr; };
69
71 Long64_t GetEntryAndTree(Long64_t index, Int_t &treenum) override;
72 virtual Long64_t GetEntries();
73 virtual Long64_t GetEntriesFast() const { return fN; }
74
75 Long64_t GetN() const override { return fN; }
76 const char *GetTreeName() const override { return fTreeName.Data(); }
77 const char *GetFileName() const override { return fFileName.Data(); }
78 Int_t GetTreeNumber() const override { return fTreeNumber; }
79
80 virtual Int_t LoadList(Int_t listnumber);
81
82 Int_t Merge(TCollection * /*list*/) override{ return 0; }
83
84 Long64_t Next() override;
85 void OptimizeStorage() override {};
86 bool Remove(Long64_t /*entry*/, TTree * /*tree = nullptr */) override{ return false; }
87
88 void Print(const Option_t* option = "") const override;
89
90 void SetTree(const TTree * /*tree*/) override {}
91 void SetTree(const char * /*treename*/, const char * /*filename*/) override {}
92 virtual void SetFileNames(TObjArray *names) { fFileNames = names; }
94 virtual void SetNFiles(Int_t nfiles) { fNFiles = nfiles; }
95 void Subtract(const TEntryList * /*elist*/) override {}
96
97 ClassDefOverride(TEntryListFromFile, 1); //Manager for entry lists from different files
98};
99#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 ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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.
TString fListName
name of the list
void SetTree(const TTree *) override
If a list for a tree with such name and filename exists, sets it as the current sublist If not,...
TEntryListFromFile & operator=(const TEntryListFromFile &)
void SetTreeNumber(Int_t index) override
virtual Int_t LoadList(Int_t listnumber)
Loads the list #listnumber This is the only function that can modify fCurrent and fFile data members.
Long64_t GetN() const override
~TEntryListFromFile() override
d-tor
virtual void SetNFiles(Int_t nfiles)
TEntryList * GetEntryList(const char *, const char *, Option_t *) override
Return the entry list, corresponding to treename and filename By default, the filename is first tried...
bool Remove(Long64_t, TTree *) override
Remove entry #entry from the list.
Int_t Contains(Long64_t, TTree *) override
TFile * fFile
currently open file fCurrent points to the currently open list
virtual void SetFileNames(TObjArray *names)
void Print(const Option_t *option="") const override
Print info about this list.
Int_t fNFiles
total number of files
Long64_t Next() override
Returns the next entry in the list.
void OptimizeStorage() override
Checks if the array representation is more economical and if so, switches to it.
const char * GetFileName() const override
const char * GetTreeName() const override
bool Enter(Long64_t, const char *, const char *) override
Long64_t GetEntryAndTree(Long64_t index, Int_t &treenum) override
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 &)
void SetTree(const char *, const char *) override
If a list for a tree with such name and filename exists, sets it as the current sublist If not,...
Int_t GetTreeNumber() const override
TString fListFileName
from this string names of all files can be found
bool Enter(Long64_t, TTree *) override
Add entry #entry to the list.
void Add(const TEntryList *) override
Add 2 entry lists.
Int_t Merge(TCollection *) override
Merge this list with the lists from the collection.
Long64_t GetEntry(Long64_t index) override
Returns entry #index See also Next() for a faster alternative.
TObjArray * fFileNames
! points to the fFiles data member of the corresponding chain
Long64_t * fListOffset
[fNFiles] numbers of entries in ind. lists
virtual Long64_t GetEntriesFast() const
void Subtract(const TEntryList *) override
Remove all the entries of this entry list, that are contained in elist.
TEntryList * GetCurrentList() const override
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 an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
An array of TObjects.
Definition TObjArray.h:31
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
A TTree represents a columnar dataset.
Definition TTree.h:79