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

#include <G4INCLInteractionAvatar.hh>

+ Inheritance diagram for G4INCL::InteractionAvatar:

Public Member Functions

 InteractionAvatar (G4double, G4INCL::Nucleus *, G4INCL::Particle *)
 
 InteractionAvatar (G4double, G4INCL::Nucleus *, G4INCL::Particle *, G4INCL::Particle *)
 
virtual ~InteractionAvatar ()
 
- Public Member Functions inherited from G4INCL::IAvatar
 IAvatar ()
 
 IAvatar (G4double time)
 
virtual ~IAvatar ()
 
virtual G4INCL::IChannelgetChannel () const =0
 
G4INCL::FinalStategetFinalState ()
 
virtual void preInteraction ()=0
 
virtual FinalStatepostInteraction (FinalState *)=0
 
G4double getTime () const
 
virtual ParticleList getParticles () const =0
 
virtual std::string dump () const =0
 
AvatarType getType () const
 
G4bool isACollision () const
 
G4bool isADecay () const
 
void setType (AvatarType t)
 
long getID () const
 
std::string toString ()
 

Static Public Attributes

static const G4double locEAccuracy = 1.E-4
 Target accuracy in the determination of the local-energy Q-value.
 
static const G4int maxIterLocE = 50
 Max number of iterations for the determination of the local-energy Q-value.
 

Protected Member Functions

virtual G4INCL::IChannelgetChannel () const =0
 
G4bool bringParticleInside (Particle *const p)
 
void preInteractionLocalEnergy (Particle *const p)
 Apply local-energy transformation, if appropriate.
 
void preInteractionBlocking ()
 Store the state of the particles before the interaction.
 
void preInteraction ()
 
FinalStatepostInteraction (FinalState *)
 
void restoreParticles () const
 Restore the state of both particles.
 
G4bool shouldUseLocalEnergy () const
 true if the given avatar should use local energy
 
G4bool enforceEnergyConservation (FinalState *const fs)
 Enforce energy conservation.
 

Protected Attributes

G4INCL::NucleustheNucleus
 
G4INCL::Particleparticle1
 
G4INCL::Particleparticle2
 
ThreeVector boostVector
 
ParticleType oldParticle1Type
 
ParticleType oldParticle2Type
 
G4double oldParticle1Energy
 
G4double oldParticle2Energy
 
G4double oldTotalEnergy
 
G4double oldXSec
 
G4double oldParticle1Potential
 
G4double oldParticle2Potential
 
G4double oldParticle1Mass
 
G4double oldParticle2Mass
 
G4double oldParticle1Helicity
 
G4double oldParticle2Helicity
 
ThreeVector oldParticle1Momentum
 
ThreeVector oldParticle2Momentum
 
ThreeVector oldParticle1Position
 
ThreeVector oldParticle2Position
 
G4bool isPiN
 
- Protected Attributes inherited from G4INCL::IAvatar
G4double theTime
 

Detailed Description

Definition at line 61 of file G4INCLInteractionAvatar.hh.

Constructor & Destructor Documentation

◆ InteractionAvatar() [1/2]

G4INCL::InteractionAvatar::InteractionAvatar ( G4double  time,
G4INCL::Nucleus n,
G4INCL::Particle p1 
)

Definition at line 64 of file G4INCLInteractionAvatar.cc.

◆ InteractionAvatar() [2/2]

G4INCL::InteractionAvatar::InteractionAvatar ( G4double  time,
G4INCL::Nucleus n,
G4INCL::Particle p1,
G4INCL::Particle p2 
)

Definition at line 70 of file G4INCLInteractionAvatar.cc.

72 : IAvatar(time), theNucleus(n),
73 particle1(p1), particle2(p2),
74 isPiN((p1->isPion() && p2->isNucleon()) || (p2->isPion() && p1->isNucleon()))
75 {
76 }
G4bool isPion() const
Is this a pion?
G4bool isNucleon() const

◆ ~InteractionAvatar()

G4INCL::InteractionAvatar::~InteractionAvatar ( )
virtual

Definition at line 78 of file G4INCLInteractionAvatar.cc.

78 {
79 }

Member Function Documentation

◆ bringParticleInside()

G4bool G4INCL::InteractionAvatar::bringParticleInside ( Particle *const  p)
protected

Definition at line 131 of file G4INCLInteractionAvatar.cc.

