132 G4cout <<
"Old Momentum Direction: "
134 G4cout <<
"Old Polarization: "
143 G4double CosTheta, SinTheta, SinPhi, CosPhi, unit_x, unit_y, unit_z;
150 SinTheta = std::sqrt(1.-CosTheta*CosTheta);
156 SinPhi = std::sin(rand);
157 CosPhi = std::cos(rand);
160 unit_x = SinTheta * CosPhi;
161 unit_y = SinTheta * SinPhi;
163 NewMomentumDirection.
set (unit_x,unit_y,unit_z);
167 OldMomentumDirection = OldMomentumDirection.
unit();
168 NewMomentumDirection.
rotateUz(OldMomentumDirection);
169 NewMomentumDirection = NewMomentumDirection.
unit();
175 constant = -NewMomentumDirection.
dot(OldPolarization);
177 NewPolarization = OldPolarization + constant*NewMomentumDirection;
178 NewPolarization = NewPolarization.
unit();
183 if (NewPolarization.
mag() == 0.) {
185 NewPolarization.
set(std::cos(rand),std::sin(rand),0.);
186 NewPolarization.
rotateUz(NewMomentumDirection);
190 if (
G4UniformRand() < 0.5) NewPolarization = -NewPolarization;
194 cosTheta = NewPolarization.
dot(OldPolarization);
202 G4cout <<
"New Polarization: "
203 << NewPolarization <<
G4endl;
204 G4cout <<
"Polarization Change: "
206 G4cout <<
"New Momentum Direction: "
207 << NewMomentumDirection <<
G4endl;
208 G4cout <<
"Momentum Change: "
void set(double x, double y, double z)
const G4DynamicParticle * GetDynamicParticle() const
double dot(const Hep3Vector &) const
void ProposePolarization(G4double Px, G4double Py, G4double Pz)
const G4ThreeVector * GetMomentumDirection() const
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
Hep3Vector & rotateUz(const Hep3Vector &)
virtual void Initialize(const G4Track &)
const G4ThreeVector & GetPolarization() const
G4ParticleChange aParticleChange
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
const G4ThreeVector * GetPolarization() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)