270 fReadDirectionSet(kFALSE),
272 fPrefillType(GetConfiguredPrefillType()),
282 fEntryMax(tree->GetEntriesFast()),
300 fReadDirectionSet(
kFALSE),
302 fPrefillType(GetConfiguredPrefillType()),
363 for (
Int_t j = 0; j < nb; j++) {
365 if (!branch)
continue;
390 TLeaf *leaf, *leafcount;
401 if (!strcmp(bname,
"*")) all =
kTRUE;
402 for (i=0;i<nleaves;i++) {
409 if (strcmp(bname,branch->
GetName())
418 if (leafcount && !all) {
425 if (nb==0 && strchr(bname,
'*')==0) {
446 char *subbranch = (
char*)strstr(bname,fe->GetName());
447 if (subbranch!=bname) subbranch = 0;
449 subbranch += strlen(fe->GetName());
450 if ( *subbranch !=
'.' ) subbranch = 0;
462 if (!nb && !foundInFriend) {
463 if (
gDebug > 0)
printf(
"AddBranch: unknown branch -> %s \n", bname);
464 Error(
"AddBranch",
"unknown branch -> %s", bname);
503 for (
Int_t j = 0; j < nb; j++) {
505 if (!branch)
continue;
530 TLeaf *leaf, *leafcount;
541 if (!strcmp(bname,
"*")) all =
kTRUE;
542 for (i=0;i<nleaves;i++) {
549 if (strcmp(bname,branch->
GetName())
558 if (leafcount && !all) {
565 if (nb==0 && strchr(bname,
'*')==0) {
586 char *subbranch = (
char*)strstr(bname,fe->GetName());
587 if (subbranch!=bname) subbranch = 0;
589 subbranch += strlen(fe->GetName());
590 if ( *subbranch !=
'.' ) subbranch = 0;
602 if (!nb && !foundInFriend) {
603 if (
gDebug > 0)
printf(
"DropBranch: unknown branch -> %s \n", bname);
604 Error(
"DropBranch",
"unknown branch -> %s", bname);
662 if (entry < 0) entry = 0;
668 if (entry < 0)
return kFALSE;
674 if (entry < 0 && fEntryNext > 0) {
699 if (entry == -1) entry = 0;
731 Int_t fNtotCurrentBuf = 0;
735 fNtotCurrentBuf =
fNtot;
744 fNtotCurrentBuf =
fNtot;
748 Int_t clusterIterations = 0;
754 prevNtot = fNtotCurrentBuf;
755 Int_t nextMinBasket = INT_MAX;
769 if (!lbaskets || !entries)
continue;
777 if (j<blistsize && b->GetListOfBaskets()->UncheckedAt(j))
continue;
780 Int_t len = lbaskets[j];
781 if (pos <= 0 || len <= 0)
continue;
788 if (entries[j] < minEntry && (j<nb-1 && entries[j+1] <= minEntry))
continue;
791 if (j<nb-1) emax = entries[j+1]-1;
792 if (!elist->
ContainsRange(entries[j]+chainOffset,emax+chainOffset))
continue;
794 if (pass==2 && !firstBasketSeen) {
796 firstBasketSeen =
kTRUE;
803 if (clusterIterations > 0) {
808 Info(
"FillBuffer",
"Breaking early because %d is greater than %d at cluster iteration %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,minEntry);
821 Info(
"FillBuffer",
"Breaking early because %d is greater than 2*%d at cluster iteration %d pass %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,pass,
fEntryNext);
832 Info(
"FillBuffer",
"Breaking early because %d is greater than 2*%d at cluster iteration %d pass %d will restart at %lld",(fNtotCurrentBuf+len),
fBufferSizeMin, clusterIterations,pass,
fEntryNext);
842 fNtotCurrentBuf =
fNtot;
851 fNtotCurrentBuf =
fNtot;
853 if ( ( j < (nb-1) ) && entries[j+1] > maxReadEntry ) {
854 maxReadEntry = entries[j+1];
858 Warning(
"FillBuffer",
"There is more data in this cluster (starting at entry %lld to %lld, current=%lld) than usual ... with %d %.3f%% of the branches we already have %d bytes (instead of %d)",
868 if (j < nextMinBasket) nextMinBasket = j;
874 minEntry = clusterIter.
Next();
888 if (!((
fBufferSizeMin > ((
Long64_t)fNtotCurrentBuf*(clusterIterations+1))/clusterIterations) && (prevNtot < fNtotCurrentBuf) && (minEntry <
fEntryMax)))
895 if (minEntry >= fEntryCurrentMax && fEntryCurrentMax >0)
898 minBasket = nextMinBasket;
927 if (!(stcp =
gSystem->
Getenv(
"ROOT_TTREECACHE_PREFILL")) || !*stcp) {
1004 if ( opt.
Contains(
"cachedbranches") ) {
1006 printf(
"Cached branches....................:\n");
1009 for (
Int_t i = 0; i < nbranches; ++i) {
1011 printf(
"Branch name........................: %s\n",branch->
GetName());
1129 if (res == 0 && buffersize <= prevsize) {
1164 Info(
"SetEntryRange",
"fEntryMin=%lld, fEntryMax=%lld, fEntryNext=%lld",
1167 if (needLearningStart) {
const char * GetName() const
Returns name of object.
Long64_t GetReadEntry() const
virtual Int_t GetEntries() const
Int_t fNtot
Total size of prefetched blocks.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Long64_t fEntryMax
first entry in the cache
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Int_t fNReadOk
Number of branches in the cache.
TFile * fFile
Pointer to file.
const TObjArray * GetCachedBranches() const
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
TObjArray * GetListOfBaskets()
Collectable string class.
A cache when reading files over the network.
TEventList * GetEventList() const
Bool_t fOneTime
true if first buffer is used for prefetching
virtual Long64_t GetReadEntry() const
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetLearnPrefill(EPrefillType type=kNoPrefill)
Set whether the learning period is started with a prefilling of the cache and which type of prefillin...
A specialized TFileCacheRead object for a TTree.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Regular expression class.
virtual TObject * Remove(TObject *obj)
Remove object from array.
void ToLower()
Change string to lower-case.
virtual void Prefetch(Long64_t pos, Int_t len)
Add block of length len at position pos in the list of blocks to be prefetched.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
TBranch * GetBranch() const
virtual Long64_t GetBasketSeek(Int_t basket) const
Return address of basket in the file.
virtual void StopLearningPhase()
This is the counterpart of StartLearningPhase() and can be used to stop the learning phase...
Int_t GetEntriesFast() const
virtual void LearnPrefill()
Perform an initial prefetch, attempting to read as much of the learning phase baskets for all branche...
Long64_t * GetBasketEntry() const
void StartLearningPhase()
The name should be enough to explain the method.
virtual Int_t AddBranch(TBranch *b, Bool_t subgbranches=kFALSE)
Add a branch to the list of branches to be stored in the cache this function is called by TBranch::Ge...
virtual void Print(Option_t *option="") const
Print cache statistics.
virtual Int_t ReadBufferNormal(char *buf, Long64_t pos, Int_t len)
Old method ReadBuffer before the addition of the prefetch mechanism.
virtual TList * GetListOfFriends() const
Long64_t * GetTreeOffset() const
Helper class to iterate over cluster of baskets.
virtual void SecondPrefetch(Long64_t, Int_t)
virtual Int_t GetTreeNumber() const
Bool_t fIsTransferred
True when fBuffer contains something valid.
Int_t * GetBasketBytes() const
virtual Bool_t ContainsRange(Long64_t entrymin, Long64_t entrymax)
Return TRUE if list contains entries from entrymin to entrymax included.
EPrefillType GetConfiguredPrefillType() const
Return the desired prefill type from the environment or resource variable.
virtual Int_t GetBufferSize() const
virtual const char * Getenv(const char *env)
Get environment variable.
virtual TClusterIterator GetClusterIterator(Long64_t firstentry)
Return an iterator over the cluster of baskets starting at firstentry.
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos if the request is in the list of prefetched blocks read from fBuffer...
virtual void ResetCache()
This will simply clear the cache.
Bool_t fEnabled
read direction established
Int_t Atoi() const
Return integer value of string.
TObjArray * GetListOfBranches()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
TTree * fTree
list of branch names in the cache
virtual TFile * GetFile() const
TObject * UncheckedAt(Int_t i) const
Double_t GetEfficiency() const
Give the total efficiency of the cache...
virtual void SetEntryRange(Long64_t emin, Long64_t emax)
Set the minimum and maximum entry number to be processed this information helps to optimize the numbe...
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
virtual Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE)
Remove a branch to the list of branches to be stored in the cache this function is called by TBranch:...
R__EXTERN TSystem * gSystem
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual Int_t ReadBufferPrefetch(char *buf, Long64_t pos, Int_t len)
Used to read a chunk from a block previously fetched.
virtual ~TTreeCache()
Destructor. (in general called by the TFile destructor)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual void Print(Option_t *option="") const
Print cache statistics.
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
A TEventList object is a list of selected events (entries) in a TTree.
Bool_t fReadDirectionSet
save the value of the first entry
virtual const char * GetName() const
Returns name of object.
static void SetLearnEntries(Int_t n=10)
Static function to set the number of entries to be used in learning mode The default value for n is 1...
virtual Int_t SetBufferSize(Int_t buffersize)
Sets the buffer size.
virtual Bool_t FillBuffer()
Fill the cache buffer with the branches in the cache.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
virtual TLeaf * GetLeafCount() const
Bool_t fReverseRead
used in the learning phase
Bool_t fFirstTime
how many times we can fill the current buffer
Long64_t fEntryCurrent
last entry in the cache
Int_t fBufferSizeMin
Original size of fBuffer.
ClassImp(TTreeCache) TTreeCache
Default Constructor.
Long64_t Next()
Move on to the next cluster and return the starting entry of this next cluster.
virtual Int_t GetSize() const
virtual Long64_t GetAutoFlush() const
virtual const char * GetName() const
Returns name of object.
Bool_t fIsLearning
pointer to the current Tree
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Overload to make sure that the object specific.
EPrefillType fPrefillType
cache enabled for cached reading
virtual TTree * GetTree() const
Int_t fFillTimes
reading in reverse mode
Int_t GetEntries() const
Return the number of objects in array (i.e.
virtual Int_t SetBufferSize(Int_t buffersize)
Change the underlying buffer size of the cache.
TDirectory * GetDirectory() const
Int_t fNbranches
next entry number where cache must be filled
Int_t GetMaxBaskets() const
Bool_t fEnablePrefetching
reading by prefetching asynchronously
virtual void Add(TObject *obj)
Long64_t fFirstEntry
save the fact that we processes the first entry
A TFriendElement TF describes a TTree object TF in a file.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A chain is a collection of files containg TTree objects.
TList * fBrNames
List of branches to be stored in the cache.
Bool_t fFirstBuffer
true if cache is StopLearningPhase was used
static Int_t fgLearnEntries
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
Bool_t fIsManual
true if cache is in learning mode
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
A TTree is a list of TBranches.
Long64_t fEntryNext
current lowest entry number in the cache
Double_t GetEfficiencyRel() const
This will indicate a sort of relative efficiency...
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
static Int_t GetLearnEntries()
Static function returning the number of entries used to train the cache see SetLearnEntries.
Int_t fNseek
Number of blocks to be prefetched.
virtual TObjArray * GetListOfLeaves()
ECacheAction
TTreeCache flushing semantics.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.