Problem 669 - Resetting values in G4ParticleGun
Summary: Resetting values in G4ParticleGun
Status: RESOLVED INVALID
Alias: None
Product: Geant4
Classification: Unclassified
Component: event (show other problems)
Version: 6.2
Hardware: PC Linux
: P2 trivial
Assignee: Makoto.Asai
URL:
Depends on:
Blocks:
 
Reported: 2004-09-14 14:37 CEST by Vlasios Vasileiou
Modified: 2004-12-01 21:10 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
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.