Geant4 11.2.2
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 ()
 
FinalStategetFinalState ()
 
void fillFinalState (FinalState *fs)
 
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 Member Functions

static void deleteBackupParticles ()
 Release the memory allocated for the backup particles.
 

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 ()=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 ()
 
void postInteraction (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

NucleustheNucleus
 
Particleparticle1
 
Particleparticle2
 
ThreeVector boostVector
 
G4double oldTotalEnergy
 
G4double oldXSec
 
G4bool isPiN
 
G4double weight
 
ParticleList modified
 
ParticleList created
 
ParticleList modifiedAndCreated
 
ParticleList Destroyed
 
ParticleList ModifiedAndDestroyed
 
- Protected Attributes inherited from G4INCL::IAvatar
G4double theTime
 

Static Protected Attributes

static G4ThreadLocal ParticlebackupParticle1 = NULL
 
static G4ThreadLocal ParticlebackupParticle2 = NULL
 

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 )

◆ InteractionAvatar() [2/2]

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

Definition at line 75 of file G4INCLInteractionAvatar.cc.

77 : IAvatar(time), theNucleus(n),
78 particle1(p1), particle2(p2),
79 isPiN((p1->isPion() && p2->isNucleon()) || (p2->isPion() && p1->isNucleon())),
80 weight(1.),
81 violationEFunctor(NULL)
82 {
83 }
G4bool isPion() const
Is this a pion?
G4bool isNucleon() const

◆ ~InteractionAvatar()

G4INCL::InteractionAvatar::~InteractionAvatar ( )
virtual

Definition at line 85 of file G4INCLInteractionAvatar.cc.

85 {
86 }

Member Function Documentation

◆ bringParticleInside()

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

Definition at line 138 of file G4INCLInteractionAvatar.cc.

138 {
139 if(!theNucleus)
140 return false;
141
142 ThreeVector pos = p->getPosition();
143 p->rpCorrelate();
144 G4double pos2 = pos.mag2();
146 short iterations=0;
147 const short maxIterations=50;
148
149 if(pos2 < r*r) return true;
150
151 while( pos2 >= r*r && iterations<maxIterations ) /* Loop checking, 10.07.2015, D.Mancusi */
152 {
153 pos *= std::sqrt(r*r*0.9801/pos2); // 0.9801 == 0.99*0.99
154 pos2 = pos.mag2();
155 iterations++;
156 }
157 if( iterations < maxIterations)
158 {
159 INCL_DEBUG("Particle position vector length was : " << p->getPosition().mag() << ", rescaled to: " << pos.mag() << '\n');
160 p->setPosition(pos);
161 return true;
162 }
163 else
164 return false;
165 }
#define INCL_DEBUG(x)
double G4double
Definition G4Types.hh:83
G4double getSurfaceRadius(Particle const *const particle) const
Get the maximum allowed radius for a given particle.

Referenced by postInteraction().

◆ deleteBackupParticles()

void G4INCL::InteractionAvatar::deleteBackupParticles ( )
static

Release the memory allocated for the backup particles.

Definition at line 88 of file G4INCLInteractionAvatar.cc.

88 {
89 delete backupParticle1;
91 delete backupParticle2;
92 backupParticle1 = NULL;
93 backupParticle2 = NULL;
94 }
static G4ThreadLocal Particle * backupParticle2
static G4ThreadLocal Particle * backupParticle1

Referenced by G4INCL::INCL::~INCL().

◆ 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 364 of file G4INCLInteractionAvatar.cc.

