The first parameter to TClonesArray constructor must be the name of a class
derived from TObject. In the example we create a TClonesArray with:
gTracks = new TClonesArray("Track", 1000);
where Track is a user class derived from TObject.
You cannot pass the name of a basic data type such as "int".
I have protected TClonesArray against this type of errors in the new dev version.
Note also that the insertion of an object (eg track) in the clonesarray
requires new with placement as shown in the example:
//______________________________________________________________________________
void Event::AddTrack(Float_t random)
{
// Add a new track to the list of tracks for this event.
// To avoid calling the very time consuming operator new for each track,
// the standard but not well know C++ operator "new with placement" is called.
// if tracks[i] is NULL, a new Track object will be created
// otherwise the previous Track[i] will be overwritten.
TClonesArray &tracks = *fTracks;
new(tracks[fNtrack++]) Track(random);
}
In the current version of ROOT, you cannot call new with placement
interactively. This will be possible soon once we have introduced
the new version of CINT from Masa.
You can access the Track data interactively. That is precisely the intention
of the root/test/Event example you are quoting.
This program writes a Tree with a TClonesArray.
In an interactive session, you can then access any element of the array
with statements like:
Root > TFile f("Event.root");
Root > T.Draw("fPx"); where fPx is a data member of the class Track
Rene Brun
PS. I am away until July 15