Custom event tree fails at run time

Hi All,

I am have a custom Event structure based on the examples provided with root.
but my code crashes at run time and I cannot see why.

I have attached a small example that reproduces the problem. if anyone can point out what am I doing wrong, please do so.

thank you in advance
test.tar.gz (3.72 KB)

Hi,

In your default constructor you have: if(!fPrimaries) fPrimaries = new TClonesArray("EventPrimary", 20); if(!fHits1) fHits1 = new TClonesArray("hit2", 100); if(!fHits2) fHits2 = new TClonesArray("hit1", 100);Since fPrimaries, fHits and fHits are not static member variables, when the constructor start they are not initialized and hence the ‘if (!fPrimaries)’ has a random result (and actually in most case fPrimaries will not be null and hence you will go on to use random value for fPrimaries).
So to fix your code simply use: fPrimaries = new TClonesArray("EventPrimary", 20); fHits1 = new TClonesArray("hit2", 100); fHits2 = new TClonesArray("hit1", 100);

Cheers,
Philippe