364 {
365 // Set up the violationE calculation
366 const G4bool manyBodyFinalState = (modifiedAndCreated.size() > 1);
367
368 if(manyBodyFinalState)
369 violationEFunctor = new ViolationEMomentumFunctor(theNucleus, modifiedAndCreated, fs->getTotalEnergyBeforeInteraction(), boostVector, shouldUseLocalEnergy());
370 else {
371 if (modified.empty()) {
372 Particle * const p1 = created.front(); //we destroy all nucleons during annihilation in NNbar case
373 // The following condition is necessary for the functor to work
374 // correctly. A similar condition exists in INCL4.6.
375 if(p1->getMass() < ParticleTable::minDeltaMass)
376 return false;
377 violationEFunctor = new ViolationEEnergyFunctor(theNucleus, p1, fs->getTotalEnergyBeforeInteraction(), shouldUseLocalEnergy());
378 }
379 else{
380 Particle * const p2 = modified.front(); // normal situation
381 // The following condition is necessary for the functor to work
382 // correctly. A similar condition exists in INCL4.6.
383 if(p2->getMass() < ParticleTable::minDeltaMass)
384 return false;
385 violationEFunctor = new ViolationEEnergyFunctor(theNucleus, p2, fs->getTotalEnergyBeforeInteraction(), shouldUseLocalEnergy());
386 }
387 }
388
389 // Apply the root-finding algorithm
390 const RootFinder::Solution theSolution = RootFinder::solve(violationEFunctor, 1.0);
391 if(theSolution.success) { // Apply the solution
392 (*violationEFunctor)(theSolution.x);
393 } else if(theNucleus){
394 INCL_DEBUG("Couldn't enforce energy conservation after an interaction, root-finding algorithm failed." << '\n');
396 }
397 delete violationEFunctor;
398 violationEFunctor = NULL;
399 return theSolution.success;
400 }
bool G4bool
Definition G4Types.hh:86
void incrementEnergyViolationInteraction()
Definition G4INCLBook.hh:80
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
Store * getStore() const
Book & getBook()
G4ThreadLocal G4double minDeltaMass
Solution solve(RootFunctor const *const f, const G4double x0)
Numerically solve a one-dimensional equation.

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

◆ getChannel()

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

◆ postInteraction()

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

Implements G4INCL::IAvatar.

Definition at line 167 of file G4INCLInteractionAvatar.cc.

