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) -> Long64_t {
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 static_cast<Long64_t>(ret); // static_cast necessary for use in ternary expression below
210 };
211 auto GetLong64 = [this](bool isMajor) {
213 };
214 // Note: in ternary expression ensure both branches have same return data type Long64_t.
215 // otherwise, with LongDouble_t, the expression is implicitly cast to their
216 // common type `long double` regardless of the branch taken. On platforms where
217 // `sizeof(long double) == sizeof(double)` (macOS arm64, Windows) this silently
218 // rounds the exact Long64_t value, defeating the purpose of the long64 flag.
219 tmp_major[i] = long64major ? GetLong64(true) : GetAndRangeCheck(true, i);
220 tmp_minor[i] = long64minor ? GetLong64(false) : GetAndRangeCheck(false, i);
221 }
222 fIndex = new Long64_t[fN];
223 for(i = 0; i < fN; i++) { fIndex[i] = i; }
225 //TMath::Sort(fN,w,fIndex,0);
226 fIndexValues = new Long64_t[fN];
228 bool duplicatedKeys = false;
229 for (i = 0; i < fN; i++) {
232 const bool checkDuplicates = i > 0 && (!duplicatedKeys || gDebug >= 1);
233 if (checkDuplicates) {
234 if (fIndexValues[i - 1] == fIndexValues[i] && fIndexValuesMinor[i - 1] == fIndexValuesMinor[i]) {
235 Error("TTreeIndex",
236 "In entry %lld, a duplicate key was found value at (%s, %s) = (%lld, %lld)",
238 );
239 if (gDebug < 1) {
240 Warning("TTreeIndex", "Further potential duplicates won't be checked, use gDebug >= 1 to check all.");
241 }
242 duplicatedKeys = true;
243 }
244 }
245 }
246
247 delete [] tmp_major;
248 delete [] tmp_minor;
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Destructor.
254
256{
257 if (fTree && fTree->GetTreeIndex() == this) fTree->SetTreeIndex(nullptr);
258 delete [] fIndexValues; fIndexValues = nullptr;
259 delete [] fIndexValuesMinor; fIndexValuesMinor = nullptr;
260 delete [] fIndex; fIndex = nullptr;
261 delete fMajorFormula; fMajorFormula = nullptr;
262 delete fMinorFormula; fMinorFormula = nullptr;
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Append 'add' to this index. Entry 0 in add will become entry n+1 in this.
269/// If delaySort is true, do not sort the value, then you must call
270/// Append(0,false);
271
273{
274
275 if (add && add->GetN()) {
276 // Create new buffer (if needed)
277
278 const TTreeIndex *ti_add = dynamic_cast<const TTreeIndex*>(add);
279 if (ti_add == nullptr) {
280 Error("Append","Can only Append a TTreeIndex to a TTreeIndex but got a %s",
281 add->IsA()->GetName());
282 }
283
284 Long64_t oldn = fN;
285 fN += add->GetN();
286
290
291 fIndex = new Long64_t[fN];
292 fIndexValues = new Long64_t[fN];
294
295 // Copy data
296 Long_t size = sizeof(Long64_t) * oldn;
297 Long_t add_size = sizeof(Long64_t) * add->GetN();
298
302
303 Long64_t *addIndex = ti_add->GetIndex();
304 Long64_t *addValues = ti_add->GetIndexValues();
305 Long64_t *addValues2 = ti_add->GetIndexValuesMinor();
306
310 for(Int_t i = 0; i < add->GetN(); i++) {
311 fIndex[oldn + i] += oldn;
312 }
313
314 delete [] oldIndex;
315 delete [] oldValues;
316 delete [] oldValues2;
317 }
318
319 // Sort.
320 if (!delaySort) {
324 Long64_t *conv = new Long64_t[fN];
325
326 for(Long64_t i = 0; i < fN; i++) { conv[i] = i; }
327 std::sort(conv, conv+fN, IndexSortComparator(addValues, addValues2) );
328 //Long64_t *w = fIndexValues;
329 //TMath::Sort(fN,w,conv,0);
330
331 fIndex = new Long64_t[fN];
332 fIndexValues = new Long64_t[fN];
334
335 for (Int_t i=0;i<fN;i++) {
336 fIndex[i] = ind[conv[i]];
337 fIndexValues[i] = addValues[conv[i]];
338 fIndexValuesMinor[i] = addValues2[conv[i]];
339 }
340 delete [] addValues;
341 delete [] addValues2;
342 delete [] ind;
343 delete [] conv;
344 }
345}
346
347
348
349////////////////////////////////////////////////////////////////////////////////
350/// Conversion from old 64bit indexes.
351/// Before, major and minor were stored as a single 64-bit register, with
352/// bits [0,30] for minor and bits [31,64] for major.
353/// Now, both minor and major have their own 64-bit register.
354/// \return true if index was converted
355
357{
358 if( !fIndexValuesMinor && fN ) {
360 for(int i=0; i<fN; i++) {
361 fIndexValuesMinor[i] = (fIndexValues[i] & 0x7fffffff);
362 fIndexValues[i] >>= 31;
363 }
364 return true;
365 }
366 return false;
367}
368
369
370
371////////////////////////////////////////////////////////////////////////////////
372/// Returns the entry number in this (friend) Tree corresponding to entry in
373/// the master Tree 'parent'.
374/// In case this (friend) Tree and 'master' do not share an index with the same
375/// major and minor name, the entry serial number in the (friend) tree
376/// and in the master Tree are assumed to be the same
377/// \note An internal (intermediate) cast to double before storage as Long64_t
378
380{
381 if (!parent) return -3;
382 // We reached the end of the parent tree
383 Long64_t pentry = parent->GetReadEntry();
384 if (pentry >= parent->GetEntriesFast())
385 return -2;
386 GetMajorFormulaParent(parent);
387 GetMinorFormulaParent(parent);
388 if (!fMajorFormulaParent || !fMinorFormulaParent) return -1;
390 // The Tree Index in the friend has a pair majorname,minorname
391 // not available in the parent Tree T.
392 // if the friend Tree has less entries than the parent, this is an error
393 if (pentry >= fTree->GetEntries()) return -2;
394 // otherwise we ignore the Tree Index and return the entry number
395 // in the parent Tree.
396 return pentry;
397 }
398
399 // majorname, minorname exist in the parent Tree
400 // we find the current values pair majorv,minorv in the parent Tree
405 // we check if this pair exist in the index.
406 // if yes, we return the corresponding entry number
407 // if not the function returns -1
409}
410
411
412////////////////////////////////////////////////////////////////////////////////
413/// find position where major|minor values are in the IndexValues tables
414/// this is the index in IndexValues table, not entry# !
415/// use lower_bound STD algorithm.
416
418{
419 Long64_t mid, step, pos = 0, count = fN;
420 // find lower bound using bisection
421 while( count > 0 ) {
422 step = count / 2;
423 mid = pos + step;
424 // check if *mid < major|minor
425 if( fIndexValues[mid] < major
426 || ( fIndexValues[mid] == major && fIndexValuesMinor[mid] < minor ) ) {
427 pos = mid+1;
428 count -= step + 1;
429 } else
430 count = step;
431 }
432 return pos;
433}
434
435
436////////////////////////////////////////////////////////////////////////////////
437/// Return entry number corresponding to major and minor number.
438/// Note that this function returns only the entry number, not the data
439/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
440/// the BuildIndex function has created two tables of Long64_t sorted values
441/// (with an internal intermediate cast to LongDouble)
442/// The function performs binary search in this sorted table.
443/// If it finds a pair that maches val, it returns directly the
444/// index in the table, otherwise it returns -1.
445/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
446/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
447/// A runtime-warning will be printed if values above this range are detected to lead to a corresponding precision loss in your current architecture:
448/// `Warning in <TTreeIndex::TTreeIndex>: In tree entry, value event possibly out of range for internal long double`
449/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
450/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
451/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
452///
453/// If an entry corresponding to major and minor is not found, the function
454/// returns the index of the major,minor pair immediately lower than the
455/// requested value, ie it will return -1 if the pair is lower than
456/// the first entry in the index.
457///
458/// See also GetEntryNumberWithIndex
459
461{
462 if (fN == 0) return -1;
464 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
465 return fIndex[pos];
466 if( --pos < 0 )
467 return -1;
468 return fIndex[pos];
469}
470
471
472////////////////////////////////////////////////////////////////////////////////
473/// Return entry number corresponding to major and minor number.
474/// Note that this function returns only the entry number, not the data
475/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
476/// the BuildIndex function has created two tables of Long64_t sorted values
477/// (with an internal intermediate cast to LongDouble)
478/// The function performs binary search in this sorted table.
479/// If it finds a pair that maches val, it returns directly the
480/// index in the table, otherwise it returns -1.
481/// \warning Due to internal architecture details, the maximum value for `(major, minor)`
482/// for which the function works correctly and consistently in all platforms is `0xFFFFFFFFFFFF0`, which is less than `kMaxLong64`.
483/// This default behavior can be circumvented by setting long64major/minor to true in the TTreeIndex constructor,
484/// which replaces `long double` with `Long64_t`, but it's the user responsibility as range checking will be deactivated.
485/// In this case, you can go higher than `0xFFFFFFFFFFFF0` on all architectures without problems.
486///
487/// See also GetEntryNumberWithBestIndex
488
490{
491 if (fN == 0) return -1;
492
494 if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
495 return fIndex[pos];
496 return -1;
497}
498
499
500////////////////////////////////////////////////////////////////////////////////
501
506
507
508
509////////////////////////////////////////////////////////////////////////////////
510/// Return a pointer to the TreeFormula corresponding to the majorname.
511
520
521////////////////////////////////////////////////////////////////////////////////
522/// Return a pointer to the TreeFormula corresponding to the minorname.
523
532
533////////////////////////////////////////////////////////////////////////////////
534/// Return a pointer to the TreeFormula corresponding to the majorname in parent tree.
535
537{
538 if (!fMajorFormulaParent) {
539 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
540 // is a friend of the parent TTree.
542 fMajorFormulaParent = new TTreeFormula("MajorP",fMajorName.Data(),const_cast<TTree*>(parent));
544 }
545 if (fMajorFormulaParent->GetTree() != parent) {
546 fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
548 }
549 return fMajorFormulaParent;
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Return a pointer to the TreeFormula corresponding to the minorname in parent tree.
554
556{
557 if (!fMinorFormulaParent) {
558 // Prevent TTreeFormula from finding any of the branches in our TTree even if it
559 // is a friend of the parent TTree.
561 fMinorFormulaParent = new TTreeFormula("MinorP",fMinorName.Data(),const_cast<TTree*>(parent));
563 }
564 if (fMinorFormulaParent->GetTree() != parent) {
565 fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
567 }
568 return fMinorFormulaParent;
569}
570
571////////////////////////////////////////////////////////////////////////////////
572/// Return true if index can be applied to the TTree
573
574bool TTreeIndex::IsValidFor(const TTree *parent)
575{
576 auto *majorFormula = GetMajorFormulaParent(parent);
577 auto *minorFormula = GetMinorFormulaParent(parent);
578 if ((majorFormula == nullptr || majorFormula->GetNdim() == 0) ||
579 (minorFormula == nullptr || minorFormula->GetNdim() == 0))
580 return false;
581 return true;
582}
583
584////////////////////////////////////////////////////////////////////////////////
585/// Print the table with : serial number, majorname, minorname.
586/// - if option = "10" print only the first 10 entries
587/// - if option = "100" print only the first 100 entries
588/// - if option = "1000" print only the first 1000 entries
589
591{
592 TString opt = option;
593 bool printEntry = false;
594 Long64_t n = fN;
595 if (opt.Contains("10")) n = 10;
596 if (opt.Contains("100")) n = 100;
597 if (opt.Contains("1000")) n = 1000;
598 if (opt.Contains("all")) {
599 printEntry = true;
600 }
601
602 if (printEntry) {
603 Printf("\n*****************************************************************");
604 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
605 Printf("*****************************************************************");
606 Printf("%8s : %16s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data(),"entry number");
607 Printf("*****************************************************************");
608 for (Long64_t i=0;i<n;i++) {
609 Printf("%8lld : %8lld : %8lld : %8lld",
610 i, fIndexValues[i], GetIndexValuesMinor()[i], fIndex[i]);
611 }
612
613 } else {
614 Printf("\n**********************************************");
615 Printf("* Index of Tree: %s/%s",fTree->GetName(),fTree->GetTitle());
616 Printf("**********************************************");
617 Printf("%8s : %16s : %16s","serial",fMajorName.Data(),fMinorName.Data());
618 Printf("**********************************************");
619 for (Long64_t i=0;i<n;i++) {
620 Printf("%8lld : %8lld : %8lld",
622 }
623 }
624}
625
626////////////////////////////////////////////////////////////////////////////////
627/// Stream an object of class TTreeIndex.
628/// Note that this Streamer should be changed to an automatic Streamer
629/// once TStreamerInfo supports an index of type Long64_t
630
632{
634 if (R__b.IsReading()) {
635 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
639 R__b >> fN;
640 fIndexValues = new Long64_t[fN];
641 R__b.ReadFastArray(fIndexValues,fN);
642 if( R__v > 1 ) {
644 R__b.ReadFastArray(fIndexValuesMinor,fN);
645 } else {
647 }
648 fIndex = new Long64_t[fN];
649 R__b.ReadFastArray(fIndex,fN);
650 R__b.CheckByteCount(R__s, R__c, TTreeIndex::IsA());
651 } else {
652 R__c = R__b.WriteVersion(TTreeIndex::IsA(), true);
656 R__b << fN;
657 R__b.WriteFastArray(fIndexValues, fN);
658 R__b.WriteFastArray(fIndexValuesMinor, fN);
659 R__b.WriteFastArray(fIndex, fN);
660 R__b.SetByteCount(R__c, true);
661 }
662}
663
664////////////////////////////////////////////////////////////////////////////////
665/// Called by TChain::LoadTree when the parent chain changes it's tree.
666
668{
672 if (parent) fMajorFormulaParent->SetTree(const_cast<TTree*>(parent));
674 }
676 if (parent) fMinorFormulaParent->SetTree(const_cast<TTree*>(parent));
678 }
679}
680////////////////////////////////////////////////////////////////////////////////
681/// this function is called by TChain::LoadTree and TTreePlayer::UpdateFormulaLeaves
682/// when a new Tree is loaded.
683/// Because Trees in a TChain may have a different list of leaves, one
684/// must update the leaves numbers in the TTreeFormula used by the TreeIndex.
685
687{
688 fTree = T;
689}
690
691////////////////////////////////////////////////////////////////////////////////
692/// \brief Create a deep copy of the TTreeIndex
693/// \param[in] newname A new name for the index
694///
695/// The new index is allocated on the heap without being managed. Also, it is
696/// not attached to any tree. It is the responsibility of the caller to manage
697/// its lifetime and attach it to a tree if necessary.
699{
700 auto index = new TTreeIndex();
701 index->SetName(newname && std::strlen(newname) ? newname : GetName());
702 index->SetTitle(GetTitle());
703
704 // Note that the TTreeFormula * data members are not cloned since they would
705 // need the attached tree data member to function properly.
706 index->fMajorName = fMajorName;
707 index->fMinorName = fMinorName;
708
709 if (fN == 0)
710 return index;
711
712 index->fN = fN;
713
714 index->fIndexValues = new Long64_t[index->fN];
715 std::copy(fIndexValues, fIndexValues + fN, index->fIndexValues);
716
717 index->fIndexValuesMinor = new Long64_t[index->fN];
718 std::copy(fIndexValuesMinor, fIndexValuesMinor + fN, index->fIndexValuesMinor);
719
720 index->fIndex = new Long64_t[index->fN];
721 std::copy(fIndex, fIndex + fN, index->fIndex);
722
723 return index;
724}
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:783
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:42
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
void MakeZombie()
Definition TObject.h:55
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:641
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:605
virtual Long64_t GetEntries() const
Definition TTree.h:510
virtual Long64_t GetReadEntry() const
Definition TTree.h:596
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:552
virtual Int_t GetTreeNumber() const
Definition TTree.h:606
@ 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
TTree * fTree
! pointer to Tree
const Int_t n
Definition legend1.C:16
bool operator()(Index i1, Index i2)
IndexSortComparator(Long64_t *major, Long64_t *minor)