[G14_run] Bug in rootbeer.

daoh at andrew.cmu.edu daoh at andrew.cmu.edu
Wed Apr 9 12:19:25 EDT 2014


Dear collaborators,

If you are using rootbeer for analysis, your code probably has a small
bug. The bug causes your code to terminate because it thinks the current
DST root file is a zombie file. The problem lies inside a very innocent
lines of code:


if((rootbeer=createBeerObject(inFile))==NULL) return;   // create rootbeer
object, should use continue, not return.

if you go to src/RootBeerUtil.cxx (this folder inside rootbeer), you would
see the how the createBeerObject function defined.
If you see the followings, then we have the same version:


//************************* createBeerObject()
********************************
TRootBeer *createBeerObject(char *bankFileName){
  Int_t error=0;

  //work out whether it's a bos file or a root file and create the
  //appropriate object
  if((strstr(bankFileName,".root"))!=NULL){
    rootbeer = new TDST(bankFileName,bankAddress,nBankTypes); //<--problem
is here
  }
  else{
    rootbeer = new TBos(bankFileName,bankAddress,nBankTypes);
  }
  error=rootbeer->GetError(); //<--problem is here
  if(error){
    delete rootbeer;
    return NULL;
  }
  else  return rootbeer;
}


The variable error is used as a flag to indicate whether the current root
file is Zombile or not.
Open the file TDST.cxx (the same directory), you would see that
rootbeer->GetError() returns fError.  For some reasons, fError can have a
non zero value, even though the file is NOT zombie. The problem is that
the fError needs to be initialized before it can be used (the below
function is a constructor). So just add this line fError=0; //-->ADDING
THIS LINE to the function below.

TDST::TDST(const char *bosFile, void* addresses, int total)
{
// Create one TDST object and open the 1st data file

  fError=0; //-->ADDING THIS LINE
  fBankAddr = (struct addressBanks_t*)addresses;        //all info about
bank variables
  fBankTotal = total;                                   //total no of
defined banks
  fDSTfile = new TFile(bosFile);                        //open DST input file
  if(fDSTfile->IsZombie()){                             //if failed return
error
    fprintf(stderr,"Zombie file? \n");
    fError=1;
    return;
  }
  fBankTree = (TTree*)gDirectory->Get("bankTree");      //get the tree
  if(fBankTree==NULL){
    fprintf(stderr,"failed to open banktree \n");
    return;
  }
  fBigBuff = new char[100000];          //create a 100k buffer to hold the
event
  fDataStartAddr = fBigBuff;            //init the data pointer
  fDataAddr = fBigBuff;                 //ditto
  fServedBankNo=0;                      //init the no of banks being handled
  fEntry=0;
  fMaxEntry=(int)fBankTree->GetEntries(); //get the no of events in the
DST file
  for(int n=0;n<fBankTotal;n++){        //init the status of all banks to
zero
      fBankStatus[n]=0;
  }
}



If you still have same problems, then the root file is truely a zombie!
But it is a good practice to initialize variables before using them. Btw,
you need to reinstall rootbeer.

Sincerely,
Dao Ho



More information about the G14_run mailing list