Geant4 10.7.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 ()=0
 
FinalStategetFinalState ()
 
void fillFinalState (FinalState *fs)
 
virtual void preInteraction ()=0
 
virtual void postInteraction (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 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 
)

Definition at line 65 of file G4INCLInteractionAvatar.cc.

◆ InteractionAvatar() [2/2]

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

Definition at line 74 of file G4INCLInteractionAvatar.cc.

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

◆ ~InteractionAvatar()

G4INCL::InteractionAvatar::~InteractionAvatar ( )
virtual

Definition at line 84 of file G4INCLInteractionAvatar.cc.

84 {
85 }

Member Function Documentation

◆ bringParticleInside()

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

Definition at line 137 of file G4INCLInteractionAvatar.cc.

137 {
138 if(!theNucleus)
139 return false;
140
141 ThreeVector pos = p->getPosition();
142 p->rpCorrelate();
143 G4double pos2 = pos.mag2();
145 short iterations=0;
146 const short maxIterations=50;
147
148 if(pos2 < r*r) return true;
149
150 while( pos2 >= r*r && iterations<maxIterations ) /* Loop checking, 10.07.2015, D.Mancusi */
151 {
152 pos *= std::sqrt(r*r*0.9801/pos2); // 0.9801 == 0.99*0.99
153 pos2 = pos.mag2();
154 iterations++;
155 }
156 if( iterations < maxIterations)
157 {
158 INCL_DEBUG("Particle position vector length was : " << p->getPosition().mag() << ", rescaled to: " << pos.mag() << '\n');
159 p->setPosition(pos);
160 return true;
161 }
162 else
163 return false;
164 }
#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 87 of file G4INCLInteractionAvatar.cc.

87 {
88 delete backupParticle1;
90 delete backupParticle2;
91 backupParticle1 = NULL;
92 backupParticle2 = NULL;
93 }
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 359 of file G4INCLInteractionAvatar.cc.

359 {
360 // Set up the violationE calculation
361 const G4bool manyBodyFinalState = (modifiedAndCreated.size() > 1);
362
363 if(manyBodyFinalState)
364 violationEFunctor = new ViolationEMomentumFunctor(theNucleus, modifiedAndCreated, fs->getTotalEnergyBeforeInteraction(), boostVector, shouldUseLocalEnergy());
365 else {
366 Particle * const p = modified.front();
367 // The following condition is necessary for the functor to work
368 // correctly. A similar condition exists in INCL4.6.
369 if(p->getMass() < ParticleTable::minDeltaMass)
370 return false;
371 violationEFunctor = new ViolationEEnergyFunctor(theNucleus, p, fs->getTotalEnergyBeforeInteraction(), shouldUseLocalEnergy());
372 }
373
374 // Apply the root-finding algorithm
375 const RootFinder::Solution theSolution = RootFinder::solve(violationEFunctor, 1.0);
376 if(theSolution.success) { // Apply the solution
377 (*violationEFunctor)(theSolution.x);
378 } else if(theNucleus){
379 INCL_DEBUG("Couldn't enforce energy conservation after an interaction, root-finding algorithm failed." << '\n');
381 }
382 delete violationEFunctor;
383 violationEFunctor = NULL;
384 return theSolution.success;
385 }
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()
Definition: G4INCLStore.hh:259
G4ThreadLocal G4double minDeltaMass
Solution solve(RootFunctor const *const f, const G4double x0)
Numerically solve a one-dimensional equation.

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

◆ getChannel()

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

◆ postInteraction()

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

Implements G4INCL::IAvatar.

Definition at line 166 of file G4INCLInteractionAvatar.cc.

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

122 {
124
126
127 if(particle2) {
131 } else {
133 }
135 }
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 95 of file G4INCLInteractionAvatar.cc.

95 {
97 (*backupParticle1) = (*particle1);
98 else
99 backupParticle1 = new Particle(*particle1);
100
101 if(particle2) {
103 (*backupParticle2) = (*particle2);
104 else
105 backupParticle2 = new Particle(*particle2);
106
110 } else {
112 }
113 }
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 115 of file G4INCLInteractionAvatar.cc.

115 {
116 if(!theNucleus || p->isMeson()) return; // Local energy does not make any sense without a nucleus
117
120 }
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 340 of file G4INCLInteractionAvatar.cc.

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

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

◆ shouldUseLocalEnergy()

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

true if the given avatar should use local energy

Definition at line 346 of file G4INCLInteractionAvatar.cc.

346 {
347 if(!theNucleus) return false;
348 LocalEnergyType theLocalEnergyType;
350 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyPiType();
351 else
352 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyBBType();
353
354 const G4bool firstAvatar = (theNucleus->getStore()->getBook().getAcceptedCollisions() == 0);
355 return ((theLocalEnergyType == FirstCollisionLocalEnergy && firstAvatar) ||
356 theLocalEnergyType == AlwaysLocalEnergy);
357 }
G4int getAcceptedCollisions() const
Definition: G4INCLBook.hh:100
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(), 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: