Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCL::InteractionAvatar Class Referenceabstract

#include <G4INCLInteractionAvatar.hh>

Inheritance diagram for G4INCL::InteractionAvatar:
Collaboration 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. More...
 

Static Public Attributes

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

Protected Member Functions

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

Protected Attributes

NucleustheNucleus
 
Particleparticle1
 
Particleparticle2
 
ThreeVector boostVector
 
G4double oldTotalEnergy
 
G4double oldXSec
 
G4bool isPiN
 
ParticleList modified
 
ParticleList created
 
ParticleList modifiedAndCreated
 
- 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

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

Definition at line 65 of file G4INCLInteractionAvatar.cc.

66  : IAvatar(time), theNucleus(n),
67  particle1(p1), particle2(NULL),
68  isPiN(false),
69  violationEFunctor(NULL)
70  {
71  }
G4INCL::InteractionAvatar::InteractionAvatar ( G4double  time,
G4INCL::Nucleus n,
G4INCL::Particle p1,
G4INCL::Particle p2 
)

Definition at line 73 of file G4INCLInteractionAvatar.cc.

75  : IAvatar(time), theNucleus(n),
76  particle1(p1), particle2(p2),
77  isPiN((p1->isPion() && p2->isNucleon()) || (p2->isPion() && p1->isNucleon())),
78  violationEFunctor(NULL)
79  {
80  }
G4bool isNucleon() const
G4bool isPion() const
Is this a pion?
G4INCL::InteractionAvatar::~InteractionAvatar ( )
virtual

Definition at line 82 of file G4INCLInteractionAvatar.cc.

82  {
83  }

Member Function Documentation

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

Definition at line 135 of file G4INCLInteractionAvatar.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4INCL::InteractionAvatar::deleteBackupParticles ( )
static

Release the memory allocated for the backup particles.

Definition at line 85 of file G4INCLInteractionAvatar.cc.

85  {
86  delete backupParticle1;
87  if(backupParticle2)
88  delete backupParticle2;
89  backupParticle1 = NULL;
90  backupParticle2 = NULL;
91  }
static G4ThreadLocal Particle * backupParticle2
static G4ThreadLocal Particle * backupParticle1

Here is the caller graph for this function:

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

347  {
348  // Set up the violationE calculation
349  const G4bool manyBodyFinalState = (modifiedAndCreated.size() > 1);
350  if(manyBodyFinalState)
351  violationEFunctor = new ViolationEMomentumFunctor(theNucleus, modifiedAndCreated, fs->getTotalEnergyBeforeInteraction(), boostVector, shouldUseLocalEnergy());
352  else {
353  Particle * const p = modified.front();
354  // The following condition is necessary for the functor to work
355  // correctly. A similar condition exists in INCL4.6.
356  if(p->getMass() < ParticleTable::minDeltaMass)
357  return false;
358  violationEFunctor = new ViolationEEnergyFunctor(theNucleus, p, fs->getTotalEnergyBeforeInteraction(), shouldUseLocalEnergy());
359  }
360 
361  // Apply the root-finding algorithm
362  const RootFinder::Solution theSolution = RootFinder::solve(violationEFunctor, 1.0);
363  if(theSolution.success) { // Apply the solution
364  (*violationEFunctor)(theSolution.x);
365  } else if(theNucleus){
366  INCL_DEBUG("Couldn't enforce energy conservation after an interaction, root-finding algorithm failed." << '\n');
368  }
369  delete violationEFunctor;
370  violationEFunctor = NULL;
371  return theSolution.success;
372  }
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
const char * p
Definition: xmltok.h:285
Store * getStore() const
Book & getBook()
Definition: G4INCLStore.hh:259
bool G4bool
Definition: G4Types.hh:79
void incrementEnergyViolationInteraction()
Definition: G4INCLBook.hh:80
G4ThreadLocal G4double minDeltaMass
Solution solve(RootFunctor const *const f, const G4double x0)
Numerically solve a one-dimensional equation.
#define INCL_DEBUG(x)

Here is the call graph for this function:

Here is the caller graph for this function:

virtual G4INCL::IChannel* G4INCL::InteractionAvatar::getChannel ( )
protectedpure virtual
void G4INCL::InteractionAvatar::postInteraction ( FinalState fs)
protectedvirtual

Implements G4INCL::IAvatar.

Definition at line 164 of file G4INCLInteractionAvatar.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4INCL::InteractionAvatar::preInteraction ( )
protectedvirtual