167 {
168 INCL_DEBUG("postInteraction: final state: " << '\n' << fs->print() << '\n');
169 modified = fs->getModifiedParticles();
170 created = fs->getCreatedParticles();
171 Destroyed = fs->getDestroyedParticles();
173 modifiedAndCreated.insert(modifiedAndCreated.end(), created.begin(), created.end());
175 ModifiedAndDestroyed.insert(ModifiedAndDestroyed.end(), Destroyed.begin(), Destroyed.end());
176
177 // Boost back to lab
179
180 // If there is no Nucleus, just return
181 if(!theNucleus) return;
182
183 // Mark pions and kaons that have been created outside their well (we will force them
184 // to be emitted later).
185 for(ParticleIter i=created.begin(), e=created.end(); i!=e; ++i )
186 if(((*i)->isPion() || (*i)->isKaon() || (*i)->isAntiKaon()) && (*i)->getPosition().mag() > theNucleus->getSurfaceRadius(*i)) {
187 (*i)->makeParticipant();
188 (*i)->setOutOfWell();
189 fs->addOutgoingParticle(*i);
190 INCL_DEBUG("Pion was created outside its potential well." << '\n'
191 << (*i)->print());
192 }
193
194 // Try to enforce energy conservation
195 fs->setTotalEnergyBeforeInteraction(oldTotalEnergy);
196 G4bool success = enforceEnergyConservation(fs);
197 if(!success) {
198 INCL_DEBUG("Enforcing energy conservation: failed!" << '\n');
199
200 // Restore the state of the initial particles
202
203 // Delete newly created particles
204 for(ParticleIter i=created.begin(), e=created.end(); i!=e; ++i )
205 delete *i;
206
207 fs->reset();
208 fs->makeNoEnergyConservation();
209 fs->setTotalEnergyBeforeInteraction(0.0);
210
211 return; // Interaction is blocked. Return an empty final state.
212 }
213 INCL_DEBUG("Enforcing energy conservation: success!" << '\n');
214
215 INCL_DEBUG("postInteraction after energy conservation: final state: " << '\n' << fs->print() << '\n');
216
217 // Check that outgoing delta resonances can decay to pi-N
218 for(ParticleIter i=modified.begin(), e=modified.end(); i!=e; ++i )
219 if((*i)->isDelta() &&
220 (*i)->getMass() < ParticleTable::minDeltaMass) {
221 INCL_DEBUG("Mass of the produced delta below decay threshold; forbidding collision. deltaMass=" <<
222 (*i)->getMass() << '\n');
223
224 // Restore the state of the initial particles
226
227 // Delete newly created particles
228 for(ParticleIter j=created.begin(), end=created.end(); j!=end; ++j )
229 delete *j;
230
231 fs->reset();
232 fs->makeNoEnergyConservation();
233 fs->setTotalEnergyBeforeInteraction(0.0);
234
235 return; // Interaction is blocked. Return an empty final state.
236 }
237
238 INCL_DEBUG("Random seeds before Pauli blocking: " << Random::getSeeds() << '\n');
239 // Test Pauli blocking
241
242 if(isBlocked) {
243 INCL_DEBUG("Pauli: Blocked!" << '\n');
244
245 // Restore the state of the initial particles
247
248 // Delete newly created particles
249 for(ParticleIter i=created.begin(), e=created.end(); i!=e; ++i )
250 delete *i;
251
252 fs->reset();
253 fs->makePauliBlocked();
254 fs->setTotalEnergyBeforeInteraction(0.0);
255
256 return; // Interaction is blocked. Return an empty final state.
257 }
258 INCL_DEBUG("Pauli: Allowed!" << '\n');
259
260 // Test CDPP blocking
262
263 if(isCDPPBlocked) {
264 INCL_DEBUG("CDPP: Blocked!" << '\n');
265
266 // Restore the state of the initial particles
268
269 // Delete newly created particles
270 for(ParticleIter i=created.begin(), e=created.end(); i!=e; ++i )
271 delete *i;
272
273 fs->reset();
274 fs->makePauliBlocked();
275 fs->setTotalEnergyBeforeInteraction(0.0);
276
277 return; // Interaction is blocked. Return an empty final state.
278 }
279 INCL_DEBUG("CDPP: Allowed!" << '\n');
280
281 // If all went well, try to bring particles inside the nucleus...
282 for(ParticleIter i=modifiedAndCreated.begin(), e=modifiedAndCreated.end(); i!=e; ++i )
283 {
284 // ...except for pions beyond their surface radius.
285 if((*i)->isOutOfWell()) continue;
286
287 const G4bool successBringParticlesInside = bringParticleInside(*i);
288 if( !successBringParticlesInside ) {
289 INCL_ERROR("Failed to bring particle inside the nucleus!" << '\n');
290 }
291 }
292
293 // Collision accepted!
294 // Biasing of the final state
295 std::vector<G4int> newBiasCollisionVector;
296 newBiasCollisionVector = ModifiedAndDestroyed.getParticleListBiasVector();
297 if(std::fabs(weight-1.) > 1E-6){
298 newBiasCollisionVector.push_back(Particle::nextBiasedCollisionID);
300 weight = 1.; // useless?
301 }
302 for(ParticleIter i=modifiedAndCreated.begin(), e=modifiedAndCreated.end(); i!=e; ++i ) {
303 (*i)->setBiasCollisionVector(newBiasCollisionVector);
304 if(!(*i)->isOutOfWell()) {
305 // Decide if the particle should be made into a spectator
306 // (Back to spectator)
307 G4bool goesBackToSpectator = false;
308 if((*i)->isNucleon() && theNucleus->getStore()->getConfig()->getBackToSpectator()) {
309 G4double threshold = (*i)->getPotentialEnergy();
310 if((*i)->getType()==Proton)
312 if((*i)->getKineticEnergy() < threshold)
313 goesBackToSpectator = true;
314 }
315 // Thaw the particle propagation
316 (*i)->thawPropagation();
317
318 // Increment or decrement the participant counters
319 if(goesBackToSpectator) {
320 INCL_DEBUG("The following particle goes back to spectator:" << '\n'
321 << (*i)->print() << '\n');
322 if(!(*i)->isTargetSpectator()) {
324 }
325 (*i)->makeTargetSpectator();
326 } else {
327 if((*i)->isTargetSpectator()) {
329 }
330 (*i)->makeParticipant();
331 }
332 }
333 }
334 ParticleList destroyed = fs->getDestroyedParticles();
335 for(ParticleIter i=destroyed.begin(), e=destroyed.end(); i!=e; ++i )
336 if(!(*i)->isTargetSpectator())
338 return;
339 }
#define INCL_ERROR(x)
void decrementCascading()
Definition G4INCLBook.hh:78
void incrementCascading()
Definition G4INCLBook.hh:77
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)
G4double getTransmissionBarrier(Particle const *const p)
Get the transmission barrier.
std::vector< G4int > getParticleListBiasVector() const
void boost(const ThreeVector &b) const
static void FillINCLBiasVector(G4double newBias)
static G4ThreadLocal G4int nextBiasedCollisionID
Config const * getConfig()
const G4double twoThirds
G4bool isBlocked(ParticleList const &p, Nucleus const *const n)
Check Pauli blocking.
G4bool isCDPPBlocked(ParticleList const &p, Nucleus const *const n)
Check CDPP blocking.
SeedVector getSeeds()
ParticleList::const_iterator ParticleIter

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

