Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCLReflectionChannel.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// INCL++ intra-nuclear cascade model
27// Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28// Davide Mancusi, CEA
29// Alain Boudard, CEA
30// Sylvie Leray, CEA
31// Joseph Cugnon, University of Liege
32//
33// INCL++ revision: v5.1.8
34//
35#define INCLXX_IN_GEANT4_MODE 1
36
37#include "globals.hh"
38
40#include "G4INCLFinalState.hh"
41#include "G4INCLRandom.hh"
43
44#include <cmath>
45
46namespace G4INCL {
47 const G4double ReflectionChannel::sinMinReflectionAngleSquaredOverFour = std::pow(std::sin(2.*Math::pi/200.),2.);
48 const G4double ReflectionChannel::positionScalingFactor = 0.99;
49
51 :theNucleus(n),theParticle(p)
52 {
53 }
54
56 {
57 }
58
60 {
61 FinalState *fs = new FinalState(); // Create final state for the output
62 fs->setTotalEnergyBeforeInteraction(theParticle->getEnergy() - theParticle->getPotentialEnergy());
63
64 const ThreeVector &oldMomentum = theParticle->getMomentum();
65 G4double pspr = theParticle->getPosition().dot(oldMomentum);
66 if(pspr>=0) { // This means that the particle is trying to leave; perform a reflection
67 const G4double x2cour = theParticle->getPosition().mag2();
68 const ThreeVector newMomentum = oldMomentum - (theParticle->getPosition() * (2.0 * pspr/x2cour));
69 const G4double deltaP2 = (newMomentum-oldMomentum).mag2();
70 theParticle->setMomentum(newMomentum);
71 const G4double minDeltaP2 = sinMinReflectionAngleSquaredOverFour * newMomentum.mag2();
72 if(deltaP2 < minDeltaP2) { // Avoid extremely small reflection angles
73 theParticle->setPosition(theParticle->getPosition() * positionScalingFactor);
74 DEBUG("Reflection angle for particle " << theParticle->getID() << " was too tangential: " << std::endl
75 << " " << deltaP2 << "=deltaP2<minDeltaP2=" << minDeltaP2 << std::endl
76 << " Resetting the particle position to ("
77 << theParticle->getPosition().getX() << ", "
78 << theParticle->getPosition().getY() << ", "
79 << theParticle->getPosition().getZ() << ")" << std::endl);
80 }
81 theNucleus->updatePotentialEnergy(theParticle);
82 } else { // The particle momentum is already directed towards the inside of the nucleus; do nothing
83 // ...but make sure this only happened because of the frozen propagation
84// assert(theParticle->getPosition().dot(theParticle->getPropagationVelocity())>0.);
85 }
86
87 theParticle->thawPropagation();
88 fs->addModifiedParticle(theParticle);
89 return fs;
90 }
91}
92
Abstract interface to the nuclear potential.
#define DEBUG(x)
double G4double
Definition: G4Types.hh:64
void addModifiedParticle(Particle *p)
void setTotalEnergyBeforeInteraction(G4double E)
void updatePotentialEnergy(Particle *p)
Update the particle potential energy.
G4double getEnergy() const
G4double getPotentialEnergy() const
Get the particle potential energy.
const G4INCL::ThreeVector & getPosition() const
const G4INCL::ThreeVector & getMomentum() const
virtual void setMomentum(const G4INCL::ThreeVector &momentum)
void thawPropagation()
Unfreeze particle propagation.
virtual void setPosition(const G4INCL::ThreeVector &position)
long getID() const
ReflectionChannel(Nucleus *n, Particle *p)
G4double getY() const
G4double getZ() const
G4double dot(const ThreeVector &v) const
G4double mag2() const
G4double getX() const
const G4double pi