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". However the result
91/// must be integer.
92///
93/// In case an expression is specified, the equivalent expression must be computed
94/// when calling GetEntryWithIndex.
95///
96/// To build an index with only majorname, specify minorname="0" (default)
97///
98/// ## TreeIndex and Friend Trees
99///
100/// Assuming a parent Tree T and a friend Tree TF, the following cases are supported:
101/// - CASE 1: T->GetEntry(entry) is called
102/// In this case, the serial number entry is used to retrieve
103/// the data in both Trees.
104/// - CASE 2: T->GetEntry(entry) is called, TF has a TreeIndex
105/// the expressions given in major/minorname of TF are used
106/// to compute the value pair major,minor with the data in T.
107/// TF->GetEntryWithIndex(major,minor) is then called (tricky case!)
108/// - CASE 3: T->GetEntryWithIndex(major,minor) is called.
109/// It is assumed that both T and TF have a TreeIndex built using
110/// the same major and minor name.
111///
112/// ## Saving the TreeIndex
113///
114/// Once the index is built, it can be saved with the TTree object
115/// with tree.Write(); (if the file has been open in "update" mode).
116///
117/// The most convenient place to create the index is at the end of
118/// the filling process just before saving the Tree header.
119/// If a previous index was computed, it is redefined by this new call.
120///
121/// Note that this function can also be applied to a TChain.
122///
123/// The return value is the number of entries in the Index (< 0 indicates failure)
124///
125/// It is possible to play with different TreeIndex in the same Tree.
126/// see comments in TTree::SetTreeIndex.
127
128TTreeIndex::TTreeIndex(const TTree *T, const char *majorname, const char *minorname)
129 : TVirtualIndex()
130{
131 fTree = (TTree*)T;
132 fN = 0;
133 fIndexValues = nullptr;
134 fIndexValuesMinor = nullptr;
135 fIndex = nullptr;
136 fMajorFormula = nullptr;
137 fMinorFormula = nullptr;
138 fMajorFormulaParent = nullptr;
139 fMinorFormulaParent = nullptr;
142 if (!T) return;
143 fN = T->GetEntries();
144 if (fN <= 0) {
145 MakeZombie();
146 Error("TreeIndex","Cannot build a TreeIndex with a Tree having no entries");
147 return;
148 }
149
152 if (!fMajorFormula || !fMinorFormula) {
153 MakeZombie();
154 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
155 return;
156 }
157 if ((fMajorFormula->GetNdim() != 1) || (fMinorFormula->GetNdim() != 1)) {
158 MakeZombie();
159 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
160 return;
161 }
162 // accessing array elements should be OK
163 //if ((fMajorFormula->GetMultiplicity() != 0) || (fMinorFormula->GetMultiplicity() != 0)) {
164 // MakeZombie();
165 // Error("TreeIndex","Cannot build the index with major=%s, minor=%s that cannot be arrays",fMajorName.Data(), fMinorName.Data());
166 // return;
167 //}
168
171 Long64_t i;
173 Int_t current = -1;
174 for (i=0;i<fN;i++) {
176 if (centry < 0) break;
177 if (fTree->GetTreeNumber() != current) {
178 current = fTree->GetTreeNumber();
181 }
182 auto GetAndRangeCheck = [this](bool isMajor, Long64_t entry) {
184 // Check whether the value (vs significant bits) of ldRet can represent
185 // the full precision of the returned value. If we return 10^60, the
186 // value fits into a long double, but if sizeof(long double) ==
187 // sizeof(double) it cannot store the ones: the value returned by
188 // EvalInstance() only stores the higher bits.
190 if (ret > 0)
191 retCloserToZero -= 1;
192 else
193 retCloserToZero += 1;
194 if (retCloserToZero == ret) {
195 Warning("TTreeIndex",
196 "In tree entry %lld, %s value %s=%Lf possibly out of range for internal `long double`", entry,
197 isMajor ? "major" : "minor", isMajor ? fMajorName.Data() : fMinorName.Data(), ret);
198 }
199 return ret;
200 };
201 tmp_major[i] = GetAndRangeCheck(true, i);
202 tmp_minor[i] = GetAndRangeCheck(false, i);
203 }
204 fIndex = new Long64_t[fN];
205 for(i = 0; i < fN; i++) { fIndex[i] = i; }
207 //TMath::Sort(fN,w,fIndex,0);
208 fIndexValues = new Long64_t[fN];
210 bool duplicatedKeys = false;
211 for (i = 0; i < fN; i++) {
214 const bool checkDuplicates = i > 0 && (!duplicatedKeys || gDebug >= 1);
215 if (checkDuplicates) {
216 if (fIndexValues[i - 1] == fIndexValues[i] && fIndexValuesMinor[i - 1] == fIndexValuesMinor[i]) {
217 Error("TTreeIndex",
218 "In entry %lld, a duplicate key was found value at (%s, %s) = (%lld, %lld)",
220 );
221 if (gDebug < 1) {
222 Warning("TTreeIndex", "Further potential duplicates won't be checked, use gDebug >= 1 to check all.");
223 }
224 duplicatedKeys = true;
225 }
226 }
227 }
228
229 delete [] tmp_major;
230 delete [] tmp_minor;
232}
233
234////////////////////////////////////////////////////////////////////////////////
235/// Destructor.
236
238{
239 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(nullptr);
240 delete [] fIndexValues; fIndexValues = nullptr;
241 delete [] fIndexValuesMinor; fIndexValuesMinor = nullptr;
242 delete [] fIndex; fIndex = nullptr;
243 delete fMajorFormula; fMajorFormula = nullptr;
244 delete fMinorFormula; fMinorFormula = nullptr;
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
251/// If delaySort is true, do not sort the value, then you must call
252/// Append(0,false);
253
255{
256
257 if (add && add->GetN()) {
258 // Create new buffer (if needed)
259
260 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
261 if (ti_add == nullptr) {
262 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
263 add->IsA()->GetName());
264 }
265
266 Long64_t oldn = fN;
267 fN += add->GetN();
268
272
273 fIndex = new Long64_t[fN];
274 fIndexValues = new Long64_t[fN];
276
277 // Copy data
278 Long_t size = sizeof(Long64_t) * oldn;
279 Long_t add_size = sizeof(Long64_t) * add->GetN();
280
284
285 Long64_t *addIndex = ti_add->GetIndex();
286 Long64_t *addValues = ti_add->GetIndexValues();
287 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
288
292 for(Int_t i = 0; i < add->GetN(); i++) {
293 fIndex[oldn + i] += oldn;
294 }
295
296 delete [] oldIndex;
297 delete [] oldValues;
298 delete [] oldValues2;
299 }
300
301 // Sort.
302 if (!delaySort) {
306 Long64_t *conv = new Long64_t[fN];
307
308 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
309 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
310 //Long64_t *w = fIndexValues;
311 //TMath::Sort(fN,w,conv,0);
312
313 fIndex = new Long64_t[fN];
314 fIndexValues = new Long64_t[fN];
316
317 for (Int_t i=0;i<fN;i++) {
318 fIndex[i] = ind[conv[i]];
319 fIndexValues[i] = addValues[conv[i]];
320 fIndexValuesMinor[i] = addValues2[conv[i]];
321 }
322 delete [] addValues;
323 delete [] addValues2;
324 delete [] ind;
325 delete [] conv;
326 }
327}
328
329
330
331////////////////////////////////////////////////////////////////////////////////
332/// conversion from old 64bit indexes
333/// return true if index was converted
334
336{
337 if( !fIndexValuesMinor && fN ) {
339 for(int i=0; i<fN; i++) {
340 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
341 fIndexValues[i] >>= 31;
342 }
343 return true;
344 }
345 return false;
346}
347
348
349
350////////////////////////////////////////////////////////////////////////////////
351/// Returns the entry number in this (friend) Tree corresponding to entry in
352/// the master Tree 'parent'.
353/// In case this (friend) Tree and 'master' do not share an index with the same
354/// major and minor name, the entry serial number in the (friend) tree
355/// and in the master Tree are assumed to be the same
356
358{
359 if (!parent) return -3;
360 // We reached the end of the parent tree
361 Long64_t pentry = parent->GetReadEntry();
362 if (pentry >= parent->GetEntriesFast())
363 return -2;
364 GetMajorFormulaParent(parent);
365 GetMinorFormulaParent(parent);
366 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
368 // The Tree Index in the friend has a pair majorname,minorname
369 // not available in the parent Tree T.
370 // if the friend Tree has less entries than the parent, this is an error
371 if (pentry >= fTree->GetEntries()) return -2;
372 // otherwise we ignore the Tree Index and return the entry number
373 // in the parent Tree.
374 return pentry;
375 }
376
377 // majorname, minorname exist in the parent Tree
378 // we find the current values pair majorv,minorv in the parent Tree
383 // we check if this pair exist in the index.
384 // if yes, we return the corresponding entry number
385 // if not the function returns -1
387}
388
389
390////////////////////////////////////////////////////////////////////////////////
391/// find position where major|minor values are in the IndexValues tables
392/// this is the index in IndexValues table, not entry# !
393/// use lower_bound STD algorithm.
394
396{
397 Long64_t mid, step, pos = 0, count = fN;
398 // find lower bound using bisection
399 while( count > 0 ) {
400 step = count / 2;
401 mid = pos + step;
402 // check if *mid < major|minor
403 if( fIndexValues[mid] < major
404 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
405 pos = mid+1;
406 count -= step + 1;
407 } else
408 count = step;
409 }
410 return pos;
411}
412
413
414////////////////////////////////////////////////////////////////////////////////
415/// Return entry number corresponding to major and minor number.
416/// Note that this function returns only the entry number, not the data
417/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
418/// the BuildIndex function has created a table of Double_t* of sorted values
419/// corresponding to val = major<<31 + minor;
420/// The function performs binary search in this sorted table.
421/// If it finds a pair that maches val, it returns directly the
422/// index in the table.
423/// If an entry corresponding to major and minor is not found, the function
424/// returns the index of the major,minor pair immediately lower than the
425/// requested value, ie it will return -1 if the pair is lower than
426/// the first entry in the index.
427///
428/// See also GetEntryNumberWithIndex
429
431{
432 if (fN == 0) return -1;
433
435 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
436 return fIndex[pos];
437 if( --pos < 0 )
438 return -1;
439 return fIndex[pos];
440}
441
442
443////////////////////////////////////////////////////////////////////////////////
444/// Return entry number corresponding to major and minor number.
445/// Note that this function returns only the entry number, not the data
446/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
447/// the BuildIndex function has created a table of Double_t* of sorted values
448/// corresponding to val = major<<31 + minor;
449/// The function performs binary search in this sorted table.
450/// If it finds a pair that maches val, it returns directly the
451/// index in the table, otherwise it returns -1.
452///
453/// See also GetEntryNumberWithBestIndex
454
456{
457 if (fN == 0) return -1;
458
460 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
461 return fIndex[pos];
462 return -1;
463}
464
465
466////////////////////////////////////////////////////////////////////////////////
467
472
473
474
475////////////////////////////////////////////////////////////////////////////////
476/// Return a pointer to the TreeFormula corresponding to the majorname.
477
486
487////////////////////////////////////////////////////////////////////////////////
488/// Return a pointer to the TreeFormula corresponding to the minorname.
489
498
499////////////////////////////////////////////////////////////////////////////////
500/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
501
503{
504 if (!fMajorFormulaParent) {
505 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
506 // is a friend of the parent TTree.
508 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
510 }
511 if (fMajorFormulaParent->GetTree() != parent) {
512 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
514 }
515 return fMajorFormulaParent;
516}
517
518////////////////////////////////////////////////////////////////////////////////
519/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
520
522{
523 if (!fMinorFormulaParent) {
524 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
525 // is a friend of the parent TTree.
527 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
529 }
530 if (fMinorFormulaParent->GetTree() != parent) {
531 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
533 }
534 return fMinorFormulaParent;
535}
536
537////////////////////////////////////////////////////////////////////////////////
538/// Return true if index can be applied to the TTree
539
540bool TTreeIndex::IsValidFor(const TTree *parent)
541{
542 auto *majorFormula = GetMajorFormulaParent(parent);
543 auto *minorFormula = GetMinorFormulaParent(parent);
544 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
545 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
546 return false;
547 return true;
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Print the table with : serial number, majorname, minorname.
552/// - if option = "10" print only the first 10 entries
553/// - if option = "100" print only the first 100 entries
554/// - if option = "1000" print only the first 1000 entries
555
557{
558 TString opt = option;
559 bool printEntry = false;
560 Long64_t n = fN;
561 if (opt.Contains("10")) n = 10;
562 if (opt.Contains("100")) n = 100;
563 if (opt.Contains("1000")) n = 1000;
564 if (opt.Contains("all")) {
565 printEntry = true;
566 }
567
568 if (printEntry) {
569 Printf("\n*****************************************************************");
570 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
571 Printf("*****************************************************************");
572 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
573 Printf("*****************************************************************");
574 for (Long64_t i=0;i<n;i++) {
575 Printf("%8lld : %8lld : %8lld : %8lld",
576 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
577 }
578
579 } else {
580 Printf("\n**********************************************");
581 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
582 Printf("**********************************************");
583 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
584 Printf("**********************************************");
585 for (Long64_t i=0;i<n;i++) {
586 Printf("%8lld : %8lld : %8lld",
588 }
589 }
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Stream an object of class TTreeIndex.
594/// Note that this Streamer should be changed to an automatic Streamer
595/// once TStreamerInfo supports an index of type Long64_t
596
598{
600 if (R__b.IsReading()) {
601 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
605 R__b >> fN;
606 fIndexValues = new Long64_t[fN];
607 R__b.ReadFastArray(fIndexValues,fN);
608 if( R__v > 1 ) {
610 R__b.ReadFastArray(fIndexValuesMinor,fN);
611 } else {
613 }
614 fIndex = new Long64_t[fN];
615 R__b.ReadFastArray(fIndex,fN);
616 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
617 } else {
618 R__c = R__b.WriteVersion(TTreeIndex::IsA(), true);
622 R__b << fN;
623 R__b.WriteFastArray(fIndexValues, fN);
624 R__b.WriteFastArray(fIndexValuesMinor, fN);
625 R__b.WriteFastArray(fIndex, fN);
626 R__b.SetByteCount(R__c, true);
627 }
628}
629
630////////////////////////////////////////////////////////////////////////////////
631/// Called by TChain::LoadTree when the parent chain changes it's tree.
632
634{
638 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
640 }
642 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
644 }
645}
646////////////////////////////////////////////////////////////////////////////////
647/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
648/// when a new Tree is loaded.
649/// Because Trees in a TChain may have a different list of leaves, one
650/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
651
653{
654 fTree = T;
655}
656
657////////////////////////////////////////////////////////////////////////////////
658/// \brief Create a deep copy of the TTreeIndex
659/// \param[in] newname A new name for the index
660///
661/// The new index is allocated on the heap without being managed. Also, it is
662/// not attached to any tree. It is the responsibility of the caller to manage
663/// its lifetime and attach it to a tree if necessary.
665{
666 auto index = new TTreeIndex();
667 index->SetName(newname && std::strlen(newname) ? newname : GetName());
668 index->SetTitle(GetTitle());
669
670 // Note that the TTreeFormula * data members are not cloned since they would
671 // need the attached tree data member to function properly.
672 index->fMajorName = fMajorName;
673 index->fMinorName = fMinorName;
674
675 if (fN == 0)
676 return index;
677
678 index->fN = fN;
679
680 index->fIndexValues = new Long64_t[index->fN];
681 std::copy(fIndexValues, fIndexValues + fN, index->fIndexValues);
682
683 index->fIndexValuesMinor = new Long64_t[index->fN];
684 std::copy(fIndexValuesMinor, fIndexValuesMinor + fN, index->fIndexValuesMinor);
685
686 index->fIndex = new Long64_t[index->fN];
687 std::copy(fIndex, fIndex + fN, index->fIndex);
688
689 return index;
690}
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
Int_t gDebug
Definition TROOT.cxx:622
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:5966
virtual TVirtualIndex * GetTreeIndex() const
Definition TTree.h:570
virtual Long64_t GetEntries() const
Definition TTree.h:475
virtual Long64_t GetReadEntry() const
Definition TTree.h:561
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition TTree.cxx:6529
virtual Long64_t GetEntriesFast() const
Return a number greater or equal to the total number of entries in the dataset.
Definition TTree.h:517
virtual Int_t GetTreeNumber() const
Definition TTree.h:571
@ 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:9504
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)