Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-6885

TChain::Process with more than kBigNumber entries without reading TTree headers


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 5.34/23
    • Fix Version/s: None
    • Component/s: Core Libraries
    • Labels:
    • Environment:



      TChain::Process stops prematurely after kBigNumber (1234567890) entries if trees were added without reading their sizes.

      One can add files to TChain without touching them by using default value of the second parameter of AddFile:
      AddFile(const char* name, Long64_t nentries = kBigNumber, const char* tname = "");

      In which case we take the second branch below and set fEntries = nentries = kBigNumber

      TChain::AddFile at TChain.cxx:515

         if (nentries > 0) {
            if (nentries != kBigNumber) {
               fTreeOffset[fNtrees+1] = fTreeOffset[fNtrees] + nentries;
               fEntries += nentries;
            } else {
               fTreeOffset[fNtrees+1] = theBigNumber;
               fEntries = nentries;

      Which is problematic, because TTreePlayer::Process gets it from TTree::GetEntriesFriend via GetEntriesToProcess and uses it to decide how many entries to process:

      TTreePlayer::Process at TTreePlayer.cxx:2109

      nentries = GetEntriesToProcess(firstentry, nentries);

      As a result it stops after kBigNumber (1234567890) entries

      Later when another tree is loaded on demand it sets fEntries = fTreeOffset[fNtrees] = theBigNumber

      TChain::LoadTree at TChain.cxx:1530

         if (fTreeOffset[fTreeNumber+1] != (fTreeOffset[fTreeNumber] + nentries)) {
            fTreeOffset[fTreeNumber+1] = fTreeOffset[fTreeNumber] + nentries;
            fEntries = fTreeOffset[fNtrees];

      It would make sense to set fEntries to theBigNumber already in TChain::AddFile so TTreePlayer::Process uses it as the upper limit.
      So line TChain.cxx:521 would look like

               fEntries = theBigNumber;

      Nothing in TChain relies on fEntries being equal to kBigNumber and it changes to theBigNumber after the first tree is loaded anyway.

      PS Line numbers correspond to git tag v5-34-23


          Issue Links



              • Assignee:
                pcanal Philippe Canal
                c4fd138f4e9f3f1eace9 Valery Yundin
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: