Pasha Murat wrote: > > Dear ROOT developers, > > a couple of weeks ago I reported a problem with interactive handling of > TClonesArray. Briefly remind what it was - it is still present in 1.01/07: > -------------------------------------------------------------------------------- > ******************************************* > * * > * W E L C O M E to R O O T * > * * > * Version 1.01/07 3 July 1997 * > * Development version * > * * > * You are welcome to visit our Web site * > * http://root.cern.ch * > * * > ******************************************* > > CINT/ROOT C/C++ Interpreter version 5.13.11, May 25 1997 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > root [0] a= TClonesArray("int",100); > root [1] .p a[0] > > *** Break *** segmentation violation > -------------------------------------------------------------------------------- > I consider this problem to be a *major* one: user can't process an event, > containing a list (TClonesArray) of tracks, which is a general case > in particle physics. In particular, following one of the most helpful ROOT test > examples (test/MainEvent.cxx) one can access only the data stored in the event > header, whereas track data are not available interactively. > > Just want to attract your attention to the importance of this issue, > 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
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:20 MET