34#define INCLXX_IN_GEANT4_MODE 1
61 for(std::map<long, Particle*>::const_iterator i=storedComponents.begin(); i!=storedComponents.end(); ++i) {
63 EnergyLevelMap::iterator energyIter = theInitialEnergyLevels.find(i->first);
65 const G4double energyLevel = energyIter->second;
66 theInitialEnergyLevels.erase(energyIter);
67 theInitialEnergyLevels[p->
getID()] = energyLevel;
79 INCL_DEBUG(
"The following Particle is about to be removed from the ProjectileRemnant:"
81 <<
"theProjectileCorrection=" << theProjectileCorrection <<
'\n');
90#if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
99 const G4double theProjectileCorrectionPerNucleon = theProjectileCorrection /
particles.size();
103 (*i)->setEnergy((*i)->getEnergy() + theProjectileCorrectionPerNucleon);
104 (*i)->setMass((*i)->getInvariantMass());
105#if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
106 theTotalMomentum += (*i)->getMomentum();
107 theTotalEnergy += (*i)->getEnergy();
113 theEnergy -= oldEnergy - theProjectileCorrection;
117 INCL_DEBUG(
"After Particle removal, the ProjectileRemnant looks like this:"
126 unsigned int accepted;
127 unsigned long loopCounter = 0;
128 const unsigned long maxLoopCounter = 10000000;
132 for(
ParticleIter p=toBeAdded.begin(), e=toBeAdded.end(); p!=e; ++p) {
133 G4bool isAccepted = addDynamicalSpectator(*p);
140 }
while(loopCounter<maxLoopCounter && accepted > 0);
154 theNewMomentum += getStoredMomentum(*p);
155 theNewEnergy += (*p)->getEnergy();
156 theNewA += (*p)->getA();
157 theNewZ += (*p)->getZ();
158 theNewS += (*p)->getS();
164 const G4double theNewEffectiveMass = theNewMass + theNewExcitationEnergy;
168 if(theNewEnergy<theNewEffectiveMass) {
169 INCL_WARN(
"Could not add all the dynamical spectators back into the projectile remnant."
170 <<
" Falling back to the \"most\" method." <<
'\n');
181 const G4double scalingFactorSquared = (theNewEnergy*theNewEnergy-theNewEffectiveMass*theNewEffectiveMass)/theNewMomentum.
mag2();
182 const G4double scalingFactor = std::sqrt(scalingFactorSquared);
183 INCL_DEBUG(
"Scaling factor for the projectile-remnant momentum = " << scalingFactor <<
'\n');
209 theNewMomentum += getStoredMomentum(*p);
210 theNewEnergy += (*p)->getEnergy();
211 theNewA += (*p)->getA();
212 theNewZ += (*p)->getZ();
213 theNewS += (*p)->getS();
218 const G4double theNewInvariantMassSquared = theNewEnergy*theNewEnergy-theNewMomentum.
mag2();
220 G4bool positiveExcitationEnergy =
false;
221 if(theNewInvariantMassSquared>=0.) {
222 const G4double theNewInvariantMass = std::sqrt(theNewInvariantMassSquared);
223 positiveExcitationEnergy = (theNewInvariantMass-theNewMass>-1.e-5);
229 while(!positiveExcitationEnergy && !pL.empty()) {
230 G4double maxExcitationEnergy = -1.E30;
234 G4int bestA = -1, bestZ = -1, bestS = 0;
235 for(ParticleList::iterator p=pL.begin(), e=pL.end(); p!=e; ++p) {
238 const ThreeVector theNewerMomentum = theNewMomentum - getStoredMomentum(*p);
239 const G4double theNewerEnergy = theNewEnergy - (*p)->getEnergy();
240 const G4int theNewerA = theNewA - (*p)->getA();
241 const G4int theNewerZ = theNewZ - (*p)->getZ();
242 const G4int theNewerS = theNewS - (*p)->getS();
245 const G4double theNewerInvariantMassSquared = theNewerEnergy*theNewerEnergy-theNewerMomentum.
mag2();
247 if(theNewerInvariantMassSquared>=-1.e-5) {
248 const G4double theNewerInvariantMass = std::sqrt(std::max(0.,theNewerInvariantMassSquared));
249 const G4double theNewerExcitationEnergy = ((theNewerA>1) ? theNewerInvariantMass-theNewerMass : 0.);
252 if(theNewerExcitationEnergy>maxExcitationEnergy) {
254 maxExcitationEnergy = theNewerExcitationEnergy;
255 bestMomentum = theNewerMomentum;
256 bestEnergy = theNewerEnergy;
268 rejected.push_back(*best);
270 theNewMomentum = bestMomentum;
271 theNewEnergy = bestEnergy;
276 if(maxExcitationEnergy>0.) {
278 positiveExcitationEnergy =
true;
295 G4bool ProjectileRemnant::addDynamicalSpectator(
Particle *
const p) {
299 ThreeVector const &oldMomentum = getStoredMomentum(p);
306 const G4double theNewInvariantMassSquared = theNewEnergy*theNewEnergy-theNewMomentum.
mag2();
308 if(theNewInvariantMassSquared<0.)
311 const G4double theNewInvariantMass = std::sqrt(theNewInvariantMassSquared);
313 if(theNewInvariantMass-theNewMass<-1.e-5)
326 const EnergyLevels theEnergyLevels = getPresentEnergyLevelsExcept(exceptID);
327 return computeExcitationEnergy(theEnergyLevels);
331 const EnergyLevels theEnergyLevels = getPresentEnergyLevelsWith(pL);
332 return computeExcitationEnergy(theEnergyLevels);
335 G4double ProjectileRemnant::computeExcitationEnergy(
const EnergyLevels &levels)
const {
340 const unsigned theNewA = levels.size();
345 const G4double groundState = theGroundStateEnergies.at(theNewA-1);
348 const G4double excitedState = std::accumulate(
353 return excitedState-groundState;
359 if((*p)->getID()!=exceptID) {
360 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
362 theEnergyLevels.push_back(i->second);
366 return theEnergyLevels;
372 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
374 theEnergyLevels.push_back(i->second);
377 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
379 theEnergyLevels.push_back(i->second);
383 return theEnergyLevels;
Class for constructing a projectile-like remnant.
void removeParticle(Particle *const p)
Remove a particle from the cluster components.
void addParticle(Particle *const p)
std::string print() const
G4int getS() const
Returns the strangeness number.
G4INCL::ThreeVector theMomentum
G4double getEnergy() const
G4double thePotentialEnergy
G4int getZ() const
Returns the charge number.
const G4INCL::ThreeVector & getMomentum() const
std::string print() const
void setTableMass()
Set the mass of the Particle to its table mass.
G4int getA() const
Returns the baryon number.
G4INCL::ThreeVector thePosition
void removeParticle(Particle *const p, const G4double theProjectileCorrection)
Remove a nucleon from the projectile remnant.
std::vector< G4double > EnergyLevels
G4double computeExcitationEnergyWith(const ParticleList &pL) const
Compute the excitation energy if some nucleons are put back.
ParticleList addMostDynamicalSpectators(ParticleList pL)
Add back dynamical spectators to the projectile remnant.
ParticleList addAllDynamicalSpectators(ParticleList const &pL)
Add back all dynamical spectators to the projectile remnant.
ParticleList addDynamicalSpectators(ParticleList pL)
Add back dynamical spectators to the projectile remnant.
G4double computeExcitationEnergyExcept(const long exceptID) const
Compute the excitation energy when a nucleon is removed.
void reset()
Reset the projectile remnant to the state at the beginning of the cascade.
G4ThreadLocal NuclearMassFn getTableMass
Static pointer to the mass function for nuclei.
ParticleList::iterator ParticleMutableIter
ParticleList::const_iterator ParticleIter