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 bool duplicatedKeys = false;
216 for (i = 0; i < fN; i++) {
219 const bool checkDuplicates = i > 0 && (!duplicatedKeys || gDebug >= 1);
220 if (checkDuplicates) {
221 if (fIndexValues[i - 1] == fIndexValues[i] && fIndexValuesMinor[i - 1] == fIndexValuesMinor[i]) {
222 Error("TTreeIndex",
223 "In entry %lld, a duplicate key was found value at (%s, %s) = (%lld, %lld)",
225 );
226 if (gDebug < 1) {
227 Warning("TTreeIndex", "Further potential duplicates won't be checked, use gDebug >= 1 to check all.");
228 }
229 duplicatedKeys = true;
230 }
231 }
232 }
233
234 delete [] tmp_major;
235 delete [] tmp_minor;
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// Destructor.
241
243{
244 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(nullptr);
245 delete [] fIndexValues; fIndexValues = nullptr;
246 delete [] fIndexValuesMinor; fIndexValuesMinor = nullptr;
247 delete [] fIndex; fIndex = nullptr;
248 delete fMajorFormula; fMajorFormula = nullptr;
249 delete fMinorFormula; fMinorFormula = nullptr;
252}
253
254////////////////////////////////////////////////////////////////////////////////
255/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
256/// If delaySort is true, do not sort the value, then you must call
257/// Append(0,false);
258
260{
261
262 if (add && add->GetN()) {
263 // Create new buffer (if needed)
264
265 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
266 if (ti_add == nullptr) {
267 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
268 add->IsA()->GetName());
269 }
270
271 Long64_t oldn = fN;
272 fN += add->GetN();
273
277
278 fIndex = new Long64_t[fN];
279 fIndexValues = new Long64_t[fN];
281
282 // Copy data
283 Long_t size = sizeof(Long64_t) * oldn;
284 Long_t add_size = sizeof(Long64_t) * add->GetN();
285
289
290 Long64_t *addIndex = ti_add->GetIndex();
291 Long64_t *addValues = ti_add->GetIndexValues();
292 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
293
297 for(Int_t i = 0; i < add->GetN(); i++) {
298 fIndex[oldn + i] += oldn;
299 }
300
301 delete [] oldIndex;
302 delete [] oldValues;
303 delete [] oldValues2;
304 }
305
306 // Sort.
307 if (!delaySort) {
311 Long64_t *conv = new Long64_t[fN];
312
313 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
314 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
315 //Long64_t *w = fIndexValues;
316 //TMath::Sort(fN,w,conv,0);
317
318 fIndex = new Long64_t[fN];
319 fIndexValues = new Long64_t[fN];
321
322 for (Int_t i=0;i<fN;i++) {
323 fIndex[i] = ind[conv[i]];
324 fIndexValues[i] = addValues[conv[i]];
325 fIndexValuesMinor[i] = addValues2[conv[i]];
326 }
327 delete [] addValues;
328 delete [] addValues2;
329 delete [] ind;
330 delete [] conv;
331 }
332}
333
334
335
336////////////////////////////////////////////////////////////////////////////////
337/// Conversion from old 64bit indexes.
338/// Before, major and minor were stored as a single 64-bit register, with
339/// bits [0,30] for minor and bits [31,64] for major.
340/// Now, both minor and major have their own 64-bit register.
341/// \return true if index was converted
342
344{
345 if( !fIndexValuesMinor && fN ) {
347 for(int i=0; i<fN; i++) {
348 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
349 fIndexValues[i] >>= 31;
350 }
351 return true;
352 }
353 return false;
354}
355
356
357
358////////////////////////////////////////////////////////////////////////////////
359/// Returns the entry number in this (friend) Tree corresponding to entry in
360/// the master Tree 'parent'.
361/// In case this (friend) Tree and 'master' do not share an index with the same
362/// major and minor name, the entry serial number in the (friend) tree
363/// and in the master Tree are assumed to be the same
364/// \note An internal (intermediate) cast to double before storage as Long64_t
365
367{
368 if (!parent) return -3;
369 // We reached the end of the parent tree
370 Long64_t pentry = parent->GetReadEntry();
371 if (pentry >= parent->GetEntriesFast())
372 return -2;
373 GetMajorFormulaParent(parent);
374 GetMinorFormulaParent(parent);
375 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
377 // The Tree Index in the friend has a pair majorname,minorname
378 // not available in the parent Tree T.
379 // if the friend Tree has less entries than the parent, this is an error
380 if (pentry >= fTree->GetEntries()) return -2;
381 // otherwise we ignore the Tree Index and return the entry number
382 // in the parent Tree.
383 return pentry;
384 }
385
386 // majorname, minorname exist in the parent Tree
387 // we find the current values pair majorv,minorv in the parent Tree
392 // we check if this pair exist in the index.
393 // if yes, we return the corresponding entry number
394 // if not the function returns -1
396}
397
398
399////////////////////////////////////////////////////////////////////////////////
400/// find position where major|minor values are in the IndexValues tables
401/// this is the index in IndexValues table, not entry# !
402/// use lower_bound STD algorithm.
403
405{
406 Long64_t mid, step, pos = 0, count = fN;
407 // find lower bound using bisection
408 while( count > 0 ) {
409 step = count / 2;
410 mid = pos + step;
411 // check if *mid < major|minor
412 if( fIndexValues[mid] < major
413 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
414 pos = mid+1;
415 count -= step + 1;
416 } else
417 count = step;
418 }
419 return pos;
420}
421
422
423////////////////////////////////////////////////////////////////////////////////
424/// Return entry number corresponding to major and minor number.
425/// Note that this function returns only the entry number, not the data
426/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
427/// the BuildIndex function has created two tables of Long64_t sorted values
428/// (with an internal intermediate cast to LongDouble)
429/// The function performs binary search in this sorted table.
430/// If it finds a pair that maches val, it returns directly the
431/// index in the table, otherwise it returns -1.
432/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
433/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
434/// A runtime-warning will be printed if values above this range are detected to lead to a corresponding precision loss in your current architecture:
435/// `Warning in <TTreeIndex::TTreeIndex>: In tree entry, value event possibly out of range for internal long double`
436/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
437/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
438/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
439///
440/// If an entry corresponding to major and minor is not found, the function
441/// returns the index of the major,minor pair immediately lower than the
442/// requested value, ie it will return -1 if the pair is lower than
443/// the first entry in the index.
444///
445/// See also GetEntryNumberWithIndex
446
448{
449 if (fN == 0) return -1;
451 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
452 return fIndex[pos];
453 if( --pos < 0 )
454 return -1;
455 return fIndex[pos];
456}
457
458
459////////////////////////////////////////////////////////////////////////////////
460/// Return entry number corresponding to major and minor number.
461/// Note that this function returns only the entry number, not the data
462/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
463/// the BuildIndex function has created two tables of Long64_t sorted values
464/// (with an internal intermediate cast to LongDouble)
465/// The function performs binary search in this sorted table.
466/// If it finds a pair that maches val, it returns directly the
467/// index in the table, otherwise it returns -1.
468/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
469/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
470/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
471/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
472/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
473///
474/// See also GetEntryNumberWithBestIndex
475
477{
478 if (fN == 0) return -1;
479
481 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
482 return fIndex[pos];
483 return -1;
484}
485
486
487////////////////////////////////////////////////////////////////////////////////
488
493
494
495
496////////////////////////////////////////////////////////////////////////////////
497/// Return a pointer to the TreeFormula corresponding to the majorname.
498
507
508////////////////////////////////////////////////////////////////////////////////
509/// Return a pointer to the TreeFormula corresponding to the minorname.
510
519
520////////////////////////////////////////////////////////////////////////////////
521/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
522
524{
525 if (!fMajorFormulaParent) {
526 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
527 // is a friend of the parent TTree.
529 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
531 }
532 if (fMajorFormulaParent->GetTree() != parent) {
533 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
535 }
536 return fMajorFormulaParent;
537}
538
539////////////////////////////////////////////////////////////////////////////////
540/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
541
543{
544 if (!fMinorFormulaParent) {
545 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
546 // is a friend of the parent TTree.
548 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
550 }
551 if (fMinorFormulaParent->GetTree() != parent) {
552 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
554 }
555 return fMinorFormulaParent;
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Return true if index can be applied to the TTree
560
561bool TTreeIndex::IsValidFor(const TTree *parent)
562{
563 auto *majorFormula = GetMajorFormulaParent(parent);
564 auto *minorFormula = GetMinorFormulaParent(parent);
565 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
566 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
567 return false;
568 return true;
569}
570
571////////////////////////////////////////////////////////////////////////////////
572/// Print the table with : serial number, majorname, minorname.
573/// - if option = "10" print only the first 10 entries
574/// - if option = "100" print only the first 100 entries
575/// - if option = "1000" print only the first 1000 entries
576
578{
579 TString opt = option;
580 bool printEntry = false;
581 Long64_t n = fN;
582 if (opt.Contains("10")) n = 10;
583 if (opt.Contains("100")) n = 100;
584 if (opt.Contains("1000")) n = 1000;
585 if (opt.Contains("all")) {
586 printEntry = true;
587 }
588
589 if (printEntry) {
590 Printf("\n*****************************************************************");
591 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
592 Printf("*****************************************************************");
593 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
594 Printf("*****************************************************************");
595 for (Long64_t i=0;i<n;i++) {
596 Printf("%8lld : %8lld : %8lld : %8lld",
597 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
598 }
599
600 } else {
601 Printf("\n**********************************************");
602 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
603 Printf("**********************************************");
604 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
605 Printf("**********************************************");
606 for (Long64_t i=0;i<n;i++) {
607 Printf("%8lld : %8lld : %8lld",
609 }
610 }
611}
612
613////////////////////////////////////////////////////////////////////////////////
614/// Stream an object of class TTreeIndex.
615/// Note that this Streamer should be changed to an automatic Streamer
616/// once TStreamerInfo supports an index of type Long64_t
617
619{
621 if (R__b.IsReading()) {
622 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
626 R__b >> fN;
627 fIndexValues = new Long64_t[fN];
628 R__b.ReadFastArray(fIndexValues,fN);
629 if( R__v > 1 ) {
631 R__b.ReadFastArray(fIndexValuesMinor,fN);
632 } else {
634 }
635 fIndex = new Long64_t[fN];
636 R__b.ReadFastArray(fIndex,fN);
637 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
638 } else {
639 R__c = R__b.WriteVersion(TTreeIndex::IsA(), true);
643 R__b << fN;
644 R__b.WriteFastArray(fIndexValues, fN);
645 R__b.WriteFastArray(fIndexValuesMinor, fN);
646 R__b.WriteFastArray(fIndex, fN);
647 R__b.SetByteCount(R__c, true);
648 }
649}
650
651////////////////////////////////////////////////////////////////////////////////
652/// Called by TChain::LoadTree when the parent chain changes it's tree.
653
655{
659 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
661 }
663 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
665 }
666}
667////////////////////////////////////////////////////////////////////////////////
668/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
669/// when a new Tree is loaded.
670/// Because Trees in a TChain may have a different list of leaves, one
671/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
672
674{
675 fTree = T;
676}
677
678////////////////////////////////////////////////////////////////////////////////
679/// \brief Create a deep copy of the TTreeIndex
680/// \param[in] newname A new name for the index
681///
682/// The new index is allocated on the heap without being managed. Also, it is
683/// not attached to any tree. It is the responsibility of the caller to manage
684/// its lifetime and attach it to a tree if necessary.
686{
687 auto index = new TTreeIndex();
688 index->SetName(newname && std::strlen(newname) ? newname : GetName());
689 index->SetTitle(GetTitle());
690
691 // Note that the TTreeFormula * data members are not cloned since they would
692 // need the attached tree data member to function properly.
693 index->fMajorName = fMajorName;
694 index->fMinorName = fMinorName;
695
696 if (fN == 0)
697 return index;
698
699 index->fN = fN;
700
701 index->fIndexValues = new Long64_t[index->fN];
702 std::copy(fIndexValues, fIndexValues + fN, index->fIndexValues);
703
704 index->fIndexValuesMinor = new Long64_t[index->fN];
705 std::copy(fIndexValuesMinor, fIndexValuesMinor + fN, index->fIndexValuesMinor);
706
707 index->fIndex = new Long64_t[index->fN];
708 std::copy(fIndex, fIndex + fN, index->fIndex);
709
710 return index;
711}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassImp(name)
Definition Rtypes.h:376
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
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2510
virtual Int_t GetNdim() const
Definition TFormula.h:238
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:1058
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1072
void MakeZombie()
Definition TObject.h:53
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1419
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:640
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.
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:221
A TTree represents a columnar dataset.
Definition TTree.h:89
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor=0) const
Return entry number corresponding to major and minor number.
Definition TTree.cxx:5991
virtual TVirtualIndex * GetTreeIndex() const
Definition TTree.h:595
virtual Long64_t GetEntries() const
Definition TTree.h:500
virtual Long64_t GetReadEntry() const
Definition TTree.h:586
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition TTree.cxx:6555
virtual Long64_t GetEntriesFast() const
Return a number greater or equal to the total number of entries in the dataset.
Definition TTree.h:542
virtual Int_t GetTreeNumber() const
Definition TTree.h:596
@ kFindBranch
Definition TTree.h:245
@ kFindLeaf
Definition TTree.h:246
@ kGetBranch
Definition TTree.h:248
@ kGetLeaf
Definition TTree.h:253
virtual void SetTreeIndex(TVirtualIndex *index)
The current TreeIndex is replaced by the new index.
Definition TTree.cxx:9565
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)