35 template<
typename Index>
146 fN = T->GetEntries();
149 Error(
"TreeIndex",
"Cannot build a TreeIndex with a Tree having no entries");
179 if (centry < 0)
break;
180 if (
fTree->GetTreeNumber() != current) {
181 current =
fTree->GetTreeNumber();
189 Error(
"TTreeIndex",
"In tree entry %lld, Ndata in formula is zero for both '%s' and '%s'", i,
192 auto GetAndRangeCheck = [
this](
bool isMajor,
Long64_t entry) {
201 retCloserToZero -= 1;
203 retCloserToZero += 1;
204 if (retCloserToZero ==
ret) {
206 "In tree entry %lld, %s value %s=%Lf possibly out of range for internal `long double`", entry,
211 auto GetLong64 = [
this](
bool isMajor) {
214 tmp_major[i] = long64major ? GetLong64(
true) : GetAndRangeCheck(
true, i);
215 tmp_minor[i] = long64minor ? GetLong64(
false) : GetAndRangeCheck(
false, i);
218 for(i = 0; i <
fN; i++) {
fIndex[i] = i; }
223 bool duplicatedKeys =
false;
224 for (i = 0; i <
fN; i++) {
227 const bool checkDuplicates = i > 0 && (!duplicatedKeys ||
gDebug >= 1);
228 if (checkDuplicates) {
231 "In entry %lld, a duplicate key was found value at (%s, %s) = (%lld, %lld)",
235 Warning(
"TTreeIndex",
"Further potential duplicates won't be checked, use gDebug >= 1 to check all.");
237 duplicatedKeys =
true;
244 fTree->LoadTree(oldEntry);
252 if (
fTree &&
fTree->GetTreeIndex() ==
this)
fTree->SetTreeIndex(
nullptr);
270 if (add && add->
GetN()) {
274 if (ti_add ==
nullptr) {
275 Error(
"Append",
"Can only Append a TTreeIndex to a TTreeIndex but got a %s",
302 memcpy(
fIndex + oldn, addIndex, add_size);
311 delete [] oldValues2;
321 for(
Long64_t i = 0; i <
fN; i++) { conv[i] = i; }
336 delete [] addValues2;
355 for(
int i=0; i<
fN; i++) {
376 if (!parent)
return -3;
388 if (pentry >=
fTree->GetEntries())
return -2;
403 return fTree->GetEntryNumberWithIndex(majorv,minorv);
457 if (
fN == 0)
return -1;
486 if (
fN == 0)
return -1;
573 if ((majorFormula ==
nullptr || majorFormula->GetNdim() == 0) ||
574 (minorFormula ==
nullptr || minorFormula->GetNdim() == 0))
588 bool printEntry =
false;
598 Printf(
"\n*****************************************************************");
600 Printf(
"*****************************************************************");
602 Printf(
"*****************************************************************");
604 Printf(
"%8lld : %8lld : %8lld : %8lld",
609 Printf(
"\n**********************************************");
611 Printf(
"**********************************************");
613 Printf(
"**********************************************");
615 Printf(
"%8lld : %8lld : %8lld",
696 index->SetName(newname && std::strlen(newname) ? newname :
GetName());
709 index->fIndexValues =
new Long64_t[index->fN];
712 index->fIndexValuesMinor =
new Long64_t[index->fN];
715 index->fIndex =
new Long64_t[index->fN];
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
double Double_t
Double 8 bytes.
long double LongDouble_t
Long Double (not portable).
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual void WriteFastArray(const Bool_t *b, Long64_t n)=0
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TTreeIndex()
Default constructor for TTreeIndex.
virtual Long64_t * GetIndexValues() const
virtual Long64_t * GetIndexValuesMinor() const
TTreeFormula * fMajorFormula
! Pointer to major TreeFormula
TTreeFormula * fMajorFormulaParent
! Pointer to major TreeFormula in Parent tree (if any)
Long64_t * fIndex
[fN] Index of sorted values
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.
TClass * IsA() const override
virtual Long64_t * GetIndex() const
bool ConvertOldToNew()
Conversion from old 64bit indexes.
TTreeFormula * fMinorFormula
! Pointer to minor TreeFormula
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.
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.
TTreeIndex(const TTreeIndex &)=delete
Long64_t * fIndexValues
[fN] Sorted index values, higher 64bits
TString fMajorName
Index major name.
Long64_t * fIndexValuesMinor
[fN] Sorted index values, lower 64bits
~TTreeIndex() override
Destructor.
TTreeFormula * fMinorFormulaParent
! Pointer to minor TreeFormula in Parent tree (if any)
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.
A TTree represents a columnar dataset.
virtual Long64_t GetReadEntry() const
virtual Long64_t GetEntriesFast() const
Return a number greater or equal to the total number of entries in the dataset.
TVirtualIndex()
Default constructor for TVirtualIndex.
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
bool operator()(Index i1, Index i2)
IndexSortComparator(Long64_t *major, Long64_t *minor)