Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TwistedTubs Class Reference

#include <G4TwistedTubs.hh>

+ Inheritance diagram for G4TwistedTubs:

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 *)
 
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
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=false, G4bool *validnorm=nullptr, G4ThreeVector *n=nullptr) 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
 
virtual void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
 
virtual EInside Inside (const G4ThreeVector &p) const =0
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const =0
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
virtual G4double GetCubicVolume ()
 
virtual G4double GetSurfaceArea ()
 
virtual G4GeometryType GetEntityType () const =0
 
virtual G4ThreeVector GetPointOnSurface () const
 
virtual G4VSolidClone () const
 
virtual std::ostream & StreamInfo (std::ostream &os) const =0
 
void DumpInfo () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const =0
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual G4PolyhedronGetPolyhedron () 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
 

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 55 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 62 of file G4TwistedTubs.cc.

68 : G4VSolid(pname), fDPhi(dphi),
69 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
70 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
71{
72 if (endinnerrad < DBL_MIN)
73 {
74 G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
75 FatalErrorInArgument, "Invalid end-inner-radius!");
76 }
77
78 G4double sinhalftwist = std::sin(0.5 * twistedangle);
79
80 G4double endinnerradX = endinnerrad * sinhalftwist;
81 G4double innerrad = std::sqrt( endinnerrad * endinnerrad
82 - endinnerradX * endinnerradX );
83
84 G4double endouterradX = endouterrad * sinhalftwist;
85 G4double outerrad = std::sqrt( endouterrad * endouterrad
86 - endouterradX * endouterradX );
87
88 // temporary treatment!!
89 SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
90 CreateSurfaces();
91}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
#define DBL_MIN
Definition: templates.hh:54

◆ G4TwistedTubs() [2/6]

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

Definition at line 93 of file G4TwistedTubs.cc.

100 : G4VSolid(pname),
101 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
102 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
103{
104
105 if (!nseg)
106 {
107 std::ostringstream message;
108 message << "Invalid number of segments." << G4endl
109 << " nseg = " << nseg;
110 G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
111 FatalErrorInArgument, message);
112 }
113 if (totphi == DBL_MIN || endinnerrad < DBL_MIN)
114 {
115 G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
116 FatalErrorInArgument, "Invalid total-phi or end-inner-radius!");
117 }
118
119 G4double sinhalftwist = std::sin(0.5 * twistedangle);
120
121 G4double endinnerradX = endinnerrad * sinhalftwist;
122 G4double innerrad = std::sqrt( endinnerrad * endinnerrad
123 - endinnerradX * endinnerradX );
124
125 G4double endouterradX = endouterrad * sinhalftwist;
126 G4double outerrad = std::sqrt( endouterrad * endouterrad
127 - endouterradX * endouterradX );
128
129 // temporary treatment!!
130 fDPhi = totphi / nseg;
131 SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
132 CreateSurfaces();
133}
#define G4endl
Definition: G4ios.hh:57

◆ G4TwistedTubs() [3/6]

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

Definition at line 135 of file G4TwistedTubs.cc.

142 : G4VSolid(pname), fDPhi(dphi),
143 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
144 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
145{
146 if (innerrad < DBL_MIN)
147 {
148 G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
149 FatalErrorInArgument, "Invalid end-inner-radius!");
150 }
151
152 SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
153 CreateSurfaces();
154}

◆ 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 156 of file G4TwistedTubs.cc.

164 : G4VSolid(pname),
165 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
166 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
167{
168 if (!nseg)
169 {
170 std::ostringstream message;
171 message << "Invalid number of segments." << G4endl
172 << " nseg = " << nseg;
173 G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
174 FatalErrorInArgument, message);
175 }
176 if (totphi == DBL_MIN || innerrad < DBL_MIN)
177 {
178 G4Exception("G4TwistedTubs::G4TwistedTubs()", "GeomSolids0002",
179 FatalErrorInArgument, "Invalid total-phi or end-inner-radius!");
180 }
181
182 fDPhi = totphi / nseg;
183 SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
184 CreateSurfaces();
185}

◆ ~G4TwistedTubs()

G4TwistedTubs::~G4TwistedTubs ( )
virtual

Definition at line 202 of file G4TwistedTubs.cc.

203{
204 if (fLowerEndcap) { delete fLowerEndcap; }
205 if (fUpperEndcap) { delete fUpperEndcap; }
206 if (fLatterTwisted) { delete fLatterTwisted; }
207 if (fFormerTwisted) { delete fFormerTwisted; }
208 if (fInnerHype) { delete fInnerHype; }
209 if (fOuterHype) { delete fOuterHype; }
210 if (fpPolyhedron) { delete fpPolyhedron; fpPolyhedron = nullptr; }
211}

◆ G4TwistedTubs() [5/6]

G4TwistedTubs::G4TwistedTubs ( __void__ &  a)

Definition at line 190 of file G4TwistedTubs.cc.

191 : G4VSolid(a), fPhiTwist(0.), fInnerRadius(0.), fOuterRadius(0.), fDPhi(0.),
192 fZHalfLength(0.), fInnerStereo(0.), fOuterStereo(0.), fTanInnerStereo(0.),
193 fTanOuterStereo(0.), fKappa(0.), fInnerRadius2(0.), fOuterRadius2(0.),
194 fTanInnerStereo2(0.), fTanOuterStereo2(0.), fLowerEndcap(0), fUpperEndcap(0),
195 fLatterTwisted(0), fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
196{
197}

