For my G4Polycone DistanceToOut(p, v) returns 9e+99 for the point while Inside returns for it kSurface. Here is small program to illustrate: #include"G4Polycone.hh" #include"globals.hh" void inside(EInside i) { switch(i){ case kInside: G4cout << "inside" << G4endl; break; case kSurface: G4cout << "surface" << G4endl; break; case kOutside: G4cout << "outside" << G4endl; break; default: G4cout << "unknown" << G4endl; break; } } int main(void) { G4cout.precision(20); G4ThreeVector a(-8.532841757012601,695.2835945311123,514); G4cout << a << G4endl; G4cout << a.rho() << " " << a.phi()/deg << G4endl; G4double z[2] = { 501.375, 514 }; G4double min[2] = { 343.2479844802456, 344.2789431275381 }; G4double max[2] = { 693.2492457175576, 695.3359520494782 }; G4double phi0 = 83.46327433164964 * deg, phi1 = 96.53672566835034 * deg; G4Polycone *C = new G4Polycone("C", phi0, phi1 - phi0, 2, z, min, max); G4cout << *C << G4endl; G4cout << a << " "; inside(C->Inside(a)); G4ThreeVector v(-0.9999247018391445,-0.01227153828571976,0); G4cout << v << G4endl; G4cout << C->DistanceToOut(a, v) << G4endl; } -------------------------------------------------------------------- End of output is: (-8.532841757012601,695.2835945311123,514) surface (-0.9999247018391445,-0.01227153828571976,0) 9e+99
The trajectory in the given example does not actually intersect the solid at any point (thus the report of kInfinity). The interesting question is whether this violates the design of G4VSolid. I don't believe this is the correct venue to discuss this type of design issue, so rather than debate whether or not the current behavior is correct, I have added code to produce a return value which I hope will be satisfactory to everyone. The code changes have been placed into the geant4 code repository (see geometry/solids/specific/src/G4VCSGfaceted.cc revision 1.11). This fix will check before returning kInfinity whether the give point of the trajectory is on the solid surface. This will require additional CPU time, however, since the situation is anomolous I hope it is therefore rare, and that the additional overhead is not a problem.