7 #ifndef PORTABLE_LAR_SHAPE
11 #include "CLHEP/Units/PhysicalConstants.h"
19 LWSDBG(1, std::cout << TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP) << std::endl);
24 LWSDBG(2, std::cout <<
"Outside BS" << std::endl);
27 G4ThreeVector
p(inputP);
36 const G4double
d = fabs(
GetCalculator()->DistanceToTheNearestFan(
p, p_fan));
39 LWSDBG(2, std::cout <<
"dti result = " <<
result << std::endl);
42 LWSDBG(2, std::cout <<
"already inside, return 0" << MSG_VECTOR(
p) << std::endl);
47 const G4ThreeVector &inputV)
const
49 LWSDBG(1, std::cout << TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
50 << MSG_VECTOR(inputV) << std::endl);
54 G4ThreeVector
p(inputP);
55 if(inside_BS == kOutside) {
58 LWSDBG(2, std::cout <<
"Infinity distance to m_BoundingShape" << MSG_VECTOR(inputP) << MSG_VECTOR(inputV) << std::endl);
63 LWSDBG(2, std::cout <<
"shift" << MSG_VECTOR(inputP) << std::endl);
66 const G4double
phi0 =
p.phi();
70 LWSDBG(2, std::cout <<
"already inside fan" << MSG_VECTOR(
p) << std::endl);
72 if(inside_BS == kSurface) {
73 LWSDBG(2, std::cout <<
"On BS surface" << std::endl);
78 G4ThreeVector
v(inputV);
84 #ifdef DEBUG_LARWHEELSOLID
87 std::cout << MSG_VECTOR(inputP)
88 <<
" " << MSG_VECTOR(inputV) << std::endl;
90 std::cout <<
"dti: " <<
d0 <<
", DTI: " <<
distance << std::endl;
96 std::cout <<
"DTI hit at dist. " <<
distance <<
", point "
97 << MSG_VECTOR(
p2) <<
", "
100 std::cout <<
"got infinity from dti" << std::endl;
103 #ifdef LWS_HARD_TEST_DTI
104 if(test_dti(inputP, inputV,
distance)){
106 std::cout << TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
107 << MSG_VECTOR(inputV) << std::endl;
111 std::cout << TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
112 << MSG_VECTOR(inputV) <<
" " <<
distance << std::endl;
114 #endif // ifdef LWS_HARD_TEST_DTI
116 #endif // ifdef DEBUG_LARWHEELSOLID
127 const G4ThreeVector &
p, G4double dist_p, G4ThreeVector &
B,
int p_fan
130 LWSDBG(6, std::cout <<
"iip from " <<
p <<
" to " <<
B
131 <<
" dir " << (
B -
p).
unit()
137 unsigned int niter = 0;
144 if(dist_c * dist_p < 0. || fabs(dist_c) <
m_FHTminusT){
155 LWSDBG(7, std::cout <<
"iip result in " << niter <<
" = " <<
B
156 <<
" " <<
diff.mag() << std::endl);
163 const G4ThreeVector &p_in,
const G4double dist_p_in,
164 const G4ThreeVector &p_out,
int p_fan
167 LWSDBG(6, std::cout <<
"sfnp " << MSG_VECTOR(p_in) <<
" "
168 << MSG_VECTOR(p_out) << std::endl);
176 G4double
sign = dist_p_in < 0.? -1. : 1.;
179 unsigned long niter = 0;
184 if(dist_c *
sign <= 0.){
185 LWSDBG(7, std::cout <<
"sfnp0 " << dist_c << std::endl);
192 if(d_prime < 0.)
A =
C;
199 LWSDBG(7, std::cout <<
"sfnp1 " << dist_c << std::endl);
203 if(dist_p_in *
sign < dist_c *
sign){
208 if(dist_p_out *
sign < dist_c *
sign)
C = p_out;
210 LWSDBG(7, std::cout <<
"sfnp2 " << dist_p_out << std::endl);
218 LWSDBG(4, std::cout <<
"dti: " << MSG_VECTOR(
p) <<
" "
219 << MSG_VECTOR(
v) << std::endl);
222 #ifdef LARWHEELSOLID_USE_FANBOUND
223 if(FanBound->Inside(
p) == kOutside) {
224 const G4double
d = FanBound->DistanceToIn(
p,
v);
230 if(
v.x() >= 0.)
return kInfinity;
232 const G4double
y2 =
p.y() +
v.y() *
b;
233 const G4double z2 =
p.z() +
v.z() *
b;
237 if(
v.x() <= 0.)
return kInfinity;
239 const G4double
y2 =
p.y() +
v.y() *
b;
240 const G4double z2 =
p.z() +
v.z() *
b;
248 LWSDBG(5, std::cout <<
"dti corrected: " << MSG_VECTOR(
p) << std::endl);
252 LWSDBG(5, std::cout <<
"hit fan dist_p=" << dist_p <<
", m_FHTminusT=" <<
m_FHTminusT << std::endl);
256 #ifdef CHECK_DIRTONORM_ANGLE_ON_SURFACE
258 LWSDBG(5, std::cout <<
"outside fan dist_p=" << dist_p <<
", m_FHTplusT=" <<
m_FHTplusT << std::endl);
260 LWSDBG(5, std::cout <<
"on fan surface dist_p=" << dist_p <<
", m_FHTplusT=" <<
m_FHTplusT <<
", m_FHTminusT=" <<
m_FHTminusT << std::endl);
264 if ( (
p-
d).cosTheta(
v) < -AngularTolerance ) {
273 #ifdef LARWHEELSOLID_USE_FANBOUND
274 q =
p +
v * FanBound->DistanceToOut(
p,
v);
284 <<
" " <<
step << std::endl);
290 const G4double
x1 =
p.x() +
v.x() *
d1,
y1 =
p.y() +
v.y() *
d1;
293 LWSDBG(5, std::cout <<
i <<
">" <<
p <<
" " << dist_p <<
" "
294 <<
p1 <<
" " << dist_p1 << std::endl);
295 G4double
dd = kInfinity;
296 if(dist_p * dist_p1 < 0.){
300 LWSDBG(6, std::cout <<
i <<
"> dd=" <<
dd <<
", d2=" <<
d2 <<
", distance=" <<
distance << std::endl);
303 }
else if(
dd < kInfinity){
312 LWSDBG(5, std::cout <<
"dti exit point: " << MSG_VECTOR(
q) <<
" "
313 << dist_q << std::endl);
314 G4double
dd = kInfinity;
315 if(dist_p * dist_q < 0.){
321 }
else if(
dd < kInfinity){