A question about TClonesArray

From: Datao Gong <dtgong_at_physics.umn.edu>
Date: Thu, 10 Nov 2005 10:32:14 -0600 (CST)


Hi, Guys,
When i read a piece of code writte by other people, i think i might misunderstand something about TClonesArray.

This code increase TClonesArray size on demand. It should not change the content which has been filled in.

My question are embeded in the comments.

   if(theMaxSize < 10) theMaxSize = 10;

   else if(theMaxSize < 30) theMaxSize = 30;
   else if(theMaxSize < 100) theMaxSize = 100;
   else if(theMaxSize < 250) theMaxSize = 250;
   else theMaxSize *= 2;

   theData->ExpandCreateFast(theMaxSize); //increase Size

   theData->Clear(); //Clear the TClonesArray, Does this mean the orignal

                     //infomation are lost after that!?

   for(Int_t entry = 0; entry < theSize; ++entry) theData->AddrAt(entry);

//AddrAt(Int_t) just return the Object* in specified slot, so it
//does nothing here?

BTW, this code works. But i just do not know why.

Thanks,

Datao Received on Thu Nov 10 2005 - 17:32:21 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET