A G4Para with the following parameters fDx = 80 fDy = 100 fDz = 120 fTalpha = 0.57735 fTthetaCphi = 0.5 fTthetaSphi = 0.866025 responds incorrectly to SurfaceNormal() method for the following point: dx= 72.45979294818625 dy= -13.0600217133 dz= 93.3122548334 The problem comes from the incorrect calculation of salpha ( = -sin(alpha) ) which affects the normal nX value: nX (double) dx = 0.654654 (double) dy = -1.13389 (double) dz = 0.654654 The value in this case is unphysical salpha = -1.5 <=== it should be 0.5
There is a simple correction. Revise the following line: if (fTalpha) {salpha = -calpha/fTalpha;} // NOTE: using MINUS std::sin(alpha) to this: if (fTalpha) {salpha = -calpha*fTalpha;} // NOTE: using MINUS std::sin(alpha) Below is a patch, which can be applied to the source. Index: src/G4Para.cc =================================================================== --- src/G4Para.cc (revision 62306) +++ src/G4Para.cc (revision 62307) @@ -495,7 +495,7 @@ newpy = p.y()-fTthetaSphi*p.z(); calpha = 1/std::sqrt(1+fTalpha*fTalpha); - if (fTalpha) {salpha = -calpha/fTalpha;} // NOTE: using MINUS std::sin(alpha) + if (fTalpha) {salpha = -calpha*fTalpha;} // NOTE: using MINUS std::sin(alpha) else {salpha = 0.;} // xshift = newpx*calpha+newpy*salpha;