Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTreeIndex.cxx
Go to the documentation of this file.
1// @(#)root/tree:$Id$
2// Author: Rene Brun 05/07/2004
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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/** \class TTreeIndex
13A Tree Index with majorname and minorname.
14*/
15
16#include "TTreeIndex.h"
17
18#include "TTreeFormula.h"
19#include "TTree.h"
20#include "TBuffer.h"
21#include "TMath.h"
22
23#include <cstring> // std::strlen
24
26
27
29
33
34 template<typename Index>
35 bool operator()(Index i1, Index i2) {
36 if( *(fValMajor + i1) == *(fValMajor + i2) )
37 return *(fValMinor + i1) < *(fValMinor + i2);
38 else
39 return *(fValMajor + i1) < *(fValMajor + i2);
40 }
41
42 // pointers to the start of index values tables keeping upper 64bit and lower 64bit
43 // of combined indexed 128bit value
45};
46
47
48////////////////////////////////////////////////////////////////////////////////
49/// Default constructor for TTreeIndex
50
52{
53 fTree = nullptr;
54 fN = 0;
55 fIndexValues = nullptr;
56 fIndexValuesMinor = nullptr;
57 fIndex = nullptr;
58 fMajorFormula = nullptr;
59 fMinorFormula = nullptr;
60 fMajorFormulaParent = nullptr;
61 fMinorFormulaParent = nullptr;
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Normal constructor for TTreeIndex
66///
67/// Build an index table using the leaves of Tree T with major & minor names
68/// The index is built with the expressions given in "majorname" and "minorname".
69///
70/// a Long64_t array fIndexValues is built with:
71///
72/// - major = the value of majorname converted to an integer
73/// - minor = the value of minorname converted to an integer
74/// - fIndexValues[i] = major<<31 + minor
75///
76/// This array is sorted. The sorted fIndex[i] contains the serial number
77/// in the Tree corresponding to the pair "major,minor" in fIndexvalues[i].
78///
79/// Once the index is computed, one can retrieve one entry via
80/// ~~~{.cpp}
81/// T->GetEntryWithIndex(majornumber, minornumber)
82/// ~~~
83/// Example:
84/// ~~~{.cpp}
85/// tree.BuildIndex("Run","Event"); //creates an index using leaves Run and Event
86/// tree.GetEntryWithIndex(1234,56789); // reads entry corresponding to
87/// // Run=1234 and Event=56789
88/// ~~~
89/// Note that majorname and minorname may be expressions using original
90/// Tree variables eg: "run-90000", "event +3*xx". These treeformulas will be calculated using
91/// long double precision, and then cast to long64. If you want to directly
92/// use long64 for the intermediate calculation, allowing for larger maximum indices, set long64major/minor to true.
93/// Minor formula can be skipped by setting it to "0".
94///
95/// In case an expression is specified, the equivalent expression must be computed
96/// when calling GetEntryWithIndex.
97///
98/// To build an index with only majorname, specify minorname="0" (default)
99///
100/// ## TreeIndex and Friend Trees
101///
102/// Assuming a parent Tree T and a friend Tree TF, the following cases are supported:
103/// - CASE 1: T->GetEntry(entry) is called
104/// In this case, the serial number entry is used to retrieve
105/// the data in both Trees.
106/// - CASE 2: T->GetEntry(entry) is called, TF has a TreeIndex
107/// the expressions given in major/minorname of TF are used
108/// to compute the value pair major,minor with the data in T.
109/// TF->GetEntryWithIndex(major,minor) is then called (tricky case!)
110/// - CASE 3: T->GetEntryWithIndex(major,minor) is called.
111/// It is assumed that both T and TF have a TreeIndex built using
112/// the same major and minor name.
113///
114/// ## Saving the TreeIndex
115///
116/// Once the index is built, it can be saved with the TTree object
117/// with tree.Write(); (if the file has been open in "update" mode).
118///
119/// The most convenient place to create the index is at the end of
120/// the filling process just before saving the Tree header.
121/// If a previous index was computed, it is redefined by this new call.
122///
123/// Note that this function can also be applied to a TChain.
124///
125/// The return value is the number of entries in the Index (< 0 indicates failure)
126///
127/// It is possible to play with different TreeIndex in the same Tree.
128/// see comments in TTree::SetTreeIndex.
129
130TTreeIndex::TTreeIndex(const TTree *T, const char *majorname, const char *minorname, bool long64major, bool long64minor)
131 : TVirtualIndex()
132{
133 fTree = (TTree*)T;
134 fN = 0;
135 fIndexValues = nullptr;
136 fIndexValuesMinor = nullptr;
137 fIndex = nullptr;
138 fMajorFormula = nullptr;
139 fMinorFormula = nullptr;
140 fMajorFormulaParent = nullptr;
141 fMinorFormulaParent = nullptr;
144 if (!T) return;
145 fN = T->GetEntries();
146 if (fN <= 0) {
147 MakeZombie();
148 Error("TreeIndex","Cannot build a TreeIndex with a Tree having no entries");
149 return;
150 }
151
154 if (!fMajorFormula || !fMinorFormula) {
155 MakeZombie();
156 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
157 return;
158 }
159 if ((fMajorFormula->GetNdim() != 1) || (fMinorFormula->GetNdim() != 1)) {
160 MakeZombie();
161 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
162 return;
163 }
164 // accessing array elements should be OK
165 //if ((fMajorFormula->GetMultiplicity() != 0) || (fMinorFormula->GetMultiplicity() != 0)) {
166 // MakeZombie();
167 // Error("TreeIndex","Cannot build the index with major=%s, minor=%s that cannot be arrays",fMajorName.Data(), fMinorName.Data());
168 // return;
169 //}
170
173 Long64_t i;
175 Int_t current = -1;
176 for (i=0;i<fN;i++) {
178 if (centry < 0) break;
179 if (fTree->GetTreeNumber() != current) {
180 current = fTree->GetTreeNumber();
183 }
184 auto GetAndRangeCheck = [this](bool isMajor, Long64_t entry) {
186 // Check whether the value (vs significant bits) of ldRet can represent
187 // the full precision of the returned value. If we return 10^60, the
188 // value fits into a long double, but if sizeof(long double) ==
189 // sizeof(double) it cannot store the ones: the value returned by
190 // EvalInstance() only stores the higher bits.
192 if (ret > 0)
193 retCloserToZero -= 1;
194 else
195 retCloserToZero += 1;
196 if (retCloserToZero == ret) {
197 Warning("TTreeIndex",
198 "In tree entry %lld, %s value %s=%Lf possibly out of range for internal `long double`", entry,
199 isMajor ? "major" : "minor", isMajor ? fMajorName.Data() : fMinorName.Data(), ret);
200 }
201 return ret;
202 };
203 auto GetLong64 = [this](bool isMajor) {
205 };
206 tmp_major[i] = long64major ? GetLong64(true) : GetAndRangeCheck(true, i);
207 tmp_minor[i] = long64minor ? GetLong64(false) : GetAndRangeCheck(false, i);
208 }
209 fIndex = new Long64_t[fN];
210 for(i = 0; i < fN; i++) { fIndex[i] = i; }
212 //TMath::Sort(fN,w,fIndex,0);
213 fIndexValues = new Long64_t[fN];
215 for (i=0;i<fN;i++) {
218 }
219
220 delete [] tmp_major;
221 delete [] tmp_minor;
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Destructor.
227
229{
230 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(nullptr);
231 delete [] fIndexValues; fIndexValues = nullptr;
232 delete [] fIndexValuesMinor; fIndexValuesMinor = nullptr;
233 delete [] fIndex; fIndex = nullptr;
234 delete fMajorFormula; fMajorFormula = nullptr;
235 delete fMinorFormula; fMinorFormula = nullptr;
238}
239
240////////////////////////////////////////////////////////////////////////////////
241/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
242/// If delaySort is true, do not sort the value, then you must call
243/// Append(0,false);
244
246{
247
248 if (add && add->GetN()) {
249 // Create new buffer (if needed)
250
251 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
252 if (ti_add == nullptr) {
253 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
254 add->IsA()->GetName());
255 }
256
257 Long64_t oldn = fN;
258 fN += add->GetN();
259
263
264 fIndex = new Long64_t[fN];
265 fIndexValues = new Long64_t[fN];
267
268 // Copy data
269 Long_t size = sizeof(Long64_t) * oldn;
270 Long_t add_size = sizeof(Long64_t) * add->GetN();
271
275
276 Long64_t *addIndex = ti_add->GetIndex();
277 Long64_t *addValues = ti_add->GetIndexValues();
278 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
279
283 for(Int_t i = 0; i < add->GetN(); i++) {
284 fIndex[oldn + i] += oldn;
285 }
286
287 delete [] oldIndex;
288 delete [] oldValues;
289 delete [] oldValues2;
290 }
291
292 // Sort.
293 if (!delaySort) {
297 Long64_t *conv = new Long64_t[fN];
298
299 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
300 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
301 //Long64_t *w = fIndexValues;
302 //TMath::Sort(fN,w,conv,0);
303
304 fIndex = new Long64_t[fN];
305 fIndexValues = new Long64_t[fN];
307
308 for (Int_t i=0;i<fN;i++) {
309 fIndex[i] = ind[conv[i]];
310 fIndexValues[i] = addValues[conv[i]];
311 fIndexValuesMinor[i] = addValues2[conv[i]];
312 }
313 delete [] addValues;
314 delete [] addValues2;
315 delete [] ind;
316 delete [] conv;
317 }
318}
319
320
321
322////////////////////////////////////////////////////////////////////////////////
323/// conversion from old 64bit indexes
324/// return true if index was converted
325
327{
328 if( !fIndexValuesMinor && fN ) {
330 for(int i=0; i<fN; i++) {
331 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
332 fIndexValues[i] >>= 31;
333 }
334 return true;
335 }
336 return false;
337}
338
339
340
341////////////////////////////////////////////////////////////////////////////////
342/// Returns the entry number in this (friend) Tree corresponding to entry in
343/// the master Tree 'parent'.
344/// In case this (friend) Tree and 'master' do not share an index with the same
345/// major and minor name, the entry serial number in the (friend) tree
346/// and in the master Tree are assumed to be the same
347
349{
350 if (!parent) return -3;
351 // We reached the end of the parent tree
352 Long64_t pentry = parent->GetReadEntry();
353 if (pentry >= parent->GetEntriesFast())
354 return -2;
355 GetMajorFormulaParent(parent);
356 GetMinorFormulaParent(parent);
357 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
359 // The Tree Index in the friend has a pair majorname,minorname
360 // not available in the parent Tree T.
361 // if the friend Tree has less entries than the parent, this is an error
362 if (pentry >= fTree->GetEntries()) return -2;
363 // otherwise we ignore the Tree Index and return the entry number
364 // in the parent Tree.
365 return pentry;
366 }
367
368 // majorname, minorname exist in the parent Tree
369 // we find the current values pair majorv,minorv in the parent Tree
374 // we check if this pair exist in the index.
375 // if yes, we return the corresponding entry number
376 // if not the function returns -1
378}
379
380
381////////////////////////////////////////////////////////////////////////////////
382/// find position where major|minor values are in the IndexValues tables
383/// this is the index in IndexValues table, not entry# !
384/// use lower_bound STD algorithm.
385
387{
388 Long64_t mid, step, pos = 0, count = fN;
389 // find lower bound using bisection
390 while( count > 0 ) {
391 step = count / 2;
392 mid = pos + step;
393 // check if *mid < major|minor
394 if( fIndexValues[mid] < major
395 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
396 pos = mid+1;
397 count -= step + 1;
398 } else
399 count = step;
400 }
401 return pos;
402}
403
404
405////////////////////////////////////////////////////////////////////////////////
406/// Return entry number corresponding to major and minor number.
407/// Note that this function returns only the entry number, not the data
408/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
409/// the BuildIndex function has created a table of Double_t* of sorted values
410/// corresponding to val = major<<31 + minor;
411/// The function performs binary search in this sorted table.
412/// If it finds a pair that maches val, it returns directly the
413/// index in the table, otherwise it returns -1.
414/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
415/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
416/// A runtime-warning will be printed if values above this range are detected to lead to a corresponding precision loss in your current architecture:
417/// `Warning in <TTreeIndex::TTreeIndex>: In tree entry, value event possibly out of range for internal long double`
418/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
419/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
420/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
421///
422/// If an entry corresponding to major and minor is not found, the function
423/// returns the index of the major,minor pair immediately lower than the
424/// requested value, ie it will return -1 if the pair is lower than
425/// the first entry in the index.
426///
427/// See also GetEntryNumberWithIndex
428
430{
431 if (fN == 0) return -1;
432
434 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
435 return fIndex[pos];
436 if( --pos < 0 )
437 return -1;
438 return fIndex[pos];
439}
440
441
442////////////////////////////////////////////////////////////////////////////////
443/// Return entry number corresponding to major and minor number.
444/// Note that this function returns only the entry number, not the data
445/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
446/// the BuildIndex function has created a table of Double_t* of sorted values
447/// corresponding to val = major<<31 + minor;
448/// The function performs binary search in this sorted table.
449/// If it finds a pair that maches val, it returns directly the
450/// index in the table, otherwise it returns -1.
451/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
452/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
453/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
454/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
455/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
456///
457/// See also GetEntryNumberWithBestIndex
458
460{
461 if (fN == 0) return -1;
462
464 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
465 return fIndex[pos];
466 return -1;
467}
468
469
470////////////////////////////////////////////////////////////////////////////////
471
476
477
478
479////////////////////////////////////////////////////////////////////////////////
480/// Return a pointer to the TreeFormula corresponding to the majorname.
481
490
491////////////////////////////////////////////////////////////////////////////////
492/// Return a pointer to the TreeFormula corresponding to the minorname.
493
502
503////////////////////////////////////////////////////////////////////////////////
504/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
505
507{
508 if (!fMajorFormulaParent) {
509 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
510 // is a friend of the parent TTree.
512 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
514 }
515 if (fMajorFormulaParent->GetTree() != parent) {
516 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
518 }
519 return fMajorFormulaParent;
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
524
526{
527 if (!fMinorFormulaParent) {
528 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
529 // is a friend of the parent TTree.
531 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
533 }
534 if (fMinorFormulaParent->GetTree() != parent) {
535 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
537 }
538 return fMinorFormulaParent;
539}
540
541////////////////////////////////////////////////////////////////////////////////
542/// Return true if index can be applied to the TTree
543
544bool TTreeIndex::IsValidFor(const TTree *parent)
545{
546 auto *majorFormula = GetMajorFormulaParent(parent);
547 auto *minorFormula = GetMinorFormulaParent(parent);
548 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
549 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
550 return false;
551 return true;
552}
553
554////////////////////////////////////////////////////////////////////////////////
555/// Print the table with : serial number, majorname, minorname.
556/// - if option = "10" print only the first 10 entries
557/// - if option = "100" print only the first 100 entries
558/// - if option = "1000" print only the first 1000 entries
559
561{
562 TString opt = option;
563 bool printEntry = false;
564 Long64_t n = fN;
565 if (opt.Contains("10")) n = 10;
566 if (opt.Contains("100")) n = 100;
567 if (opt.Contains("1000")) n = 1000;
568 if (opt.Contains("all")) {
569 printEntry = true;
570 }
571
572 if (printEntry) {
573 Printf("\n*****************************************************************");
574 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
575 Printf("*****************************************************************");
576 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
577 Printf("*****************************************************************");
578 for (Long64_t i=0;i<n;i++) {
579 Printf("%8lld : %8lld : %8lld : %8lld",
580 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
581 }
582
583 } else {
584 Printf("\n**********************************************");
585 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
586 Printf("**********************************************");
587 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
588 Printf("**********************************************");
589 for (Long64_t i=0;i<n;i++) {
590 Printf("%8lld : %8lld : %8lld",
592 }
593 }
594}
595
596////////////////////////////////////////////////////////////////////////////////
597/// Stream an object of class TTreeIndex.
598/// Note that this Streamer should be changed to an automatic Streamer
599/// once TStreamerInfo supports an index of type Long64_t
600
602{
604 if (R__b.IsReading()) {
605 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
609 R__b >> fN;
610 fIndexValues = new Long64_t[fN];
611 R__b.ReadFastArray(fIndexValues,fN);
612 if( R__v > 1 ) {
614 R__b.ReadFastArray(fIndexValuesMinor,fN);
615 } else {
617 }
618 fIndex = new Long64_t[fN];
619 R__b.ReadFastArray(fIndex,fN);
620 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
621 } else {
622 R__c = R__b.WriteVersion(TTreeIndex::IsA(), true);
626 R__b << fN;
627 R__b.WriteFastArray(fIndexValues, fN);
628 R__b.WriteFastArray(fIndexValuesMinor, fN);
629 R__b.WriteFastArray(fIndex, fN);
630 R__b.SetByteCount(R__c, true);
631 }
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Called by TChain::LoadTree when the parent chain changes it's tree.
636
638{
642 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
644 }
646 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
648 }
649}
650////////////////////////////////////////////////////////////////////////////////
651/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
652/// when a new Tree is loaded.
653/// Because Trees in a TChain may have a different list of leaves, one
654/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
655
657{
658 fTree = T;
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// \brief Create a deep copy of the TTreeIndex
663/// \param[in] newname A new name for the index
664///
665/// The new index is allocated on the heap without being managed. Also, it is
666/// not attached to any tree. It is the responsibility of the caller to manage
667/// its lifetime and attach it to a tree if necessary.
669{
670 auto index = new TTreeIndex();
671 index->SetName(newname && std::strlen(newname) ? newname : GetName());
672 index->SetTitle(GetTitle());
673
674 // Note that the TTreeFormula * data members are not cloned since they would
675 // need the attached tree data member to function properly.
676 index->fMajorName = fMajorName;
677 index->fMinorName = fMinorName;
678
679 if (fN == 0)
680 return index;
681
682 index->fN = fN;
683
684 index->fIndexValues = new Long64_t[index->fN];
685 std::copy(fIndexValues, fIndexValues + fN, index->fIndexValues);
686
687 index->fIndexValuesMinor = new Long64_t[index->fN];
688 std::copy(fIndexValuesMinor, fIndexValuesMinor + fN, index->fIndexValuesMinor);
689
690 index->fIndex = new Long64_t[index->fN];
691 std::copy(fIndex, fIndex + fN, index->fIndex);
692
693 return index;
694}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Version_t
Definition RtypesCore.h:65
long Long_t
Definition RtypesCore.h:54
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 index
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
virtual Int_t GetNdim() const
Definition TFormula.h:237
Buffer base class used for serializing objects.
Definition TBuffer.h:43
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
void MakeZombie()
Definition TObject.h:53
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1412
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Used to pass a selection expression to the Tree drawing routine.
virtual void SetTree(TTree *tree)
T EvalInstance(Int_t i=0, const char *stringStack[]=nullptr)
Evaluate this treeformula.
void SetQuickLoad(bool quick)
virtual void UpdateFormulaLeaves()
This function is called TTreePlayer::UpdateFormulaLeaves, itself called by TChain::LoadTree when a ne...
virtual TTree * GetTree() const
A Tree Index with majorname and minorname.
Definition TTreeIndex.h:29
TTreeIndex()
Default constructor for TTreeIndex.
virtual Long64_t * GetIndexValues() const
Definition TTreeIndex.h:60
virtual Long64_t * GetIndexValuesMinor() const
TTreeFormula * fMajorFormula
! Pointer to major TreeFormula
Definition TTreeIndex.h:37
TTreeFormula * fMajorFormulaParent
! Pointer to major TreeFormula in Parent tree (if any)
Definition TTreeIndex.h:39
Long64_t * fIndex
[fN] Index of sorted values
Definition TTreeIndex.h:36
Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const override
Return entry number corresponding to major and minor number.
TTreeFormula * GetMajorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
void SetTree(TTree *T) override
this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves when a new Tree is l...
bool IsValidFor(const TTree *parent) override
Return true if index can be applied to the TTree.
Long64_t fN
Number of entries.
Definition TTreeIndex.h:33
TClass * IsA() const override
Definition TTreeIndex.h:73
bool ConvertOldToNew()
conversion from old 64bit indexes return true if index was converted
TTreeFormula * fMinorFormula
! Pointer to minor TreeFormula
Definition TTreeIndex.h:38
void Append(const TVirtualIndex *, bool delaySort=false) override
Append 'add' to this index.
void UpdateFormulaLeaves(const TTree *parent) override
Called by TChain::LoadTree when the parent chain changes it's tree.
virtual TTreeFormula * GetMajorFormula()
Return a pointer to the TreeFormula corresponding to the majorname.
TTreeFormula * GetMinorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const override
Return entry number corresponding to major and minor number.
TObject * Clone(const char *newname="") const override
Create a deep copy of the TTreeIndex.
Long64_t GetEntryNumberFriend(const TTree *parent) override
Returns the entry number in this (friend) Tree corresponding to entry in the master Tree 'parent'.
TString fMinorName
Index minor name.
Definition TTreeIndex.h:32
void Print(Option_t *option="") const override
Print the table with : serial number, majorname, minorname.
void Streamer(TBuffer &) override
Stream an object of class TTreeIndex.
virtual TTreeFormula * GetMinorFormula()
Return a pointer to the TreeFormula corresponding to the minorname.
Long64_t * fIndexValues
[fN] Sorted index values, higher 64bits
Definition TTreeIndex.h:34
TString fMajorName
Index major name.
Definition TTreeIndex.h:31
Long64_t * fIndexValuesMinor
[fN] Sorted index values, lower 64bits
Definition TTreeIndex.h:35
~TTreeIndex() override
Destructor.
TTreeFormula * fMinorFormulaParent
! Pointer to minor TreeFormula in Parent tree (if any)
Definition TTreeIndex.h:40
Long64_t FindValues(Long64_t major, Long64_t minor) const
find position where major|minor values are in the IndexValues tables this is the index in IndexValues...
Helper class to prevent infinite recursion in the usage of TTree Friends.
Definition TTree.h:199
A TTree represents a columnar dataset.
Definition TTree.h:84
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor=0) const
Return entry number corresponding to major and minor number.
Definition TTree.cxx:5920
virtual TVirtualIndex * GetTreeIndex() const
Definition TTree.h:573
virtual Long64_t GetEntries() const
Definition TTree.h:478
virtual Long64_t GetReadEntry() const
Definition TTree.h:564
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition TTree.cxx:6483
virtual Long64_t GetEntriesFast() const
Return a number greater or equal to the total number of entries in the dataset.
Definition TTree.h:520
virtual Int_t GetTreeNumber() const
Definition TTree.h:574
@ kFindBranch
Definition TTree.h:223
@ kFindLeaf
Definition TTree.h:224
@ kGetBranch
Definition TTree.h:226
@ kGetLeaf
Definition TTree.h:231
virtual void SetTreeIndex(TVirtualIndex *index)
The current TreeIndex is replaced by the new index.
Definition TTree.cxx:9458
Abstract interface for Tree Index.
void Streamer(TBuffer &) override
Stream an object of class TObject.
virtual Long64_t GetN() const =0
TClass * IsA() const override
const Int_t n
Definition legend1.C:16
bool operator()(Index i1, Index i2)
IndexSortComparator(Long64_t *major, Long64_t *minor)