54 #ifndef __G4TWISTEDTUBS__
55 #define __G4TWISTEDTUBS__
135 std::ostream &
StreamInfo(std::ostream& os)
const;
156 {
return fEndInnerRadius[i]; }
158 {
return fEndOuterRadius[i]; }
160 {
return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
161 fEndInnerRadius[0] : fEndInnerRadius[1]); }
163 {
return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
164 fEndOuterRadius[0] : fEndOuterRadius[1]); }
200 void CreateSurfaces();
250 p.
set(kInfinity,kInfinity,kInfinity);
254 LastState(
const LastState&
r) : p(r.p), inside(r.inside){}
257 if (
this == &r) {
return *
this; }
258 p = r.p; inside = r.inside;
271 p.
set(kInfinity,kInfinity,kInfinity);
272 vec.set(kInfinity,kInfinity,kInfinity);
279 LastVector(
const LastVector&
r) : p(r.p), vec(r.vec)
282 surface[0] = r.surface[0];
286 if (&r ==
this) {
return *
this; }
287 p = r.p; vec = r.vec;
289 surface[0] = r.surface[0];
303 p.
set(kInfinity,kInfinity,kInfinity);
307 LastValue(
const LastValue&
r) : p(r.p),
value(r.
value){}
310 if (
this == &r) {
return *
this; }
311 p = r.p;
value = r.value;
319 class LastValueWithDoubleVector
322 LastValueWithDoubleVector()
324 p.
set(kInfinity,kInfinity,kInfinity);
325 vec.set(kInfinity,kInfinity,kInfinity);
328 ~LastValueWithDoubleVector(){}
329 LastValueWithDoubleVector(
const LastValueWithDoubleVector&
r)
331 LastValueWithDoubleVector&
operator=(
const LastValueWithDoubleVector&
r)
333 if (
this == &r) {
return *
this; }
334 p = r.p; vec = r.vec;
value = r.value;
343 LastState fLastInside;
344 LastVector fLastNormal;
345 LastValue fLastDistanceToIn;
346 LastValue fLastDistanceToOut;
347 LastValueWithDoubleVector fLastDistanceToInWithV;
348 LastValueWithDoubleVector fLastDistanceToOutWithV;
364 fPhiTwist = phitwist;
365 fEndZ[0] = negativeEndz;
366 fEndZ[1] = positiveEndz;
367 fEndZ2[0] = fEndZ[0] * fEndZ[0];
368 fEndZ2[1] = fEndZ[1] * fEndZ[1];
369 fInnerRadius = innerrad;
370 fOuterRadius = outerrad;
371 fInnerRadius2 = fInnerRadius * fInnerRadius;
372 fOuterRadius2 = fOuterRadius * fOuterRadius;
374 if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1])) {
375 fZHalfLength = std::fabs(fEndZ[0]);
377 fZHalfLength = std::fabs(fEndZ[1]);
380 G4double parity = (fPhiTwist > 0 ? 1 : -1);
381 G4double tanHalfTwist = std::tan(0.5 * fPhiTwist);
382 G4double innerNumerator = std::fabs(fInnerRadius * tanHalfTwist) * parity;
383 G4double outerNumerator = std::fabs(fOuterRadius * tanHalfTwist) * parity;
385 fTanInnerStereo = innerNumerator / fZHalfLength;
386 fTanOuterStereo = outerNumerator / fZHalfLength;
387 fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
388 fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
389 fInnerStereo = std::atan2(innerNumerator, fZHalfLength);
390 fOuterStereo = std::atan2(outerNumerator, fZHalfLength);
391 fEndInnerRadius[0] = std::sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
392 fEndInnerRadius[1] = std::sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
393 fEndOuterRadius[0] = std::sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
394 fEndOuterRadius[1] = std::sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
396 fKappa = tanHalfTwist / fZHalfLength;
397 fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
398 fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
401 G4cout <<
"/********* G4TwistedTubs::SetFields() Field Parameters ***************** " <<
G4endl;
403 G4cout <<
"/* fEndZ(0, 1) : " << fEndZ[0] <<
" , " << fEndZ[1] <<
G4endl;
404 G4cout <<
"/* fEndPhi(0, 1) : " << fEndPhi[0] <<
" , " << fEndPhi[1] <<
G4endl;
405 G4cout <<
"/* fInnerRadius, fOuterRadius : " << fInnerRadius <<
" , " << fOuterRadius <<
G4endl;
406 G4cout <<
"/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] <<
" , "
407 << fEndInnerRadius[1] <<
G4endl;
408 G4cout <<
"/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] <<
" , "
409 << fEndOuterRadius[1] <<
G4endl;
410 G4cout <<
"/* fInnerStereo, fOuterStereo : " << fInnerStereo <<
" , " << fOuterStereo <<
G4endl;
411 G4cout <<
"/* tanHalfTwist, fKappa : " << tanHalfTwist <<
" , " << fKappa <<
G4endl;
412 G4cout <<
"/*********************************************************************** " <<
G4endl;