◆ G4TwistedTubs() [6/6]

G4TwistedTubs::G4TwistedTubs ( const G4TwistedTubs rhs)

Definition at line 216 of file G4TwistedTubs.cc.

217 : G4VSolid(rhs), fPhiTwist(rhs.fPhiTwist),
218 fInnerRadius(rhs.fInnerRadius), fOuterRadius(rhs.fOuterRadius),
219 fDPhi(rhs.fDPhi), fZHalfLength(rhs.fZHalfLength),
220 fInnerStereo(rhs.fInnerStereo), fOuterStereo(rhs.fOuterStereo),
221 fTanInnerStereo(rhs.fTanInnerStereo), fTanOuterStereo(rhs.fTanOuterStereo),
222 fKappa(rhs.fKappa), fInnerRadius2(rhs.fInnerRadius2),
223 fOuterRadius2(rhs.fOuterRadius2), fTanInnerStereo2(rhs.fTanInnerStereo2),
224 fTanOuterStereo2(rhs.fTanOuterStereo2),
225 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0), fFormerTwisted(0),
226 fInnerHype(0), fOuterHype(0),
227 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
228 fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
229 fLastDistanceToIn(rhs.fLastDistanceToIn),
230 fLastDistanceToOut(rhs.fLastDistanceToOut),
231 fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
232 fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
233{
234 for (auto i=0; i<2; ++i)
235 {
236 fEndZ[i] = rhs.fEndZ[i];
237 fEndInnerRadius[i] = rhs.fEndInnerRadius[i];
238 fEndOuterRadius[i] = rhs.fEndOuterRadius[i];
239 fEndPhi[i] = rhs.fEndPhi[i];
240 fEndZ2[i] = rhs.fEndZ2[i];
241 }
242 CreateSurfaces();
243}

Member Function Documentation

◆ BoundingLimits()

void G4TwistedTubs::BoundingLimits ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 309 of file G4TwistedTubs.cc.

311{
312 // Find bounding tube
313 G4double rmin = GetInnerRadius();
315
316 G4double zmin = std::min(GetEndZ(0), GetEndZ(1));
317 G4double zmax = std::max(GetEndZ(0), GetEndZ(1));
318
319 G4double dphi = 0.5*GetDPhi();
320 G4double sphi = std::min(GetEndPhi(0), GetEndPhi(1)) - dphi;
321 G4double ephi = std::max(GetEndPhi(0), GetEndPhi(1)) + dphi;
322 G4double totalphi = ephi - sphi;
323
324 // Find bounding box
325 if (dphi <= 0 || totalphi >= CLHEP::twopi)
326 {
327 pMin.set(-rmax,-rmax, zmin);
328 pMax.set( rmax, rmax, zmax);
329 }
330 else
331 {
332 G4TwoVector vmin,vmax;
333 G4GeomTools::DiskExtent(rmin, rmax, sphi, totalphi, vmin, vmax);
334 pMin.set(vmin.x(), vmin.y(), zmin);
335 pMax.set(vmax.x(), vmax.y(), zmax);
336 }
337
338 // Check correctness of the bounding box
339 //
340 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
341 {
342 std::ostringstream message;
343 message << "Bad bounding box (min >= max) for solid: "
344 << GetName() << " !"
345 << "\npMin = " << pMin
346 << "\npMax = " << pMax;
347 G4Exception("G4TwistedTubs::BoundingLimits()", "GeomMgt0001",
348 JustWarning, message);
349 DumpInfo();
350 }
351}
@ JustWarning
double x() const
double y() const
double z() const
double x() const
double y() const
void set(double x, double y, double z)
static G4bool DiskExtent(G4double rmin, G4double rmax, G4double startPhi, G4double delPhi, G4TwoVector &pmin, G4TwoVector &pmax)
Definition: G4GeomTools.cc:390
G4double GetEndOuterRadius() const
G4double GetEndPhi(G4int i) const
G4double GetEndZ(G4int i) const
G4double GetInnerRadius() const
G4double GetDPhi() const
G4String GetName() const
void DumpInfo() const

Referenced by CalculateExtent(), and GetExtent().

◆ CalculateExtent()

G4bool G4TwistedTubs::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Definition at line 357 of file G4TwistedTubs.cc.

361{
362 G4ThreeVector bmin, bmax;
363
364 // Get bounding box
365 BoundingLimits(bmin,bmax);
366
367 // Find extent
368 G4BoundingEnvelope bbox(bmin,bmax);
369 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
370}
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const

◆ Clone()

G4VSolid * G4TwistedTubs::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1023 of file G4TwistedTubs.cc.

1024{
1025 return new G4TwistedTubs(*this);
1026}

◆ ComputeDimensions()

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

Reimplemented from G4VSolid.

Definition at line 297 of file G4TwistedTubs.cc.

300{
301 G4Exception("G4TwistedTubs::ComputeDimensions()",
302 "GeomSolids0001", FatalException,
303 "G4TwistedTubs does not support Parameterisation.");
304}
@ FatalException

◆ CreatePolyhedron()

G4Polyhedron * G4TwistedTubs::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 898 of file G4TwistedTubs.cc.

