G4IonTable::GetIon() Why can I set different valence states for proton helium ions, but for ions heavier than helium ions, no matter how you set it, you can only get the default fully ionized ion?
Thank you!
_Geant4 Version:_11.0.02
_Operating System:_Ubuntu 20.04.6 LTS
_Compiler/Version:_gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
_CMake Version:_cmake version 3.16.3
1 Like
[ Please do not ask new questions in old threads. This new one is the right place to post. ]
I guess you mean as a primary particle. The usual ParticleGun action,
/gun/particle ion
/gun/ion Z A Q
should work. If you have an example where it does not, please post it here. Have you tried one of the basic G4 examples with a macro file setting a charged ion primary? Which example? What macro commands did you use?
1 Like
Thank you for reminding me, I will pay attention to put new questions in the new topic.
Now there is a problem: I am using the run. mac can according to your code to implement with different ion of the charge, but when I use PrimaryGeneratorAction.cc, unable to realize to the set of different charge state. This puzzled me for a long time, not knowing what the problem was.
Here are my files.
Thank you again!
PrimaryGeneratorAction.cc (2.2 KB)
PrimaryGeneratorAction.hh (571 Bytes)
Why are you creating two different G4DynamicParticle
instances?
In your first G4DynamicParticle
instance (which is the one you add to your G4PrimaryParticle
) you don’t ever set the charge state, so of course it has the default charge of zero. If you look at G4DynamicParticle.hh
, you will see the following:
inline G4double GetCharge() const;
inline void SetCharge(G4double charge);
inline void SetCharge(G4int chargeInUnitOfEplus);
// Set/Get dynamical charge
Try calling dynamicParticle->SetCharge(-1)
or dynamicParticle->SetCharge(3)
or whatever charge state you want.
Thank you for reminding me that this is a mistake caused by my carelessness. I will correct it and then check if there are any other problems.