131 {
132 ThreeVector pos = p->getPosition();
133 G4double pos2 = pos.mag2();
135 short iterations=0;
136 const short maxIterations=50;
137
138 if(pos2 < r*r) return true;
139
140 while( pos2 >= r*r && iterations<maxIterations )
141 {
142 pos *= std::sqrt(r*r*0.99/pos2);
143 pos2 = pos.mag2();
144 iterations++;
145 }
146 if( iterations < maxIterations)
147 {
148 DEBUG("Particle position vector length was : " << p->getPosition().mag() << ", rescaled to: " << pos.mag() << std::endl);
149 p->setPosition(pos);
150 return true;
151 }
152 else
153 return false;
154 }
#define DEBUG(x)
double G4double
Definition: G4Types.hh:64
G4double getSurfaceRadius(Particle const *const particle) const
Get the maximum allowed radius for a given particle.

Referenced by postInteraction().

◆ enforceEnergyConservation()

G4bool G4INCL::InteractionAvatar::enforceEnergyConservation ( FinalState *const  fs)
protected

Enforce energy conservation.

Final states generated by the channels might violate energy conservation because of different reasons (energy-dependent potentials, local energy...). This conservation law must therefore be enforced by hand. We do so by rescaling the momenta of the final-state particles in the CM frame. If this turns out to be impossible, this method returns false.

Returns
true if the algorithm succeeded

Definition at line 345 of file G4INCLInteractionAvatar.cc.

345 {
346 // Set up the violationE calculation
347 ParticleList modified = fs->getModifiedParticles();
348 const G4bool manyBodyFinalState = (modified.size() + fs->getCreatedParticles().size() > 1);
349 if(manyBodyFinalState)
350 violationEFunctor = new ViolationEMomentumFunctor(theNucleus, fs, &boostVector, shouldUseLocalEnergy());
351 else {
352 Particle const * const p = modified.front();
353 // The following condition is necessary for the functor to work
354 // correctly. A similar condition exists in INCL4.6.
356 return false;
357 violationEFunctor = new ViolationEEnergyFunctor(theNucleus, fs);
358 }
359
360 // Apply the root-finding algorithm
361 const G4bool success = RootFinder::solve(violationEFunctor, 1.0);
362 if(success) { // Apply the solution
363 std::pair<G4double,G4double> theSolution = RootFinder::getSolution();
364 (*violationEFunctor)(theSolution.first);
365 } else {
366 WARN("Couldn't enforce energy conservation after an interaction, root-finding algorithm failed." << std::endl);
367 }
368 delete violationEFunctor;
369 return success;
370 }
#define WARN(x)
bool G4bool
Definition: G4Types.hh:67
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
static const G4double effectiveDeltaDecayThreshold
static std::pair< G4double, G4double > const & getSolution()
Get the solution of the last call to solve().
static G4bool solve(RootFunctor const *const f, const G4double x0)
Numerically solve a one-dimensional equation.
std::list< G4INCL::Particle * > ParticleList

Referenced by G4INCL::DecayAvatar::postInteraction(), and postInteraction().

◆ getChannel()

virtual G4INCL::IChannel * G4INCL::InteractionAvatar::getChannel ( ) const
protectedpure virtual

◆ postInteraction()

FinalState * G4INCL::InteractionAvatar::postInteraction ( FinalState fs)
protectedvirtual

Implements G4INCL::IAvatar.

Definition at line 156 of file G4INCLInteractionAvatar.cc.