899{
900 // number of meshes
901 //
902 G4double absPhiTwist = std::abs(fPhiTwist);
903 G4double dA = std::max(fDPhi,absPhiTwist);
904 const G4int k =
906 const G4int n =
907 G4int(G4Polyhedron::GetNumberOfRotationSteps() * absPhiTwist / twopi) + 2;
908
909 const G4int nnodes = 4*(k-1)*(n-2) + 2*k*k ;
910 const G4int nfaces = 4*(k-1)*(n-1) + 2*(k-1)*(k-1) ;
911
912 G4Polyhedron* ph = new G4Polyhedron;
913 typedef G4double G4double3[3];
914 typedef G4int G4int4[4];
915 G4double3* xyz = new G4double3[nnodes]; // number of nodes
916 G4int4* faces = new G4int4[nfaces] ; // number of faces
917 fLowerEndcap->GetFacets(k,k,xyz,faces,0) ;
918 fUpperEndcap->GetFacets(k,k,xyz,faces,1) ;
919 fInnerHype->GetFacets(k,n,xyz,faces,2) ;
920 fFormerTwisted->GetFacets(k,n,xyz,faces,3) ;
921 fOuterHype->GetFacets(k,n,xyz,faces,4) ;
922 fLatterTwisted->GetFacets(k,n,xyz,faces,5) ;
923
924 ph->createPolyhedron(nnodes,nfaces,xyz,faces);
925
926 delete[] xyz;
927 delete[] faces;
928
929 return ph;
930}
int G4int
Definition: G4Types.hh:85
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
static G4int GetNumberOfRotationSteps()
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])

Referenced by GetPolyhedron().

◆ DescribeYourselfTo()

void G4TwistedTubs::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 876 of file G4TwistedTubs.cc.

877{
878 scene.AddSolid (*this);
879}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

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

Implements G4VSolid.

Definition at line 572 of file G4TwistedTubs.cc.

573{
574 // DistanceToIn(p):
575 // Calculate distance to surface of shape from `outside',
576 // allowing for tolerance
577
578 //
579 // checking last value
580 //
581
582 G4ThreeVector* tmpp;
583 G4double* tmpdist;
584 if (fLastDistanceToIn.p == p)
585 {
586 return fLastDistanceToIn.value;
587 }
588 else
589 {
590 tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToIn.p));
591 tmpdist = const_cast<G4double*>(&(fLastDistanceToIn.value));
592 tmpp->set(p.x(), p.y(), p.z());
593 }
594
595 //
596 // Calculate DistanceToIn(p)
597 //
598
599 EInside currentside = Inside(p);
600
601 switch (currentside)
602 {
603 case (kInside) :
604 {}
605 case (kSurface) :
606 {
607 *tmpdist = 0.;
608 return fLastDistanceToIn.value;
609 }
610 case (kOutside) :
611 {
612 // Initialize
613 G4double distance = kInfinity;
614
615 // find intersections and choose nearest one.
616 G4VTwistSurface *surfaces[6];
617 surfaces[0] = fLowerEndcap;
618 surfaces[1] = fUpperEndcap;
619 surfaces[2] = fLatterTwisted;
620 surfaces[3] = fFormerTwisted;
621 surfaces[4] = fInnerHype;
622 surfaces[5] = fOuterHype;
623
624 G4ThreeVector xx;
625 G4ThreeVector bestxx;
626 for (auto i=0; i<6; ++i)
627 {
628 G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
629 if (tmpdistance < distance)
630 {
631 distance = tmpdistance;
632 bestxx = xx;
633 }
634 }
635 *tmpdist = distance;
636 return fLastDistanceToIn.value;
637 }
638 default :
639 {
640 G4Exception("G4TwistedTubs::DistanceToIn(p)", "GeomSolids0003",
641 FatalException, "Unknown point location!");
642 }
643 } // switch end
644
645 return kInfinity;
646}
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
EInside
Definition: geomdefs.hh:67
@ kInside
Definition: geomdefs.hh:70
@ kOutside
Definition: geomdefs.hh:68
@ kSurface
Definition: geomdefs.hh:69

◆ DistanceToIn() [2/2]

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

Implements G4VSolid.

Definition at line 482 of file G4TwistedTubs.cc.

484{
485
486 // DistanceToIn (p, v):
487 // Calculate distance to surface of shape from `outside'
488 // along with the v, allowing for tolerance.
489 // The function returns kInfinity if no intersection or
490 // just grazing within tolerance.
491
492 //
493 // checking last value
494 //
495
496 G4ThreeVector* tmpp;
497 G4ThreeVector* tmpv;
498 G4double* tmpdist;
499 if ((fLastDistanceToInWithV.p == p) && (fLastDistanceToInWithV.vec == v))
500 {
501 return fLastDistanceToIn.value;
502 }
503 else
504 {
505 tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.p));
506 tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToInWithV.vec));
507 tmpdist = const_cast<G4double*>(&(fLastDistanceToInWithV.value));
508 tmpp->set(p.x(), p.y(), p.z());
509 tmpv->set(v.x(), v.y(), v.z());
510 }
511
512 //
513 // Calculate DistanceToIn(p,v)
514 //
515
516 EInside currentside = Inside(p);
517
518 if (currentside == kInside)
519 {
520 }
521 else
522 {
523 if (currentside == kSurface)
524 {
525 // particle is just on a boundary.
526 // If the particle is entering to the volume, return 0.
527 //
528 G4ThreeVector normal = SurfaceNormal(p);
529 if (normal*v < 0)
530 {
531 *tmpdist = 0.;
532 return fLastDistanceToInWithV.value;
533 }
534 }
535 }
536
537 // now, we can take smallest positive distance.
538
539 // Initialize
540 //
541 G4double distance = kInfinity;
542
543 // find intersections and choose nearest one.
544 //
545 G4VTwistSurface* surfaces[6];
546 surfaces[0] = fLowerEndcap;
547 surfaces[1] = fUpperEndcap;
548 surfaces[2] = fLatterTwisted;
549 surfaces[3] = fFormerTwisted;
550 surfaces[4] = fInnerHype;
551 surfaces[5] = fOuterHype;
552
553 G4ThreeVector xx;
554 G4ThreeVector bestxx;
555 for (auto i=0; i<6; ++i)
556 {
557 G4double tmpdistance = surfaces[i]->DistanceToIn(p, v, xx);
558 if (tmpdistance < distance)
559 {
560 distance = tmpdistance;
561 bestxx = xx;
562 }
563 }
564 *tmpdist = distance;
565
566 return fLastDistanceToInWithV.value;
567}
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)

