Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCL::ReflectionChannel Class Reference

#include <G4INCLReflectionChannel.hh>

+ Inheritance diagram for G4INCL::ReflectionChannel:

Public Member Functions

 ReflectionChannel (Nucleus *n, Particle *p)
 
virtual ~ReflectionChannel ()
 
FinalStategetFinalState ()
 
- Public Member Functions inherited from G4INCL::IChannel
 IChannel ()
 
virtual ~IChannel ()
 
virtual G4INCL::FinalStategetFinalState ()=0
 

Detailed Description

Definition at line 48 of file G4INCLReflectionChannel.hh.

Constructor & Destructor Documentation

◆ ReflectionChannel()

G4INCL::ReflectionChannel::ReflectionChannel ( Nucleus n,
Particle p 
)

Definition at line 50 of file G4INCLReflectionChannel.cc.

51 :theNucleus(n),theParticle(p)
52 {
53 }

◆ ~ReflectionChannel()

G4INCL::ReflectionChannel::~ReflectionChannel ( )
virtual

Definition at line 55 of file G4INCLReflectionChannel.cc.

56 {
57 }

Member Function Documentation

◆ getFinalState()

FinalState * G4INCL::ReflectionChannel::getFinalState ( )
virtual

Implements G4INCL::IChannel.

Definition at line 59 of file G4INCLReflectionChannel.cc.

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 }
#define DEBUG(x)
double G4double
Definition: G4Types.hh:64
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
G4double getY() const
G4double getZ() const
G4double dot(const ThreeVector &v) const
G4double mag2() const
G4double getX() const

The documentation for this class was generated from the following files: