Problem 1174

Summary: Crash in G4TripathiLightCrossSection::GetZandACrossSection due to E_cm~<0
Product: Geant4 Reporter: Andrea Dotti <andrea.dotti>
Component: processes/hadronic/cross_sectionsAssignee: dennis.herbert.wright
Status: RESOLVED FIXED    
Severity: critical    
Priority: P1    
Version: 9.4   
Hardware: PC   
OS: Linux   

Description Andrea Dotti 2011-02-19 12:27:03 CET
Dear All,
	I have encountered a crash in 9.4.p01 for QGSP_BIC physics list with the SimplifiedCalorimeter tests (Fe/Scintillator calorimeter with pi- @ 200 GeV incident).
The crash is probably due to a Floating Point Exception, but no G4 FPE exception was raised

The crash happens in  G4TripathiLightCrossSection::GetZandACrossSection at line 174:
         std::pow(E_cm, third);
(gdb) print E_cm
$22 = -4.5474735088646412e-13

As you can see the E_cm is a very small (negative number).
E_cm is calculated at line 160:
154       G4double mT = G4ParticleTable::GetParticleTable()
155                     ->GetIonTable()
156                     ->GetIonMass(static_cast<G4int>(ZT), static_cast<G4int>(AT));
157       G4LorentzVector pT(0.0, 0.0, 0.0, mT);
158       G4LorentzVector pP(theProjectile->Get4Momentum());
159       pT = pT + pP;
160       G4double E_cm = (pT.mag()-mT-pP.m())/MeV;        <<<<<<<<<<<<<<<<<<<<<


I have started to debug and observed the following:
==============================================
1- G4TripathiLightCrossSection::GetZandACrossSection (    this=0x1f0f180, theProjectile=0x229fe48, ZZ=1, AA=2)
	- Thus the target is a triton 

==============================================
2- The projectile is a triton too with 0 kinetic energy:
	(gdb) frame 1 
#1 0x0000002aa05fb8e3 in G4TripathiLightCrossSection::GetZandACrossSection ( this=0x1f0f180, theProjectile=0x229fe48, ZZ=1, AA=2) at src/G4TripathiLightCrossSection.cc:174 
174 std::pow(E_cm, third); 
(gdb) print *theProjectile 
$31 = { 
theMomentumDirection = { .... }, 
theParticleDefinition = 0x8cb550, 
thePolarization = { .... }, 
theKineticEnergy = 0,                            <<<<<<<<<<<<<<<<<<<<<<<<<<<<<


(gdb) print *theProjectile.theParticleDefinition 
$32 = (G4Ions) { 
		<G4ParticleDefinition> = { 
				_vptr.G4ParticleDefinition = 0x2aa2087290, 
				theParticleName = { ....... _Alloc_hider: _M_p = 0x8cb4d8 "triton" } }, <No data fields>},

Due to the fact that target and projectile are both the same particle and that the projectile momentum is zero, the (available) energy in c.m. is zero.
Rounding issues (?) make it ~<0
And hence the crash.

I've never seen this problem in 9.4 or 9.4-ref01, but given the strange conditions in which it is produced probably it is just a matter of statistics.
Comment 1 dennis.herbert.wright 2011-05-05 20:49:40 CEST
Thanks for tracking this down.  The code now returns 0 cross section if the cm energy is < DBL_MIN.