◆ DistanceToOut() [1/2]

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

Implements G4VSolid.

Definition at line 762 of file G4TwistedTubs.cc.

763{
764 // DistanceToOut(p):
765 // Calculate distance to surface of shape from `inside',
766 // allowing for tolerance
767
768 //
769 // checking last value
770 //
771
772 G4ThreeVector* tmpp;
773 G4double* tmpdist;
774 if (fLastDistanceToOut.p == p)
775 {
776 return fLastDistanceToOut.value;
777 }
778 else
779 {
780 tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOut.p));
781 tmpdist = const_cast<G4double*>(&(fLastDistanceToOut.value));
782 tmpp->set(p.x(), p.y(), p.z());
783 }
784
785 //
786 // Calculate DistanceToOut(p)
787 //
788
789 EInside currentside = Inside(p);
790
791 switch (currentside)
792 {
793 case (kOutside) :
794 {
795 }
796 case (kSurface) :
797 {
798 *tmpdist = 0.;
799 return fLastDistanceToOut.value;
800 }
801 case (kInside) :
802 {
803 // Initialize
804 G4double distance = kInfinity;
805
806 // find intersections and choose nearest one.
807 G4VTwistSurface* surfaces[6];
808 surfaces[0] = fLatterTwisted;
809 surfaces[1] = fFormerTwisted;
810 surfaces[2] = fInnerHype;
811 surfaces[3] = fOuterHype;
812 surfaces[4] = fLowerEndcap;
813 surfaces[5] = fUpperEndcap;
814
815 G4ThreeVector xx;
816 G4ThreeVector bestxx;
817 for (auto i=0; i<6; ++i)
818 {
819 G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
820 if (tmpdistance < distance)
821 {
822 distance = tmpdistance;
823 bestxx = xx;
824 }
825 }
826 *tmpdist = distance;
827
828 return fLastDistanceToOut.value;
829 }
830 default :
831 {
832 G4Exception("G4TwistedTubs::DistanceToOut(p)", "GeomSolids0003",
833 FatalException, "Unknown point location!");
834 }
835 } // switch end
836
837 return 0.;
838}

◆ DistanceToOut() [2/2]

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

Implements G4VSolid.

Definition at line 651 of file G4TwistedTubs.cc.

656{
657 // DistanceToOut (p, v):
658 // Calculate distance to surface of shape from `inside'
659 // along with the v, allowing for tolerance.
660 // The function returns kInfinity if no intersection or
661 // just grazing within tolerance.
662
663 //
664 // checking last value
665 //
666
667 G4ThreeVector* tmpp;
668 G4ThreeVector* tmpv;
669 G4double* tmpdist;
670 if ((fLastDistanceToOutWithV.p == p) && (fLastDistanceToOutWithV.vec == v) )
671 {
672 return fLastDistanceToOutWithV.value;
673 }
674 else
675 {
676 tmpp = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.p));
677 tmpv = const_cast<G4ThreeVector*>(&(fLastDistanceToOutWithV.vec));
678 tmpdist = const_cast<G4double*>(&(fLastDistanceToOutWithV.value));
679 tmpp->set(p.x(), p.y(), p.z());
680 tmpv->set(v.x(), v.y(), v.z());
681 }
682
683 //
684 // Calculate DistanceToOut(p,v)
685 //
686
687 EInside currentside = Inside(p);
688
689 if (currentside == kOutside)
690 {
691 }
692 else
693 {
694 if (currentside == kSurface)
695 {
696 // particle is just on a boundary.
697 // If the particle is exiting from the volume, return 0.
698 //
699 G4ThreeVector normal = SurfaceNormal(p);
700 G4VTwistSurface *blockedsurface = fLastNormal.surface[0];
701 if (normal*v > 0)
702 {
703 if (calcNorm)
704 {
705 *norm = (blockedsurface->GetNormal(p, true));
706 *validNorm = blockedsurface->IsValidNorm();
707 }
708 *tmpdist = 0.;
709 return fLastDistanceToOutWithV.value;
710 }
711 }
712 }
713
714 // now, we can take smallest positive distance.
715
716 // Initialize
717 //
718 G4double distance = kInfinity;
719
720 // find intersections and choose nearest one.
721 //
722 G4VTwistSurface* surfaces[6];
723 surfaces[0] = fLatterTwisted;
724 surfaces[1] = fFormerTwisted;
725 surfaces[2] = fInnerHype;
726 surfaces[3] = fOuterHype;
727 surfaces[4] = fLowerEndcap;
728 surfaces[5] = fUpperEndcap;
729
730 G4int besti = -1;
731 G4ThreeVector xx;
732 G4ThreeVector bestxx;
733 for (auto i=0; i<6; ++i)
734 {
735 G4double tmpdistance = surfaces[i]->DistanceToOut(p, v, xx);
736 if (tmpdistance < distance)
737 {
738 distance = tmpdistance;
739 bestxx = xx;
740 besti = i;
741 }
742 }
743
744 if (calcNorm)
745 {
746 if (besti != -1)
747 {
748 *norm = (surfaces[besti]->GetNormal(p, true));
749 *validNorm = surfaces[besti]->IsValidNorm();
750 }
751 }
752
753 *tmpdist = distance;
754
755 return fLastDistanceToOutWithV.value;
756}
G4bool IsValidNorm() const
virtual G4double DistanceToOut(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0

◆ GetCubicVolume()

G4double G4TwistedTubs::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1031 of file G4TwistedTubs.cc.

1032{
1033 if (fCubicVolume == 0.)
1034 {
1035 G4double DPhi = GetDPhi();
1036 G4double Z0 = GetEndZ(0);
1037 G4double Z1 = GetEndZ(1);
1038 G4double Ain = GetInnerRadius();
1039 G4double Aout = GetOuterRadius();
1040 G4double R0in = GetEndInnerRadius(0);
1041 G4double R1in = GetEndInnerRadius(1);
1042 G4double R0out = GetEndOuterRadius(0);
1043 G4double R1out = GetEndOuterRadius(1);
1044
1045 // V_hyperboloid = pi*h*(2*a*a + R*R)/3
1046 fCubicVolume = (2.*(Z1 - Z0)*(Aout + Ain)*(Aout - Ain)
1047 + Z1*(R1out + R1in)*(R1out - R1in)
1048 - Z0*(R0out + R0in)*(R0out - R0in))*DPhi/6.;
1049 }
1050 return fCubicVolume;
1051}
G4double GetOuterRadius() const
G4double GetEndInnerRadius() const

◆ GetDPhi()

G4double G4TwistedTubs::GetDPhi ( ) const
inline

◆ GetEndInnerRadius() [1/2]

G4double G4TwistedTubs::GetEndInnerRadius ( ) const
inline

Definition at line 150 of file G4TwistedTubs.hh.

151 { return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
152 fEndInnerRadius[0] : fEndInnerRadius[1]); }

