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