◆ preInteraction()

void G4INCL::InteractionAvatar::preInteraction ( )
protectedvirtual

Implements G4INCL::IAvatar.

Definition at line 123 of file G4INCLInteractionAvatar.cc.

123 {
125
127
128 if(particle2) {
132 } else {
134 }
136 }
void preInteractionBlocking()
Store the state of the particles before the interaction.
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
G4double getEnergy() const
const G4INCL::ThreeVector & getMomentum() const
void boost(const ThreeVector &aBoostVector)
ThreeVector makeBoostVector(Particle const *const p1, Particle const *const p2)

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 96 of file G4INCLInteractionAvatar.cc.

96 {
98 (*backupParticle1) = (*particle1);
99 else
100 backupParticle1 = new Particle(*particle1);
101
102 if(particle2) {
104 (*backupParticle2) = (*particle2);
105 else
106 backupParticle2 = new Particle(*particle2);
107
111 } else {
113 }
114 }
G4double getPotentialEnergy() const
Get the particle potential energy.
G4double total(Particle const *const p1, Particle const *const p2)

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 116 of file G4INCLInteractionAvatar.cc.

116 {
117 if(!theNucleus || p->isMeson() || p->isPhoton() || p->isAntiNucleon()) return; // Local energy does not make any sense without a nucleus
118
121 }
G4bool isMeson() const
Is this a Meson?
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 341 of file G4INCLInteractionAvatar.cc.

341 {
342 (*particle1) = (*backupParticle1);
343 if(particle2)
344 (*particle2) = (*backupParticle2);
345 }

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

◆ shouldUseLocalEnergy()

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

true if the given avatar should use local energy

Definition at line 347 of file G4INCLInteractionAvatar.cc.

347 {
348 if(!theNucleus) return false;
349 LocalEnergyType theLocalEnergyType;
352 return false;
353 }
355 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyPiType();
356 else
357 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyBBType();
358
359 const G4bool firstAvatar = (theNucleus->getStore()->getBook().getAcceptedCollisions() == 0);
360 return ((theLocalEnergyType == FirstCollisionLocalEnergy && firstAvatar) ||
361 theLocalEnergyType == AlwaysLocalEnergy);
362 }
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.
ParticleType getProjectileType() const
Get the projectile type.
AvatarType getType() const
@ DecayAvatarType
@ FirstCollisionLocalEnergy

Referenced by enforceEnergyConservation(), and preInteractionLocalEnergy().

Member Data Documentation

◆ backupParticle1

G4ThreadLocal Particle * G4INCL::InteractionAvatar::backupParticle1 = NULL
staticprotected

◆ backupParticle2

G4ThreadLocal Particle * G4INCL::InteractionAvatar::backupParticle2 = NULL
staticprotected

◆ boostVector

ThreeVector G4INCL::InteractionAvatar::boostVector
protected

◆ created

ParticleList G4INCL::InteractionAvatar::created
protected

◆ Destroyed

ParticleList G4INCL::InteractionAvatar::Destroyed
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.

◆ modified

ParticleList G4INCL::InteractionAvatar::modified
protected

◆ modifiedAndCreated

ParticleList G4INCL::InteractionAvatar::modifiedAndCreated
protected

◆ ModifiedAndDestroyed

ParticleList G4INCL::InteractionAvatar::ModifiedAndDestroyed
protected

◆ oldTotalEnergy

G4double G4INCL::InteractionAvatar::oldTotalEnergy
protected

◆ oldXSec

G4double G4INCL::InteractionAvatar::oldXSec
protected

◆ particle1

◆ particle2

◆ theNucleus

◆ weight

G4double G4INCL::InteractionAvatar::weight
protected

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