Referenced by GetCubicVolume(), GetPointOnSurface(), and GetSurfaceArea().

◆ GetEndInnerRadius() [2/2]

G4double G4TwistedTubs::GetEndInnerRadius ( G4int  i) const
inline

Definition at line 146 of file G4TwistedTubs.hh.

147 { return fEndInnerRadius[i]; }

◆ GetEndOuterRadius() [1/2]

G4double G4TwistedTubs::GetEndOuterRadius ( ) const
inline

Definition at line 153 of file G4TwistedTubs.hh.

154 { return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
155 fEndOuterRadius[0] : fEndOuterRadius[1]); }

Referenced by BoundingLimits(), GetCubicVolume(), GetPointOnSurface(), and GetSurfaceArea().

◆ GetEndOuterRadius() [2/2]

G4double G4TwistedTubs::GetEndOuterRadius ( G4int  i) const
inline

Definition at line 148 of file G4TwistedTubs.hh.

149 { return fEndOuterRadius[i]; }

◆ GetEndPhi()

G4double G4TwistedTubs::GetEndPhi ( G4int  i) const
inline

Definition at line 145 of file G4TwistedTubs.hh.

145{ return fEndPhi[i]; }

Referenced by BoundingLimits().

◆ GetEndZ()

G4double G4TwistedTubs::GetEndZ ( G4int  i) const
inline

Definition at line 144 of file G4TwistedTubs.hh.

144{ return fEndZ[i] ; }

Referenced by BoundingLimits(), GetCubicVolume(), GetSurfaceArea(), and G4GDMLWriteSolids::TwistedtubsWrite().

◆ GetEntityType()

G4GeometryType G4TwistedTubs::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 1015 of file G4TwistedTubs.cc.

1016{
1017 return G4String("G4TwistedTubs");
1018}

◆ GetExtent()

G4VisExtent G4TwistedTubs::GetExtent ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 884 of file G4TwistedTubs.cc.

885{
886 // Define the sides of the box into which the G4Tubs instance would fit.
887 //
888 G4ThreeVector pmin,pmax;
889 BoundingLimits(pmin,pmax);
890 return G4VisExtent(pmin.x(),pmax.x(),
891 pmin.y(),pmax.y(),
892 pmin.z(),pmax.z());
893}

◆ GetInnerRadius()

G4double G4TwistedTubs::GetInnerRadius ( ) const
inline

◆ GetInnerStereo()

G4double G4TwistedTubs::GetInnerStereo ( ) const
inline

Definition at line 134 of file G4TwistedTubs.hh.

134{ return fInnerStereo; }

◆ GetKappa()

G4double G4TwistedTubs::GetKappa ( ) const
inline

Definition at line 137 of file G4TwistedTubs.hh.

137{ return fKappa ; }

◆ GetOuterRadius()

G4double G4TwistedTubs::GetOuterRadius ( ) const
inline

Definition at line 133 of file G4TwistedTubs.hh.

133{ return fOuterRadius; }

Referenced by GetCubicVolume(), G4tgbGeometryDumper::GetSolidParams(), GetSurfaceArea(), and G4GDMLWriteSolids::TwistedtubsWrite().

