Geant4  10.02.p03
G4TwistedTubs Class Reference

#include <G4TwistedTubs.hh>

Inheritance diagram for G4TwistedTubs:
Collaboration diagram for G4TwistedTubs:

Classes

class  LastState
 
class  LastValue
 
class  LastValueWithDoubleVector
 
class  LastVector
 

Public Member Functions

 G4TwistedTubs (const G4String &pname, G4double twistedangle, G4double endinnerrad, G4double endouterrad, G4double halfzlen, G4double dphi)
 
 G4TwistedTubs (const G4String &pname, G4double twistedangle, G4double endinnerrad, G4double endouterrad, G4double halfzlen, G4int nseg, G4double totphi)
 
 G4TwistedTubs (const G4String &pname, G4double twistedangle, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz, G4double dphi)
 
 G4TwistedTubs (const G4String &pname, G4double twistedangle, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz, G4int nseg, G4double totphi)
 
virtual ~G4TwistedTubs ()
 
void ComputeDimensions (G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *)
 
G4bool CalculateExtent (const EAxis paxis, const G4VoxelLimits &pvoxellimit, const G4AffineTransform &ptransform, G4double &pmin, G4double &pmax) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=G4bool(false), G4bool *validnorm=0, G4ThreeVector *n=0) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
EInside Inside (const G4ThreeVector &p) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4PolyhedronCreatePolyhedron () const
 
G4PolyhedronGetPolyhedron () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4double GetDPhi () const
 
G4double GetPhiTwist () const
 
G4double GetInnerRadius () const
 
G4double GetOuterRadius () const
 
G4double GetInnerStereo () const
 
G4double GetOuterStereo () const
 
G4double GetZHalfLength () const
 
G4double GetKappa () const
 
G4double GetTanInnerStereo () const
 
G4double GetTanInnerStereo2 () const
 
G4double GetTanOuterStereo () const
 
G4double GetTanOuterStereo2 () const
 
G4double GetEndZ (G4int i) const
 
G4double GetEndPhi (G4int i) const
 
G4double GetEndInnerRadius (G4int i) const
 
G4double GetEndOuterRadius (G4int i) const
 
G4double GetEndInnerRadius () const
 
G4double GetEndOuterRadius () const
 
G4VisExtent GetExtent () const
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
G4ThreeVector GetPointOnSurface () const
 
 G4TwistedTubs (__void__ &)
 
 G4TwistedTubs (const G4TwistedTubs &rhs)
 
G4TwistedTubsoperator= (const G4TwistedTubs &rhs)
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
void DumpInfo () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

Private Member Functions

void SetFields (G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
 
void CreateSurfaces ()
 

Static Private Member Functions

static void AddPolyToExtent (const G4ThreeVector &v0, const G4ThreeVector &v1, const G4ThreeVector &w1, const G4ThreeVector &w0, const G4VoxelLimits &voxellimit, const EAxis axis, G4SolidExtentList &extentlist)
 

Private Attributes

G4double fPhiTwist
 
G4double fInnerRadius
 
G4double fOuterRadius
 
G4double fEndZ [2]
 
G4double fDPhi
 
G4double fZHalfLength
 
G4double fInnerStereo
 
G4double fOuterStereo
 
G4double fTanInnerStereo
 
G4double fTanOuterStereo
 
G4double fKappa
 
G4double fEndInnerRadius [2]
 
G4double fEndOuterRadius [2]
 
G4double fEndPhi [2]
 
G4double fInnerRadius2
 
G4double fOuterRadius2
 
G4double fTanInnerStereo2
 
G4double fTanOuterStereo2
 
G4double fEndZ2 [2]
 
G4VTwistSurfacefLowerEndcap
 
G4VTwistSurfacefUpperEndcap
 
G4VTwistSurfacefLatterTwisted
 
G4VTwistSurfacefFormerTwisted
 
G4VTwistSurfacefInnerHype
 
G4VTwistSurfacefOuterHype
 
G4double fCubicVolume
 
G4double fSurfaceArea
 
G4bool fRebuildPolyhedron
 
G4PolyhedronfpPolyhedron
 
LastState fLastInside
 
LastVector fLastNormal
 
LastValue fLastDistanceToIn
 
LastValue fLastDistanceToOut
 
LastValueWithDoubleVector fLastDistanceToInWithV
 
LastValueWithDoubleVector fLastDistanceToOutWithV
 

Additional Inherited Members

- Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 65 of file G4TwistedTubs.hh.

Constructor & Destructor Documentation

◆ G4TwistedTubs() [1/6]

G4TwistedTubs::G4TwistedTubs ( const G4String pname,
G4double  twistedangle,
G4double  endinnerrad,
G4double  endouterrad,
G4double  halfzlen,
G4double  dphi 
)

Definition at line 72 of file G4TwistedTubs.cc.

78  : G4VSolid(pname), fDPhi(dphi),
81  fCubicVolume(0.), fSurfaceArea(0.),
83 {
84  if (endinnerrad < DBL_MIN)
85  {
86  G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
87  FatalErrorInArgument, "Invalid end-inner-radius!");
88  }
89 
90  G4double sinhalftwist = std::sin(0.5 * twistedangle);
91 
92  G4double endinnerradX = endinnerrad * sinhalftwist;
93  G4double innerrad = std::sqrt( endinnerrad * endinnerrad
94  - endinnerradX * endinnerradX );
95 
96  G4double endouterradX = endouterrad * sinhalftwist;
97  G4double outerrad = std::sqrt( endouterrad * endouterrad
98  - endouterradX * endouterradX );
99 
100  // temporary treatment!!
101  SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
102  CreateSurfaces();
103 }
G4VTwistSurface * fFormerTwisted
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
void SetFields(G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
G4bool fRebuildPolyhedron
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VTwistSurface * fLatterTwisted
G4VTwistSurface * fInnerHype
#define DBL_MIN
Definition: templates.hh:75
G4Polyhedron * fpPolyhedron
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
double G4double
Definition: G4Types.hh:76
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4TwistedTubs() [2/6]

G4TwistedTubs::G4TwistedTubs ( const G4String pname,
G4double  twistedangle,
G4double  endinnerrad,
G4double  endouterrad,
G4double  halfzlen,
G4int  nseg,
G4double  totphi 
)

Definition at line 105 of file G4TwistedTubs.cc.

112  : G4VSolid(pname),
115  fCubicVolume(0.), fSurfaceArea(0.),
117 {
118 
119  if (!nseg)
120  {
121  std::ostringstream message;
122  message << "Invalid number of segments." << G4endl
123  << " nseg = " << nseg;
124  G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
125  FatalErrorInArgument, message);
126  }
127  if (totphi == DBL_MIN || endinnerrad < DBL_MIN)
128  {
129  G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
130  FatalErrorInArgument, "Invalid total-phi or end-inner-radius!");
131  }
132 
133  G4double sinhalftwist = std::sin(0.5 * twistedangle);
134 
135  G4double endinnerradX = endinnerrad * sinhalftwist;
136  G4double innerrad = std::sqrt( endinnerrad * endinnerrad
137  - endinnerradX * endinnerradX );
138 
139  G4double endouterradX = endouterrad * sinhalftwist;
140  G4double outerrad = std::sqrt( endouterrad * endouterrad
141  - endouterradX * endouterradX );
142 
143  // temporary treatment!!
144  fDPhi = totphi / nseg;
145  SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
146  CreateSurfaces();
147 }
G4VTwistSurface * fFormerTwisted
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
void SetFields(G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
G4bool fRebuildPolyhedron
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VTwistSurface * fLatterTwisted
G4VTwistSurface * fInnerHype
#define DBL_MIN
Definition: templates.hh:75
G4Polyhedron * fpPolyhedron
#define G4endl
Definition: G4ios.hh:61
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
double G4double
Definition: G4Types.hh:76
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ G4TwistedTubs() [3/6]

G4TwistedTubs::G4TwistedTubs ( const G4String pname,
G4double  twistedangle,
G4double  innerrad,
G4double  outerrad,
G4double  negativeEndz,
G4double  positiveEndz,
G4double  dphi 
)

Definition at line 149 of file G4TwistedTubs.cc.

156  : G4VSolid(pname), fDPhi(dphi),
159  fCubicVolume(0.), fSurfaceArea(0.),
161 {
162  if (innerrad < DBL_MIN)
163  {
164  G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
165  FatalErrorInArgument, "Invalid end-inner-radius!");
166  }
167 
168  SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
169  CreateSurfaces();
170 }
G4VTwistSurface * fFormerTwisted
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
void SetFields(G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
G4bool fRebuildPolyhedron
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VTwistSurface * fLatterTwisted
G4VTwistSurface * fInnerHype
#define DBL_MIN
Definition: templates.hh:75
G4Polyhedron * fpPolyhedron
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ G4TwistedTubs() [4/6]

G4TwistedTubs::G4TwistedTubs ( const G4String pname,
G4double  twistedangle,
G4double  innerrad,
G4double  outerrad,
G4double  negativeEndz,
G4double  positiveEndz,
G4int  nseg,
G4double  totphi 
)

Definition at line 172 of file G4TwistedTubs.cc.

180  : G4VSolid(pname),
183  fCubicVolume(0.), fSurfaceArea(0.),
185 {
186  if (!nseg)
187  {
188  std::ostringstream message;
189  message << "Invalid number of segments." << G4endl
190  << " nseg = " << nseg;
191  G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
192  FatalErrorInArgument, message);
193  }
194  if (totphi == DBL_MIN || innerrad < DBL_MIN)
195  {
196  G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
197  FatalErrorInArgument, "Invalid total-phi or end-inner-radius!");
198  }
199 
200  fDPhi = totphi / nseg;
201  SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
202  CreateSurfaces();
203 }
G4VTwistSurface * fFormerTwisted
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
void SetFields(G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
G4bool fRebuildPolyhedron
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VTwistSurface * fLatterTwisted
G4VTwistSurface * fInnerHype
#define DBL_MIN
Definition: templates.hh:75
G4Polyhedron * fpPolyhedron
#define G4endl
Definition: G4ios.hh:61
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ ~G4TwistedTubs()

G4TwistedTubs::~G4TwistedTubs ( )
virtual

Definition at line 222 of file G4TwistedTubs.cc.

223 {
224  if (fLowerEndcap) { delete fLowerEndcap; }
225  if (fUpperEndcap) { delete fUpperEndcap; }
226  if (fLatterTwisted) { delete fLatterTwisted; }
227  if (fFormerTwisted) { delete fFormerTwisted; }
228  if (fInnerHype) { delete fInnerHype; }
229  if (fOuterHype) { delete fOuterHype; }
230  if (fpPolyhedron) { delete fpPolyhedron; fpPolyhedron = 0; }
231 }
G4VTwistSurface * fFormerTwisted
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
G4VTwistSurface * fLatterTwisted
G4VTwistSurface * fInnerHype
G4Polyhedron * fpPolyhedron
G4VTwistSurface * fLowerEndcap

◆ G4TwistedTubs() [5/6]

G4TwistedTubs::G4TwistedTubs ( __void__ &  a)

Definition at line 208 of file G4TwistedTubs.cc.

209  : G4VSolid(a), fPhiTwist(0.), fInnerRadius(0.), fOuterRadius(0.), fDPhi(0.),
214  fCubicVolume(0.), fSurfaceArea(0.),
216 {
217 }
G4double fZHalfLength
G4double fPhiTwist
G4VTwistSurface * fFormerTwisted
G4VTwistSurface * fUpperEndcap
G4double fInnerRadius
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
G4double fInnerRadius2
G4double fOuterRadius2
G4bool fRebuildPolyhedron
G4VTwistSurface * fLatterTwisted
G4double fOuterRadius
G4VTwistSurface * fInnerHype
G4double fTanOuterStereo
G4double fTanInnerStereo2
G4Polyhedron * fpPolyhedron
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
G4double fTanOuterStereo2
G4double fTanInnerStereo
G4double fInnerStereo
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
G4double fOuterStereo

◆ G4TwistedTubs() [6/6]

G4TwistedTubs::G4TwistedTubs ( const G4TwistedTubs rhs)

Definition at line 236 of file G4TwistedTubs.cc.

237  : G4VSolid(rhs), fPhiTwist(rhs.fPhiTwist),
246  fInnerHype(0), fOuterHype(0),
248  fRebuildPolyhedron(false), fpPolyhedron(0),
254 {
255  for (size_t i=0; i<2; ++i)
256  {
257  fEndZ[i] = rhs.fEndZ[i];
258  fEndInnerRadius[i] = rhs.fEndInnerRadius[i];
259  fEndOuterRadius[i] = rhs.fEndOuterRadius[i];
260  fEndPhi[i] = rhs.fEndPhi[i];
261  fEndZ2[i] = rhs.fEndZ2[i];
262  }
263  CreateSurfaces();
264 }
G4double fZHalfLength
G4double fPhiTwist
G4VTwistSurface * fFormerTwisted
G4double fEndOuterRadius[2]
LastValueWithDoubleVector fLastDistanceToInWithV
LastValue fLastDistanceToIn
G4double fEndInnerRadius[2]
G4VTwistSurface * fUpperEndcap
G4double fEndPhi[2]
G4double fInnerRadius
G4double fEndZ[2]
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
G4double fInnerRadius2
G4double fOuterRadius2
G4bool fRebuildPolyhedron
LastValueWithDoubleVector fLastDistanceToOutWithV
G4double fEndZ2[2]
LastValue fLastDistanceToOut
LastState fLastInside
G4VTwistSurface * fLatterTwisted
G4double fOuterRadius
G4VTwistSurface * fInnerHype
G4double fTanOuterStereo
G4double fTanInnerStereo2
G4Polyhedron * fpPolyhedron
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:60
LastVector fLastNormal
G4double fTanOuterStereo2
G4double fTanInnerStereo
G4double fInnerStereo
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
G4double fOuterStereo
Here is the call graph for this function:

Member Function Documentation

◆ AddPolyToExtent()

void G4TwistedTubs::AddPolyToExtent ( const G4ThreeVector v0,
const G4ThreeVector v1,
const G4ThreeVector w1,
const G4ThreeVector w0,
const G4VoxelLimits voxellimit,
const EAxis  axis,
G4SolidExtentList extentlist 
)
staticprivate

Definition at line 544 of file G4TwistedTubs.cc.

551 {
552  // Utility function for CalculateExtent
553  //
554  G4ClippablePolygon phiPoly;
555 
556  phiPoly.AddVertexInOrder( v0 );
557  phiPoly.AddVertexInOrder( v1 );
558  phiPoly.AddVertexInOrder( w1 );
559  phiPoly.AddVertexInOrder( w0 );
560 
561  if (phiPoly.PartialClip( voxelLimit, axis ))
562  {
563  phiPoly.SetNormal( (v1-v0).cross(w0-v0).unit() );
564  extentList.AddSurface( phiPoly );
565  }
566 }
void SetNormal(const G4ThreeVector &newNormal)
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual void AddVertexInOrder(const G4ThreeVector vertex)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateExtent()

G4bool G4TwistedTubs::CalculateExtent ( const EAxis  paxis,
const G4VoxelLimits pvoxellimit,
const G4AffineTransform ptransform,
G4double pmin,
G4double pmax 
) const
virtual

Implements G4VSolid.

Definition at line 331 of file G4TwistedTubs.cc.

336 {
337 
338  G4SolidExtentList extentList( axis, voxelLimit );
339  G4double maxEndOuterRad = (fEndOuterRadius[0] > fEndOuterRadius[1] ?
341  G4double maxEndInnerRad = (fEndInnerRadius[0] > fEndInnerRadius[1] ?
343  G4double maxphi = (std::fabs(fEndPhi[0]) > std::fabs(fEndPhi[1]) ?
344  std::fabs(fEndPhi[0]) : std::fabs(fEndPhi[1]));
345 
346  //
347  // Choose phi size of our segment(s) based on constants as
348  // defined in meshdefs.hh
349  //
350  // G4int numPhi = kMaxMeshSections;
351  G4double sigPhi = 2*maxphi + fDPhi;
352  G4double rFudge = 1.0/std::cos(0.5*sigPhi);
353  G4double fudgeEndOuterRad = rFudge * maxEndOuterRad;
354 
355  //
356  // We work around in phi building polygons along the way.
357  // As a reasonable compromise between accuracy and
358  // complexity (=cpu time), the following facets are chosen:
359  //
360  // 1. If fOuterRadius/maxEndOuterRad > 0.95, approximate
361  // the outer surface as a cylinder, and use one
362  // rectangular polygon (0-1) to build its mesh.
363  //
364  // Otherwise, use two trapazoidal polygons that
365  // meet at z = 0 (0-4-1)
366  //
367  // 2. If there is no inner surface, then use one
368  // polygon for each entire endcap. (0) and (1)
369  //
370  // Otherwise, use a trapazoidal polygon for each
371  // phi segment of each endcap. (0-2) and (1-3)
372  //
373  // 3. For the inner surface, if fInnerRadius/maxEndInnerRad > 0.95,
374  // approximate the inner surface as a cylinder of
375  // radius fInnerRadius and use one rectangular polygon
376  // to build each phi segment of its mesh. (2-3)
377  //
378  // Otherwise, use one rectangular polygon centered
379  // at z = 0 (5-6) and two connecting trapazoidal polygons
380  // for each phi segment (2-5) and (3-6).
381  //
382 
383  G4bool splitOuter = (fOuterRadius/maxEndOuterRad < 0.95);
384  G4bool splitInner = (fInnerRadius/maxEndInnerRad < 0.95);
385 
386  //
387  // Vertex assignments (v and w arrays)
388  // [0] and [1] are mandatory
389  // the rest are optional
390  //
391  // + -
392  // [0]------[4]------[1] <--- outer radius
393  // | |
394  // | |
395  // [2]---[5]---[6]---[3] <--- inner radius
396  //
397 
398  G4ClippablePolygon endPoly1, endPoly2;
399 
400  G4double phimax = maxphi + 0.5*fDPhi;
401  if ( phimax > pi/2) { phimax = pi-phimax; }
402  G4double phimin = - phimax;
403 
404  G4ThreeVector v0, v1, v2, v3, v4, v5, v6; // -ve phi verticies for polygon
405  G4ThreeVector w0, w1, w2, w3, w4, w5, w6; // +ve phi verticies for polygon
406 
407  //
408  // decide verticies of -ve phi boundary
409  //
410 
411  G4double cosPhi = std::cos(phimin);
412  G4double sinPhi = std::sin(phimin);
413 
414  // Outer hyperbolic surface
415 
416  v0 = transform.TransformPoint(
417  G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
418  + fZHalfLength));
419  v1 = transform.TransformPoint(
420  G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
421  - fZHalfLength));
422  if (splitOuter)
423  {
424  v4 = transform.TransformPoint(
425  G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi, 0));
426  }
427 
428  // Inner hyperbolic surface
429 
430  G4double zInnerSplit = 0.;
431  if (splitInner)
432  {
433  v2 = transform.TransformPoint(
434  G4ThreeVector(maxEndInnerRad*cosPhi, maxEndInnerRad*sinPhi,
435  + fZHalfLength));
436  v3 = transform.TransformPoint(
437  G4ThreeVector(maxEndInnerRad*cosPhi, maxEndInnerRad*sinPhi,
438  - fZHalfLength));
439 
440  // Find intersection of tangential line of inner
441  // surface at z = fZHalfLength and line r=fInnerRadius.
443  G4double dz = maxEndInnerRad;
444  zInnerSplit = fZHalfLength + (fInnerRadius - maxEndInnerRad) * dz / dr;
445 
446  // Build associated vertices
447  v5 = transform.TransformPoint(
448  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
449  + zInnerSplit));
450  v6 = transform.TransformPoint(
451  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
452  - zInnerSplit));
453  }
454  else
455  {
456  v2 = transform.TransformPoint(
457  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
458  + fZHalfLength));
459  v3 = transform.TransformPoint(
460  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
461  - fZHalfLength));
462  }
463 
464  //
465  // decide vertices of +ve phi boundary
466  //
467 
468  cosPhi = std::cos(phimax);
469  sinPhi = std::sin(phimax);
470 
471  // Outer hyperbolic surface
472 
473  w0 = transform.TransformPoint(
474  G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
475  + fZHalfLength));
476  w1 = transform.TransformPoint(
477  G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
478  - fZHalfLength));
479  if (splitOuter)
480  {
481  G4double r = rFudge*fOuterRadius;
482 
483  w4 = transform.TransformPoint(G4ThreeVector( r*cosPhi, r*sinPhi, 0 ));
484 
485  AddPolyToExtent( v0, v4, w4, w0, voxelLimit, axis, extentList );
486  AddPolyToExtent( v4, v1, w1, w4, voxelLimit, axis, extentList );
487  }
488  else
489  {
490  AddPolyToExtent( v0, v1, w1, w0, voxelLimit, axis, extentList );
491  }
492 
493  // Inner hyperbolic surface
494 
495  if (splitInner)
496  {
497  w2 = transform.TransformPoint(
498  G4ThreeVector(maxEndInnerRad*cosPhi, maxEndInnerRad*sinPhi,
499  + fZHalfLength));
500  w3 = transform.TransformPoint(
501  G4ThreeVector(maxEndInnerRad*cosPhi, maxEndInnerRad*sinPhi,
502  - fZHalfLength));
503 
504  w5 = transform.TransformPoint(
505  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
506  + zInnerSplit));
507  w6 = transform.TransformPoint(
508  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
509  - zInnerSplit));
510 
511  AddPolyToExtent( v3, v6, w6, w3, voxelLimit, axis, extentList );
512  AddPolyToExtent( v6, v5, w5, w6, voxelLimit, axis, extentList );
513  AddPolyToExtent( v5, v2, w2, w5, voxelLimit, axis, extentList );
514 
515  }
516  else
517  {
518  w2 = transform.TransformPoint(
519  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
520  + fZHalfLength));
521  w3 = transform.TransformPoint(
522  G4ThreeVector(fInnerRadius*cosPhi, fInnerRadius*sinPhi,
523  - fZHalfLength));
524 
525  AddPolyToExtent( v3, v2, w2, w3, voxelLimit, axis, extentList );
526  }
527 
528  //
529  // Endplate segments
530  //
531  AddPolyToExtent( v1, v3, w3, w1, voxelLimit, axis, extentList );
532  AddPolyToExtent( v2, v0, w0, w2, voxelLimit, axis, extentList );
533 
534  //
535  // Return min/max value
536  //
537  return extentList.GetExtent( min, max );
538 }
G4double fZHalfLength
CLHEP::Hep3Vector G4ThreeVector
static void AddPolyToExtent(const G4ThreeVector &v0, const G4ThreeVector &v1, const G4ThreeVector &w1, const G4ThreeVector &w0, const G4VoxelLimits &voxellimit, const EAxis axis, G4SolidExtentList &extentlist)
G4double fEndOuterRadius[2]
G4double fEndInnerRadius[2]
G4double fEndPhi[2]
G4double fInnerRadius
bool G4bool
Definition: G4Types.hh:79
G4double fOuterRadius
static const double pi
Definition: G4SIunits.hh:74
G4double fTanInnerStereo2
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ Clone()

G4VSolid * G4TwistedTubs::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1222 of file G4TwistedTubs.cc.

1223 {
1224  return new G4TwistedTubs(*this);
1225 }
G4TwistedTubs(const G4String &pname, G4double twistedangle, G4double endinnerrad, G4double endouterrad, G4double halfzlen, G4double dphi)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeDimensions()

void G4TwistedTubs::ComputeDimensions ( G4VPVParameterisation ,
const G4int  ,
const G4VPhysicalVolume  
)
virtual

Reimplemented from G4VSolid.

Definition at line 318 of file G4TwistedTubs.cc.

321 {
322  G4Exception("G4TwistedTubs::ComputeDimensions()",
323  "GeomSolids0001", FatalException,
324  "G4TwistedTubs does not support Parameterisation.");
325 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:

◆ CreatePolyhedron()

G4Polyhedron * G4TwistedTubs::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1098 of file G4TwistedTubs.cc.

1099 {
1100  // number of meshes
1101  //
1103  const G4int k =
1105  const G4int n =
1107 
1108  const G4int nnodes = 4*(k-1)*(n-2) + 2*k*k ;
1109  const G4int nfaces = 4*(k-1)*(n-1) + 2*(k-1)*(k-1) ;
1110 
1111  G4Polyhedron *ph=new G4Polyhedron;
1112  typedef G4double G4double3[3];
1113  typedef G4int G4int4[4];
1114  G4double3* xyz = new G4double3[nnodes]; // number of nodes
1115  G4int4* faces = new G4int4[nfaces] ; // number of faces
1116  fLowerEndcap->GetFacets(k,k,xyz,faces,0) ;
1117  fUpperEndcap->GetFacets(k,k,xyz,faces,1) ;
1118  fInnerHype->GetFacets(k,n,xyz,faces,2) ;
1119  fFormerTwisted->GetFacets(k,n,xyz,faces,3) ;
1120  fOuterHype->GetFacets(k,n,xyz,faces,4) ;
1121  fLatterTwisted->GetFacets(k,n,xyz,faces,5) ;
1122 
1123  ph->createPolyhedron(nnodes,nfaces,xyz,faces);
1124 
1125  delete[] xyz;
1126  delete[] faces;
1127 
1128  return ph;
1129 }
G4double fPhiTwist
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
G4VTwistSurface * fFormerTwisted
int G4int
Definition: G4Types.hh:78
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
Char_t n[5]
static const double twopi
Definition: G4SIunits.hh:75
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
G4VTwistSurface * fLatterTwisted
static G4int GetNumberOfRotationSteps()
G4VTwistSurface * fInnerHype
double G4double
Definition: G4Types.hh:76
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateSurfaces()

void G4TwistedTubs::CreateSurfaces ( )
private

Definition at line 1153 of file G4TwistedTubs.cc.

1154 {
1155  // create 6 surfaces of TwistedTub
1156 
1157  G4ThreeVector x0(0, 0, fEndZ[0]);
1158  G4ThreeVector n (0, 0, -1);
1159 
1160  fLowerEndcap = new G4TwistTubsFlatSide("LowerEndcap",
1162  fDPhi, fEndPhi, fEndZ, -1) ;
1163 
1164  fUpperEndcap = new G4TwistTubsFlatSide("UpperEndcap",
1166  fDPhi, fEndPhi, fEndZ, 1) ;
1167 
1168  G4RotationMatrix rotHalfDPhi;
1169  rotHalfDPhi.rotateZ(0.5*fDPhi);
1170 
1171  fLatterTwisted = new G4TwistTubsSide("LatterTwisted",
1173  fDPhi, fEndPhi, fEndZ,
1175  1 ) ;
1176  fFormerTwisted = new G4TwistTubsSide("FormerTwisted",
1178  fDPhi, fEndPhi, fEndZ,
1180  -1 ) ;
1181 
1182  fInnerHype = new G4TwistTubsHypeSide("InnerHype",
1184  fDPhi, fEndPhi, fEndZ,
1187  fOuterHype = new G4TwistTubsHypeSide("OuterHype",
1189  fDPhi, fEndPhi, fEndZ,
1192 
1193 
1194  // set neighbour surfaces
1195  //
1208 }
G4VTwistSurface * fFormerTwisted
G4double fEndOuterRadius[2]
G4double fEndInnerRadius[2]
G4VTwistSurface * fUpperEndcap
G4double fEndPhi[2]
G4double fInnerRadius
G4double fEndZ[2]
G4VTwistSurface * fOuterHype
Char_t n[5]
void SetNeighbours(G4VTwistSurface *axis0min, G4VTwistSurface *axis1min, G4VTwistSurface *axis0max, G4VTwistSurface *axis1max)
G4VTwistSurface * fLatterTwisted
G4double fOuterRadius
G4VTwistSurface * fInnerHype
G4double fTanOuterStereo
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:92
G4double fTanInnerStereo
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DescribeYourselfTo()

void G4TwistedTubs::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1077 of file G4TwistedTubs.cc.

1078 {
1079  scene.AddSolid (*this);
1080 }
virtual void AddSolid(const G4Box &)=0
Here is the call graph for this function:

◆ DistanceToIn() [1/2]

G4double G4TwistedTubs::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 679 of file G4TwistedTubs.cc.

681 {
682 
683  // DistanceToIn (p, v):
684  // Calculate distance to surface of shape from `outside'
685  // along with the v, allowing for tolerance.
686  // The function returns kInfinity if no intersection or
687  // just grazing within tolerance.
688 
689  //
690  // checking last value
691  //
692 
693  G4ThreeVector *tmpp;
694  G4ThreeVector *tmpv;
695  G4double *tmpdist;
696  if ((fLastDistanceToInWithV.p == p) && (fLastDistanceToInWithV.vec == v))
697  {
698  return fLastDistanceToIn.value;
699  }
700  else
701  {
702  tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.p));
703  tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.vec));
704  tmpdist = const_cast<G4double*>(&(fLastDistanceToInWithV.value));
705  tmpp->set(p.x(), p.y(), p.z());
706  tmpv->set(v.x(), v.y(), v.z());
707  }
708 
709  //
710  // Calculate DistanceToIn(p,v)
711  //
712 
713  EInside currentside = Inside(p);
714 
715  if (currentside == kInside)
716  {
717  }
718  else
719  {
720  if (currentside == kSurface)
721  {
722  // particle is just on a boundary.
723  // If the particle is entering to the volume, return 0.
724  //
726  if (normal*v < 0)
727  {
728  *tmpdist = 0;
730  }
731  }
732  }
733 
734  // now, we can take smallest positive distance.
735 
736  // Initialize
737  //
738  G4double distance = kInfinity;
739 
740  // find intersections and choose nearest one.
741  //
742  G4VTwistSurface *surfaces[6];
743  surfaces[0] = fLowerEndcap;
744  surfaces[1] = fUpperEndcap;
745  surfaces[2] = fLatterTwisted;
746  surfaces[3] = fFormerTwisted;
747  surfaces[4] = fInnerHype;
748  surfaces[5] = fOuterHype;
749 
751  G4ThreeVector bestxx;
752  G4int i;
753  for (i=0; i< 6; i++)
754  {
755  G4double tmpdistance = surfaces[i]->DistanceToIn(p, v, xx);
756  if (tmpdistance < distance)
757  {
758  distance = tmpdistance;
759  bestxx = xx;
760  }
761  }
762  *tmpdist = distance;
763 
765 }
void set(double x, double y, double z)
static const G4double kInfinity
Definition: geomdefs.hh:42
G4VTwistSurface * fFormerTwisted
Double_t xx
LastValueWithDoubleVector fLastDistanceToInWithV
LastValue fLastDistanceToIn
int G4int
Definition: G4Types.hh:78
G4VTwistSurface * fUpperEndcap
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4VTwistSurface * fOuterHype
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
double x() const
G4VTwistSurface * fLatterTwisted
double y() const
EInside
Definition: geomdefs.hh:58
G4VTwistSurface * fInnerHype
double z() const
double G4double
Definition: G4Types.hh:76
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ DistanceToIn() [2/2]

