Dear rooters,
I want to stream this class:
Class MyEvent: Public TObject
{
…
int eventid;
TClonesArray* trks; //->
TClonesArray* pts; //->
…
}
The TClonesArray* pts contains these objects:
Class StEmcPoint:Public TObject
{
…
float energy;
vector<StTrack*> mTracks;
…
}
Each of a StEmcPoint object has zero or None-zero track(s) associated with it. the vector<StTrack*> is to do this. The vector doesn’t own the tracks.
The TClonesArray* trks contains pointers to StTracks: StTrack*. However, I never explictly add things into this container.
Before, I didn’t do the StEmcPoint-StTrack association, so the vector<StTrack*> might be always just empty. I didn’t have any problem to write and read the tree.
Then I did the association. I didn’t have problem to write the tree. But when I read the tree, for the first a few events when there is zero StTrack associated with the StEmcPoint, no problem. But when there is a StTrack associated with the StEmcPoint, the program crashed.
During the above process, I never explictly added StTrack* to the TClonesArray* trks! I only added StEmcPoint* to the TClonesArray* pts. I thought if there were any StTracks associated with one StEmcPoint, these StTracks should be automatically streamed and saved when the StEmcPoint was streamed, am I right?
The program crashed when GetEntry(i).
Any idea of what’s going on? Thanks!