Problem 780

Summary: nan-producing operation in ionization models
Product: Geant4 Reporter: dennis.herbert.wright
Component: processes/electromagneticAssignee: Michel.Maire
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 7.1   
Hardware: PC   
OS: Linux   

Description dennis.herbert.wright 2005-08-10 16:07:27 CEST
On both Linux and Sun, I encountered program aborts which I traced back to
a NAN-producing operation in G4BraggModel::SampleSecondaries and
G4BetheBlochModel::SampleSecondaries.  The problem is in the lines:

G4double cost = deltaKinEnergy * (energy + electron_mass_c2) /
                                   (deltaMomentum * totMomentum);
G4double sint = sqrt(1.0 - cost*cost);

cost is occaisionally > 1 by a small amount, causing the argument of sqrt to be
negative.  My temporary fix was to protect the calculation of cost by taking
the std::min of the calculated value and 1.0.

The same problem also occurs in G4BraggIonModel and G4MollerBhabhaModel.
Comment 1 Michel.Maire 2005-09-23 04:34:59 CEST
Bug fixed and commited
Comment 2 Michel.Maire 2005-09-23 04:35:59 CEST
Bug fixed and commited
Comment 3 Michel.Maire 2005-09-23 04:36:59 CEST
Bug fixed and commited