Message: Re: Problem with setting particle gun as an ion Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Problem with setting particle gun as an ion 

Forum: Particles
Re: None Problem with setting particle gun as an ion
Date: 13 Feb, 2014
From: michel maire <michel maire>

On Wed, 12 Feb 2014 23:42:28 GMT, breanainneire wrote:
> Hello,
> 
> I am relatively new to Geant, and am just fooling around with a really
> basic build. So far, I can set the particle of the particle gun to
> gammas, neutrons, protons, etc, but today I decided to see if I can do
> other ions as well.
> 
> I put the code in my primary action generator as this:
> 
> PrimaryGeneratorAction::PrimaryGeneratorAction()
> {
>   G4int NumberOfParticles = 1;
>   particleGun = new G4ParticleGun(NumberOfParticles);
> 
>   G4IonTable* ionTable = G4IonTable::GetIonTable();
>   G4int Z = 6, A = 12;
>   G4double excitEnergy = 0.*keV;
>   G4ParticleDefinition* particle = ionTable->GetIon(Z,A,excitEnergy);
>   particleGun->SetParticleDefinition(particle);
>   particleGun->SetParticleEnergy(1.0*MeV);
> }
> 
> Everything compiles fine, but when I run the program, I get these
> errors,
> 
> -------- WWWW ------- G4Exception-START -------- WWWW -------
> *** G4Exception : PART105
>       issued by : G4IonTable::CreateIon()
> Can not create ions because GenericIon is not ready
> *** This is just a warning message. ***
> -------- WWWW -------- G4Exception-END --------- WWWW -------
> 
> -------- EEEE ------- G4Exception-START -------- EEEE -------
> *** G4Exception : Event0101
>       issued by : G4ParticleGun::SetParticleDefinition()
> Null pointer is given.
> *** Fatal Exception *** core dump ***
> -------- EEEE -------- G4Exception-END --------- EEEE -------
> 
> I'm pretty new at this, and I've search for what these mean, but I'm at
> a loss. If anyone can shed some light on this, it would be greatly
> appreciated!
> 

 To complement Peter answer, it is too early to invoke IonTable in the constructor of PrimaryGeneratorAction : the Ion table is not yet ready.
 Instead, you can do it in GeneratePrimaries() or by UI command.
 See examples: basic/B3 or radioactivedecay/rdecay01

 Add Message Add Message
to: "Re: Problem with setting particle gun as an ion"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]