G4double G4TwistedTubs::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 770 of file G4TwistedTubs.cc.

771 {
772  // DistanceToIn(p):
773  // Calculate distance to surface of shape from `outside',
774  // allowing for tolerance
775 
776  //
777  // checking last value
778  //
779 
780  G4ThreeVector *tmpp;
781  G4double *tmpdist;
782  if (fLastDistanceToIn.p == p)
783  {
784  return fLastDistanceToIn.value;
785  }
786  else
787  {
788  tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToIn.p));
789  tmpdist = const_cast<G4double*>(&(fLastDistanceToIn.value));
790  tmpp->set(p.x(), p.y(), p.z());
791  }
792 
793  //
794  // Calculate DistanceToIn(p)
795  //
796 
797  EInside currentside = Inside(p);
798 
799  switch (currentside)
800  {
801  case (kInside) :
802  {}
803  case (kSurface) :
804  {
805  *tmpdist = 0.;
806  return fLastDistanceToIn.value;
807  }
808  case (kOutside) :
809  {
810  // Initialize
811  G4double distance = kInfinity;
812 
813  // find intersections and choose nearest one.
814  G4VTwistSurface *surfaces[6];
815  surfaces[0] = fLowerEndcap;
816  surfaces[1] = fUpperEndcap;
817  surfaces[2] = fLatterTwisted;
818  surfaces[3] = fFormerTwisted;
819  surfaces[4] = fInnerHype;
820  surfaces[5] = fOuterHype;
821 
822  G4int i;
824  G4ThreeVector bestxx;
825  for (i=0; i< 6; i++)
826  {
827  G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
828  if (tmpdistance < distance)
829  {
830  distance = tmpdistance;
831  bestxx = xx;
832  }
833  }
834  *tmpdist = distance;
835  return fLastDistanceToIn.value;
836  }
837  default :
838  {
839  G4Exception("G4TwistedTubs::DistanceToIn(p)", "GeomSolids0003",
840  FatalException, "Unknown point location!");
841  }
842  } // switch end
843 
844  return kInfinity;
845 }
void set(double x, double y, double z)
static const G4double kInfinity
Definition: geomdefs.hh:42
G4VTwistSurface * fFormerTwisted
Double_t xx
LastValue fLastDistanceToIn
int G4int
Definition: G4Types.hh:78
G4VTwistSurface * fUpperEndcap
EInside Inside(const G4ThreeVector &p) const
G4VTwistSurface * fOuterHype
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double x() const
G4VTwistSurface * fLatterTwisted
double y() const
EInside
Definition: geomdefs.hh:58
G4VTwistSurface * fInnerHype
double z() const
double G4double
Definition: G4Types.hh:76
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ DistanceToOut() [1/2]

G4double G4TwistedTubs::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcnorm = G4bool(false),
G4bool validnorm = 0,
G4ThreeVector n = 0 
) const
virtual

Implements G4VSolid.

Definition at line 850 of file G4TwistedTubs.cc.

855 {
856  // DistanceToOut (p, v):
857  // Calculate distance to surface of shape from `inside'
858  // along with the v, allowing for tolerance.
859  // The function returns kInfinity if no intersection or
860  // just grazing within tolerance.
861 
862  //
863  // checking last value
864  //
865 
866  G4ThreeVector *tmpp;
867  G4ThreeVector *tmpv;
868  G4double *tmpdist;
870  {
872  }
873  else
874  {
875  tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.p));
876  tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.vec));
877  tmpdist = const_cast<G4double*>(&(fLastDistanceToOutWithV.value));
878  tmpp->set(p.x(), p.y(), p.z());
879  tmpv->set(v.x(), v.y(), v.z());
880  }
881 
882  //
883  // Calculate DistanceToOut(p,v)
884  //
885 
886  EInside currentside = Inside(p);
887 
888  if (currentside == kOutside)
889  {
890  }
891  else
892  {
893  if (currentside == kSurface)
894  {
895  // particle is just on a boundary.
896  // If the particle is exiting from the volume, return 0.
897  //
899  G4VTwistSurface *blockedsurface = fLastNormal.surface[0];
900  if (normal*v > 0)
901  {
902  if (calcNorm)
903  {
904  *norm = (blockedsurface->GetNormal(p, true));
905  *validNorm = blockedsurface->IsValidNorm();
906  }
907  *tmpdist = 0.;
909  }
910  }
911  }
912 
913  // now, we can take smallest positive distance.
914 
915  // Initialize
916  //
917  G4double distance = kInfinity;
918 
919  // find intersections and choose nearest one.
920  //
921  G4VTwistSurface *surfaces[6];
922  surfaces[0] = fLatterTwisted;
923  surfaces[1] = fFormerTwisted;
924  surfaces[2] = fInnerHype;
925  surfaces[3] = fOuterHype;
926  surfaces[4] = fLowerEndcap;
927  surfaces[5] = fUpperEndcap;
928 
929  G4int i;
930  G4int besti = -1;
932  G4ThreeVector bestxx;
933  for (i=0; i< 6; i++)
934  {
935  G4double tmpdistance = surfaces[i]->DistanceToOut(p, v, xx);
936  if (tmpdistance < distance)
937  {
938  distance = tmpdistance;
939  bestxx = xx;
940  besti = i;
941  }
942  }
943 
944  if (calcNorm)
945  {
946  if (besti != -1)
947  {
948  *norm = (surfaces[besti]->GetNormal(p, true));
949  *validNorm = surfaces[besti]->IsValidNorm();
950  }
951  }
952 
953  *tmpdist = distance;
954 
956 }
void set(double x, double y, double z)
static const G4double kInfinity
Definition: geomdefs.hh:42
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
Float_t norm
G4VTwistSurface * fFormerTwisted
Double_t xx
int G4int
Definition: G4Types.hh:78
G4VTwistSurface * fUpperEndcap
EInside Inside(const G4ThreeVector &p) const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4VTwistSurface * fOuterHype
G4bool IsValidNorm() const
virtual G4double DistanceToOut(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
G4VTwistSurface ** surface
LastValueWithDoubleVector fLastDistanceToOutWithV
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
double x() const
G4VTwistSurface * fLatterTwisted
double y() const
EInside
Definition: geomdefs.hh:58
G4VTwistSurface * fInnerHype
double z() const
LastVector fLastNormal
double G4double
Definition: G4Types.hh:76
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ DistanceToOut() [2/2]

G4double G4TwistedTubs::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 962 of file G4TwistedTubs.cc.

963 {
964  // DistanceToOut(p):
965  // Calculate distance to surface of shape from `inside',
966  // allowing for tolerance
967 
968  //
969  // checking last value
970  //
971 
972  G4ThreeVector *tmpp;
973  G4double *tmpdist;
974  if (fLastDistanceToOut.p == p)
975  {
976  return fLastDistanceToOut.value;
977  }
978  else
979  {
980  tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOut.p));
981  tmpdist = const_cast<G4double*>(&(fLastDistanceToOut.value));
982  tmpp->set(p.x(), p.y(), p.z());
983  }
984 
985  //
986  // Calculate DistanceToOut(p)
987  //
988 
989  EInside currentside = Inside(p);
990 
991  switch (currentside)
992  {
993  case (kOutside) :
994  {
995  }
996  case (kSurface) :
997  {
998  *tmpdist = 0.;
999  return fLastDistanceToOut.value;
1000  }
1001  case (kInside) :
1002  {
1003  // Initialize
1004  G4double distance = kInfinity;
1005 
1006  // find intersections and choose nearest one.
1007  G4VTwistSurface *surfaces[6];
1008  surfaces[0] = fLatterTwisted;
1009  surfaces[1] = fFormerTwisted;
1010  surfaces[2] = fInnerHype;
1011  surfaces[3] = fOuterHype;
1012  surfaces[4] = fLowerEndcap;
1013  surfaces[5] = fUpperEndcap;
1014 
1015  G4int i;
1016  G4ThreeVector xx;
1017  G4ThreeVector bestxx;
1018  for (i=0; i< 6; i++)
1019  {
1020  G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
1021  if (tmpdistance < distance)
1022  {
1023  distance = tmpdistance;
1024  bestxx = xx;
1025  }
1026  }
1027  *tmpdist = distance;
1028 
1029  return fLastDistanceToOut.value;
1030  }
1031  default :
1032  {
1033  G4Exception("G4TwistedTubs::DistanceToOut(p)", "GeomSolids0003",
1034  FatalException, "Unknown point location!");
1035  }
1036  } // switch end
1037 
1038  return 0;
1039 }
void set(double x, double y, double z)
static const G4double kInfinity
Definition: geomdefs.hh:42
G4VTwistSurface * fFormerTwisted
Double_t xx
int G4int
Definition: G4Types.hh:78
G4VTwistSurface * fUpperEndcap
EInside Inside(const G4ThreeVector &p) const
G4VTwistSurface * fOuterHype
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double x() const
LastValue fLastDistanceToOut
G4VTwistSurface * fLatterTwisted
double y() const
EInside
Definition: geomdefs.hh:58
G4VTwistSurface * fInnerHype
double z() const
double G4double
Definition: G4Types.hh:76
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:

◆ GetCubicVolume()

G4double G4TwistedTubs::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1230 of file G4TwistedTubs.cc.

1231 {
1232  if(fCubicVolume != 0.) {;}
1235  return fCubicVolume;
1236 }
G4double fZHalfLength
G4double fInnerRadius
G4double fOuterRadius
G4double fCubicVolume
Here is the caller graph for this function:

◆ GetDPhi()

G4double G4TwistedTubs::GetDPhi ( ) const
inline

Definition at line 138 of file G4TwistedTubs.hh.

138 { return fDPhi ; }
Here is the caller graph for this function:

◆ GetEndInnerRadius() [1/2]

G4double G4TwistedTubs::GetEndInnerRadius ( G4int  i) const
inline

Definition at line 154 of file G4TwistedTubs.hh.

155  { return fEndInnerRadius[i]; }
G4double fEndInnerRadius[2]

◆ GetEndInnerRadius() [2/2]

G4double G4TwistedTubs::GetEndInnerRadius ( ) const
inline

Definition at line 158 of file G4TwistedTubs.hh.

159  { return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
160  fEndInnerRadius[0] : fEndInnerRadius[1]); }
G4double fEndInnerRadius[2]
Here is the caller graph for this function:

◆ GetEndOuterRadius() [1/2]

G4double G4TwistedTubs::GetEndOuterRadius ( G4int  i) const
inline

Definition at line 156 of file G4TwistedTubs.hh.

157  { return fEndOuterRadius[i]; }
G4double fEndOuterRadius[2]

◆ GetEndOuterRadius() [2/2]

G4double G4TwistedTubs::GetEndOuterRadius ( ) const
inline

Definition at line 161 of file G4TwistedTubs.hh.

162  { return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
163  fEndOuterRadius[0] : fEndOuterRadius[1]); }
G4double fEndOuterRadius[2]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEndPhi()

G4double G4TwistedTubs::GetEndPhi ( G4int  i) const
inline

Definition at line 153 of file G4TwistedTubs.hh.

153 { return fEndPhi[i]; }
G4double fEndPhi[2]
Here is the caller graph for this function:

◆ GetEndZ()

G4double G4TwistedTubs::GetEndZ ( G4int  i) const
inline

Definition at line 152 of file G4TwistedTubs.hh.

152 { return fEndZ[i] ; }
G4double fEndZ[2]
Here is the caller graph for this function:

◆ GetEntityType()

G4GeometryType G4TwistedTubs::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 1214 of file G4TwistedTubs.cc.

1215 {
1216  return G4String("G4TwistedTubs");
1217 }
Here is the caller graph for this function:

◆ GetExtent()

G4VisExtent G4TwistedTubs::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1085 of file G4TwistedTubs.cc.

1086 {
1087  // Define the sides of the box into which the G4Tubs instance would fit.
1088 
1089  G4double maxEndOuterRad = (fEndOuterRadius[0] > fEndOuterRadius[1] ? 0 : 1);
1090  return G4VisExtent( -maxEndOuterRad, maxEndOuterRad,
1091  -maxEndOuterRad, maxEndOuterRad,
1093 }
G4double fZHalfLength
G4double fEndOuterRadius[2]
double G4double
Definition: G4Types.hh:76
Here is the caller graph for this function:

◆ GetInnerRadius()

G4double G4TwistedTubs::GetInnerRadius ( ) const
inline

Definition at line 140 of file G4TwistedTubs.hh.

140 { return fInnerRadius; }
G4double fInnerRadius
Here is the caller graph for this function:

◆ GetInnerStereo()

G4double G4TwistedTubs::GetInnerStereo ( ) const
inline

Definition at line 142 of file G4TwistedTubs.hh.

142 { return fInnerStereo; }
G4double fInnerStereo
Here is the caller graph for this function:

◆ GetKappa()

G4double G4TwistedTubs::GetKappa ( ) const
inline

Definition at line 145 of file G4TwistedTubs.hh.

145 { return fKappa ; }
Here is the caller graph for this function:

◆ GetOuterRadius()

G4double G4TwistedTubs::GetOuterRadius ( ) const
inline

Definition at line 141 of file G4TwistedTubs.hh.

141 { return fOuterRadius; }
G4double fOuterRadius
Here is the caller graph for this function:

◆ GetOuterStereo()

G4double G4TwistedTubs::GetOuterStereo ( ) const
inline

Definition at line 143 of file G4TwistedTubs.hh.

143 { return fOuterStereo; }
G4double fOuterStereo
Here is the caller graph for this function:

◆ GetPhiTwist()

G4double G4TwistedTubs::GetPhiTwist ( ) const
inline

Definition at line 139 of file G4TwistedTubs.hh.

139 { return fPhiTwist ; }
G4double fPhiTwist
Here is the caller graph for this function:

◆ GetPointOnSurface()

G4ThreeVector G4TwistedTubs::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1251 of file G4TwistedTubs.cc.

1252 {
1253 
1255  G4double phi , phimin, phimax ;
1256  G4double x , xmin, xmax ;
1257  G4double r , rmin, rmax ;
1258 
1265 
1266  G4double chose = G4RandFlat::shoot(0.,a1 + a2 + a3 + a4 + a5 + a6) ;
1267 
1268  if(chose < a1)
1269  {
1270 
1271  phimin = fOuterHype->GetBoundaryMin(z) ;
1272  phimax = fOuterHype->GetBoundaryMax(z) ;
1273  phi = G4RandFlat::shoot(phimin,phimax) ;
1274 
1275  return fOuterHype->SurfacePoint(phi,z,true) ;
1276 
1277  }
1278  else if ( (chose >= a1) && (chose < a1 + a2 ) )
1279  {
1280 
1281  phimin = fInnerHype->GetBoundaryMin(z) ;
1282  phimax = fInnerHype->GetBoundaryMax(z) ;
1283  phi = G4RandFlat::shoot(phimin,phimax) ;
1284 
1285  return fInnerHype->SurfacePoint(phi,z,true) ;
1286 
1287  }
1288  else if ( (chose >= a1 + a2 ) && (chose < a1 + a2 + a3 ) )
1289  {
1290 
1291  xmin = fLatterTwisted->GetBoundaryMin(z) ;
1292  xmax = fLatterTwisted->GetBoundaryMax(z) ;
1293  x = G4RandFlat::shoot(xmin,xmax) ;
1294 
1295  return fLatterTwisted->SurfacePoint(x,z,true) ;
1296 
1297  }
1298  else if ( (chose >= a1 + a2 + a3 ) && (chose < a1 + a2 + a3 + a4 ) )
1299  {
1300 
1301  xmin = fFormerTwisted->GetBoundaryMin(z) ;
1302  xmax = fFormerTwisted->GetBoundaryMax(z) ;
1303  x = G4RandFlat::shoot(xmin,xmax) ;
1304 
1305  return fFormerTwisted->SurfacePoint(x,z,true) ;
1306  }
1307  else if( (chose >= a1 + a2 + a3 + a4 )&&(chose < a1 + a2 + a3 + a4 + a5 ) )
1308  {
1309  rmin = GetEndInnerRadius(0) ;
1310  rmax = GetEndOuterRadius(0) ;
1311  r = std::sqrt(G4RandFlat::shoot()*(sqr(rmax)-sqr(rmin))+sqr(rmin));
1312 
1313  phimin = fLowerEndcap->GetBoundaryMin(r) ;
1314  phimax = fLowerEndcap->GetBoundaryMax(r) ;
1315  phi = G4RandFlat::shoot(phimin,phimax) ;
1316 
1317  return fLowerEndcap->SurfacePoint(phi,r,true) ;
1318  }
1319  else
1320  {
1321  rmin = GetEndInnerRadius(1) ;
1322  rmax = GetEndOuterRadius(1) ;
1323  r = rmin + (rmax-rmin)*std::sqrt(G4RandFlat::shoot());
1324 
1325  phimin = fUpperEndcap->GetBoundaryMin(r) ;
1326  phimax = fUpperEndcap->GetBoundaryMax(r) ;
1327  phi = G4RandFlat::shoot(phimin,phimax) ;
1328 
1329  return fUpperEndcap->SurfacePoint(phi,r,true) ;
1330  }
1331 }
ThreeVector shoot(const G4int Ap, const G4int Af)
static const G4double a1
G4VTwistSurface * fFormerTwisted
static const G4double a4
G4VTwistSurface * fUpperEndcap
G4double fEndZ[2]
G4VTwistSurface * fOuterHype
virtual G4double GetSurfaceArea()=0
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)=0
G4double GetEndInnerRadius() const
virtual G4double GetBoundaryMax(G4double)=0
static const G4double a3
virtual G4double GetBoundaryMin(G4double)=0
G4VTwistSurface * fLatterTwisted
G4VTwistSurface * fInnerHype
T sqr(const T &x)
Definition: templates.hh:145
static const G4double a5
double G4double
Definition: G4Types.hh:76
G4double GetEndOuterRadius() const
G4VTwistSurface * fLowerEndcap
static const G4double a2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPolyhedron()

G4Polyhedron * G4TwistedTubs::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1134 of file G4TwistedTubs.cc.

