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');
91#if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
100 const G4double theProjectileCorrectionPerNucleon = theProjectileCorrection /
particles.size();
104 (*i)->setEnergy((*i)->getEnergy() + theProjectileCorrectionPerNucleon);
105 (*i)->setMass((*i)->getInvariantMass());
106#if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
107 theTotalMomentum += (*i)->getMomentum();
108 theTotalEnergy += (*i)->getEnergy();
114 theEnergy -= oldEnergy - theProjectileCorrection;
118 INCL_DEBUG(
"After Particle removal, the ProjectileRemnant looks like this:"
127 unsigned int accepted;
128 unsigned long loopCounter = 0;
129 const unsigned long maxLoopCounter = 10000000;
133 for(
ParticleIter p=toBeAdded.begin(), e=toBeAdded.end(); p!=e; ++p) {
134 G4bool isAccepted = addDynamicalSpectator(*p);
141 }
while(loopCounter<maxLoopCounter && accepted > 0);
155 theNewMomentum += getStoredMomentum(*p);
156 theNewEnergy += (*p)->getEnergy();
157 theNewA += (*p)->getA();
158 theNewZ += (*p)->getZ();
159 theNewS += (*p)->getS();
165 const G4double theNewEffectiveMass = theNewMass + theNewExcitationEnergy;
169 if(theNewEnergy<theNewEffectiveMass) {
170 INCL_WARN(
"Could not add all the dynamical spectators back into the projectile remnant."
171 <<
" Falling back to the \"most\" method." <<
'\n');
182 const G4double scalingFactorSquared = (theNewEnergy*theNewEnergy-theNewEffectiveMass*theNewEffectiveMass)/theNewMomentum.
mag2();
183 const G4double scalingFactor = std::sqrt(scalingFactorSquared);
184 INCL_DEBUG(
"Scaling factor for the projectile-remnant momentum = " << scalingFactor <<
'\n');
210 theNewMomentum += getStoredMomentum(*p);
211 theNewEnergy += (*p)->getEnergy();
212 theNewA += (*p)->getA();
213 theNewZ += (*p)->getZ();
214 theNewS += (*p)->getS();
219 const G4double theNewInvariantMassSquared = theNewEnergy*theNewEnergy-theNewMomentum.
mag2();
221 G4bool positiveExcitationEnergy =
false;
222 if(theNewInvariantMassSquared>=0.) {
223 const G4double theNewInvariantMass = std::sqrt(theNewInvariantMassSquared);
224 positiveExcitationEnergy = (theNewInvariantMass-theNewMass>-1.e-5);
230 while(!positiveExcitationEnergy && !pL.empty()) {
231 G4double maxExcitationEnergy = -1.E30;
235 G4int bestA = -1, bestZ = -1, bestS = 0;
236 for(ParticleList::iterator p=pL.begin(), e=pL.end(); p!=e; ++p) {
239 const ThreeVector theNewerMomentum = theNewMomentum - getStoredMomentum(*p);
240 const G4double theNewerEnergy = theNewEnergy - (*p)->getEnergy();
241 const G4int theNewerA = theNewA - (*p)->getA();
242 const G4int theNewerZ = theNewZ - (*p)->getZ();
243 const G4int theNewerS = theNewS - (*p)->getS();
246 const G4double theNewerInvariantMassSquared = theNewerEnergy*theNewerEnergy-theNewerMomentum.
mag2();
248 if(theNewerInvariantMassSquared>=-1.e-5) {
249 const G4double theNewerInvariantMass = std::sqrt(std::max(0.,theNewerInvariantMassSquared));
250 const G4double theNewerExcitationEnergy = ((theNewerA>1) ? theNewerInvariantMass-theNewerMass : 0.);
253 if(theNewerExcitationEnergy>maxExcitationEnergy) {
255 maxExcitationEnergy = theNewerExcitationEnergy;
256 bestMomentum = theNewerMomentum;
257 bestEnergy = theNewerEnergy;
269 rejected.push_back(*best);
271 theNewMomentum = bestMomentum;
272 theNewEnergy = bestEnergy;
277 if(maxExcitationEnergy>0.) {
279 positiveExcitationEnergy =
true;
296 G4bool ProjectileRemnant::addDynamicalSpectator(
Particle *
const p) {
300 ThreeVector const &oldMomentum = getStoredMomentum(p);
307 const G4double theNewInvariantMassSquared = theNewEnergy*theNewEnergy-theNewMomentum.
mag2();
309 if(theNewInvariantMassSquared<0.)
312 const G4double theNewInvariantMass = std::sqrt(theNewInvariantMassSquared);
314 if(theNewInvariantMass-theNewMass<-1.e-5)
327 const EnergyLevels theEnergyLevels = getPresentEnergyLevelsExcept(exceptID);
328 return computeExcitationEnergy(theEnergyLevels);
332 const EnergyLevels theEnergyLevels = getPresentEnergyLevelsWith(pL);
333 return computeExcitationEnergy(theEnergyLevels);
336 G4double ProjectileRemnant::computeExcitationEnergy(
const EnergyLevels &levels)
const {
341 const std::size_t theNewA = levels.size();
346 const G4double groundState = theGroundStateEnergies.at(theNewA-1);
349 const G4double excitedState = std::accumulate(
354 return excitedState-groundState;
360 if((*p)->getID()!=exceptID) {
361 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
363 theEnergyLevels.push_back(i->second);
367 return theEnergyLevels;
373 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
375 theEnergyLevels.push_back(i->second);
378 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
380 theEnergyLevels.push_back(i->second);
384 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