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
25
26
28
32
33 template<typename Index>
34 bool operator()(Index i1, Index i2) {
35 if( *(fValMajor + i1) == *(fValMajor + i2) )
36 return *(fValMinor + i1) < *(fValMinor + i2);
37 else
38 return *(fValMajor + i1) < *(fValMajor + i2);
39 }
40
41 // pointers to the start of index values tables keeping upper 64bit and lower 64bit
42 // of combined indexed 128bit value
44};
45
46
47////////////////////////////////////////////////////////////////////////////////
48/// Default constructor for TTreeIndex
49
51{
52 fTree = nullptr;
53 fN = 0;
54 fIndexValues = nullptr;
55 fIndexValuesMinor = nullptr;
56 fIndex = nullptr;
57 fMajorFormula = nullptr;
58 fMinorFormula = nullptr;
59 fMajorFormulaParent = nullptr;
60 fMinorFormulaParent = nullptr;
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Normal constructor for TTreeIndex
65///
66/// Build an index table using the leaves of Tree T with major & minor names
67/// The index is built with the expressions given in "majorname" and "minorname".
68///
69/// a Long64_t array fIndexValues is built with:
70///
71/// - major = the value of majorname converted to an integer
72/// - minor = the value of minorname converted to an integer
73/// - fIndexValues[i] = major<<31 + minor
74///
75/// This array is sorted. The sorted fIndex[i] contains the serial number
76/// in the Tree corresponding to the pair "major,minor" in fIndexvalues[i].
77///
78/// Once the index is computed, one can retrieve one entry via
79/// ~~~{.cpp}
80/// T->GetEntryWithIndex(majornumber, minornumber)
81/// ~~~
82/// Example:
83/// ~~~{.cpp}
84/// tree.BuildIndex("Run","Event"); //creates an index using leaves Run and Event
85/// tree.GetEntryWithIndex(1234,56789); // reads entry corresponding to
86/// // Run=1234 and Event=56789
87/// ~~~
88/// Note that majorname and minorname may be expressions using original
89/// Tree variables eg: "run-90000", "event +3*xx". These treeformulas will be calculated using
90/// long double precision, and then cast to long64. If you want to directly
91/// use long64 for the intermediate calculation, allowing for larger maximum indices, set long64major/minor to true.
92/// Minor formula can be skipped by setting it to "0".
93///
94/// In case an expression is specified, the equivalent expression must be computed
95/// when calling GetEntryWithIndex.
96///
97/// To build an index with only majorname, specify minorname="0" (default)
98///
99/// ## TreeIndex and Friend Trees
100///
101/// Assuming a parent Tree T and a friend Tree TF, the following cases are supported:
102/// - CASE 1: T->GetEntry(entry) is called
103/// In this case, the serial number entry is used to retrieve
104/// the data in both Trees.
105/// - CASE 2: T->GetEntry(entry) is called, TF has a TreeIndex
106/// the expressions given in major/minorname of TF are used
107/// to compute the value pair major,minor with the data in T.
108/// TF->GetEntryWithIndex(major,minor) is then called (tricky case!)
109/// - CASE 3: T->GetEntryWithIndex(major,minor) is called.
110/// It is assumed that both T and TF have a TreeIndex built using
111/// the same major and minor name.
112///
113/// ## Saving the TreeIndex
114///
115/// Once the index is built, it can be saved with the TTree object
116/// with tree.Write(); (if the file has been open in "update" mode).
117///
118/// The most convenient place to create the index is at the end of
119/// the filling process just before saving the Tree header.
120/// If a previous index was computed, it is redefined by this new call.
121///
122/// Note that this function can also be applied to a TChain.
123///
124/// The return value is the number of entries in the Index (< 0 indicates failure)
125///
126/// It is possible to play with different TreeIndex in the same Tree.
127/// see comments in TTree::SetTreeIndex.
128
129TTreeIndex::TTreeIndex(const TTree *T, const char *majorname, const char *minorname, bool long64major, bool long64minor)
130 : TVirtualIndex()
131{
132 fTree = (TTree*)T;
133 fN = 0;
134 fIndexValues = nullptr;
135 fIndexValuesMinor = nullptr;
136 fIndex = nullptr;
137 fMajorFormula = nullptr;
138 fMinorFormula = nullptr;
139 fMajorFormulaParent = nullptr;
140 fMinorFormulaParent = nullptr;
143 if (!T) return;
144 fN = T->GetEntries();
145 if (fN <= 0) {
146 MakeZombie();
147 Error("TreeIndex","Cannot build a TreeIndex with a Tree having no entries");
148 return;
149 }
150
153 if (!fMajorFormula || !fMinorFormula) {
154 MakeZombie();
155 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
156 return;
157 }
158 if ((fMajorFormula->GetNdim() != 1) || (fMinorFormula->GetNdim() != 1)) {
159 MakeZombie();
160 Error("TreeIndex","Cannot build the index with major=%s, minor=%s",fMajorName.Data(), fMinorName.Data());
161 return;
162 }
163 // accessing array elements should be OK
164 //if ((fMajorFormula->GetMultiplicity() != 0) || (fMinorFormula->GetMultiplicity() != 0)) {
165 // MakeZombie();
166 // Error("TreeIndex","Cannot build the index with major=%s, minor=%s that cannot be arrays",fMajorName.Data(), fMinorName.Data());
167 // return;
168 //}
169
172 Long64_t i;
174 Int_t current = -1;
175 for (i=0;i<fN;i++) {
177 if (centry < 0) break;
178 if (fTree->GetTreeNumber() != current) {
179 current = fTree->GetTreeNumber();
182 }
183 auto GetAndRangeCheck = [this](bool isMajor, Long64_t entry) {
185 // Check whether the value (vs significant bits) of ldRet can represent
186 // the full precision of the returned value. If we return 10^60, the
187 // value fits into a long double, but if sizeof(long double) ==
188 // sizeof(double) it cannot store the ones: the value returned by
189 // EvalInstance() only stores the higher bits.
191 if (ret > 0)
192 retCloserToZero -= 1;
193 else
194 retCloserToZero += 1;
195 if (retCloserToZero == ret) {
196 Warning("TTreeIndex",
197 "In tree entry %lld, %s value %s=%Lf possibly out of range for internal `long double`", entry,
198 isMajor ? "major" : "minor", isMajor ? fMajorName.Data() : fMinorName.Data(), ret);
199 }
200 return ret;
201 };
202 auto GetLong64 = [this](bool isMajor) {
204 };
205 tmp_major[i] = long64major ? GetLong64(true) : GetAndRangeCheck(true, i);
206 tmp_minor[i] = long64minor ? GetLong64(false) : GetAndRangeCheck(false, i);
207 }
208 fIndex = new Long64_t[fN];
209 for(i = 0; i < fN; i++) { fIndex[i] = i; }
211 //TMath::Sort(fN,w,fIndex,0);
212 fIndexValues = new Long64_t[fN];
214 bool duplicatedKeys = false;
215 for (i = 0; i < fN; i++) {
218 const bool checkDuplicates = i > 0 && (!duplicatedKeys || gDebug >= 1);
219 if (checkDuplicates) {
220 if (fIndexValues[i - 1] == fIndexValues[i] && fIndexValuesMinor[i - 1] == fIndexValuesMinor[i]) {
221 Error("TTreeIndex",
222 "In entry %lld, a duplicate key was found value at (%s, %s) = (%lld, %lld)",
224 );
225 if (gDebug < 1) {
226 Warning("TTreeIndex", "Further potential duplicates won't be checked, use gDebug >= 1 to check all.");
227 }
228 duplicatedKeys = true;
229 }
230 }
231 }
232
233 delete [] tmp_major;
234 delete [] tmp_minor;
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Destructor.
240
242{
243 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(nullptr);
244 delete [] fIndexValues; fIndexValues = nullptr;
245 delete [] fIndexValuesMinor; fIndexValuesMinor = nullptr;
246 delete [] fIndex; fIndex = nullptr;
247 delete fMajorFormula; fMajorFormula = nullptr;
248 delete fMinorFormula; fMinorFormula = nullptr;
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
255/// If delaySort is true, do not sort the value, then you must call
256/// Append(0,false);
257
259{
260
261 if (add && add->GetN()) {
262 // Create new buffer (if needed)
263
264 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
265 if (ti_add == nullptr) {
266 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
267 add->IsA()->GetName());
268 }
269
270 Long64_t oldn = fN;
271 fN += add->GetN();
272
276
277 fIndex = new Long64_t[fN];
278 fIndexValues = new Long64_t[fN];
280
281 // Copy data
282 Long_t size = sizeof(Long64_t) * oldn;
283 Long_t add_size = sizeof(Long64_t) * add->GetN();
284
288
289 Long64_t *addIndex = ti_add->GetIndex();
290 Long64_t *addValues = ti_add->GetIndexValues();
291 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
292
296 for(Int_t i = 0; i < add->GetN(); i++) {
297 fIndex[oldn + i] += oldn;
298 }
299
300 delete [] oldIndex;
301 delete [] oldValues;
302 delete [] oldValues2;
303 }
304
305 // Sort.
306 if (!delaySort) {
310 Long64_t *conv = new Long64_t[fN];
311
312 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
313 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
314 //Long64_t *w = fIndexValues;
315 //TMath::Sort(fN,w,conv,0);
316
317 fIndex = new Long64_t[fN];
318 fIndexValues = new Long64_t[fN];
320
321 for (Int_t i=0;i<fN;i++) {
322 fIndex[i] = ind[conv[i]];
323 fIndexValues[i] = addValues[conv[i]];
324 fIndexValuesMinor[i] = addValues2[conv[i]];
325 }
326 delete [] addValues;
327 delete [] addValues2;
328 delete [] ind;
329 delete [] conv;
330 }
331}
332
333
334
335////////////////////////////////////////////////////////////////////////////////
336/// Conversion from old 64bit indexes.
337/// Before, major and minor were stored as a single 64-bit register, with
338/// bits [0,30] for minor and bits [31,64] for major.
339/// Now, both minor and major have their own 64-bit register.
340/// \return true if index was converted
341
343{
344 if( !fIndexValuesMinor && fN ) {
346 for(int i=0; i<fN; i++) {
347 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
348 fIndexValues[i] >>= 31;
349 }
350 return true;
351 }
352 return false;
353}
354
355
356
357////////////////////////////////////////////////////////////////////////////////
358/// Returns the entry number in this (friend) Tree corresponding to entry in
359/// the master Tree 'parent'.
360/// In case this (friend) Tree and 'master' do not share an index with the same
361/// major and minor name, the entry serial number in the (friend) tree
362/// and in the master Tree are assumed to be the same
363/// \note An internal (intermediate) cast to double before storage as Long64_t
364
366{
367 if (!parent) return -3;
368 // We reached the end of the parent tree
369 Long64_t pentry = parent->GetReadEntry();
370 if (pentry >= parent->GetEntriesFast())
371 return -2;
372 GetMajorFormulaParent(parent);
373 GetMinorFormulaParent(parent);
374 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
376 // The Tree Index in the friend has a pair majorname,minorname
377 // not available in the parent Tree T.
378 // if the friend Tree has less entries than the parent, this is an error
379 if (pentry >= fTree->GetEntries()) return -2;
380 // otherwise we ignore the Tree Index and return the entry number
381 // in the parent Tree.
382 return pentry;
383 }
384
385 // majorname, minorname exist in the parent Tree
386 // we find the current values pair majorv,minorv in the parent Tree
391 // we check if this pair exist in the index.
392 // if yes, we return the corresponding entry number
393 // if not the function returns -1
395}
396
397
398////////////////////////////////////////////////////////////////////////////////
399/// find position where major|minor values are in the IndexValues tables
400/// this is the index in IndexValues table, not entry# !
401/// use lower_bound STD algorithm.
402
404{
405 Long64_t mid, step, pos = 0, count = fN;
406 // find lower bound using bisection
407 while( count > 0 ) {
408 step = count / 2;
409 mid = pos + step;
410 // check if *mid < major|minor
411 if( fIndexValues[mid] < major
412 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
413 pos = mid+1;
414 count -= step + 1;
415 } else
416 count = step;
417 }
418 return pos;
419}
420
421
422////////////////////////////////////////////////////////////////////////////////
423/// Return entry number corresponding to major and minor number.
424/// Note that this function returns only the entry number, not the data
425/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
426/// the BuildIndex function has created two tables of Long64_t sorted values
427/// (with an internal intermediate cast to LongDouble)
428/// The function performs binary search in this sorted table.
429/// If it finds a pair that maches val, it returns directly the
430/// index in the table, otherwise it returns -1.
431/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
432/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
433/// A runtime-warning will be printed if values above this range are detected to lead to a corresponding precision loss in your current architecture:
434/// `Warning in <TTreeIndex::TTreeIndex>: In tree entry, value event possibly out of range for internal long double`
435/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
436/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
437/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
438///
439/// If an entry corresponding to major and minor is not found, the function
440/// returns the index of the major,minor pair immediately lower than the
441/// requested value, ie it will return -1 if the pair is lower than
442/// the first entry in the index.
443///
444/// See also GetEntryNumberWithIndex
445
447{
448 if (fN == 0) return -1;
450 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
451 return fIndex[pos];
452 if( --pos < 0 )
453 return -1;
454 return fIndex[pos];
455}
456
457
458////////////////////////////////////////////////////////////////////////////////
459/// Return entry number corresponding to major and minor number.
460/// Note that this function returns only the entry number, not the data
461/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
462/// the BuildIndex function has created two tables of Long64_t sorted values
463/// (with an internal intermediate cast to LongDouble)
464/// The function performs binary search in this sorted table.
465/// If it finds a pair that maches val, it returns directly the
466/// index in the table, otherwise it returns -1.
467/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
468/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
469/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
470/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
471/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
472///
473/// See also GetEntryNumberWithBestIndex
474
476{
477 if (fN == 0) return -1;
478
480 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
481 return fIndex[pos];
482 return -1;
483}
484
485
486////////////////////////////////////////////////////////////////////////////////
487
492
493
494
495////////////////////////////////////////////////////////////////////////////////
496/// Return a pointer to the TreeFormula corresponding to the majorname.
497
506
507////////////////////////////////////////////////////////////////////////////////
508/// Return a pointer to the TreeFormula corresponding to the minorname.
509
518
519////////////////////////////////////////////////////////////////////////////////
520/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
521
523{
524 if (!fMajorFormulaParent) {
525 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
526 // is a friend of the parent TTree.
528 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
530 }
531 if (fMajorFormulaParent->GetTree() != parent) {
532 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
534 }
535 return fMajorFormulaParent;
536}
537
538////////////////////////////////////////////////////////////////////////////////
539/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
540
542{
543 if (!fMinorFormulaParent) {
544 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
545 // is a friend of the parent TTree.
547 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
549 }
550 if (fMinorFormulaParent->GetTree() != parent) {
551 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
553 }
554 return fMinorFormulaParent;
555}
556
557////////////////////////////////////////////////////////////////////////////////
558/// Return true if index can be applied to the TTree
559
560bool TTreeIndex::IsValidFor(const TTree *parent)
561{
562 auto *majorFormula = GetMajorFormulaParent(parent);
563 auto *minorFormula = GetMinorFormulaParent(parent);
564 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
565 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
566 return false;
567 return true;
568}
569
570////////////////////////////////////////////////////////////////////////////////
571/// Print the table with : serial number, majorname, minorname.
572/// - if option = "10" print only the first 10 entries
573/// - if option = "100" print only the first 100 entries
574/// - if option = "1000" print only the first 1000 entries
575
577{
578 TString opt = option;
579 bool printEntry = false;
580 Long64_t n = fN;
581 if (opt.Contains("10")) n = 10;
582 if (opt.Contains("100")) n = 100;
583 if (opt.Contains("1000")) n = 1000;
584 if (opt.Contains("all")) {
585 printEntry = true;
586 }
587
588 if (printEntry) {
589 Printf("\n*****************************************************************");
590 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
591 Printf("*****************************************************************");
592 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
593 Printf("*****************************************************************");
594 for (Long64_t i=0;i<n;i++) {
595 Printf("%8lld : %8lld : %8lld : %8lld",
596 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
597 }
598
599 } else {
600 Printf("\n**********************************************");
601 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
602 Printf("**********************************************");
603 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
604 Printf("**********************************************");
605 for (Long64_t i=0;i<n;i++) {
606 Printf("%8lld : %8lld : %8lld",
608 }
609 }
610}
611
612////////////////////////////////////////////////////////////////////////////////
613/// Stream an object of class TTreeIndex.
614/// Note that this Streamer should be changed to an automatic Streamer
615/// once TStreamerInfo supports an index of type Long64_t
616
618{
620 if (R__b.IsReading()) {
621 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
625 R__b >> fN;
626 fIndexValues = new Long64_t[fN];
627 R__b.ReadFastArray(fIndexValues,fN);
628 if( R__v > 1 ) {
630 R__b.ReadFastArray(fIndexValuesMinor,fN);
631 } else {
633 }
634 fIndex = new Long64_t[fN];
635 R__b.ReadFastArray(fIndex,fN);
636 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
637 } else {
638 R__c = R__b.WriteVersion(TTreeIndex::IsA(), true);
642 R__b << fN;
643 R__b.WriteFastArray(fIndexValues, fN);
644 R__b.WriteFastArray(fIndexValuesMinor, fN);
645 R__b.WriteFastArray(fIndex, fN);
646 R__b.SetByteCount(R__c, true);
647 }
648}
649
650////////////////////////////////////////////////////////////////////////////////
651/// Called by TChain::LoadTree when the parent chain changes it's tree.
652
654{
658 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
660 }
662 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
664 }
665}
666////////////////////////////////////////////////////////////////////////////////
667/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
668/// when a new Tree is loaded.
669/// Because Trees in a TChain may have a different list of leaves, one
670/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
671
673{
674 fTree = T;
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// \brief Create a deep copy of the TTreeIndex
679/// \param[in] newname A new name for the index
680///
681/// The new index is allocated on the heap without being managed. Also, it is
682/// not attached to any tree. It is the responsibility of the caller to manage
683/// its lifetime and attach it to a tree if necessary.
685{
686 auto index = new TTreeIndex();
687 index->SetName(newname && std::strlen(newname) ? newname : GetName());
688 index->SetTitle(GetTitle());
689
690 // Note that the TTreeFormula * data members are not cloned since they would
691 // need the attached tree data member to function properly.
692 index->fMajorName = fMajorName;
693 index->fMinorName = fMinorName;
694
695 if (fN == 0)
696 return index;
697
698 index->fN = fN;
699
700 index->fIndexValues = new Long64_t[index->fN];
701 std::copy(fIndexValues, fIndexValues + fN, index->fIndexValues);
702
703 index->fIndexValuesMinor = new Long64_t[index->fN];
704 std::copy(fIndexValuesMinor, fIndexValuesMinor + fN, index->fIndexValuesMinor);
705
706 index->fIndex = new Long64_t[index->fN];
707 std::copy(fIndex, fIndex + fN, index->fIndex);
708
709 return index;
710}
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
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:2509
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: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:138
const char * Data() const
Definition TString.h:384
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1418
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:5990
virtual TVirtualIndex * GetTreeIndex() const
Definition TTree.h:597
virtual Long64_t GetEntries() const
Definition TTree.h:502
virtual Long64_t GetReadEntry() const
Definition TTree.h:588
virtual Long64_t LoadTree(Long64_t entry)
Set current entry.
Definition TTree.cxx:6554
virtual Long64_t GetEntriesFast() const
Return a number greater or equal to the total number of entries in the dataset.
Definition TTree.h:544
virtual Int_t GetTreeNumber() const
Definition TTree.h:598
@ 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:9564
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)