Hi all,
I too am having terrible difficulty that I suspect is coming from
TClonesArray. (I didn't compile ROOT in debug mode, so my Totalview
cannot show me what happens when I tree->Fill.) I have .Dump() output
for the stuff going into the Branch and all looks as I expect.
My problems occured after my initial tests with TClonesArray were
successful. I don't remember changing my branch objects after my test,
I just started making <vector>s of branches and objects, all of which
look like they are working fine.
Perhaps Tommaso and I are falling into the same traps, but I don't think
our code is doing things the same way.
- John
Tommaso Chiarusi wrote:
>On Tue, 1 Jul 2003, Philippe Canal wrote:
>
>
>
>>>I think that the problem resides in the destruction of the Event objects
>>>at the end of the loop. But I don't know why, since when I fill the
>>>TClonesArray of Event objects, it should copy the objects..., shouldn't
>>>it?
>>>
>>>
>>yes except that in $ROOTSYS/test/Event.h the copy constructor has not been
>>implemented and the default one (provided by the compiler) is wrong due to
>>the usage of pointers. Worse the design of that class assume (but do not
>>enforce) that it is basically a singleton.
>>So unless you change those quirks, you will have some trouble keeping
>>several 'Event' around.
>>
>>Cheers,
>>Philippe
>>
>>
>>
>
>Hi,
>I indeed provided a Copy constructor for the Event class:
>
>//---------
>
>Event::Event(const Event& event)
>{
> // Create an Event object by copying the tracks from a second event.
> // When the constructor is invoked for the first time, the class static
> // variable fgTracks is 0 and the TClonesArray fgTracks is created.
> //
>
>
> if (!fgTracks) fgTracks = new TClonesArray("Track", 1000);
> fTracks = fgTracks;
> fNtrack = 0;
> fH = 0;
> Int_t i0,i1;
> for (i0 = 0; i0 < 4; i0++) {
> for (i1 = 0; i1 < 4; i1++) {
> fMatrix[i0][i1] = 0.0;
> }
> }
> for (i0 = 0; i0 <10; i0++) fMeasures[i0] = 0;
> fClosestDistance = 0;
> fEventName = 0;
> fWebHistogram.SetAction(this);
>
>
> int ntra = event.GetNtrack();
> for(int nt = 0;nt<ntra;nt++)
> {
> Track *t = (Track*)event.GetTracks()->UncheckedAt(nt);
> AddTrack(*t);
> }
>
>
>}
>
>//---------
>But the result (segmentation violation) remains the same....
>I also tried to use an STL vector instead of the TClonesArray but the
>segmentation keeps on....
>
>Any idea?
>Thank you very much,
>Tommaso
>
>
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET