How to get Ion Particle Definition and compare it to current particle in Track

Hi everyone,
I get the particle in the current step with:

G4ParticleDefinition* particle = step->GetTrack()->GetDefinition();

and want the program to tell me when the current particle interacted with is an C12 Atom. I think there must be a way with G4Ions but I don’t know how to exactly get the particle I want with that class to compare it to the current Track.
I worked out how to do it with protons as H1:

G4Proton* proton = G4Proton::Definition();
if (proton == particle) {...}

And this works. But how can I do this with other Ions with given A,Z such as C12?
Can anyone help me?

Thank you everyone in advance

if (particle->GetAtomicNumber() == 6 && particle->GetAtomicMass() == 12) {
  G4cout << "C-12" << G4endl;
}

Those member functions of G4ParticleDefinition always exist (of course), but they’ll return zeroes for non-nuclei.

Thank you very much it helped me a lot!

sorry, one question regarding this. What particle is addressed by this if clause? For example if I shoot neutrons on a mixture of C and H. First it hits H and transfers all its energy. the energy deposited falls under particle == hydrogen, right? And after that the proton of hydrogen bounces into C. I guess that would fall under particle == Carbon. So is the first energy removed from the record or do you record more than the original energy?

And another question is there also a method to ask for the source particle like: if (sourceparticle == proton && target particle == C12) {…}
Thanks for the help