Skip to content

Commit 1bcbfc2

Browse files
committed
[tree] major and minor indices to 64bit, the 32bit were remnants from old legacy interface
Fixes https://its.cern.ch/jira/browse/ROOT-9028 [treeindex] print error when requesting out of bonds combination 31bit restriction was old, now they have separate 64-bit registers better document old2new
1 parent 002d793 commit 1bcbfc2

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

tree/tree/inc/TChain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class TChain : public TTree {
101101
Long64_t GetEntries(const char *sel) override { return TTree::GetEntries(sel); }
102102
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override;
103103
Long64_t GetEntryNumber(Long64_t entry) const override;
104-
Int_t GetEntryWithIndex(Int_t major, Int_t minor=0) override;
104+
Int_t GetEntryWithIndex(Long64_t major, Long64_t minor=0) override;
105105
TFile *GetFile() const;
106106
TLeaf *GetLeaf(const char* branchname, const char* leafname) override;
107107
TLeaf *GetLeaf(const char* name) override;

tree/tree/inc/TTree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ class TTree : public TNamed, public TAttLine, public TAttFill, public TAttMarker
467467
virtual Long64_t GetEstimate() const { return fEstimate; }
468468
virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0);
469469
Int_t GetEvent(Long64_t entry, Int_t getall = 0) { return GetEntry(entry, getall); }
470-
virtual Int_t GetEntryWithIndex(Int_t major, Int_t minor = 0);
470+
virtual Int_t GetEntryWithIndex(Long64_t major, Long64_t minor = 0);
471471
virtual Long64_t GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor = 0) const;
472472
virtual Long64_t GetEntryNumberWithIndex(Long64_t major, Long64_t minor = 0) const;
473473
TEventList *GetEventList() const { return fEventList; }

tree/tree/src/TChain.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,13 @@ Long64_t TChain::GetEntryNumber(Long64_t entry) const
10231023
////////////////////////////////////////////////////////////////////////////////
10241024
/// Return entry corresponding to major and minor number.
10251025
///
1026-
/// The function returns the total number of bytes read.
1026+
/// The function returns the total number of bytes read; -1 if entry not found.
10271027
/// If the Tree has friend trees, the corresponding entry with
10281028
/// the index values (major,minor) is read. Note that the master Tree
10291029
/// and its friend may have different entry serial numbers corresponding
10301030
/// to (major,minor).
10311031

1032-
Int_t TChain::GetEntryWithIndex(Int_t major, Int_t minor)
1032+
Int_t TChain::GetEntryWithIndex(Long64_t major, Long64_t minor)
10331033
{
10341034
Long64_t serial = GetEntryNumberWithIndex(major, minor);
10351035
if (serial < 0) return -1;

tree/tree/src/TTree.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5919,13 +5919,13 @@ Long64_t TTree::GetEntryNumberWithIndex(Long64_t major, Long64_t minor) const
59195919
////////////////////////////////////////////////////////////////////////////////
59205920
/// Read entry corresponding to major and minor number.
59215921
///
5922-
/// The function returns the total number of bytes read.
5922+
/// The function returns the total number of bytes read; -1 if entry not found.
59235923
/// If the Tree has friend trees, the corresponding entry with
59245924
/// the index values (major,minor) is read. Note that the master Tree
59255925
/// and its friend may have different entry serial numbers corresponding
59265926
/// to (major,minor).
59275927

5928-
Int_t TTree::GetEntryWithIndex(Int_t major, Int_t minor)
5928+
Int_t TTree::GetEntryWithIndex(Long64_t major, Long64_t minor)
59295929
{
59305930
// We already have been visited while recursively looking
59315931
// through the friends tree, let's return.

tree/treeplayer/src/TTreeIndex.cxx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,11 @@ void TTreeIndex::Append(const TVirtualIndex *add, bool delaySort )
315315

316316

317317
////////////////////////////////////////////////////////////////////////////////
318-
/// conversion from old 64bit indexes
319-
/// return true if index was converted
318+
/// Conversion from old 64bit indexes.
319+
/// Before, major and minor were stored as a single 64-bit register, with
320+
/// bits [0,30] for minor and bits [31,64] for major.
321+
/// Now, both minor and major have their own 64-bit register.
322+
/// \return true if index was converted
320323

321324
bool TTreeIndex::ConvertOldToNew()
322325
{
@@ -339,6 +342,7 @@ bool TTreeIndex::ConvertOldToNew()
339342
/// In case this (friend) Tree and 'master' do not share an index with the same
340343
/// major and minor name, the entry serial number in the (friend) tree
341344
/// and in the master Tree are assumed to be the same
345+
/// \note An internal (intermediate) cast to double before storage as Long64_t
342346

343347
Long64_t TTreeIndex::GetEntryNumberFriend(const TTree *parent)
344348
{
@@ -401,8 +405,8 @@ Long64_t TTreeIndex::FindValues(Long64_t major, Long64_t minor) const
401405
/// Return entry number corresponding to major and minor number.
402406
/// Note that this function returns only the entry number, not the data
403407
/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
404-
/// the BuildIndex function has created a table of Double_t* of sorted values
405-
/// corresponding to val = major<<31 + minor;
408+
/// the BuildIndex function has created two tables of Long64_t sorted values
409+
/// (with an internal intermediate cast to LongDouble)
406410
/// The function performs binary search in this sorted table.
407411
/// If it finds a pair that maches val, it returns directly the
408412
/// index in the table.
@@ -416,7 +420,6 @@ Long64_t TTreeIndex::FindValues(Long64_t major, Long64_t minor) const
416420
Long64_t TTreeIndex::GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor) const
417421
{
418422
if (fN == 0) return -1;
419-
420423
Long64_t pos = FindValues(major, minor);
421424
if( pos < fN && fIndexValues[pos] == major && fIndexValuesMinor[pos] == minor )
422425
return fIndex[pos];
@@ -430,8 +433,8 @@ Long64_t TTreeIndex::GetEntryNumberWithBestIndex(Long64_t major, Long64_t minor)
430433
/// Return entry number corresponding to major and minor number.
431434
/// Note that this function returns only the entry number, not the data
432435
/// To read the data corresponding to an entry number, use TTree::GetEntryWithIndex
433-
/// the BuildIndex function has created a table of Double_t* of sorted values
434-
/// corresponding to val = major<<31 + minor;
436+
/// the BuildIndex function has created two tables of Long64_t sorted values
437+
/// (with an internal intermediate cast to LongDouble)
435438
/// The function performs binary search in this sorted table.
436439
/// If it finds a pair that maches val, it returns directly the
437440
/// index in the table, otherwise it returns -1.

0 commit comments

Comments
 (0)