TMCParticle TParticle inheritance and TGenerator

There seems to be an issue in TGenerator::GetParticle in that it returns (TParticle*)fParticles->UncheckedAt(i);

but if one is using TPythia6, fParticles is actually filled with pointers to TMCParticle objects. Recall that fParticles is declared by “TObjArray *fParticles;”.

TMCParticle does not inherit from TParticle (on the surface, it seems like it should), so one gets a TParticle pointer that actually points to an object that does not inherit from TParticle. This seems bad. Am I missing some subtly?

I noticed this with 5.16, but it appear to be true in 5.18 as well.


TPythia6 creates a TClonesArray of TMCParticle by default (for historical reasons before we introduced TParticle). We also give the possibility to create a TClonesArray of TParticle (See the two functions ImportParticles).
We will soon introduce the TPythia8 interface that will fill only a TClonesArray of TParticle.