33 #define INCLXX_IN_GEANT4_MODE 1
47 #include "G4String.hh"
53 complainedAboutBackupModel(false)
56 if(getenv(
"G4INCLXX_NO_DE_EXCITATION")) {
57 G4String message =
"de-excitation is completely disabled!";
59 theExcitationHandler = 0;
69 delete theBackupModel;
70 delete theExcitationHandler;
87 ss <<
"the model does not know how to handle a collision between a "
109 if(pA > theMaxProjMassINCL)
111 else if(tA > theMaxProjMassINCL)
124 && theNucleus.
GetA_asInt() > theMaxProjMassINCL) {
125 if(!complainedAboutBackupModel) {
126 complainedAboutBackupModel =
true;
127 std::stringstream ss;
128 ss <<
"INCL++ refuses to handle reactions between nuclei with A>"
129 << theMaxProjMassINCL
130 <<
". A backup model ("
132 <<
") will be used instead.";
138 const G4int maxTries = 200;
141 const G4bool inverseKinematics = AccurateProjectile(aTrack, theNucleus);
147 G4Nucleus *theTargetNucleus = &theNucleus;
148 if(inverseKinematics) {
155 if(oldProjectileDef != 0 && oldTargetDef != 0) {
159 if(newTargetA > 0 && newTargetZ > 0) {
161 theTargetNucleus =
new G4Nucleus(newTargetA, newTargetZ);
164 G4LorentzVector theProjectile4Momentum(0.0, 0.0, 0.0, theProjectileMass);
165 G4DynamicParticle swappedProjectileParticle(oldTargetDef, (*toInverseKinematics) * theProjectile4Momentum);
168 G4String message =
"badly defined target after swapping. Falling back to normal (non-swapped) mode.";
173 G4String message =
"oldProjectileDef or oldTargetDef was null";
209 std::list<G4Fragment> remnants;
218 const G4double kineticEnergy = toINCLKineticEnergy(*aProjectileTrack);
233 if(inverseKinematics) {
250 momentum *= toLabFrame;
252 if(inverseKinematics) {
253 momentum *= *toDirectKinematics;
262 G4String message =
"the model produced a particle that couldn't be converted to Geant4 particle.";
277 eventInfo.
jyRem[i]*hbar_Planck,
278 eventInfo.
jzRem[i]*hbar_Planck
282 const G4double scaling = remnant4MomentumScaling(nuclearMass,
287 if(std::abs(scaling - 1.0) > 0.01) {
288 std::stringstream ss;
289 ss <<
"momentum scaling = " << scaling
290 <<
"\n Lorentz vector = " << fourMomentum
291 <<
")\n A = " << A <<
", Z = " << Z
292 <<
"\n E* = " << excitationE <<
", nuclearMass = " << nuclearMass
293 <<
"\n remnant i=" << i <<
", nRemnants=" << eventInfo.
nRemnants
297 <<
", in " << (inverseKinematics ?
"inverse" :
"direct") <<
" kinematics.";
302 fourMomentum *= toLabFrame;
305 if(inverseKinematics) {
306 fourMomentum *= *toDirectKinematics;
312 remnants.push_back(remnant);
316 }
while(!eventIsOK && nTries < maxTries);
319 if(inverseKinematics) {
320 delete aProjectileTrack;
321 delete theTargetNucleus;
322 delete toInverseKinematics;
323 delete toDirectKinematics;
327 std::stringstream ss;
328 ss <<
"maximum number of tries exceeded for the proposed "
331 <<
" inelastic reaction, in " << (inverseKinematics ?
"inverse" :
"direct") <<
" kinematics.";
341 if(theExcitationHandler != 0) {
342 for(std::list<G4Fragment>::const_iterator i = remnants.begin();
343 i != remnants.end(); i++) {
346 for(G4ReactionProductVector::iterator fragment = deExcitationResult->begin();
347 fragment != deExcitationResult->end(); ++fragment) {
355 for(G4ReactionProductVector::iterator fragment = deExcitationResult->begin();
356 fragment != deExcitationResult->end(); ++fragment) {
359 deExcitationResult->clear();
360 delete deExcitationResult;
413 else if(A == 3 && Z == 2)
return G4He3::He3();
415 else if(A > 0 && Z > 0 && A > Z) {
441 const G4double p2 = px*px + py*py + pz*pz;
443 const G4double pnew2 = kineticE*kineticE + 2.0*kineticE*mass;
444 return std::sqrt(pnew2)/std::sqrt(p2);