About Tparticle Charge() problem

Dear Rooters,

I am a root beginner and I try to read Primary charged particles from kinematics.root file. I write a some code but it does not work for charged primary particle part. When I try to work I prompt a message

“Entries=304
Error: C++ exception caught”

I have attached the code for you. I would be grateful if you could help me.

Thank you.

Hi,

you don’t give enough info to tell you a definitive answer (e.g. what does the tree look like?), but my guess is that your “Particles” branch contains more than one particle. And the way you set it up (TParticle*) it contains exactly one. You might want to check whether it contains e.g. a TClonesArray of TParticle objects, and set up the BranchAddress pointer accordingly. Check e.g. the tree tutorials in $ROOTSYS/tutorials.

Cheers, Axel.