Problem 669

Summary: Resetting values in G4ParticleGun
Product: Geant4 Reporter: Vlasios Vasileiou <vlasisva>
Component: eventAssignee: Makoto.Asai
Status: RESOLVED INVALID    
Severity: trivial    
Priority: P2    
Version: 6.2   
Hardware: PC   
OS: Linux   

Description Vlasios Vasileiou 2004-09-14 14:37:38 CEST
In case a user uses many GeneratePrimaryVertex events in his
PrimaryGeneratorAction and for each PrimaryVertex he uses SetParticleMomentum()
with different momenta every time, then the warning message "Kinetic Energy is
overwritten" is shown for most events after the first one.

This is because the particle_energy left from the first GeneratePrimaryVertex()
(in PrimaryGeneratorAction) is not reset (to zero) after the
GeneratePrimaryVertex (in G4ParticleGun) has finished.

I propose to add a SetInitialValues() at the end of GeneratePrimaryVertex like that

.
.
.
.

    particle->SetCharge( particle_charge );
    particle->SetPolarization(particle_polarization.x(),
                               particle_polarization.y(),
                               particle_polarization.z());
    vertex->SetPrimary( particle );
  }


  evt->AddPrimaryVertex( vertex );
  SetInitialValues();


}
Comment 1 asai 2004-12-01 21:10:59 CET
If you specify the particle before setting its momentum, or set kinetic energy
instead of momentum, this message should not appear.