Re: static TClonesArrays

From: Rene BRUN <>
Date: Fri, 11 Feb 2005 10:57:45 +0100


The fact that the TClonesArray pointer is declared static or not has no impact on the speed. What is important is to create your TClonesArray(s) only once. In the test/Event example, we have used a static pointer to show that the array should be created only once. It would have been better to create a Run class owning this array and filled in the Event class.

Rene Brun

Alessandro Thea wrote:
> Hi rooters,
> up to now I've worked with an event bases on the Event example available
> with root, in particular it uses a static TClonesArray as suggested in
> many other posts.
> Now I would like, or let's say that I need the capability to have
> multiple copies of my event and to to that I'm thinking to remove the
> static attribute of the TClonesArray.
> The problem is that I do not understand where and how much my code would
> be slowed down.
> The basic structure I use is the following:
> {
> Event* ev = 0;
> TTree *t= new TTree("...");
> t->Branch("Event",&ev);
> for(Int_t i(0); i<nMaxEv; i+) {
> /*
> Fill Event... and the TClonesArray
> */
> t->Fill();
> ev->Clear() // calls TClonesArray::Clear(), not Delete
> }
> // writing tree, closing file and so on
> }
> Thanks in advance for any suggestion,
> Alessandro
Received on Fri Feb 11 2005 - 10:57:50 MET

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