1135 {
1136  if (!fpPolyhedron ||
1140  {
1141  G4AutoLock l(&polyhedronMutex);
1142  delete fpPolyhedron;
1144  fRebuildPolyhedron = false;
1145  l.unlock();
1146  }
1147  return fpPolyhedron;
1148 }
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4bool fRebuildPolyhedron
static G4int GetNumberOfRotationSteps()
G4Polyhedron * CreatePolyhedron() const
G4Polyhedron * fpPolyhedron
Here is the call graph for this function:

◆ GetSurfaceArea()

G4double G4TwistedTubs::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1241 of file G4TwistedTubs.cc.

1242 {
1243  if(fSurfaceArea != 0.) {;}
1245  return fSurfaceArea;
1246 }
G4double fSurfaceArea
virtual G4double GetSurfaceArea()
Definition: G4VSolid.cc:250
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTanInnerStereo()

G4double G4TwistedTubs::GetTanInnerStereo ( ) const
inline

Definition at line 147 of file G4TwistedTubs.hh.

147 { return fTanInnerStereo ; }
G4double fTanInnerStereo
Here is the caller graph for this function:

◆ GetTanInnerStereo2()

G4double G4TwistedTubs::GetTanInnerStereo2 ( ) const
inline

Definition at line 148 of file G4TwistedTubs.hh.

148 { return fTanInnerStereo2 ; }
G4double fTanInnerStereo2
Here is the caller graph for this function:

◆ GetTanOuterStereo()

G4double G4TwistedTubs::GetTanOuterStereo ( ) const
inline

Definition at line 149 of file G4TwistedTubs.hh.

149 { return fTanOuterStereo ; }
G4double fTanOuterStereo
Here is the caller graph for this function:

◆ GetTanOuterStereo2()

G4double G4TwistedTubs::GetTanOuterStereo2 ( ) const
inline

Definition at line 150 of file G4TwistedTubs.hh.

150 { return fTanOuterStereo2 ; }
G4double fTanOuterStereo2
Here is the caller graph for this function:

◆ GetZHalfLength()

G4double G4TwistedTubs::GetZHalfLength ( ) const
inline

Definition at line 144 of file G4TwistedTubs.hh.

144 { return fZHalfLength; }
G4double fZHalfLength
Here is the caller graph for this function:

◆ Inside()

EInside G4TwistedTubs::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 572 of file G4TwistedTubs.cc.

573 {
574 
575  const G4double halftol
577  // static G4int timerid = -1;
578  // G4Timer timer(timerid, "G4TwistedTubs", "Inside");
579  // timer.Start();
580 
581  G4ThreeVector *tmpp;
582  EInside *tmpinside;
583  if (fLastInside.p == p)
584  {
585  return fLastInside.inside;
586  }
587  else
588  {
589  tmpp = const_cast<G4ThreeVector*>(&(fLastInside.p));
590  tmpinside = const_cast<EInside*>(&(fLastInside.inside));
591  tmpp->set(p.x(), p.y(), p.z());
592  }
593 
594  EInside outerhypearea = ((G4TwistTubsHypeSide *)fOuterHype)->Inside(p);
595  G4double innerhyperho = ((G4TwistTubsHypeSide *)fInnerHype)->GetRhoAtPZ(p);
596  G4double distanceToOut = p.getRho() - innerhyperho; // +ve: inside
597 
598  if ((outerhypearea == kOutside) || (distanceToOut < -halftol))
599  {
600  *tmpinside = kOutside;
601  }
602  else if (outerhypearea == kSurface)
603  {
604  *tmpinside = kSurface;
605  }
606  else
607  {
608  if (distanceToOut <= halftol)
609  {
610  *tmpinside = kSurface;
611  }
612  else
613  {
614  *tmpinside = kInside;
615  }
616  }
617 
618  return fLastInside.inside;
619 }
void set(double x, double y, double z)
G4VTwistSurface * fOuterHype
G4double GetRadialTolerance() const
double x() const
LastState fLastInside
double y() const
EInside
Definition: geomdefs.hh:58
G4VTwistSurface * fInnerHype
double z() const
double getRho() const
double G4double
Definition: G4Types.hh:76
static G4GeometryTolerance * GetInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

G4TwistedTubs & G4TwistedTubs::operator= ( const G4TwistedTubs rhs)

Definition at line 270 of file G4TwistedTubs.cc.

271 {
272  // Check assignment to self
273  //
274  if (this == &rhs) { return *this; }
275 
276  // Copy base class data
277  //
278  G4VSolid::operator=(rhs);
279 
280  // Copy data
281  //
282  fPhiTwist= rhs.fPhiTwist;
298 
299  for (size_t i=0; i<2; ++i)
300  {
301  fEndZ[i] = rhs.fEndZ[i];
302  fEndInnerRadius[i] = rhs.fEndInnerRadius[i];
303  fEndOuterRadius[i] = rhs.fEndOuterRadius[i];
304  fEndPhi[i] = rhs.fEndPhi[i];
305  fEndZ2[i] = rhs.fEndZ2[i];
306  }
307 
308  CreateSurfaces();
309  fRebuildPolyhedron = false;
310  delete fpPolyhedron; fpPolyhedron = 0;
311 
312  return *this;
313 }
G4double fZHalfLength
G4double fPhiTwist
G4VTwistSurface * fFormerTwisted
G4double fEndOuterRadius[2]
LastValueWithDoubleVector fLastDistanceToInWithV
LastValue fLastDistanceToIn
G4double fEndInnerRadius[2]
G4VTwistSurface * fUpperEndcap
G4double fEndPhi[2]
G4double fInnerRadius
G4double fEndZ[2]
G4VTwistSurface * fOuterHype
G4double fSurfaceArea
G4double fInnerRadius2
G4double fOuterRadius2
G4bool fRebuildPolyhedron
LastValueWithDoubleVector fLastDistanceToOutWithV
G4double fEndZ2[2]
LastValue fLastDistanceToOut
LastState fLastInside
G4VTwistSurface * fLatterTwisted
G4double fOuterRadius
G4VTwistSurface * fInnerHype
G4double fTanOuterStereo
G4double fTanInnerStereo2
G4Polyhedron * fpPolyhedron
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:110
LastVector fLastNormal
G4double fTanOuterStereo2
G4double fTanInnerStereo
G4double fInnerStereo
G4double fCubicVolume
G4VTwistSurface * fLowerEndcap
G4double fOuterStereo
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFields()

void G4TwistedTubs::SetFields ( G4double  phitwist,
G4double  innerrad,
G4double  outerrad,
G4double  negativeEndz,
G4double  positiveEndz 
)
inlineprivate

Definition at line 359 of file G4TwistedTubs.hh.

362 {
363  fCubicVolume = 0.;
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;
373 
374  if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1])) {
375  fZHalfLength = std::fabs(fEndZ[0]);
376  } else {
377  fZHalfLength = std::fabs(fEndZ[1]);
378  }
379 
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;
384 
385  fTanInnerStereo = innerNumerator / fZHalfLength;
386  fTanOuterStereo = outerNumerator / fZHalfLength;
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);
395 
396  fKappa = tanHalfTwist / fZHalfLength;
397  fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
398  fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
399 
400 #ifdef G4TWISTDEBUG
401  G4cout << "/********* G4TwistedTubs::SetFields() Field Parameters ***************** " << G4endl;
402  G4cout << "/* fPhiTwist : " << fPhiTwist << 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;
413 #endif
414 }
G4double fZHalfLength
G4double fPhiTwist
G4double fEndOuterRadius[2]
static int parity(int x)
G4double fEndInnerRadius[2]
G4double fEndPhi[2]
G4double fInnerRadius
G4double fEndZ[2]
G4double fInnerRadius2
G4GLOB_DLL std::ostream G4cout
G4double fOuterRadius2
G4double fEndZ2[2]
G4double fOuterRadius
G4double fTanOuterStereo
G4double fTanInnerStereo2
#define G4endl
Definition: G4ios.hh:61
G4double fTanOuterStereo2
G4double fTanInnerStereo
double G4double
Definition: G4Types.hh:76
G4double fInnerStereo
G4double fCubicVolume
G4double fOuterStereo
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StreamInfo()

std::ostream & G4TwistedTubs::StreamInfo ( std::ostream &  os) const
virtual

Implements G4VSolid.

Definition at line 1044 of file G4TwistedTubs.cc.

1045 {
1046  //
1047  // Stream object contents to an output stream
1048  //
1049  G4int oldprc = os.precision(16);
1050  os << "-----------------------------------------------------------\n"
1051  << " *** Dump for solid - " << GetName() << " ***\n"
1052  << " ===================================================\n"
1053  << " Solid type: G4TwistedTubs\n"
1054  << " Parameters: \n"
1055  << " -ve end Z : " << fEndZ[0]/mm << " mm \n"
1056  << " +ve end Z : " << fEndZ[1]/mm << " mm \n"
1057  << " inner end radius(-ve z): " << fEndInnerRadius[0]/mm << " mm \n"
1058  << " inner end radius(+ve z): " << fEndInnerRadius[1]/mm << " mm \n"
1059  << " outer end radius(-ve z): " << fEndOuterRadius[0]/mm << " mm \n"
1060  << " outer end radius(+ve z): " << fEndOuterRadius[1]/mm << " mm \n"
1061  << " inner radius (z=0) : " << fInnerRadius/mm << " mm \n"
1062  << " outer radius (z=0) : " << fOuterRadius/mm << " mm \n"
1063  << " twisted angle : " << fPhiTwist/degree << " degrees \n"
1064  << " inner stereo angle : " << fInnerStereo/degree << " degrees \n"
1065  << " outer stereo angle : " << fOuterStereo/degree << " degrees \n"
1066  << " phi-width of a piece : " << fDPhi/degree << " degrees \n"
1067  << "-----------------------------------------------------------\n";
1068  os.precision(oldprc);
1069 
1070  return os;
1071 }
G4double fPhiTwist
G4double fEndOuterRadius[2]
int G4int
Definition: G4Types.hh:78
G4double fEndInnerRadius[2]
G4String GetName() const
G4double fInnerRadius
G4double fEndZ[2]
G4double fOuterRadius
static const double degree
Definition: G4SIunits.hh:143
G4double fInnerStereo
static const double mm
Definition: G4SIunits.hh:114
G4double fOuterStereo
Here is the call graph for this function:

◆ SurfaceNormal()

G4ThreeVector G4TwistedTubs::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 624 of file G4TwistedTubs.cc.

625 {
626  //
627  // return the normal unit vector to the Hyperbolical Surface at a point
628  // p on (or nearly on) the surface
629  //
630  // Which of the three or four surfaces are we closest to?
631  //
632 
633  if (fLastNormal.p == p)
634  {
635  return fLastNormal.vec;
636  }
637  G4ThreeVector *tmpp =
638  const_cast<G4ThreeVector*>(&(fLastNormal.p));
639  G4ThreeVector *tmpnormal =
640  const_cast<G4ThreeVector*>(&(fLastNormal.vec));
641  G4VTwistSurface **tmpsurface =
642  const_cast<G4VTwistSurface**>(fLastNormal.surface);
643  tmpp->set(p.x(), p.y(), p.z());
644 
645  G4double distance = kInfinity;
646 
647  G4VTwistSurface *surfaces[6];
648  surfaces[0] = fLatterTwisted;
649  surfaces[1] = fFormerTwisted;
650  surfaces[2] = fInnerHype;
651  surfaces[3] = fOuterHype;
652  surfaces[4] = fLowerEndcap;
653  surfaces[5] = fUpperEndcap;
654 
656  G4ThreeVector bestxx;
657  G4int i;
658  G4int besti = -1;
659  for (i=0; i< 6; i++)
660  {
661  G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
662  if (tmpdistance < distance)
663  {
664  distance = tmpdistance;
665  bestxx = xx;
666  besti = i;
667  }
668  }
669 
670  tmpsurface[0] = surfaces[besti];
671  *tmpnormal = tmpsurface[0]->GetNormal(bestxx, true);
672 
673  return fLastNormal.vec;
674 }
void set(double x, double y, double z)
static const G4double kInfinity
Definition: geomdefs.hh:42
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
G4VTwistSurface * fFormerTwisted
Double_t xx
int G4int
Definition: G4Types.hh:78
G4VTwistSurface * fUpperEndcap
G4VTwistSurface * fOuterHype
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
G4VTwistSurface ** surface
double x() const
G4VTwistSurface * fLatterTwisted
double y() const
G4VTwistSurface * fInnerHype
double z() const
LastVector fLastNormal
double G4double
Definition: G4Types.hh:76
G4VTwistSurface * fLowerEndcap
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fCubicVolume

G4double G4TwistedTubs::fCubicVolume
private

Definition at line 239 of file G4TwistedTubs.hh.

◆ fDPhi

G4double G4TwistedTubs::fDPhi
private

Definition at line 214 of file G4TwistedTubs.hh.

◆ fEndInnerRadius

G4double G4TwistedTubs::fEndInnerRadius[2]
private

Definition at line 222 of file G4TwistedTubs.hh.

◆ fEndOuterRadius

G4double G4TwistedTubs::fEndOuterRadius[2]
private

Definition at line 223 of file G4TwistedTubs.hh.

◆ fEndPhi

G4double G4TwistedTubs::fEndPhi[2]
private

Definition at line 224 of file G4TwistedTubs.hh.

◆ fEndZ

G4double G4TwistedTubs::fEndZ[2]
private

Definition at line 213 of file G4TwistedTubs.hh.

◆ fEndZ2

G4double G4TwistedTubs::fEndZ2[2]
private

Definition at line 230 of file G4TwistedTubs.hh.

◆ fFormerTwisted

G4VTwistSurface* G4TwistedTubs::fFormerTwisted
private

Definition at line 235 of file G4TwistedTubs.hh.

◆ fInnerHype

G4VTwistSurface* G4TwistedTubs::fInnerHype
private

Definition at line 236 of file G4TwistedTubs.hh.

◆ fInnerRadius

G4double G4TwistedTubs::fInnerRadius
private

Definition at line 211 of file G4TwistedTubs.hh.

◆ fInnerRadius2

G4double G4TwistedTubs::fInnerRadius2
private

Definition at line 226 of file G4TwistedTubs.hh.

◆ fInnerStereo

G4double G4TwistedTubs::fInnerStereo
private

Definition at line 217 of file G4TwistedTubs.hh.

◆ fKappa

G4double G4TwistedTubs::fKappa
private

Definition at line 221 of file G4TwistedTubs.hh.

◆ fLastDistanceToIn

LastValue G4TwistedTubs::fLastDistanceToIn
private

Definition at line 345 of file G4TwistedTubs.hh.

◆ fLastDistanceToInWithV

LastValueWithDoubleVector G4TwistedTubs::fLastDistanceToInWithV
private

Definition at line 347 of file G4TwistedTubs.hh.

◆ fLastDistanceToOut

LastValue G4TwistedTubs::fLastDistanceToOut
private

Definition at line 346 of file G4TwistedTubs.hh.

◆ fLastDistanceToOutWithV

LastValueWithDoubleVector G4TwistedTubs::fLastDistanceToOutWithV
private

Definition at line 348 of file G4TwistedTubs.hh.

◆ fLastInside

LastState G4TwistedTubs::fLastInside
private

Definition at line 343 of file G4TwistedTubs.hh.

◆ fLastNormal

LastVector G4TwistedTubs::fLastNormal
private

Definition at line 344 of file G4TwistedTubs.hh.

◆ fLatterTwisted

G4VTwistSurface* G4TwistedTubs::fLatterTwisted
private

Definition at line 234 of file G4TwistedTubs.hh.

◆ fLowerEndcap

G4VTwistSurface* G4TwistedTubs::fLowerEndcap
private

Definition at line 232 of file G4TwistedTubs.hh.

◆ fOuterHype

G4VTwistSurface* G4TwistedTubs::fOuterHype
private

Definition at line 237 of file G4TwistedTubs.hh.

◆ fOuterRadius

G4double G4TwistedTubs::fOuterRadius
private

Definition at line 212 of file G4TwistedTubs.hh.

◆ fOuterRadius2

G4double G4TwistedTubs::fOuterRadius2
private

Definition at line 227 of file G4TwistedTubs.hh.

◆ fOuterStereo

G4double G4TwistedTubs::fOuterStereo
private

Definition at line 218 of file G4TwistedTubs.hh.

◆ fPhiTwist

G4double G4TwistedTubs::fPhiTwist
private

Definition at line 210 of file G4TwistedTubs.hh.

◆ fpPolyhedron

G4Polyhedron* G4TwistedTubs::fpPolyhedron
mutableprivate

Definition at line 243 of file G4TwistedTubs.hh.

◆ fRebuildPolyhedron

G4bool G4TwistedTubs::fRebuildPolyhedron
mutableprivate

Definition at line 242 of file G4TwistedTubs.hh.

◆ fSurfaceArea

G4double G4TwistedTubs::fSurfaceArea
private

Definition at line 240 of file G4TwistedTubs.hh.

◆ fTanInnerStereo

G4double G4TwistedTubs::fTanInnerStereo
private

Definition at line 219 of file G4TwistedTubs.hh.

◆ fTanInnerStereo2

G4double G4TwistedTubs::fTanInnerStereo2
private

Definition at line 228 of file G4TwistedTubs.hh.

◆ fTanOuterStereo

G4double G4TwistedTubs::fTanOuterStereo
private

Definition at line 220 of file G4TwistedTubs.hh.

◆ fTanOuterStereo2

G4double G4TwistedTubs::fTanOuterStereo2
private

Definition at line 229 of file G4TwistedTubs.hh.

◆ fUpperEndcap

G4VTwistSurface* G4TwistedTubs::fUpperEndcap
private

Definition at line 233 of file G4TwistedTubs.hh.

◆ fZHalfLength

G4double G4TwistedTubs::fZHalfLength
private

Definition at line 215 of file G4TwistedTubs.hh.


The documentation for this class was generated from the following files: