Logo ROOT  
Reference Guide
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
27
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 upper 64bit and lower 64bit
41 // of combined indexed 128bit value
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 ret = (isMajor ? fMajorFormula : fMinorFormula)->EvalInstance<LongDouble_t>();
182 // Check whether the value (vs significant bits) of ldRet can represent
183 // the full precision of the returned value. If we return 10^60, the
184 // value fits into a long double, but if sizeof(long double) ==
185 // sizeof(double) it cannot store the ones: the value returned by
186 // EvalInstance() only stores the higher bits.
187 LongDouble_t retCloserToZero = ret;
188 if (ret > 0)
189 retCloserToZero -= 1;
190 else
191 retCloserToZero += 1;
192 if (retCloserToZero == ret) {
193 Warning("TTreeIndex",
194 "In tree entry %lld, %s value %s=%Lf possibly out of range for internal `long double`", entry,
195 isMajor ? "major" : "minor", isMajor ? fMajorName.Data() : fMinorName.Data(), ret);
196 }
197 return ret;
198 };
199 tmp_major[i] = GetAndRangeCheck(true, i);
200 tmp_minor[i] = GetAndRangeCheck(false, i);
201 }
202 fIndex = new Long64_t[fN];
203 for(i = 0; i < fN; i++) { fIndex[i] = i; }
204 std::sort(fIndex, fIndex + fN, IndexSortComparator(tmp_major, tmp_minor) );
205 //TMath::Sort(fN,w,fIndex,0);
206 fIndexValues = new Long64_t[fN];
208 for (i=0;i<fN;i++) {
209 fIndexValues[i] = tmp_major[fIndex[i]];
210 fIndexValuesMinor[i] = tmp_minor[fIndex[i]];
211 }
212
213 delete [] tmp_major;
214 delete [] tmp_minor;
215 fTree->LoadTree(oldEntry);
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Destructor.
220
222{
223 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(0);
224 delete [] fIndexValues; fIndexValues = 0;
226 delete [] fIndex; fIndex = 0;
227 delete fMajorFormula; fMajorFormula = 0;
228 delete fMinorFormula; fMinorFormula = 0;
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
235/// If delaySort is true, do not sort the value, then you must call
236/// Append(0,kFALSE);
237
238void TTreeIndex::Append(const TVirtualIndex *add, Bool_t delaySort )
239{
240
241 if (add && add->GetN()) {
242 // Create new buffer (if needed)
243
244 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
245 if (ti_add == 0) {
246 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
247 add->IsA()->GetName());
248 }
249
250 Long64_t oldn = fN;
251 fN += add->GetN();
252
253 Long64_t *oldIndex = fIndex;
254 Long64_t *oldValues = GetIndexValues();
255 Long64_t *oldValues2 = GetIndexValuesMinor();
256
257 fIndex = new Long64_t[fN];
258 fIndexValues = new Long64_t[fN];
260
261 // Copy data
262 Long_t size = sizeof(Long64_t) * oldn;
263 Long_t add_size = sizeof(Long64_t) * add->GetN();
264
265 memcpy(fIndex,oldIndex, size);
266 memcpy(fIndexValues,oldValues, size);
267 memcpy(fIndexValuesMinor,oldValues2, size);
268
269 Long64_t *addIndex = ti_add->GetIndex();
270 Long64_t *addValues = ti_add->GetIndexValues();
271 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
272
273 memcpy(fIndex + oldn, addIndex, add_size);
274 memcpy(fIndexValues + oldn, addValues, add_size);
275 memcpy(fIndexValuesMinor + oldn, addValues2, add_size);
276 for(Int_t i = 0; i < add->GetN(); i++) {
277 fIndex[oldn + i] += oldn;
278 }
279
280 delete [] oldIndex;
281 delete [] oldValues;
282 delete [] oldValues2;
283 }
284
285 // Sort.
286 if (!delaySort) {
287 Long64_t *addValues = GetIndexValues();
288 Long64_t *addValues2 = GetIndexValuesMinor();
289 Long64_t *ind = fIndex;
290 Long64_t *conv = new Long64_t[fN];
291
292 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
293 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
294 //Long64_t *w = fIndexValues;
295 //TMath::Sort(fN,w,conv,0);
296
297 fIndex = new Long64_t[fN];
298 fIndexValues = new Long64_t[fN];
300
301 for (Int_t i=0;i<fN;i++) {
302 fIndex[i] = ind[conv[i]];
303 fIndexValues[i] = addValues[conv[i]];
304 fIndexValuesMinor[i] = addValues2[conv[i]];
305 }
306 delete [] addValues;
307 delete [] addValues2;
308 delete [] ind;
309 delete [] conv;
310 }
311}
312
313
314
315////////////////////////////////////////////////////////////////////////////////
316/// conversion from old 64bit indexes
317/// return true if index was converted
318
320{
321 if( !fIndexValuesMinor && fN ) {
323 for(int i=0; i<fN; i++) {
324 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
325 fIndexValues[i] >>= 31;
326 }
327 return true;
328 }
329 return false;
330}
331
332
333
334////////////////////////////////////////////////////////////////////////////////
335/// Returns the entry number in this (friend) Tree corresponding to entry in
336/// the master Tree 'parent'.
337/// In case this (friend) Tree and 'master' do not share an index with the same
338/// major and minor name, the entry serial number in the (friend) tree
339/// and in the master Tree are assumed to be the same
340
342{
343 if (!parent) return -3;
344 // We reached the end of the parent tree
345 Long64_t pentry = parent->GetReadEntry();
346 if (pentry >= parent->GetEntries())
347 return -2;
348 GetMajorFormulaParent(parent);
349 GetMinorFormulaParent(parent);
350 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
352 // The Tree Index in the friend has a pair majorname,minorname
353 // not available in the parent Tree T.
354 // if the friend Tree has less entries than the parent, this is an error
355 if (pentry >= fTree->GetEntries()) return -2;
356 // otherwise we ignore the Tree Index and return the entry number
357 // in the parent Tree.
358 return pentry;
359 }
360
361 // majorname, minorname exist in the parent Tree
362 // we find the current values pair majorv,minorv in the parent Tree
365 Long64_t majorv = (Long64_t)majord;
366 Long64_t minorv = (Long64_t)minord;
367 // we check if this pair exist in the index.
368 // if yes, we return the corresponding entry number
369 // if not the function returns -1
370 return fTree->GetEntryNumberWithIndex(majorv,minorv);
371}
372
373
374////////////////////////////////////////////////////////////////////////////////
375/// find position where major|minor values are in the IndexValues tables
376/// this is the index in IndexValues table, not entry# !
377/// use lower_bound STD algorithm.
378
380{
381 Long64_t mid, step, pos = 0, count = fN;
382 // find lower bound using bisection
383 while( count > 0 ) {
384 step = count / 2;
385 mid = pos + step;
386 // check if *mid < major|minor
387 if( fIndexValues[mid] < major
388 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
389 pos = mid+1;
390 count -= step + 1;
391 } else
392 count = step;
393 }
394 return pos;
395}
396
397
398////////////////////////////////////////////////////////////////////////////////
399/// Return entry number corresponding to major and minor number.
400/// Note that this function returns only the entry number, not the data
401/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
402/// the BuildIndex function has created a table of Double_t* of sorted values
403/// corresponding to val = major<<31 + minor;
404/// The function performs binary search in this sorted table.
405/// If it finds a pair that maches val, it returns directly the
406/// index in the table.
407/// If an entry corresponding to major and minor is not found, the function
408/// returns the index of the major,minor pair immediately lower than the
409/// requested value, ie it will return -1 if the pair is lower than
410/// the first entry in the index.
411///
412/// See also GetEntryNumberWithIndex
413
415{
416 if (fN == 0) return -1;
417
418 Long64_t pos = FindValues(major, minor);
419 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
420 return fIndex[pos];
421 if( --pos < 0 )
422 return -1;
423 return fIndex[pos];
424}
425
426
427////////////////////////////////////////////////////////////////////////////////
428/// Return entry number corresponding to major and minor number.
429/// Note that this function returns only the entry number, not the data
430/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
431/// the BuildIndex function has created a table of Double_t* of sorted values
432/// corresponding to val = major<<31 + minor;
433/// The function performs binary search in this sorted table.
434/// If it finds a pair that maches val, it returns directly the
435/// index in the table, otherwise it returns -1.
436///
437/// See also GetEntryNumberWithBestIndex
438
440{
441 if (fN == 0) return -1;
442
443 Long64_t pos = FindValues(major, minor);
444 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
445 return fIndex[pos];
446 return -1;
447}
448
449
450////////////////////////////////////////////////////////////////////////////////
451
453{
454 return fIndexValuesMinor;
455}
456
457
458
459////////////////////////////////////////////////////////////////////////////////
460/// Return a pointer to the TreeFormula corresponding to the majorname.
461
463{
464 if (!fMajorFormula) {
467 }
468 return fMajorFormula;
469}
470
471////////////////////////////////////////////////////////////////////////////////
472/// Return a pointer to the TreeFormula corresponding to the minorname.
473
475{
476 if (!fMinorFormula) {
479 }
480 return fMinorFormula;
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
485
487{
488 if (!fMajorFormulaParent) {
489 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
490 // is a friend of the parent TTree.
492 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
494 }
495 if (fMajorFormulaParent->GetTree() != parent) {
496 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
498 }
499 return fMajorFormulaParent;
500}
501
502////////////////////////////////////////////////////////////////////////////////
503/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
504
506{
507 if (!fMinorFormulaParent) {
508 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
509 // is a friend of the parent TTree.
511 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
513 }
514 if (fMinorFormulaParent->GetTree() != parent) {
515 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
517 }
518 return fMinorFormulaParent;
519}
520
521////////////////////////////////////////////////////////////////////////////////
522/// Return kTRUE if index can be applied to the TTree
523
525{
526 auto *majorFormula = GetMajorFormulaParent(parent);
527 auto *minorFormula = GetMinorFormulaParent(parent);
528 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
529 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
530 return kFALSE;
531 return kTRUE;
532}
533
534////////////////////////////////////////////////////////////////////////////////
535/// Print the table with : serial number, majorname, minorname.
536/// - if option = "10" print only the first 10 entries
537/// - if option = "100" print only the first 100 entries
538/// - if option = "1000" print only the first 1000 entries
539
541{
542 TString opt = option;
543 Bool_t printEntry = kFALSE;
544 Long64_t n = fN;
545 if (opt.Contains("10")) n = 10;
546 if (opt.Contains("100")) n = 100;
547 if (opt.Contains("1000")) n = 1000;
548 if (opt.Contains("all")) {
549 printEntry = kTRUE;
550 }
551
552 if (printEntry) {
553 Printf("\n*****************************************************************");
554 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
555 Printf("*****************************************************************");
556 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
557 Printf("*****************************************************************");
558 for (Long64_t i=0;i<n;i++) {
559 Printf("%8lld : %8lld : %8lld : %8lld",
560 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
561 }
562
563 } else {
564 Printf("\n**********************************************");
565 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
566 Printf("**********************************************");
567 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
568 Printf("**********************************************");
569 for (Long64_t i=0;i<n;i++) {
570 Printf("%8lld : %8lld : %8lld",
572 }
573 }
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// Stream an object of class TTreeIndex.
578/// Note that this Streamer should be changed to an automatic Streamer
579/// once TStreamerInfo supports an index of type Long64_t
580
582{
583 UInt_t R__s, R__c;
584 if (R__b.IsReading()) {
585 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
587 fMajorName.Streamer(R__b);
588 fMinorName.Streamer(R__b);
589 R__b >> fN;
590 fIndexValues = new Long64_t[fN];
592 if( R__v > 1 ) {
595 } else {
597 }
598 fIndex = new Long64_t[fN];
599 R__b.ReadFastArray(fIndex,fN);
600 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
601 } else {
602 R__c = R__b.WriteVersion(TTreeIndex::IsA(), kTRUE);
604 fMajorName.Streamer(R__b);
605 fMinorName.Streamer(R__b);
606 R__b << fN;
609 R__b.WriteFastArray(fIndex, fN);
610 R__b.SetByteCount(R__c, kTRUE);
611 }
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Called by TChain::LoadTree when the parent chain changes it's tree.
616
618{
622 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
624 }
626 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
628 }
629}
630////////////////////////////////////////////////////////////////////////////////
631/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
632/// when a new Tree is loaded.
633/// Because Trees in a TChain may have a different list of leaves, one
634/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
635
637{
638 fTree = (TTree*)T;
639}
640
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Version_t
Definition: RtypesCore.h:65
const Bool_t kFALSE
Definition: RtypesCore.h:101
long Long_t
Definition: RtypesCore.h:54
long double LongDouble_t
Definition: RtypesCore.h:61
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:375
Option_t Option_t option
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition: TString.cxx:2466
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
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
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
virtual void Streamer(TBuffer &)
Stream a string object.
Definition: TString.cxx:1375
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.
Definition: TTreeFormula.h:58
T EvalInstance(Int_t i=0, const char *stringStack[]=0)
Evaluate this treeformula.
virtual void SetTree(TTree *tree)
Definition: TTreeFormula.h:208
virtual void UpdateFormulaLeaves()
This function is called TTreePlayer::UpdateFormulaLeaves, itself called by TChain::LoadTree when a ne...
virtual TTree * GetTree() const
Definition: TTreeFormula.h:210
void SetQuickLoad(Bool_t quick)
Definition: TTreeFormula.h:207
A Tree Index with majorname and minorname.
Definition: TTreeIndex.h:29
TTreeIndex()
Default constructor for TTreeIndex.
Definition: TTreeIndex.cxx:49
virtual Long64_t * GetIndexValues() const
Definition: TTreeIndex.h:61
virtual Long64_t * GetIndexValuesMinor() const
Definition: TTreeIndex.cxx:452
TTreeFormula * fMajorFormula
! Pointer to major TreeFormula
Definition: TTreeIndex.h:38
TTreeFormula * fMajorFormulaParent
! Pointer to major TreeFormula in Parent tree (if any)
Definition: TTreeIndex.h:40
Long64_t * fIndex
[fN] Index of sorted values
Definition: TTreeIndex.h:37
TTreeFormula * GetMajorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
Definition: TTreeIndex.cxx:486
virtual ~TTreeIndex()
Destructor.
Definition: TTreeIndex.cxx:221
virtual TClass * IsA() const
Definition: TTreeIndex.h:73
Long64_t fN
Number of entries.
Definition: TTreeIndex.h:34
virtual Long64_t * GetIndex() const
Definition: TTreeIndex.h:60
virtual void Streamer(TBuffer &)
Stream an object of class TTreeIndex.
Definition: TTreeIndex.cxx:581
bool ConvertOldToNew()
conversion from old 64bit indexes return true if index was converted
Definition: TTreeIndex.cxx:319
TTreeFormula * fMinorFormula
! Pointer to minor TreeFormula
Definition: TTreeIndex.h:39
virtual Bool_t IsValidFor(const TTree *parent)
Return kTRUE if index can be applied to the TTree.
Definition: TTreeIndex.cxx:524
virtual TTreeFormula * GetMajorFormula()
Return a pointer to the TreeFormula corresponding to the majorname.
Definition: TTreeIndex.cxx:462
virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const
Return entry number corresponding to major and minor number.
Definition: TTreeIndex.cxx:414
virtual void Print(Option_t *option="") const
Print the table with : serial number, majorname, minorname.
Definition: TTreeIndex.cxx:540
TTreeFormula * GetMinorFormulaParent(const TTree *parent)
Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
Definition: TTreeIndex.cxx:505
TString fMinorName
Index minor name.
Definition: TTreeIndex.h:33
virtual TTreeFormula * GetMinorFormula()
Return a pointer to the TreeFormula corresponding to the minorname.
Definition: TTreeIndex.cxx:474
virtual void Append(const TVirtualIndex *, Bool_t delaySort=kFALSE)
Append 'add' to this index.
Definition: TTreeIndex.cxx:238
Long64_t * fIndexValues
[fN] Sorted index values, higher 64bits
Definition: TTreeIndex.h:35
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const
Return entry number corresponding to major and minor number.
Definition: TTreeIndex.cxx:439
TString fMajorName
Index major name.
Definition: TTreeIndex.h:32
Long64_t * fIndexValuesMinor
[fN] Sorted index values, lower 64bits
Definition: TTreeIndex.h:36
TTreeFormula * fMinorFormulaParent
! Pointer to minor 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...
Definition: TTreeIndex.cxx:379
virtual void SetTree(const TTree *T)
this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves when a new Tree is l...
Definition: TTreeIndex.cxx:636
virtual Long64_t GetEntryNumberFriend(const TTree *parent)
Returns the entry number in this (friend) Tree corresponding to entry in the master Tree 'parent'.
Definition: TTreeIndex.cxx:341
virtual void UpdateFormulaLeaves(const TTree *parent)
Called by TChain::LoadTree when the parent chain changes it's tree.
Definition: TTreeIndex.cxx:617
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:5884
virtual TVirtualIndex * GetTreeIndex() const
Definition: TTree.h:514
virtual Long64_t GetEntries() const
Definition: TTree.h:459
virtual Long64_t GetReadEntry() const
Definition: TTree.h:505
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition: TTree.cxx:6447
virtual Int_t GetTreeNumber() const
Definition: TTree.h:515
@ 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:9284
Abstract interface for Tree Index.
Definition: TVirtualIndex.h:30
void Streamer(TBuffer &) override
Stream an object of class TObject.
virtual Long64_t GetN() const =0
TClass * IsA() const override
Definition: TVirtualIndex.h:50
RooCmdArg Index(RooCategory &icat)
const Int_t n
Definition: legend1.C:16
double T(double x)
Definition: ChebyshevPol.h:34
bool operator()(Index i1, Index i2)
Definition: TTreeIndex.cxx:33
Long64_t * fValMinor
Definition: TTreeIndex.cxx:42
Long64_t * fValMajor
Definition: TTreeIndex.cxx:42
IndexSortComparator(Long64_t *major, Long64_t *minor)
Definition: TTreeIndex.cxx:28