getPDGCharge() returning suspicious values

Geant4.10.05p1
Ubuntu 16.04
gcc v.5.4.0-6ubuntu1-16.04.11
make v.3.5.2

Hi all,

I have a very modified version of the TestEm7 example and I’m attempting to determine the charge of a heavy ion as it crosses from an attenuator into the absorber.

The ion is defined in the mac file thus:

/gps/particle ion
/gps/ion 88 224 1 0

And I interrogate the particle properties so:

  void SteppingAction::UserSteppingAction(const G4Step* step)
  {
      G4Track* track = step->GetTrack();

      ......

      G4StepPoint* prePoint  = step->GetPreStepPoint();
      G4StepPoint* postPoint = step->GetPostStepPoint();

     G4VPhysicalVolume* prePhysVol = prePoint->GetPhysicalVolume();
     G4VPhysicalVolume* postPhysVol = postPoint->GetPhysicalVolume();

     if (prePhysVol != postPhysVol)
     {    
         G4double KE = track->GetKineticEnergy();

         G4String postPhysVolName = postPhysVol->GetName();
  
         if (postPhysVolName == "Absorber")
         {
             G4ThreeVector Position = track->GetPosition();    
             G4ThreeVector Momentum = track->GetMomentum();

             G4double Charge = track->GetParticleDefinition()->GetPDGCharge();

             etc.

However the getPDGCharge() always returns a value of 88. Completely positively ionised. This is highly unlikely.

Do you know what I might be doing wrong?

Regards

Tim

The PDGCharge will always return 88 as that is the atomic number (Z) of your incoming ion and it is a constant.

If I understand correctly what you want is the charge state of the ion. Those type of “variable” properties are stored in the DynamicParticle Class. from there you can get the charge via G4DynamicParticle::GetCharge()

Cheers

Hi Pico

many thanks for your reply.

I’m not looking to change the state but determine whether the particle has been (further) ionised by the attenuating medium. I assume that the G4DynamicParticle::GetCharge() returns the change in charge if any? I’ve implemented as you suggested but it’s returning a blank field and I’m unable to persuade the particles to (further) ionise as they pass through an attenuating medium and thereafter into the absorber.

Regards

Tim