Message: Re: Geant4 G4ParticleGun Output Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Re: Geant4 G4ParticleGun Output 

Forum: Event and Track Management
Re: Question Geant4 G4ParticleGun Output (Andreas Tepe)
Re: Feedback Re: Geant4 G4ParticleGun Output (Gumplinger Peter)
Date: 11 Feb, 2016
From: Emanuele Leonardi <Emanuele Leonardi>

On Tue, 27 Jul 2010 21:01:32 GMT, Gumplinger Peter wrote:
> Hi Andreas,
> 
> Where (and how) do you G4ParticleGun::SetParticleEnergy - from a macro
> or in your PrimaryGeneratorAction? It looks like you set it to zero:
> 
> G4ParticleGun::gamma
>  was defined in terms of Momentum: 0.0039373441GeV/c
>  is now defined in terms of KineticEnergy: 0GeV
> 
> And you seem to be toggling between SetParticleEnergy and
> SetParticleMomentum.
> 
> Peter
> 

I am getting this puzzling behaviour with G4ParticleGun: when I create a new gun I would expect it to be initialized to 0 and if I look inside the code this looks like to be the case:

G4ParticleGun::G4ParticleGun()
{
  SetInitialValues();
}

void G4ParticleGun::SetInitialValues()
{
  NumberOfParticlesToBeGenerated = 1;
  particle_definition = 0;
  G4ThreeVector zero;
  particle_momentum_direction = (G4ParticleMomentum)zero;
  particle_energy = 0.0;
  particle_momentum = 0.0;
  particle_position = zero;
  particle_time = 0.0;
  particle_polarization = zero;
  particle_charge = 0.0;
  theMessenger = new G4ParticleGunMessenger(this);
}

i.e. no particle definition and both energy and momentum are set to 0.

But apparently in my code someone is initializing the gun to a 1GeV geantino.

If I run the following code:

 G4ParticleGun* gun = new G4ParticleGun();
 G4cout << "Test before " << gun->GetParticleEnergy() << " " <<  gun->GetParticleMomentum() << G4endl;
 gun->SetParticleMomentum(550.*MeV);
 G4cout << "Test after " << gun->GetParticleEnergy() << " " <<  gun->GetParticleMomentum() << G4endl;

I get this output:

Test before 1000 0
G4ParticleGun::geantino
 was defined in terms of KineticEnergy: 1GeV
 is now defined in terms Momentum: 0.55GeV/c
Test after 550 550

I checked in all my code but G4ParticleGun is not used anywhere else.

Any idea of what is going on?

Thank you

Emanuele Leonardi

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Feedback: Re: Geant4 G4ParticleGun Output   (Gumplinger Peter - 11 Feb, 2016)
 Add Message Add Message
to: "Re: Geant4 G4ParticleGun Output"

 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 ]