use of globals in test examples

From: Rutger van der Eijk (r36@nikhef.nl)
Date: Tue Mar 24 1998 - 12:08:29 MET


Hi all,

I was taking a close look at the event/track example in $ROOTSYS/test and
started to wonder why a global *gTracks is defined. The constructor of the
event class creates the gTracks global (a TClonesArray) if it does not
exist yet and puts the fTracks datamember of the instantiated Event object
to this global. In the MainEvent program only one instantiation of Event
is made. In a loop the datamembers are set to different values and
everytime a tree is filled with the event. 
	I wonder now what would happen if we would create 2 Event
objects. In that case both Event objects will use the same Track array.
This doesn't seem object-oriented to me, and I don't see the advantage of
using the global gTracks in this case. I'm a new user of ROOT so I might
make a mistake here, and miss the reason why a global object should be
used in this case. If this is the case I would appriciate anybody
explaining this to me, so that i can use this in my own programs. (I can
imagine that it has something to do with the addresspointer used by the
tree fill function...)

Rutger van der Eijk



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET