ERROR, fNBasketRAM

From: Wilden (L.Wilden@Physik.TU-Dresden.DE)
Date: Fri Mar 10 2000 - 08:40:18 MET


Hi,

When reading lots of data from ROOT files I sometimes get the error
message

  ERROR, fNBasketRAM =-9

printed on the screen. The same observation was reported by Stephan Kluth
last year, see

 http://root.cern.ch/root/roottalk/roottalk99/2664.html

and was suppossedly fixed in ROOT versions later than 2.23-09.
However the problem is still present in 2.23-12.

I have looked at the implementation of TBranch::DropBaskets and came to
the preliminary conclusion that fNBasketRAM is not always incremented
properly. Maybe I have not understood the code completely at this point
(it is very late already) but the following should give a hint at what is
happening. Here is the piece of code in question:

 //general algorithm looping on the full baskets table.
   Int_t nbaskets = GetListOfBaskets()->GetEntriesFast();
   fNBasketRAM = 0;
   for (j=0;j<nbaskets-1;j++)  {
      basket = (TBasket*)fBaskets.UncheckedAt(j);
      if (!basket) continue;
      if (fNBasketRAM < kMaxRAM) fBasketRAM[fNBasketRAM] = j;
      fNBasketRAM++;
      if (j == fReadBasket || j == fWriteBasket) continue;
      basket->DropBuffers();
      GetListOfBaskets()->RemoveAt(j);
      delete basket;
      fNBasketRAM--;
      if (!fTree->MemoryFull(0)) break;
   }

>From looking at the other places where fNBasketRAM is used I believe it
was intended to contain the number of valid baskets in the basket list of
a branch. However in the above piece of code the loop may end
prematurely and fNBasketRAM does not get incremented properly:
First of all it loops only up to j=nbaskets-2 (should it loop over the
entire list?) and secondly there is a break statement if enough memory has
been freed. Thus fNBasketRAM may be smaller than the actual number of
baskets after the loop. This will result in the observed error message
later (in the "fast dropping algorithm"):

  for (i=0;i<kMaxRAM;i++) {
         j = fBasketRAM[i];
         if (j < 0) continue;
         if (j == fReadBasket || j == fWriteBasket) continue;
         basket = (TBasket*)fBaskets.UncheckedAt(j);
         if (!basket) continue;
         basket->DropBuffers();
         GetListOfBaskets()->RemoveAt(j);
         delete basket;
         fBasketRAM[i] = -1;
         fNBasketRAM--;
      }
      if (fNBasketRAM < 0) {
         printf("ERROR, fNBasketRAM =%dn",fNBasketRAM);
         fNBasketRAM = 0;
      }

Help would be appreciated very much since we (that is BaBar) are planning
to produce lots and lots of root files very soon and would like to
understand this problem beforehand.

Greetings,
Leif.


  Dipl. Phys. Leif Wilden - BaBar Collaboration, Group Dresden
  e-mail  : wilden@slac.stanford.edu
  homepage: http://hep.phy.tu-dresden.de/~wilden/
  address, phone etc.: see my homepage



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:21 MET