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;
81 INCL_DEBUG(
"The following Particle is about to be removed from the ProjectileRemnant:"
83 <<
"theProjectileCorrection=" << theProjectileCorrection <<
'\n');
93#if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
102 const G4double theProjectileCorrectionPerNucleon = theProjectileCorrection /
particles.size();
106 (*i)->setEnergy((*i)->getEnergy() + theProjectileCorrectionPerNucleon);
107 (*i)->setMass((*i)->getInvariantMass());
108#if !defined(NDEBUG) && !defined(INCLXX_IN_GEANT4_MODE)
109 theTotalMomentum += (*i)->getMomentum();
110 theTotalEnergy += (*i)->getEnergy();
116 theEnergy -= oldEnergy - theProjectileCorrection;
120 INCL_DEBUG(
"After Particle removal, the ProjectileRemnant looks like this:"
129 unsigned int accepted;
130 unsigned long loopCounter = 0;
131 const unsigned long maxLoopCounter = 10000000;
135 for(
ParticleIter p=toBeAdded.begin(), e=toBeAdded.end(); p!=e; ++p) {
136 G4bool isAccepted = addDynamicalSpectator(*p);
143 }
while(loopCounter<maxLoopCounter && accepted > 0);
157 theNewMomentum += getStoredMomentum(*p);
158 theNewEnergy += (*p)->getEnergy();
159 theNewA += (*p)->getA();
160 theNewZ += (*p)->getZ();
161 theNewS += (*p)->getS();
171 const G4double theNewEffectiveMass = theNewMass + theNewExcitationEnergy;
175 if(theNewEnergy<theNewEffectiveMass) {
176 INCL_WARN(
"Could not add all the dynamical spectators back into the projectile remnant."
177 <<
" Falling back to the \"most\" method." <<
'\n');
188 const G4double scalingFactorSquared = (theNewEnergy*theNewEnergy-theNewEffectiveMass*theNewEffectiveMass)/theNewMomentum.
mag2();
189 const G4double scalingFactor = std::sqrt(scalingFactorSquared);
190 INCL_DEBUG(
"Scaling factor for the projectile-remnant momentum = " << scalingFactor <<
'\n');
216 theNewMomentum += getStoredMomentum(*p);
217 theNewEnergy += (*p)->getEnergy();
218 theNewA += (*p)->getA();
219 theNewZ += (*p)->getZ();
220 theNewS += (*p)->getS();
229 const G4double theNewInvariantMassSquared = theNewEnergy*theNewEnergy-theNewMomentum.
mag2();
231 G4bool positiveExcitationEnergy =
false;
232 if(theNewInvariantMassSquared>=0.) {
233 const G4double theNewInvariantMass = std::sqrt(theNewInvariantMassSquared);
234 positiveExcitationEnergy = (theNewInvariantMass-theNewMass>-1.e-5);
240 while(!positiveExcitationEnergy && !pL.empty()) {
241 G4double maxExcitationEnergy = -1.E30;
245 G4int bestA = -1, bestZ = -1, bestS = 0;
246 for(ParticleList::iterator p=pL.begin(), e=pL.end(); p!=e; ++p) {
249 const ThreeVector theNewerMomentum = theNewMomentum - getStoredMomentum(*p);
250 const G4double theNewerEnergy = theNewEnergy - (*p)->getEnergy();
251 const G4int theNewerA = theNewA - (*p)->getA();
252 const G4int theNewerZ = theNewZ - (*p)->getZ();
253 const G4int theNewerS = theNewS - (*p)->getS();
260 const G4double theNewerInvariantMassSquared = theNewerEnergy*theNewerEnergy-theNewerMomentum.
mag2();
262 if(theNewerInvariantMassSquared>=-1.e-5) {
263 const G4double theNewerInvariantMass = std::sqrt(std::max(0.,theNewerInvariantMassSquared));
264 const G4double theNewerExcitationEnergy = ((theNewerA>1) ? theNewerInvariantMass-theNewerMass : 0.);
267 if(theNewerExcitationEnergy>maxExcitationEnergy) {
269 maxExcitationEnergy = theNewerExcitationEnergy;
270 bestMomentum = theNewerMomentum;
271 bestEnergy = theNewerEnergy;
283 rejected.push_back(*best);
285 theNewMomentum = bestMomentum;
286 theNewEnergy = bestEnergy;
291 if(maxExcitationEnergy>0.) {
293 positiveExcitationEnergy =
true;
310 G4bool ProjectileRemnant::addDynamicalSpectator(
Particle *
const p) {
314 ThreeVector const &oldMomentum = getStoredMomentum(p);
325 const G4double theNewInvariantMassSquared = theNewEnergy*theNewEnergy-theNewMomentum.
mag2();
327 if(theNewInvariantMassSquared<0.)
330 const G4double theNewInvariantMass = std::sqrt(theNewInvariantMassSquared);
332 if(theNewInvariantMass-theNewMass<-1.e-5)
345 const EnergyLevels theEnergyLevels = getPresentEnergyLevelsExcept(exceptID);
346 return computeExcitationEnergy(theEnergyLevels);
350 const EnergyLevels theEnergyLevels = getPresentEnergyLevelsWith(pL);
351 return computeExcitationEnergy(theEnergyLevels);
354 G4double ProjectileRemnant::computeExcitationEnergy(
const EnergyLevels &levels)
const {
359 const std::size_t theNewA = levels.size();
364 const G4double groundState = theGroundStateEnergies.at(theNewA-1);
367 const G4double excitedState = std::accumulate(
372 return excitedState-groundState;
378 if((*p)->getID()!=exceptID) {
379 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
381 theEnergyLevels.push_back(i->second);
385 return theEnergyLevels;
391 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
393 theEnergyLevels.push_back(i->second);
396 EnergyLevelMap::const_iterator i = theInitialEnergyLevels.find((*p)->getID());
398 theEnergyLevels.push_back(i->second);
402 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