◆ GetOuterStereo()

G4double G4TwistedTubs::GetOuterStereo ( ) const
inline

Definition at line 135 of file G4TwistedTubs.hh.

135{ return fOuterStereo; }

◆ GetPhiTwist()

G4double G4TwistedTubs::GetPhiTwist ( ) const
inline

Definition at line 131 of file G4TwistedTubs.hh.

131{ return fPhiTwist ; }

Referenced by G4tgbGeometryDumper::GetSolidParams(), and G4GDMLWriteSolids::TwistedtubsWrite().

◆ GetPointOnSurface()

G4ThreeVector G4TwistedTubs::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1147 of file G4TwistedTubs.cc.

1148{
1149
1150 G4double z = G4RandFlat::shoot(fEndZ[0],fEndZ[1]);
1151 G4double phi , phimin, phimax ;
1152 G4double x , xmin, xmax ;
1153 G4double r , rmin, rmax ;
1154
1155 G4double a1 = fOuterHype->GetSurfaceArea() ;
1156 G4double a2 = fInnerHype->GetSurfaceArea() ;
1157 G4double a3 = fLatterTwisted->GetSurfaceArea() ;
1158 G4double a4 = fFormerTwisted->GetSurfaceArea() ;
1159 G4double a5 = fLowerEndcap->GetSurfaceArea() ;
1160 G4double a6 = fUpperEndcap->GetSurfaceArea() ;
1161
1162 G4double chose = G4RandFlat::shoot(0.,a1 + a2 + a3 + a4 + a5 + a6) ;
1163
1164 if(chose < a1)
1165 {
1166
1167 phimin = fOuterHype->GetBoundaryMin(z) ;
1168 phimax = fOuterHype->GetBoundaryMax(z) ;
1169 phi = G4RandFlat::shoot(phimin,phimax) ;
1170
1171 return fOuterHype->SurfacePoint(phi,z,true) ;
1172
1173 }
1174 else if ( (chose >= a1) && (chose < a1 + a2 ) )
1175 {
1176
1177 phimin = fInnerHype->GetBoundaryMin(z) ;
1178 phimax = fInnerHype->GetBoundaryMax(z) ;
1179 phi = G4RandFlat::shoot(phimin,phimax) ;
1180
1181 return fInnerHype->SurfacePoint(phi,z,true) ;
1182
1183 }
1184 else if ( (chose >= a1 + a2 ) && (chose < a1 + a2 + a3 ) )
1185 {
1186
1187 xmin = fLatterTwisted->GetBoundaryMin(z) ;
1188 xmax = fLatterTwisted->GetBoundaryMax(z) ;
1189 x = G4RandFlat::shoot(xmin,xmax) ;
1190
1191 return fLatterTwisted->SurfacePoint(x,z,true) ;
1192
1193 }
1194 else if ( (chose >= a1 + a2 + a3 ) && (chose < a1 + a2 + a3 + a4 ) )
1195 {
1196
1197 xmin = fFormerTwisted->GetBoundaryMin(z) ;
1198 xmax = fFormerTwisted->GetBoundaryMax(z) ;
1199 x = G4RandFlat::shoot(xmin,xmax) ;
1200
1201 return fFormerTwisted->SurfacePoint(x,z,true) ;
1202 }
1203 else if( (chose >= a1 + a2 + a3 + a4 )&&(chose < a1 + a2 + a3 + a4 + a5 ) )
1204 {
1205 rmin = GetEndInnerRadius(0) ;
1206 rmax = GetEndOuterRadius(0) ;
1207 r = std::sqrt(G4RandFlat::shoot()*(sqr(rmax)-sqr(rmin))+sqr(rmin));
1208
1209 phimin = fLowerEndcap->GetBoundaryMin(r) ;
1210 phimax = fLowerEndcap->GetBoundaryMax(r) ;
1211 phi = G4RandFlat::shoot(phimin,phimax) ;
1212
1213 return fLowerEndcap->SurfacePoint(phi,r,true) ;
1214 }
1215 else
1216 {
1217 rmin = GetEndInnerRadius(1) ;
1218 rmax = GetEndOuterRadius(1) ;
1219 r = rmin + (rmax-rmin)*std::sqrt(G4RandFlat::shoot());
1220
1221 phimin = fUpperEndcap->GetBoundaryMin(r) ;
1222 phimax = fUpperEndcap->GetBoundaryMax(r) ;
1223 phi = G4RandFlat::shoot(phimin,phimax) ;
1224
1225 return fUpperEndcap->SurfacePoint(phi,r,true) ;
1226 }
1227}
virtual G4double GetBoundaryMin(G4double)=0
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)=0
virtual G4double GetBoundaryMax(G4double)=0
virtual G4double GetSurfaceArea()=0
T sqr(const T &x)
Definition: templates.hh:128

◆ GetPolyhedron()

G4Polyhedron * G4TwistedTubs::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 935 of file G4TwistedTubs.cc.

936{
937 if (fpPolyhedron == nullptr ||
938 fRebuildPolyhedron ||
940 fpPolyhedron->GetNumberOfRotationSteps())
941 {
942 G4AutoLock l(&polyhedronMutex);
943 delete fpPolyhedron;
944 fpPolyhedron = CreatePolyhedron();
945 fRebuildPolyhedron = false;
946 l.unlock();
947 }
948 return fpPolyhedron;
949}
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4Polyhedron * CreatePolyhedron() const

◆ GetSurfaceArea()