156 {
157 ParticleList modified = fs->getModifiedParticles();
158 ParticleList modifiedAndCreated = modified;
159 ParticleList created = fs->getCreatedParticles();
160 modifiedAndCreated.insert(modifiedAndCreated.end(), created.begin(), created.end());
161
162 if(!isPiN) {
163 // Boost back to lab
164 for( ParticleIter i = modifiedAndCreated.begin(); i != modifiedAndCreated.end(); ++i )
165 (*i)->boost(-boostVector);
166 }
167
168 // If there is no Nucleus, just return
169 if(!theNucleus) return fs;
170
171 // Mark pions that have been created outside their well (we will force them
172 // to be emitted later).
173 for( ParticleIter i = created.begin(); i != created.end(); ++i )
174 if((*i)->isPion() && (*i)->getPosition().mag() > theNucleus->getSurfaceRadius(*i)) {
175 (*i)->makeParticipant();
176 (*i)->setOutOfWell();
177 fs->addOutgoingParticle(*i);
178 DEBUG("Pion was created outside its potential well." << std::endl
179 << (*i)->print());
180 }
181
182 // Try to enforce energy conservation
183 fs->setTotalEnergyBeforeInteraction(oldTotalEnergy);
184 G4bool success = true;
186 success = enforceEnergyConservation(fs);
187 if(!success) {
188 DEBUG("Enforcing energy conservation: failed!" << std::endl);
189
190 // Restore the state of the initial particles
192
193 // Delete newly created particles
194 for( ParticleIter i = created.begin(); i != created.end(); ++i )
195 delete *i;
196
197 FinalState *fsBlocked = new FinalState;
198 delete fs;
199 fsBlocked->makeNoEnergyConservation();
200 fsBlocked->setTotalEnergyBeforeInteraction(0.0);
201
202 return fsBlocked; // Interaction is blocked. Return an empty final state.
203 }
204 DEBUG("Enforcing energy conservation: success!" << std::endl);
205
206 // Check that outgoing delta resonances can decay to pi-N
207 for( ParticleIter i = modified.begin(); i != modified.end(); ++i )
208 if((*i)->isDelta() &&
210 DEBUG("Mass of the produced delta below decay threshold; forbidding collision. deltaMass=" <<
211 (*i)->getMass() << std::endl);
212
213 // Restore the state of the initial particles
215
216 // Delete newly created particles
217 for( ParticleIter j = created.begin(); j != created.end(); ++j )
218 delete *j;
219
220 FinalState *fsBlocked = new FinalState;
221 delete fs;
222 fsBlocked->makeNoEnergyConservation();
223 fsBlocked->setTotalEnergyBeforeInteraction(0.0);
224
225 return fsBlocked; // Interaction is blocked. Return an empty final state.
226 }
227
228 // Test Pauli blocking
229 G4bool isBlocked = Pauli::isBlocked(modifiedAndCreated, theNucleus);
230
231 if(isBlocked) {
232 DEBUG("Pauli: Blocked!" << std::endl);
233
234 // Restore the state of the initial particles
236
237 // Delete newly created particles
238 for( ParticleIter i = created.begin(); i != created.end(); ++i )
239 delete *i;
240
241 FinalState *fsBlocked = new FinalState;
242 delete fs;
243 fsBlocked->makePauliBlocked();
244 fsBlocked->setTotalEnergyBeforeInteraction(0.0);
245
246 return fsBlocked; // Interaction is blocked. Return an empty final state.
247 }
248 DEBUG("Pauli: Allowed!" << std::endl);
249
250 // Test CDPP blocking
251 G4bool isCDPPBlocked = Pauli::isCDPPBlocked(created, theNucleus);
252
253 if(isCDPPBlocked) {
254 DEBUG("CDPP: Blocked!" << std::endl);
255
256 // Restore the state of the initial particles
258
259 // Delete newly created particles
260 for( ParticleIter i = created.begin(); i != created.end(); ++i )
261 delete *i;
262
263 FinalState *fsBlocked = new FinalState;
264 delete fs;
265 fsBlocked->makePauliBlocked();
266 fsBlocked->setTotalEnergyBeforeInteraction(0.0);
267
268 return fsBlocked; // Interaction is blocked. Return an empty final state.
269 }
270 DEBUG("CDPP: Allowed!" << std::endl);
271
272 // If all went well, try to bring particles inside the nucleus...
273 for( ParticleIter i = modifiedAndCreated.begin(); i != modifiedAndCreated.end(); ++i )
274 {
275 // ...except for pions beyond their surface radius.
276 if((*i)->isOutOfWell()) continue;
277
278 const G4bool successBringParticlesInside = bringParticleInside(*i);
279 if( !successBringParticlesInside ) {
280 ERROR("Failed to bring particle inside the nucleus!" << std::endl);
281 }
282 }
283
284 // Collision accepted!
285 for( ParticleIter i = modifiedAndCreated.begin(); i != modifiedAndCreated.end(); ++i ) {
286 if(!(*i)->isOutOfWell()) {
287 // Decide if the particle should be made into a spectator
288 // (Back to spectator)
289 G4bool goesBackToSpectator = false;
290 if((*i)->isNucleon() && theNucleus->getStore()->getConfig()->getBackToSpectator()) {
291 G4double threshold = (*i)->getPotentialEnergy();
292 if((*i)->getType()==Proton)
294 if((*i)->getKineticEnergy() < threshold)
295 goesBackToSpectator = true;
296 }
297
298 // Thaw the particle propagation
299 (*i)->thawPropagation();
300
301 // Increment or decrement the participant counters
302 if(goesBackToSpectator) {
303 DEBUG("The following particle goes back to spectator:" << std::endl
304 << (*i)->print() << std::endl);
305 if(!(*i)->isTargetSpectator()) {
307 }
308 (*i)->makeTargetSpectator();
309 } else {
310 if((*i)->isTargetSpectator()) {
312 }
313 (*i)->makeParticipant();
314 }
315 }
316 }
317 ParticleList destroyed = fs->getDestroyedParticles();
318 for( ParticleIter i = destroyed.begin(); i != destroyed.end(); ++i )
319 if(!(*i)->isTargetSpectator())
321
322 return fs;
323 }
#define ERROR(x)
void decrementCascading()
Definition: G4INCLBook.hh:74
void incrementCascading()
Definition: G4INCLBook.hh:73
G4bool getBackToSpectator() const
Get back-to-spectator.
void restoreParticles() const
Restore the state of both particles.
G4bool enforceEnergyConservation(FinalState *const fs)
Enforce energy conservation.
G4bool bringParticleInside(Particle *const p)
Store * getStore() const
G4double getTransmissionBarrier(Particle const *const p)
Get the transmission barrier.
static G4bool isBlocked(ParticleList const p, Nucleus const *const n)
Check Pauli blocking.
static G4bool isCDPPBlocked(ParticleList const p, Nucleus const *const n)
Check CDPP blocking.
Book * getBook()
Definition: G4INCLStore.hh:243
Config const * getConfig()
Definition: G4INCLStore.hh:257
const G4double twoThirds
std::list< G4INCL::Particle * >::const_iterator ParticleIter

