Message: "Kinetic energy is overwritten message" Not Logged In (login)

## "Kinetic energy is overwritten message"

Forum: Event and Track Management
Date: 14 Apr, 2004
From: Vlasios Vasileiou <Vlasios Vasileiou>

 In my PrimaryGeneratorAction I use a loop to generate many particles with different energies. for () { setmomentum() generateprimaryvertex } Everytime I set a new momentum, the following code from G4PrimaryGun::SetParticleMomentum is executed ``` 98 G4double mass = particle_definition->GetPDGMass(); 99 G4double p = aMomentum.mag(); 100 particle_momentum_direction = aMomentum.unit(); 101 if ((particle_energy>0.0)&&(abs(particle_energy+mass-sqrt(p*p+mass*mass))>keV)) 102 { 103 G4cout << "G4ParticleGun::" << particle_definition->GetParticleName() << G4endl; 104 G4cout << " KineticEnergy and Momentum could be inconsistent" << G4endl; 105 G4cout << " (Momentum:" << p/GeV << " GeV/c"; 106 G4cout << " Mass:" << mass/GeV << " GeV/c/c)" << G4endl; 107 G4cout << " KineticEnergy is overwritten!! "; 108 G4cout << particle_energy/GeV << "->"; 109 G4cout << (sqrt(p*p+mass*mass)-mass)/GeV << "GeV" << G4endl; 110 } 111 particle_energy = sqrt(p*p+mass*mass)-mass;``` with the result of giving me a warning (lines 103-109) for every particle I shoot, after the first one. What is the use of lines 101-110? The particle_energy at the if at 101 is the momentum of the previous particle shot. Shouldn't the particle_energy be reset to 0 after every GeneratePrimaryVertex has finished? Thanks, Vlasios Vasileiou

 Inline Depth: Outline Depth: Add message:

1 Re: "Kinetic energy is overwritten message"   (Vlasios Vasileiou - 22 Apr, 2004)
Re: "Kinetic energy is overwritten message"   (liuhm@mail.ihep.ac.cn - 24 Apr, 2004)
 to: ""Kinetic energy is overwritten message""
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 ]