G4double G4TwistedTubs::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 1104 of file G4TwistedTubs.cc.

1105{
1106 if (fSurfaceArea == 0.)
1107 {
1108 G4double dphi = GetDPhi();
1109 G4double Ainn = GetInnerRadius();
1110 G4double Aout = GetOuterRadius();
1111 G4double Rinn0 = GetEndInnerRadius(0);
1112 G4double Rout0 = GetEndOuterRadius(0);
1113 G4double Rinn1 = GetEndInnerRadius(1);
1114 G4double Rout1 = GetEndOuterRadius(1);
1115 G4double z0 = GetEndZ(0);
1116 G4double z1 = GetEndZ(1);
1117
1118 G4double base0 = 0.5*dphi*(Rout0*Rout0 - Rinn0*Rinn0); // lower base
1119 G4double inner0 = GetLateralArea(Ainn, Rinn0, z0); // lower inner surface
1120 G4double outer0 = GetLateralArea(Aout, Rout0, z0); // lower outer surface
1121 G4double cut0 = // lower phi cut
1122 GetPhiCutArea(Aout, Rout0, z0) - GetPhiCutArea(Ainn, Rinn0, z0);
1123
1124 G4double base1 = base0;
1125 G4double inner1 = inner0;
1126 G4double outer1 = outer0;
1127 G4double cut1 = cut0;
1128 if (std::abs(z0) != std::abs(z1))
1129 {
1130 base1 = 0.5*dphi*(Rout1*Rout1 - Rinn1*Rinn1); // upper base
1131 inner1 = GetLateralArea(Ainn, Rinn1, z1); // upper inner surface
1132 outer1 = GetLateralArea(Aout, Rout1, z1); // upper outer surface
1133 cut1 = // upper phi cut
1134 GetPhiCutArea(Aout, Rout1, z1) - GetPhiCutArea(Ainn, Rinn1, z1);
1135 }
1136 fSurfaceArea = base0 + base1 +
1137 ((z0*z1 < 0) ?
1138 (inner0 + inner1 + outer0 + outer1 + 2.*(cut0 + cut1)) :
1139 std::abs(inner0 - inner1 + outer0 - outer1 + 2.*(cut0 - cut1)));
1140 }
1141 return fSurfaceArea;
1142}

◆ GetTanInnerStereo()

G4double G4TwistedTubs::GetTanInnerStereo ( ) const
inline

Definition at line 139 of file G4TwistedTubs.hh.

139{ return fTanInnerStereo ; }

◆ GetTanInnerStereo2()

G4double G4TwistedTubs::GetTanInnerStereo2 ( ) const
inline

Definition at line 140 of file G4TwistedTubs.hh.

140{ return fTanInnerStereo2 ; }

◆ GetTanOuterStereo()

G4double G4TwistedTubs::GetTanOuterStereo ( ) const
inline

Definition at line 141 of file G4TwistedTubs.hh.

141{ return fTanOuterStereo ; }

◆ GetTanOuterStereo2()

G4double G4TwistedTubs::GetTanOuterStereo2 ( ) const
inline

Definition at line 142 of file G4TwistedTubs.hh.

142{ return fTanOuterStereo2 ; }

◆ GetZHalfLength()

G4double G4TwistedTubs::GetZHalfLength ( ) const
inline

Definition at line 136 of file G4TwistedTubs.hh.

136{ return fZHalfLength; }

Referenced by G4tgbGeometryDumper::GetSolidParams().

◆ Inside()

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

Implements G4VSolid.

Definition at line 376 of file G4TwistedTubs.cc.

377{
378
379 const G4double halftol
381 // static G4int timerid = -1;
382 // G4Timer timer(timerid, "G4TwistedTubs", "Inside");
383 // timer.Start();
384
385 G4ThreeVector *tmpp;
386 EInside *tmpinside;
387 if (fLastInside.p == p)
388 {
389 return fLastInside.inside;
390 }
391 else
392 {
393 tmpp = const_cast<G4ThreeVector*>(&(fLastInside.p));
394 tmpinside = const_cast<EInside*>(&(fLastInside.inside));
395 tmpp->set(p.x(), p.y(), p.z());
396 }
397
398 EInside outerhypearea = ((G4TwistTubsHypeSide *)fOuterHype)->Inside(p);
399 G4double innerhyperho = ((G4TwistTubsHypeSide *)fInnerHype)->GetRhoAtPZ(p);
400 G4double distanceToOut = p.getRho() - innerhyperho; // +ve: inside
401
402 if ((outerhypearea == kOutside) || (distanceToOut < -halftol))
403 {
404 *tmpinside = kOutside;
405 }
406 else if (outerhypearea == kSurface)
407 {
408 *tmpinside = kSurface;
409 }
410 else
411 {
412 if (distanceToOut <= halftol)
413 {
414 *tmpinside = kSurface;
415 }
416 else
417 {
418 *tmpinside = kInside;
419 }
420 }
421
422 return fLastInside.inside;
423}
double getRho() const
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()

Referenced by DistanceToIn(), and DistanceToOut().

◆ operator=()

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

Definition at line 249 of file G4TwistedTubs.cc.

