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

G4TwistTubsFlatSide describes a flat boundary surface for a cylinder. More...

#include <G4TwistTubsFlatSide.hh>

Inheritance diagram for G4TwistTubsFlatSide:

Public Member Functions

 G4TwistTubsFlatSide (const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, const G4ThreeVector &n, const EAxis axis0=kRho, const EAxis axis1=kPhi, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
 G4TwistTubsFlatSide (const G4String &name, G4double EndInnerRadius[2], G4double EndOuterRadius[2], G4double DPhi, G4double EndPhi[2], G4double EndZ[2], G4int handedness)
 ~G4TwistTubsFlatSide () override=default
G4ThreeVector GetNormal (const G4ThreeVector &, G4bool isGlobal=false) override
G4int DistanceToSurface (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol) override
G4int DistanceToSurface (const G4ThreeVector &gp, G4ThreeVector gxx[], G4double distance[], G4int areacode[]) override
 G4TwistTubsFlatSide (__void__ &)
Public Member Functions inherited from G4VTwistSurface
 G4VTwistSurface (const G4String &name)
 G4VTwistSurface (const G4String &name, const G4RotationMatrix &rot, const G4ThreeVector &tlate, G4int handedness, const EAxis axis0, const EAxis axis1, G4double axis0min=-kInfinity, G4double axis1min=-kInfinity, G4double axis0max=kInfinity, G4double axis1max=kInfinity)
virtual ~G4VTwistSurface ()=default
virtual G4int AmIOnLeftSide (const G4ThreeVector &me, const G4ThreeVector &vec, G4bool withTol=true)
virtual G4double DistanceToBoundary (G4int areacode, G4ThreeVector &xx, const G4ThreeVector &p)
virtual G4double DistanceToIn (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4double DistanceToOut (const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4double DistanceTo (const G4ThreeVector &gp, G4ThreeVector &gxx)
virtual void GetBoundaryParameters (const G4int &areacode, G4ThreeVector &d, G4ThreeVector &x0, G4int &boundarytype) const
virtual G4ThreeVector GetBoundaryAtPZ (G4int areacode, const G4ThreeVector &p) const
G4double DistanceToPlaneWithV (const G4ThreeVector &p, const G4ThreeVector &v, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &n0, G4ThreeVector &xx)
G4double DistanceToPlane (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &t1, const G4ThreeVector &t2, G4ThreeVector &xx, G4ThreeVector &n)
G4double DistanceToLine (const G4ThreeVector &p, const G4ThreeVector &x0, const G4ThreeVector &d, G4ThreeVector &xx)
G4bool IsAxis0 (G4int areacode) const
G4bool IsAxis1 (G4int areacode) const
G4bool IsOutside (G4int areacode) const
G4bool IsInside (G4int areacode, G4bool testbitmode=false) const
G4bool IsBoundary (G4int areacode, G4bool testbitmode=false) const
G4bool IsCorner (G4int areacode, G4bool testbitmode=false) const
G4bool IsValidNorm () const
G4bool IsSameBoundary (G4VTwistSurface *surface1, G4int areacode1, G4VTwistSurface *surface2, G4int areacode2) const
G4int GetAxisType (G4int areacode, G4int whichaxis) const
G4ThreeVector ComputeGlobalPoint (const G4ThreeVector &lp) const
G4ThreeVector ComputeLocalPoint (const G4ThreeVector &gp) const
G4ThreeVector ComputeGlobalDirection (const G4ThreeVector &lp) const
G4ThreeVector ComputeLocalDirection (const G4ThreeVector &gp) const
void SetAxis (G4int i, const EAxis axis)
void SetNeighbours (G4VTwistSurface *ax0min, G4VTwistSurface *ax1min, G4VTwistSurface *ax0max, G4VTwistSurface *ax1max)
G4int GetNode (G4int i, G4int j, G4int m, G4int n, G4int iside)
G4int GetFace (G4int i, G4int j, G4int m, G4int n, G4int iside)
G4int GetEdgeVisibility (G4int i, G4int j, G4int m, G4int n, G4int number, G4int orientation)
const G4StringGetName () const
void DebugPrint () const
 G4VTwistSurface (__void__ &)

Additional Inherited Members

Public Types inherited from G4VTwistSurface
enum  EValidate { kDontValidate = 0 , kValidateWithTol = 1 , kValidateWithoutTol = 2 , kUninitialized = 3 }
Static Public Attributes inherited from G4VTwistSurface
static const G4int sOutside = 0x00000000
static const G4int sInside = 0x10000000
static const G4int sBoundary = 0x20000000
static const G4int sCorner = 0x40000000
static const G4int sC0Min1Min = 0x40000101
static const G4int sC0Max1Min = 0x40000201
static const G4int sC0Max1Max = 0x40000202
static const G4int sC0Min1Max = 0x40000102
static const G4int sAxisMin = 0x00000101
static const G4int sAxisMax = 0x00000202
static const G4int sAxisX = 0x00000404
static const G4int sAxisY = 0x00000808
static const G4int sAxisZ = 0x00000C0C
static const G4int sAxisRho = 0x00001010
static const G4int sAxisPhi = 0x00001414
static const G4int sAxis0 = 0x0000FF00
static const G4int sAxis1 = 0x000000FF
static const G4int sSizeMask = 0x00000303
static const G4int sAxisMask = 0x0000FCFC
static const G4int sAreaMask = 0XF0000000
Protected Member Functions inherited from G4VTwistSurface
G4VTwistSurface ** GetNeighbours ()
G4int GetNeighbours (G4int areacode, G4VTwistSurface *surfaces[])
G4ThreeVector GetCorner (G4int areacode) const
void GetBoundaryAxis (G4int areacode, EAxis axis[]) const
void GetBoundaryLimit (G4int areacode, G4double limit[]) const
virtual void SetBoundary (const G4int &axiscode, const G4ThreeVector &direction, const G4ThreeVector &x0, const G4int &boundarytype)
void SetCorner (G4int areacode, G4double x, G4double y, G4double z)
Protected Attributes inherited from G4VTwistSurface
EAxis fAxis [2]
G4double fAxisMin [2]
G4double fAxisMax [2]
CurrentStatus fCurStatWithV
CurrentStatus fCurStat
G4RotationMatrix fRot
G4ThreeVector fTrans
G4int fHandedness
G4SurfCurNormal fCurrentNormal
G4bool fIsValidNorm
G4double kCarTolerance

Detailed Description

G4TwistTubsFlatSide describes a flat boundary surface for a cylinder.

Definition at line 45 of file G4TwistTubsFlatSide.hh.

Constructor & Destructor Documentation

◆ G4TwistTubsFlatSide() [1/3]

G4TwistTubsFlatSide::G4TwistTubsFlatSide ( const G4String & name,
const G4RotationMatrix & rot,
const G4ThreeVector & tlate,
const G4ThreeVector & n,
const EAxis axis0 = kRho,
const EAxis axis1 = kPhi,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity )

Constructs a cylinder flat boundary surface, given its parameters.

Parameters
[in]nameThe surface name.
[in]rotRotation.
[in]tlateTranslation.
[in]nNormal vector.
[in]axis0Rho axis.
[in]axis1Phi axis.
[in]axis0minMinimum in Rho.
[in]axis1minMinimum in Phi.
[in]axis0maxMaximum in Rho.
[in]axis1maxMaximum in Phi.

Definition at line 39 of file G4TwistTubsFlatSide.cc.

49 : G4VTwistSurface(name, rot, tlate, 0, axis0, axis1,
50 axis0min, axis1min, axis0max, axis1max)
51{
52 if (axis0 == kPhi && axis1 == kRho)
53 {
54 G4Exception("G4TwistTubsFlatSide::G4TwistTubsFlatSide()",
55 "GeomSolids0002", FatalErrorInArgument,
56 "Should swap axis0 and axis1!");
57 }
58
59 G4ThreeVector normal = rot.inverse()*n;
60 fCurrentNormal.normal = normal.unit(); // in local coordinate system
61 fIsValidNorm = true;
62
63 SetCorners();
64 SetBoundaries();
65
66 fSurfaceArea = 1. ; // NOTE: not yet implemented!
67}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector unit() const
HepRotation inverse() const
G4VTwistSurface(const G4String &name)
G4SurfCurNormal fCurrentNormal
@ kPhi
Definition geomdefs.hh:60
@ kRho
Definition geomdefs.hh:58

◆ G4TwistTubsFlatSide() [2/3]

G4TwistTubsFlatSide::G4TwistTubsFlatSide ( const G4String & name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2],
G4int handedness )

Alternative Construct for a cylinder flat boundary surface.

Parameters
[in]nameThe surface name.
[in]EndInnerRadiusInner-hype radius at z=0.
[in]EndOuterRadiusOuter-hype radius at z=0.
[in]DPhiPhi angle.
[in]EndPhiTotal Phi.
[in]EndZZ length.
[in]handednessOrientation: +z = +ve, -z = -ve.

Definition at line 69 of file G4TwistTubsFlatSide.cc.

76 : G4VTwistSurface(name)
77{
78 fHandedness = handedness; // +z = +ve, -z = -ve
79 fAxis[0] = kRho; // in local coordinate system
80 fAxis[1] = kPhi;
81 G4int i = (handedness < 0 ? 0 : 1);
82 fAxisMin[0] = EndInnerRadius[i]; // Inner-hype radius at z=0
83 fAxisMax[0] = EndOuterRadius[i]; // Outer-hype radius at z=0
84 fAxisMin[1] = -0.5*DPhi;
85 fAxisMax[1] = -fAxisMin[1];
86 fCurrentNormal.normal.set(0, 0, (fHandedness < 0 ? -1 : 1));
87 // Unit vector, in local coordinate system
88 fRot.rotateZ(EndPhi[i]);
89 fTrans.set(0, 0, EndZ[i]);
90 fIsValidNorm = true;
91
92 SetCorners();
93 SetBoundaries();
94
95 fSurfaceArea = 0.5*DPhi * (EndOuterRadius[i]*EndOuterRadius[i]
96 - EndInnerRadius[i]*EndInnerRadius[i] ) ;
97}
int G4int
Definition G4Types.hh:85
G4RotationMatrix fRot
G4ThreeVector fTrans

◆ ~G4TwistTubsFlatSide()

G4TwistTubsFlatSide::~G4TwistTubsFlatSide ( )
overridedefault

Default destructor.

◆ G4TwistTubsFlatSide() [3/3]

G4TwistTubsFlatSide::G4TwistTubsFlatSide ( __void__ & a)

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 102 of file G4TwistTubsFlatSide.cc.

103 : G4VTwistSurface(a)
104{
105}

Member Function Documentation

◆ DistanceToSurface() [1/2]

G4int G4TwistTubsFlatSide::DistanceToSurface ( const G4ThreeVector & gp,
const G4ThreeVector & gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol )
overridevirtual

Returns the distance to surface, given point 'gp' and direction 'gv'.

Parameters
[in]gpThe point from where computing the distance.
[in]gvThe direction along which computing the distance.
[out]gxxVector of global points based on number of solutions.
[out]distanceThe distance vector based on number of solutions.
[out]areacodeThe location vector based on number of solutions.
[out]isvalidValidity vector based on number of solutions.
[in]validateAdopted validation criteria.
Returns
The number of solutions.

Implements G4VTwistSurface.

Definition at line 123 of file G4TwistTubsFlatSide.cc.

130{
131 fCurStatWithV.ResetfDone(validate, &gp, &gv);
132
133 if (fCurStatWithV.IsDone())
134 {
135 for (G4int i=0; i<fCurStatWithV.GetNXX(); ++i)
136 {
137 gxx[i] = fCurStatWithV.GetXX(i);
138 distance[i] = fCurStatWithV.GetDistance(i);
139 areacode[i] = fCurStatWithV.GetAreacode(i);
140 isvalid[i] = fCurStatWithV.IsValid(i);
141 }
142 return fCurStatWithV.GetNXX();
143 }
144
145 // initialize
146 for (G4int i=0; i<2; ++i)
147 {
148 distance[i] = kInfinity;
149 areacode[i] = sOutside;
150 isvalid[i] = false;
151 gxx[i].set(kInfinity, kInfinity, kInfinity);
152 }
153
156
157 //
158 // special case!
159 // if p is on surface, distance = 0.
160 //
161
162 if (std::fabs(p.z()) == 0.) // if p is on the plane
163 {
164 distance[0] = 0;
165 G4ThreeVector xx = p;
166 gxx[0] = ComputeGlobalPoint(xx);
167
168 if (validate == kValidateWithTol)
169 {
170 areacode[0] = GetAreaCode(xx);
171 if (!IsOutside(areacode[0]))
172 {
173 isvalid[0] = true;
174 }
175 }
176 else if (validate == kValidateWithoutTol)
177 {
178 areacode[0] = GetAreaCode(xx, false);
179 if (IsInside(areacode[0]))
180 {
181 isvalid[0] = true;
182 }
183 }
184 else // kDontValidate
185 {
186 areacode[0] = sInside;
187 isvalid[0] = true;
188 }
189 return 1;
190 }
191 //
192 // special case end
193 //
194
195 if (v.z() == 0)
196 {
197 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
198 isvalid[0], 0, validate, &gp, &gv);
199 return 0;
200 }
201
202 distance[0] = - (p.z() / v.z());
203
204 G4ThreeVector xx = p + distance[0]*v;
205 gxx[0] = ComputeGlobalPoint(xx);
206
207 if (validate == kValidateWithTol)
208 {
209 areacode[0] = GetAreaCode(xx);
210 if (!IsOutside(areacode[0]))
211 {
212 if (distance[0] >= 0) { isvalid[0] = true; }
213 }
214 }
215 else if (validate == kValidateWithoutTol)
216 {
217 areacode[0] = GetAreaCode(xx, false);
218 if (IsInside(areacode[0]))
219 {
220 if (distance[0] >= 0) { isvalid[0] = true; }
221 }
222 }
223 else // kDontValidate
224 {
225 areacode[0] = sInside;
226 if (distance[0] >= 0) { isvalid[0] = true; }
227 }
228
229 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
230 isvalid[0], 1, validate, &gp, &gv);
231
232#ifdef G4TWISTDEBUG
233 G4cerr << "ERROR - G4TwistTubsFlatSide::DistanceToSurface(p,v)" << G4endl;
234 G4cerr << " Name : " << GetName() << G4endl;
235 G4cerr << " xx : " << xx << G4endl;
236 G4cerr << " gxx[0] : " << gxx[0] << G4endl;
237 G4cerr << " dist[0] : " << distance[0] << G4endl;
238 G4cerr << " areacode[0] : " << areacode[0] << G4endl;
239 G4cerr << " isvalid[0] : " << isvalid[0] << G4endl;
240#endif
241 return 1;
242}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67
double z() const
void set(double x, double y, double z)
static const G4int sOutside
const G4String & GetName() const
G4ThreeVector ComputeLocalDirection(const G4ThreeVector &gp) const
G4bool IsInside(G4int areacode, G4bool testbitmode=false) const
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &gp) const
G4bool IsOutside(G4int areacode) const
static const G4int sInside
CurrentStatus fCurStatWithV
G4ThreeVector ComputeGlobalPoint(const G4ThreeVector &lp) const

◆ DistanceToSurface() [2/2]

G4int G4TwistTubsFlatSide::DistanceToSurface ( const G4ThreeVector & gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[] )
overridevirtual

Returns the safety distance to surface, given point 'gp'.

Parameters
[in]gpThe point from where computing the safety distance.
[out]gxxVector of global points based on number of solutions.
[out]distanceThe distance vector based on number of solutions.
[out]areacodeThe location vector based on number of solutions.
Returns
The number of solutions.

Implements G4VTwistSurface.

Definition at line 247 of file G4TwistTubsFlatSide.cc.

251{
252 // Calculate distance to plane in local coordinate,
253 // then return distance and global intersection points.
254 //
255
256 fCurStat.ResetfDone(kDontValidate, &gp);
257
258 if (fCurStat.IsDone())
259 {
260 for (G4int i=0; i<fCurStat.GetNXX(); ++i)
261 {
262 gxx[i] = fCurStat.GetXX(i);
263 distance[i] = fCurStat.GetDistance(i);
264 areacode[i] = fCurStat.GetAreacode(i);
265 }
266 return fCurStat.GetNXX();
267 }
268
269 // initialize
270 for (auto i=0; i<2; ++i)
271 {
272 distance[i] = kInfinity;
273 areacode[i] = sOutside;
274 gxx[i].set(kInfinity, kInfinity, kInfinity);
275 }
276
278 G4ThreeVector xx;
279
280 // The plane is placed on origin with making its normal
281 // parallel to z-axis.
282 if (std::fabs(p.z()) <= 0.5 * kCarTolerance) // if p is on plane, return 1
283 {
284 distance[0] = 0;
285 xx = p;
286 }
287 else
288 {
289 distance[0] = std::fabs(p.z());
290 xx.set(p.x(), p.y(), 0);
291 }
292
293 gxx[0] = ComputeGlobalPoint(xx);
294 areacode[0] = sInside;
295 G4bool isvalid = true;
296 fCurStat.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
297 isvalid, 1, kDontValidate, &gp);
298 return 1;
299}
bool G4bool
Definition G4Types.hh:86
double x() const
double y() const
CurrentStatus fCurStat

◆ GetNormal()

G4ThreeVector G4TwistTubsFlatSide::GetNormal ( const G4ThreeVector & ,
G4bool isGlobal = false )
overridevirtual

Returns a normal vector at a surface (or very close to the surface) point at 'p'.

Parameters
[in]pNot used. Using current normal.
[in]isGlobalIf true, it returns the normal in global coordinates.
Returns
The current normal vector.

Implements G4VTwistSurface.

Definition at line 110 of file G4TwistTubsFlatSide.cc.

112{
113 if (isGlobal)
114 {
116 }
117 return fCurrentNormal.normal;
118}
G4ThreeVector ComputeGlobalDirection(const G4ThreeVector &lp) const

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