I’m getting an error when I use a inverse CDF sampling in energy that I don’t see using a flat distribution. The error is:
G4ParticleChange::CheckIt : the Momentum Change is not unit vector !! Difference: 1
neutron E=2.51889 pos=-0.0902091, -0.0902091, 9.99919
-----------------------------------------------
G4ParticleChange Information
-----------------------------------------------
# of 2ndaries : 0
-----------------------------------------------
Energy Deposit (MeV): 0
Non-ionizing Energy Deposit (MeV): 0
Track Status : Alive
True Path Length (mm) : 0
Stepping Control : 0
First Step In the voulme :
Mass (GeV) : 0
Charge (eplus) : 0
MagneticMoment : 0
: = 0*[e hbar]/[2 m]
Position - x (mm) : -90.2
Position - y (mm) : -90.2
Position - z (mm) : 1e+04
Time (ns) : 0
Proper Time (ns) : 0
Momentum Direct - x : 4.66e-310
Momentum Direct - y : 3.46e-323
Momentum Direct - z : 1.35e-306
Kinetic Energy (MeV): 2.52
Velocity (/c): 0.0731
Polarization - x : 0
Polarization - y : 0
Polarization - z : 0
Touchable (pointer) : 0x55d2a86ee2e0
RuntimeError: *** Event Must Be Aborted ***
*** G4Exception : TRACK003
issued by : G4ParticleChange::CheckIt
momentum, energy, and/or time was illegal
I don’t know what this error is. I’m generating my energy by:
G4float energy = interp(G4UniformRand(),cdf,energyVector);
which generates energy in MeV that ranges from 0.25 to 15 MeV. If I generate energy as:
G4float energy = 0.25 + G4UniformRand() * (15 - 0.25);
I don’t get the error. But I’ve checked all the energies and they’re all legal, I.E. no negative energy and no zero energy. What is causing the error?