250{
251 // Check assignment to self
252 //
253 if (this == &rhs) { return *this; }
254
255 // Copy base class data
256 //
258
259 // Copy data
260 //
261 fPhiTwist= rhs.fPhiTwist;
262 fInnerRadius= rhs.fInnerRadius; fOuterRadius= rhs.fOuterRadius;
263 fDPhi= rhs.fDPhi; fZHalfLength= rhs.fZHalfLength;
264 fInnerStereo= rhs.fInnerStereo; fOuterStereo= rhs.fOuterStereo;
265 fTanInnerStereo= rhs.fTanInnerStereo; fTanOuterStereo= rhs.fTanOuterStereo;
266 fKappa= rhs.fKappa; fInnerRadius2= rhs.fInnerRadius2;
267 fOuterRadius2= rhs.fOuterRadius2; fTanInnerStereo2= rhs.fTanInnerStereo2;
268 fTanOuterStereo2= rhs.fTanOuterStereo2;
269 fLowerEndcap= fUpperEndcap= fLatterTwisted= fFormerTwisted= 0;
270 fInnerHype= fOuterHype= 0;
271 fCubicVolume= rhs.fCubicVolume; fSurfaceArea= rhs.fSurfaceArea;
272 fLastInside= rhs.fLastInside; fLastNormal= rhs.fLastNormal;
273 fLastDistanceToIn= rhs.fLastDistanceToIn;
274 fLastDistanceToOut= rhs.fLastDistanceToOut;
275 fLastDistanceToInWithV= rhs.fLastDistanceToInWithV;
276 fLastDistanceToOutWithV= rhs.fLastDistanceToOutWithV;
277
278 for (auto i=0; i<2; ++i)
279 {
280 fEndZ[i] = rhs.fEndZ[i];
281 fEndInnerRadius[i] = rhs.fEndInnerRadius[i];
282 fEndOuterRadius[i] = rhs.fEndOuterRadius[i];
283 fEndPhi[i] = rhs.fEndPhi[i];
284 fEndZ2[i] = rhs.fEndZ2[i];
285 }
286
287 CreateSurfaces();
288 fRebuildPolyhedron = false;
289 delete fpPolyhedron; fpPolyhedron = nullptr;
290
291 return *this;
292}
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:107

◆ StreamInfo()

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

Implements G4VSolid.

Definition at line 843 of file G4TwistedTubs.cc.

844{
845 //
846 // Stream object contents to an output stream
847 //
848 G4long oldprc = os.precision(16);
849 os << "-----------------------------------------------------------\n"
850 << " *** Dump for solid - " << GetName() << " ***\n"
851 << " ===================================================\n"
852 << " Solid type: G4TwistedTubs\n"
853 << " Parameters: \n"
854 << " -ve end Z : " << fEndZ[0]/mm << " mm \n"
855 << " +ve end Z : " << fEndZ[1]/mm << " mm \n"
856 << " inner end radius(-ve z): " << fEndInnerRadius[0]/mm << " mm \n"
857 << " inner end radius(+ve z): " << fEndInnerRadius[1]/mm << " mm \n"
858 << " outer end radius(-ve z): " << fEndOuterRadius[0]/mm << " mm \n"
859 << " outer end radius(+ve z): " << fEndOuterRadius[1]/mm << " mm \n"
860 << " inner radius (z=0) : " << fInnerRadius/mm << " mm \n"
861 << " outer radius (z=0) : " << fOuterRadius/mm << " mm \n"
862 << " twisted angle : " << fPhiTwist/degree << " degrees \n"
863 << " inner stereo angle : " << fInnerStereo/degree << " degrees \n"
864 << " outer stereo angle : " << fOuterStereo/degree << " degrees \n"
865 << " phi-width of a piece : " << fDPhi/degree << " degrees \n"
866 << "-----------------------------------------------------------\n";
867 os.precision(oldprc);
868
869 return os;
870}
long G4long
Definition: G4Types.hh:87

◆ SurfaceNormal()

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

Implements G4VSolid.

Definition at line 428 of file G4TwistedTubs.cc.

429{
430 //
431 // return the normal unit vector to the Hyperbolical Surface at a point
432 // p on (or nearly on) the surface
433 //
434 // Which of the three or four surfaces are we closest to?
435 //
436
437 if (fLastNormal.p == p)
438 {
439 return fLastNormal.vec;
440 }
441 G4ThreeVector *tmpp =
442 const_cast<G4ThreeVector*>(&(fLastNormal.p));
443 G4ThreeVector *tmpnormal =
444 const_cast<G4ThreeVector*>(&(fLastNormal.vec));
445 G4VTwistSurface **tmpsurface =
446 const_cast<G4VTwistSurface**>(fLastNormal.surface);
447 tmpp->set(p.x(), p.y(), p.z());
448
449 G4double distance = kInfinity;
450
451 G4VTwistSurface *surfaces[6];
452 surfaces[0] = fLatterTwisted;
453 surfaces[1] = fFormerTwisted;
454 surfaces[2] = fInnerHype;
455 surfaces[3] = fOuterHype;
456 surfaces[4] = fLowerEndcap;
457 surfaces[5] = fUpperEndcap;
458
459 G4ThreeVector xx;
460 G4ThreeVector bestxx;
461 G4int besti = -1;
462 for (auto i=0; i<6; ++i)
463 {
464 G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
465 if (tmpdistance < distance)
466 {
467 distance = tmpdistance;
468 bestxx = xx;
469 besti = i;
470 }
471 }
472
473 tmpsurface[0] = surfaces[besti];
474 *tmpnormal = tmpsurface[0]->GetNormal(bestxx, true);
475
476 return fLastNormal.vec;
477}

Referenced by DistanceToIn(), and DistanceToOut().


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