Problem 1745 - photon isotropic distribution sampling in G4NeutronHPPhotonDist
Summary: photon isotropic distribution sampling in G4NeutronHPPhotonDist
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/hadronic/models/neutron_hp (show other problems)
Version: 10.1
Hardware: All All
: P5 trivial
Assignee: dennis.herbert.wright
URL:
Depends on:
Blocks:
 
Reported: 2015-05-13 15:38 CEST by Artem Zontikov
Modified: 2018-08-24 18:56 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Artem Zontikov 2015-05-13 15:38:11 CEST
In source/processes/hadronic/models/neutron_hp/src/G4NeutronHPPhotonDist.cc at line #490 theta is sampled uniformly within [0;pi] angle interval while it is assumed to be uniform within [-1;1] cosine interval.

487  if(ii<nIso)
488  {
489  // isotropic distribution
490  G4double theta = pi*G4UniformRand();
491  G4double phi = twopi*G4UniformRand();
492  G4double sinth = std::sin(theta);
493  G4double en = thePhotons->operator[](i)->GetTotalEnergy();
494  G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
495  thePhotons->operator[](i)->SetMomentum( tempVector ) ;
496  }

Obvious fix is:
...
G4double cosTheta = -1.0 + 2.0*G4UniformRand();
G4double phi = twopi*G4UniformRand();
G4double sinTheta = std::sqrt(1.0 - cosTheta*cosTheta);
...
G4ThreeVector tempVector(en*sinTheta*std::cos(phi), en*sinTheta*std::sin(phi), en*cosTheta);
...
Comment 1 tkoi 2015-06-08 23:22:03 CEST
Thank you for reporting problem and also providing fix for it.
The fix will be included in future release