Referenced by G4INCL::BinaryCollisionAvatar::postInteraction(), and G4INCL::DecayAvatar::postInteraction().

◆ preInteraction()

void G4INCL::InteractionAvatar::preInteraction ( )
protectedvirtual

Implements G4INCL::IAvatar.

Definition at line 113 of file G4INCLInteractionAvatar.cc.

113 {
115
117
118 if(particle2) {
120 if(!isPiN) {
123 }
124 } else {
126 }
127 if(!isPiN)
129 }
void preInteractionBlocking()
Store the state of the particles before the interaction.
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
static ThreeVector makeBoostVector(Particle const *const p1, Particle const *const p2)
G4double getEnergy() const
const G4INCL::ThreeVector & getMomentum() const
void boost(const ThreeVector &aBoostVector)

Referenced by G4INCL::BinaryCollisionAvatar::preInteraction(), and G4INCL::DecayAvatar::preInteraction().

◆ preInteractionBlocking()

void G4INCL::InteractionAvatar::preInteractionBlocking ( )
protected

Store the state of the particles before the interaction.

If the interaction cannot be realised for any reason, we will need to restore the particle state as it was before. This is done by calling the restoreParticles() method.

Definition at line 81 of file G4INCLInteractionAvatar.cc.

81 {
89
90 if(particle2) {
101 } else {
103 }
104 }
static G4double total(Particle const *const p1, Particle const *const p2)
G4double getPotentialEnergy() const
Get the particle potential energy.
G4double getHelicity()
const G4INCL::ThreeVector & getPosition() const
G4INCL::ParticleType getType() const
G4double getMass() const
Get the cached particle mass.

Referenced by preInteraction().

◆ preInteractionLocalEnergy()

void G4INCL::InteractionAvatar::preInteractionLocalEnergy ( Particle *const  p)
protected

Apply local-energy transformation, if appropriate.

Parameters
pparticle to apply the transformation to

Definition at line 106 of file G4INCLInteractionAvatar.cc.

106 {
107 if(!theNucleus || p->isPion()) return; // Local energy does not make any sense without a nucleus
108
111 }
static void transformToLocalEnergyFrame(Nucleus const *const n, Particle *const p)

Referenced by preInteraction().

◆ restoreParticles()