Implements G4INCL::IAvatar.

Definition at line 120 of file G4INCLInteractionAvatar.cc.

120  {
122 
124 
125  if(particle2) {
129  } else {
131  }
133  }
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
void boost(const ThreeVector &aBoostVector)
const G4INCL::ThreeVector & getMomentum() const
G4double getEnergy() const
ThreeVector makeBoostVector(Particle const *const p1, Particle const *const p2)
void preInteractionBlocking()
Store the state of the particles before the interaction.

Here is the call graph for this function:

Here is the caller graph for this function:

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

93  {
94  if(backupParticle1)
95  (*backupParticle1) = (*particle1);
96  else
97  backupParticle1 = new Particle(*particle1);
98 
99  if(particle2) {
100  if(backupParticle2)
101  (*backupParticle2) = (*particle2);
102  else
103  backupParticle2 = new Particle(*particle2);
104 
108  } else {
110  }
111  }
G4double getEnergy() const
G4double getPotentialEnergy() const
Get the particle potential energy.
static G4ThreadLocal Particle * backupParticle2
static G4ThreadLocal Particle * backupParticle1
G4double total(Particle const *const p1, Particle const *const p2)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Apply local-energy transformation, if appropriate.

Parameters
pparticle to apply the transformation to

Definition at line 113 of file G4INCLInteractionAvatar.cc.

113  {
114  if(!theNucleus || p->isPion()) return; // Local energy does not make any sense without a nucleus
115 
118  }
void transformToLocalEnergyFrame(Nucleus const *const n, Particle *const p)
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
const char * p
Definition: xmltok.h:285
G4bool isPion() const
Is this a pion?

Here is the call graph for this function:

Here is the caller graph for this function:

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

Restore the state of both particles.

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

Definition at line 328 of file G4INCLInteractionAvatar.cc.

328  {
329  (*particle1) = (*backupParticle1);
330  if(particle2)
331  (*particle2) = (*backupParticle2);
332  }

Here is the caller graph for this function:

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

true if the given avatar should use local energy

Definition at line 334 of file G4INCLInteractionAvatar.cc.

334  {
335  if(!theNucleus) return false;
336  LocalEnergyType theLocalEnergyType;
337  if(getType()==DecayAvatarType || isPiN)
338  theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyPiType();
339  else
340  theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyBBType();
341 
342  const G4bool firstAvatar = (theNucleus->getStore()->getBook().getAcceptedCollisions() == 0);
343  return ((theLocalEnergyType == FirstCollisionLocalEnergy && firstAvatar) ||
344  theLocalEnergyType == AlwaysLocalEnergy);
345  }
G4int getAcceptedCollisions() const
Definition: G4INCLBook.hh:100
Config const * getConfig()
Definition: G4INCLStore.hh:273
Store * getStore() const
Book & getBook()
Definition: G4INCLStore.hh:259
bool G4bool
Definition: G4Types.hh:79
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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 108 of file G4INCLInteractionAvatar.hh.

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

Definition at line 108 of file G4INCLInteractionAvatar.hh.

ThreeVector G4INCL::InteractionAvatar::boostVector
protected

Definition at line 109 of file G4INCLInteractionAvatar.hh.

ParticleList G4INCL::InteractionAvatar::created
protected

Definition at line 222 of file G4INCLInteractionAvatar.hh.

G4bool G4INCL::InteractionAvatar::isPiN
protected

Definition at line 111 of file G4INCLInteractionAvatar.hh.

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.

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.

ParticleList G4INCL::InteractionAvatar::modified
protected

Definition at line 222 of file G4INCLInteractionAvatar.hh.

ParticleList G4INCL::InteractionAvatar::modifiedAndCreated
protected

Definition at line 222 of file G4INCLInteractionAvatar.hh.

G4double G4INCL::InteractionAvatar::oldTotalEnergy
protected

Definition at line 110 of file G4INCLInteractionAvatar.hh.

G4double G4INCL::InteractionAvatar::oldXSec
protected

Definition at line 110 of file G4INCLInteractionAvatar.hh.

Particle* G4INCL::InteractionAvatar::particle1
protected

Definition at line 107 of file G4INCLInteractionAvatar.hh.

Particle * G4INCL::InteractionAvatar::particle2
protected

Definition at line 107 of file G4INCLInteractionAvatar.hh.

Nucleus* G4INCL::InteractionAvatar::theNucleus
protected

Definition at line 106 of file G4INCLInteractionAvatar.hh.


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