Message: Re: Easy way to suppress G4ParticleGun messages on event-by-event changes? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Easy way to suppress G4ParticleGun messages on event-by-event changes? 

Forum: Event and Track Management
Re: Question Easy way to suppress G4ParticleGun messages on event-by-event changes? (Michael H. Kelsey)
Re: Feedback Re: Easy way to suppress G4ParticleGun messages on event-by-event changes? (Gumplinger Peter)
Date: 03 Jun, 2011
From: Michael H. Kelsey <Michael H. Kelsey>

Gumplinger Peter writes:
> I have run into this before and probably for the exact same reason.
> SetParticleMomentum expects you to provide the momentum vector. This
> vector is not a unity vector but has norm p = |p_vect|. Don't know what
> G4LorentzVector::vect() returns but looking at your code snippet likely
> the unit vector direction.

Hi, Peter.  G4LorentzVector::vect() returns the full momentum (spatial)
vector; you have to do .unit() to get the unit directon vector.

> This is not what you want to do because the norm of the latter is used to
> (re)caclulate the energy of the particle, hence the unprotected warming!

When I looked at the G4ParticleGun code, it seems like both energy and
momentum setting are "protected" -- if the energy is non-zero, setting the
momentum triggers a message, and if the momentum is non-zero, setting the
energy triggers one.  The trouble is that once you have the gun set, both
values are non-zero and changing anything leads to a message.

I even tried, for example, setting the energy to zero first, before changing
the momentum, but since the (prior) momentum is non-zero, that still
triggers the message.

      -- Mike

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

1 None: Re: Easy way to suppress G4ParticleGun messages on event-by-event changes?   (tntakahashi - 03 Dec, 2011)
(_ None: Re: Easy way to suppress G4ParticleGun messages on event-by-event changes?   (Mike Kelsey - 04 Dec, 2011)
 Add Message Add Message
to: "Re: Easy way to suppress G4ParticleGun messages on event-by-event changes?"

 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 ]