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
24
25
26struct IndexSortComparator {
27
28 IndexSortComparator(Long64_t *major, Long64_t *minor)
29 : fValMajor(major), fValMinor(minor)
30 {}
31
32 template<typename Index>
33 bool operator()(Index i1, Index i2) {
34 if( *(fValMajor + i1) == *(fValMajor + i2) )
35 return *(fValMinor + i1) < *(fValMinor + i2);
36 else
37 return *(fValMajor + i1) < *(fValMajor + i2);
38 }
39
40 // pointers to the start of index values tables keeping uppder 64bit and lower 64bit
41 // of combined indexed 128bit value
42 Long64_t *fValMajor, *fValMinor;
43};
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Default constructor for TTreeIndex
48
50{
51 fTree = 0;
52 fN = 0;
53 fIndexValues = 0;
55 fIndex = 0;
56 fMajorFormula = 0;
57 fMinorFormula = 0;
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Normal constructor for TTreeIndex
64///
65/// Build an index table using the leaves of Tree T with major & minor names
66/// The index is built with the expressions given in "majorname" and "minorname".
67///
68/// a Long64_t array fIndexValues is built with:
69///
70/// - major = the value of majorname converted to an integer
71/// - minor = the value of minorname converted to an integer
72/// - fIndexValues[i] = major<<31 + minor
73///
74/// This array is sorted. The sorted fIndex[i] contains the serial number
75/// in the Tree corresponding to the pair "major,minor" in fIndexvalues[i].
76///
77/// Once the index is computed, one can retrieve one entry via
78/// ~~~{.cpp}
79/// T->GetEntryWithIndex(majornumber, minornumber)
80/// ~~~
81/// Example:
82/// ~~~{.cpp}
83/// tree.BuildIndex("Run","Event"); //creates an index using leaves Run and Event
84/// tree.GetEntryWithIndex(1234,56789); // reads entry corresponding to
85/// // Run=1234 and Event=56789
86/// ~~~
87/// Note that majorname and minorname may be expressions using original
88/// Tree variables eg: "run-90000", "event +3*xx". However the result
89/// must be integer.
90///
91/// In case an expression is specified, the equivalent expression must be computed
92/// when calling GetEntryWithIndex.
93///
94/// To build an index with only majorname, specify minorname="0" (default)
95///
96/// ## TreeIndex and Friend Trees
97///
98/// Assuming a parent Tree T and a friend Tree TF, the following cases are supported:
99/// - CASE 1: T->GetEntry(entry) is called
100/// In this case, the serial number entry is used to retrieve
101/// the data in both Trees.
102/// - CASE 2: T->GetEntry(entry) is called, TF has a TreeIndex
103/// the expressions given in major/minorname of TF are used
104/// to compute the value pair major,minor with the data in T.
105/// TF->GetEntryWithIndex(major,minor) is then called (tricky case!)
106/// - CASE 3: T->GetEntryWithIndex(major,minor) is called.
107/// It is assumed that both T and TF have a TreeIndex built using
108/// the same major and minor name.
109///
110/// ## Saving the TreeIndex
111///
112/// Once the index is built, it can be saved with the TTree object
113/// with tree.Write(); (if the file has been open in "update" mode).
114///
115/// The most convenient place to create the index is at the end of
116/// the filling process just before saving the Tree header.
117/// If a previous index was computed, it is redefined by this new call.
118///
119/// Note that this function can also be applied to a TChain.
120///
121/// The return value is the number of entries in the Index (< 0 indicates failure)
122///
123/// It is possible to play with different TreeIndex in the same Tree.
124/// see comments in TTree::SetTreeIndex.
125
126TTreeIndex::TTreeIndex(const TTree *T, const char *majorname, const char *minorname)
127 : TVirtualIndex()
128{
129 fTree = (TTree*)T;
130 fN = 0;
131 fIndexValues = 0;
133 fIndex = 0;
134 fMajorFormula = 0;
135 fMinorFormula = 0;
138 fMajorName = majorname;
139 fMinorName = minorname;
140 if (!T) return;
141 fN = T->GetEntries();
142 if (fN <= 0) {
143 MakeZombie();
144 Error("TreeIndex","Cannot build a TreeIndex with a Tree having no entries");
145 return;
146 }
147
150 if (!fMajorFormula || !fMinorFormula) {
151 MakeZombie();
152 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
153 return;
154 }
155 if ((fMajorFormula->GetNdim() != 1) || (fMinorFormula->GetNdim() != 1)) {
156 MakeZombie();
157 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
158 return;
159 }
160 // accessing array elements should be OK
161 //if ((fMajorFormula->GetMultiplicity() != 0) || (fMinorFormula->GetMultiplicity() != 0)) {
162 // MakeZombie();
163 // Error("TreeIndex","Cannot build the index with major=%s, minor=%s that cannot be arrays",fMajorName.Data(), fMinorName.Data());
164 // return;
165 //}
166
167 Long64_t *tmp_major = new Long64_t[fN];
168 Long64_t *tmp_minor = new Long64_t[fN];
169 Long64_t i;
170 Long64_t oldEntry = fTree->GetReadEntry();
171 Int_t current = -1;
172 for (i=0;i<fN;i++) {
173 Long64_t centry = fTree->LoadTree(i);
174 if (centry < 0) break;
175 if (fTree->GetTreeNumber() != current) {
176 current = fTree->GetTreeNumber();
179 }
180 auto GetAndRangeCheck = [this](bool isMajor, Long64_t entry) {
181 LongDouble_t ldRet = (isMajor ? fMajorFormula : fMinorFormula)->EvalInstance<LongDouble_t>();
182 Long64_t ret = (Long64_t) ldRet;
183 Long64_t retCloserToZero = ret > 0 ? ret - 1 : ret + 1;
184 if (retCloserToZero == ret) {
185 Warning("TTreeIndex",
186 "In tree entry %lld, %s value %s=%lld possibly out of range for internal `long double`",
187 entry, isMajor ? "major" : "minor", isMajor ? fMajorName.Data() : fMinorName.Data(), ret);
188 }
189 return ret;
190 };
191 tmp_major[i] = GetAndRangeCheck(true, i);
192 tmp_minor[i] = GetAndRangeCheck(false, i);
193 }
194 fIndex = new Long64_t[fN];
195 for(i = 0; i < fN; i++) { fIndex[i] = i; }
196 std::sort(fIndex, fIndex + fN, IndexSortComparator(tmp_major, tmp_minor) );
197 //TMath::Sort(fN,w,fIndex,0);
198 fIndexValues = new Long64_t[fN];
200 for (i=0;i<fN;i++) {
201 fIndexValues[i] = tmp_major[fIndex[i]];
202 fIndexValuesMinor[i] = tmp_minor[fIndex[i]];
203 }
204
205 delete [] tmp_major;
206 delete [] tmp_minor;
207 fTree->LoadTree(oldEntry);
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Destructor.
212
214{
215 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(0);
216 delete [] fIndexValues; fIndexValues = 0;
218 delete [] fIndex; fIndex = 0;
219 delete fMajorFormula; fMajorFormula = 0;
220 delete fMinorFormula; fMinorFormula = 0;
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
227/// If delaySort is true, do not sort the value, then you must call
228/// Append(0,kFALSE);
229
230void TTreeIndex::Append(const TVirtualIndex *add, Bool_t delaySort )
231{
232
233 if (add && add->GetN()) {
234 // Create new buffer (if needed)
235
236 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
237 if (ti_add == 0) {
238 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
239 add->IsA()->GetName());
240 }
241
242 Long64_t oldn = fN;
243 fN += add->GetN();
244
245 Long64_t *oldIndex = fIndex;
246 Long64_t *oldValues = GetIndexValues();
247 Long64_t *oldValues2 = GetIndexValuesMinor();
248
249 fIndex = new Long64_t[fN];
250 fIndexValues = new Long64_t[fN];
252
253 // Copy data
254 Long_t size = sizeof(Long64_t) * oldn;
255 Long_t add_size = sizeof(Long64_t) * add->GetN();
256
257 memcpy(fIndex,oldIndex, size);
258 memcpy(fIndexValues,oldValues, size);
259 memcpy(fIndexValuesMinor,oldValues2, size);
260
261 Long64_t *addIndex = ti_add->GetIndex();
262 Long64_t *addValues = ti_add->GetIndexValues();
263 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
264
265 memcpy(fIndex + oldn, addIndex, add_size);
266 memcpy(fIndexValues + oldn, addValues, add_size);
267 memcpy(fIndexValuesMinor + oldn, addValues2, add_size);
268 for(Int_t i = 0; i < add->GetN(); i++) {
269 fIndex[oldn + i] += oldn;
270 }
271
272 delete [] oldIndex;
273 delete [] oldValues;
274 delete [] oldValues2;
275 }
276
277 // Sort.
278 if (!delaySort) {
279 Long64_t *addValues = GetIndexValues();
280 Long64_t *addValues2 = GetIndexValuesMinor();
281 Long64_t *ind = fIndex;
282 Long64_t *conv = new Long64_t[fN];
283
284 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
285 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
286 //Long64_t *w = fIndexValues;
287 //TMath::Sort(fN,w,conv,0);
288
289 fIndex = new Long64_t[fN];
290 fIndexValues = new Long64_t[fN];
292
293 for (Int_t i=0;i<fN;i++) {
294 fIndex[i] = ind[conv[i]];
295 fIndexValues[i] = addValues[conv[i]];
296 fIndexValuesMinor[i] = addValues2[conv[i]];
297 }
298 delete [] addValues;
299 delete [] addValues2;
300 delete [] ind;
301 delete [] conv;
302 }
303}
304
305
306
307////////////////////////////////////////////////////////////////////////////////
308/// conversion from old 64bit indexes
309/// return true if index was converted
310
312{
313 if( !fIndexValuesMinor && fN ) {
315 for(int i=0; i<fN; i++) {
316 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
317 fIndexValues[i] >>= 31;
318 }
319 return true;
320 }
321 return false;
322}
323
324
325
326////////////////////////////////////////////////////////////////////////////////
327/// Returns the entry number in this (friend) Tree corresponding to entry in
328/// the master Tree 'parent'.
329/// In case this (friend) Tree and 'master' do not share an index with the same
330/// major and minor name, the entry serial number in the (friend) tree
331/// and in the master Tree are assumed to be the same
332
334{
335 if (!parent) return -3;
336 // We reached the end of the parent tree
337 Long64_t pentry = parent->GetReadEntry();
338 if (pentry >= parent->GetEntries())
339 return -2;
340 GetMajorFormulaParent(parent);
341 GetMinorFormulaParent(parent);
342 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
344 // The Tree Index in the friend has a pair majorname,minorname
345 // not available in the parent Tree T.
346 // if the friend Tree has less entries than the parent, this is an error
347 if (pentry >= fTree->GetEntries()) return -2;
348 // otherwise we ignore the Tree Index and return the entry number
349 // in the parent Tree.
350 return pentry;
351 }
352
353 // majorname, minorname exist in the parent Tree
354 // we find the current values pair majorv,minorv in the parent Tree
357 Long64_t majorv = (Long64_t)majord;
358 Long64_t minorv = (Long64_t)minord;
359 // we check if this pair exist in the index.
360 // if yes, we return the corresponding entry number
361 // if not the function returns -1
362 return fTree->GetEntryNumberWithIndex(majorv,minorv);
363}
364
365
366////////////////////////////////////////////////////////////////////////////////
367/// find position where major|minor values are in the IndexValues tables
368/// this is the index in IndexValues table, not entry# !
369/// use lower_bound STD algorithm.
370
372{
373 Long64_t mid, step, pos = 0, count = fN;
374 // find lower bound using bisection
375 while( count > 0 ) {
376 step = count / 2;
377 mid = pos + step;
378 // check if *mid < major|minor
379 if( fIndexValues[mid] < major
380 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
381 pos = mid+1;
382 count -= step + 1;
383 } else
384 count = step;
385 }
386 return pos;
387}
388
389
390////////////////////////////////////////////////////////////////////////////////
391/// Return entry number corresponding to major and minor number.
392/// Note that this function returns only the entry number, not the data
393/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
394/// the BuildIndex function has created a table of Double_t* of sorted values
395/// corresponding to val = major<<31 + minor;
396/// The function performs binary search in this sorted table.
397/// If it finds a pair that maches val, it returns directly the
398/// index in the table.
399/// If an entry corresponding to major and minor is not found, the function
400/// returns the index of the major,minor pair immediatly lower than the
401/// requested value, ie it will return -1 if the pair is lower than
402/// the first entry in the index.
403///
404/// See also GetEntryNumberWithIndex
405
407{
408 if (fN == 0) return -1;
409
410 Long64_t pos = FindValues(major, minor);
411 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
412 return fIndex[pos];
413 if( --pos < 0 )
414 return -1;
415 return fIndex[pos];
416}
417
418
419////////////////////////////////////////////////////////////////////////////////
420/// Return entry number corresponding to major and minor number.
421/// Note that this function returns only the entry number, not the data
422/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
423/// the BuildIndex function has created a table of Double_t* of sorted values
424/// corresponding to val = major<<31 + minor;
425/// The function performs binary search in this sorted table.
426/// If it finds a pair that maches val, it returns directly the
427/// index in the table, otherwise it returns -1.
428///
429/// See also GetEntryNumberWithBestIndex
430
432{
433 if (fN == 0) return -1;
434
435 Long64_t pos = FindValues(major, minor);
436 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
437 return fIndex[pos];
438 return -1;
439}
440
441
442////////////////////////////////////////////////////////////////////////////////
443
445{
446 return fIndexValuesMinor;
447}
448
449
450
451////////////////////////////////////////////////////////////////////////////////
452/// Return a pointer to the TreeFormula corresponding to the majorname.
453
455{
456 if (!fMajorFormula) {
459 }
460 return fMajorFormula;
461}
462
463////////////////////////////////////////////////////////////////////////////////
464/// Return a pointer to the TreeFormula corresponding to the minorname.
465
467{
468 if (!fMinorFormula) {
471 }
472 return fMinorFormula;
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
477
479{
480 if (!fMajorFormulaParent) {
481 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
482 // is a friend of the parent TTree.
484 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
486 }
487 if (fMajorFormulaParent->GetTree() != parent) {
488 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
490 }
491 return fMajorFormulaParent;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
496
498{
499 if (!fMinorFormulaParent) {
500 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
501 // is a friend of the parent TTree.
503 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
505 }
506 if (fMinorFormulaParent->GetTree() != parent) {
507 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
509 }
510 return fMinorFormulaParent;
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Return kTRUE if index can be applied to the TTree
515
517{
518 auto *majorFormula = GetMajorFormulaParent(parent);
519 auto *minorFormula = GetMinorFormulaParent(parent);
520 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
521 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
522 return kFALSE;
523 return kTRUE;
524}
525
526////////////////////////////////////////////////////////////////////////////////
527/// Print the table with : serial number, majorname, minorname.
528/// - if option = "10" print only the first 10 entries
529/// - if option = "100" print only the first 100 entries
530/// - if option = "1000" print only the first 1000 entries
531
532void TTreeIndex::Print(Option_t * option) const
533{
534 TString opt = option;
535 Bool_t printEntry = kFALSE;
536 Long64_t n = fN;
537 if (opt.Contains("10")) n = 10;
538 if (opt.Contains("100")) n = 100;
539 if (opt.Contains("1000")) n = 1000;
540 if (opt.Contains("all")) {
541 printEntry = kTRUE;
542 }
543
544 if (printEntry) {
545 Printf("\n*****************************************************************");
546 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
547 Printf("*****************************************************************");
548 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
549 Printf("*****************************************************************");
550 for (Long64_t i=0;i<n;i++) {
551 Printf("%8lld : %8lld : %8lld : %8lld",
552 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
553 }
554
555 } else {
556 Printf("\n**********************************************");
557 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
558 Printf("**********************************************");
559 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
560 Printf("**********************************************");
561 for (Long64_t i=0;i<n;i++) {
562 Printf("%8lld : %8lld : %8lld",
564 }
565 }
566}
567
568////////////////////////////////////////////////////////////////////////////////
569/// Stream an object of class TTreeIndex.
570/// Note that this Streamer should be changed to an automatic Streamer
571/// once TStreamerInfo supports an index of type Long64_t
572
573void TTreeIndex::Streamer(TBuffer &R__b)
574{
575 UInt_t R__s, R__c;
576 if (R__b.IsReading()) {
577 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
578 TVirtualIndex::Streamer(R__b);
579 fMajorName.Streamer(R__b);
580 fMinorName.Streamer(R__b);
581 R__b >> fN;
582 fIndexValues = new Long64_t[fN];
584 if( R__v > 1 ) {
587 } else {
589 }
590 fIndex = new Long64_t[fN];
591 R__b.ReadFastArray(fIndex,fN);
592 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
593 } else {
594 R__c = R__b.WriteVersion(TTreeIndex::IsA(), kTRUE);
595 TVirtualIndex::Streamer(R__b);
596 fMajorName.Streamer(R__b);
597 fMinorName.Streamer(R__b);
598 R__b << fN;
601 R__b.WriteFastArray(fIndex, fN);
602 R__b.SetByteCount(R__c, kTRUE);
603 }
604}
605
606////////////////////////////////////////////////////////////////////////////////
607/// Called by TChain::LoadTree when the parent chain changes it's tree.
608
610{
614 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
616 }
618 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
620 }
621}
622////////////////////////////////////////////////////////////////////////////////
623/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
624/// when a new Tree is loaded.
625/// Because Trees in a TChain may have a different list of leaves, one
626/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
627
629{
630 fTree = (TTree*)T;
631}
632
short Version_t
Definition RtypesCore.h:65
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:92
long Long_t
Definition RtypesCore.h:54
double Double_t
Definition RtypesCore.h:59
long double LongDouble_t
Definition RtypesCore.h:61
long long Long64_t
Definition RtypesCore.h:73
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:364
TRObject operator()(const T1 &t1) const
void Printf(const char *fmt,...)
virtual Int_t GetNdim() const
Definition TFormula.h:237
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
virtual const char * GetTitle() const
Returns title of object.
Definition TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:879
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:893
void MakeZombie()
Definition TObject.h:49
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
Used to pass a selection expression to the Tree drawing routine.
T EvalInstance(Int_t i=0, const char *stringStack[]=0)
Evaluate this treeformula.
virtual void SetTree(TTree *tree)
virtual void UpdateFormulaLeaves()
This function is called TTreePlayer::UpdateFormulaLeaves, itself called by TChain::LoadTree when a ne...
virtual TTree * GetTree() const
void SetQuickLoad(Bool_t quick)
A Tree Index with majorname and minorname.
Definition TTreeIndex.h:29
TTreeIndex()
Default constructor for TTreeIndex.
virtual Long64_t * GetIndexValues() const
Definition TTreeIndex.h:61
virtual Long64_t * GetIndexValuesMinor() const
TTreeFormula * fMajorFormula
Definition TTreeIndex.h:38
TTreeFormula * fMajorFormulaParent
Pointer to minor TreeFormula.
Definition TTreeIndex.h:40
Long64_t * fIndex
Definition TTreeIndex.h:37
TTreeFormula * GetMajorFormulaParent(const TTree *parent)
Pointer to minor TreeFormula in Parent tree (if any)
virtual ~TTreeIndex()
Destructor.
Long64_t fN
Definition TTreeIndex.h:34
virtual Long64_t * GetIndex() const
Definition TTreeIndex.h:60
bool ConvertOldToNew()
conversion from old 64bit indexes return true if index was converted
TTreeFormula * fMinorFormula
Pointer to major TreeFormula.
Definition TTreeIndex.h:39
virtual Bool_t IsValidFor(const TTree *parent)
Return kTRUE if index can be applied to the TTree.
virtual TTreeFormula * GetMajorFormula()
Return a pointer to the TreeFormula corresponding to the majorname.
virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const
Return entry number corresponding to major and minor number.
virtual void Print(Option_t *option="") const
Print the table with : serial number, majorname, minorname.
TTreeFormula * GetMinorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
TString fMinorName
Definition TTreeIndex.h:33
virtual TTreeFormula * GetMinorFormula()
Return a pointer to the TreeFormula corresponding to the minorname.
virtual void Append(const TVirtualIndex *, Bool_t delaySort=kFALSE)
Append 'add' to this index.
Long64_t * fIndexValues
Definition TTreeIndex.h:35
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const
Return entry number corresponding to major and minor number.
TString fMajorName
Definition TTreeIndex.h:32
Long64_t * fIndexValuesMinor
Definition TTreeIndex.h:36
TTreeFormula * fMinorFormulaParent
Pointer to major TreeFormula in Parent tree (if any)
Definition TTreeIndex.h:41
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...
virtual void SetTree(const TTree *T)
this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves when a new Tree is l...
virtual Long64_t GetEntryNumberFriend(const TTree *parent)
Returns the entry number in this (friend) Tree corresponding to entry in the master Tree 'parent'.
virtual void UpdateFormulaLeaves(const TTree *parent)
Called by TChain::LoadTree when the parent chain changes it's tree.
Helper class to prevent infinite recursion in the usage of TTree Friends.
Definition TTree.h:185
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor=0) const
Return entry number corresponding to major and minor number.
Definition TTree.cxx:5891
virtual TVirtualIndex * GetTreeIndex() const
Definition TTree.h:515
virtual Long64_t GetEntries() const
Definition TTree.h:460
virtual Long64_t GetReadEntry() const
Definition TTree.h:506
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition TTree.cxx:6454
virtual Int_t GetTreeNumber() const
Definition TTree.h:516
@ kFindBranch
Definition TTree.h:209
@ kFindLeaf
Definition TTree.h:210
@ kGetBranch
Definition TTree.h:212
@ kGetLeaf
Definition TTree.h:217
virtual void SetTreeIndex(TVirtualIndex *index)
The current TreeIndex is replaced by the new index.
Definition TTree.cxx:9279
Abstract interface for Tree Index.
virtual Long64_t GetN() const =0
const Int_t n
Definition legend1.C:16