void G4INCL::InteractionAvatar::restoreParticles ( ) const
protected

Restore the state of both particles.

The state must first be stored by calling preInteractionBlocking().

Definition at line 325 of file G4INCLInteractionAvatar.cc.

Referenced by G4INCL::BinaryCollisionAvatar::getChannel(), G4INCL::DecayAvatar::postInteraction(), and postInteraction().

◆ shouldUseLocalEnergy()

G4bool G4INCL::InteractionAvatar::shouldUseLocalEnergy ( ) const
inlineprotected

true if the given avatar should use local energy

Definition at line 101 of file G4INCLInteractionAvatar.hh.

101 {
102 if(!theNucleus) return false;
103 LocalEnergyType theLocalEnergyType;
105 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyPiType();
106 else
107 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyBBType();
108
109 const G4bool firstAvatar = (theNucleus->getStore()->getBook()->getAcceptedCollisions() == 0);
110 return ((theLocalEnergyType == FirstCollisionLocalEnergy && firstAvatar) ||
111 theLocalEnergyType == AlwaysLocalEnergy);
112 }
G4int getAcceptedCollisions() const
Definition: G4INCLBook.hh:85
LocalEnergyType getLocalEnergyPiType() const
Get the type of local energy for pi-N and decay avatars.
LocalEnergyType getLocalEnergyBBType() const
Get the type of local energy for N-N avatars.
AvatarType getType() const
@ DecayAvatarType
@ FirstCollisionLocalEnergy

Referenced by enforceEnergyConservation(), G4INCL::BinaryCollisionAvatar::getChannel(), postInteraction(), and preInteractionLocalEnergy().

Member Data Documentation

◆ boostVector

ThreeVector G4INCL::InteractionAvatar::boostVector
protected

◆ isPiN

G4bool G4INCL::InteractionAvatar::isPiN
protected

◆ locEAccuracy

const G4double G4INCL::InteractionAvatar::locEAccuracy = 1.E-4
static

Target accuracy in the determination of the local-energy Q-value.

Definition at line 68 of file G4INCLInteractionAvatar.hh.

◆ maxIterLocE

const G4int G4INCL::InteractionAvatar::maxIterLocE = 50
static

Max number of iterations for the determination of the local-energy Q-value.

Definition at line 70 of file G4INCLInteractionAvatar.hh.

◆ oldParticle1Energy

G4double G4INCL::InteractionAvatar::oldParticle1Energy
protected

Definition at line 118 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle1Helicity

G4double G4INCL::InteractionAvatar::oldParticle1Helicity
protected

Definition at line 121 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle1Mass

G4double G4INCL::InteractionAvatar::oldParticle1Mass
protected

Definition at line 120 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle1Momentum

ThreeVector G4INCL::InteractionAvatar::oldParticle1Momentum
protected

Definition at line 122 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle1Position

ThreeVector G4INCL::InteractionAvatar::oldParticle1Position
protected

Definition at line 123 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle1Potential

G4double G4INCL::InteractionAvatar::oldParticle1Potential
protected

Definition at line 119 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle1Type

ParticleType G4INCL::InteractionAvatar::oldParticle1Type
protected

Definition at line 117 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Energy

G4double G4INCL::InteractionAvatar::oldParticle2Energy
protected

Definition at line 118 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Helicity

G4double G4INCL::InteractionAvatar::oldParticle2Helicity
protected

Definition at line 121 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Mass

G4double G4INCL::InteractionAvatar::oldParticle2Mass
protected

Definition at line 120 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Momentum

ThreeVector G4INCL::InteractionAvatar::oldParticle2Momentum
protected

Definition at line 122 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Position

ThreeVector G4INCL::InteractionAvatar::oldParticle2Position
protected

Definition at line 123 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Potential

G4double G4INCL::InteractionAvatar::oldParticle2Potential
protected

Definition at line 119 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldParticle2Type

ParticleType G4INCL::InteractionAvatar::oldParticle2Type
protected

Definition at line 117 of file G4INCLInteractionAvatar.hh.

Referenced by preInteractionBlocking(), and restoreParticles().

◆ oldTotalEnergy

G4double G4INCL::InteractionAvatar::oldTotalEnergy
protected

◆ oldXSec

G4double G4INCL::InteractionAvatar::oldXSec
protected

◆ particle1

◆ particle2

◆ theNucleus


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