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

G4TwistTrapFlatSide describes a flat boundary surface for a trapezoid. More...

#include <G4TwistTrapFlatSide.hh>

Inheritance diagram for G4TwistTrapFlatSide:

Public Member Functions

 G4TwistTrapFlatSide (const G4String &name, G4double PhiTwist, G4double pDx1, G4double pDx2, G4double pDy, G4double pDz, G4double pAlpha, G4double pPhi, G4double pTheta, G4int handedness)
 ~G4TwistTrapFlatSide () 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
 G4TwistTrapFlatSide (__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

G4TwistTrapFlatSide describes a flat boundary surface for a trapezoid.

Definition at line 43 of file G4TwistTrapFlatSide.hh.

Constructor & Destructor Documentation

◆ G4TwistTrapFlatSide() [1/2]

G4TwistTrapFlatSide::G4TwistTrapFlatSide ( const G4String & name,
G4double PhiTwist,
G4double pDx1,
G4double pDx2,
G4double pDy,
G4double pDz,
G4double pAlpha,
G4double pPhi,
G4double pTheta,
G4int handedness )

Constructs a trapezoid flat boundary surface, given its parameters.

Parameters
[in]nameThe surface name.
[in]PhiTwistThe twist angle.
[in]pDx1Half x length at -pDz,-pDy.
[in]pDx2Half x length at -pDz,+pDy.
[in]pDyHalf y length.
[in]pDzHalf z length.
[in]pAlphaTilt angle at +pDz.
[in]pPhiDirection between end planes - azimuthal angle.
[in]pThetaDirection between end planes - polar angle.
[in]handednessOrientation: +z = +ve, -z = -ve.

Definition at line 36 of file G4TwistTrapFlatSide.cc.

46 : G4VTwistSurface(name)
47{
48 fHandedness = handedness; // +z = +ve, -z = -ve
49
50 fDx1 = pDx1 ;
51 fDx2 = pDx2 ;
52 fDy = pDy ;
53 fDz = pDz ;
54 fAlpha = pAlpha ;
55 fTAlph = std::tan(fAlpha) ;
56 fPhi = pPhi ;
57 fTheta = pTheta ;
58
59 fdeltaX = 2 * fDz * std::tan(fTheta) * std::cos(fPhi) ;
60 // dx in surface equation
61 fdeltaY = 2 * fDz * std::tan(fTheta) * std::sin(fPhi) ;
62 // dy in surface equation
63
64 fPhiTwist = PhiTwist ;
65
66 fCurrentNormal.normal.set( 0, 0, (fHandedness < 0 ? -1 : 1));
67 // Unit vector, in local coordinate system
68 fRot.rotateZ( fHandedness > 0
69 ? 0.5 * fPhiTwist
70 : -0.5 * fPhiTwist );
71
72 fTrans.set(
73 fHandedness > 0 ? 0.5*fdeltaX : -0.5*fdeltaX ,
74 fHandedness > 0 ? 0.5*fdeltaY : -0.5*fdeltaY ,
75 fHandedness > 0 ? fDz : -fDz ) ;
76
77 fIsValidNorm = true;
78
79
80 fAxis[0] = kXAxis ;
81 fAxis[1] = kYAxis ;
82 fAxisMin[0] = kInfinity ; // x-Axis cannot be fixed, because it
83 fAxisMax[0] = kInfinity ; // depends on y
84 fAxisMin[1] = -fDy ; // y - axis
85 fAxisMax[1] = fDy ;
86
87 SetCorners();
88 SetBoundaries();
89}
G4VTwistSurface(const G4String &name)
G4RotationMatrix fRot
G4ThreeVector fTrans
G4SurfCurNormal fCurrentNormal
@ kYAxis
Definition geomdefs.hh:56
@ kXAxis
Definition geomdefs.hh:55

◆ ~G4TwistTrapFlatSide()

G4TwistTrapFlatSide::~G4TwistTrapFlatSide ( )
overridedefault

Default destructor.

◆ G4TwistTrapFlatSide() [2/2]

G4TwistTrapFlatSide::G4TwistTrapFlatSide ( __void__ & a)

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

Definition at line 95 of file G4TwistTrapFlatSide.cc.

97{
98}

Member Function Documentation

◆ DistanceToSurface() [1/2]

G4int G4TwistTrapFlatSide::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 117 of file G4TwistTrapFlatSide.cc.

124{
125 fCurStatWithV.ResetfDone(validate, &gp, &gv);
126
127 if (fCurStatWithV.IsDone())
128 {
129 for (G4int i=0; i<fCurStatWithV.GetNXX(); ++i)
130 {
131 gxx[i] = fCurStatWithV.GetXX(i);
132 distance[i] = fCurStatWithV.GetDistance(i);
133 areacode[i] = fCurStatWithV.GetAreacode(i);
134 isvalid[i] = fCurStatWithV.IsValid(i);
135 }
136 return fCurStatWithV.GetNXX();
137 }
138
139 // initialize
140 for (auto i=0; i<2; ++i)
141 {
142 distance[i] = kInfinity;
143 areacode[i] = sOutside;
144 isvalid[i] = false;
145 gxx[i].set(kInfinity, kInfinity, kInfinity);
146 }
147
150
151 //
152 // special case!
153 // if p is on surface, distance = 0.
154 //
155
156 if (std::fabs(p.z()) == 0.) // if p is on the plane
157 {
158 distance[0] = 0;
159 G4ThreeVector xx = p;
160 gxx[0] = ComputeGlobalPoint(xx);
161
162 if (validate == kValidateWithTol)
163 {
164 areacode[0] = GetAreaCode(xx);
165 if (!IsOutside(areacode[0]))
166 {
167 isvalid[0] = true;
168 }
169 }
170 else if (validate == kValidateWithoutTol)
171 {
172 areacode[0] = GetAreaCode(xx, false);
173 if (IsInside(areacode[0]))
174 {
175 isvalid[0] = true;
176 }
177 }
178 else // kDontValidate
179 {
180 areacode[0] = sInside;
181 isvalid[0] = true;
182 }
183 return 1;
184 }
185 //
186 // special case end
187 //
188
189 if (v.z() == 0)
190 {
191 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
192 isvalid[0], 0, validate, &gp, &gv);
193 return 0;
194 }
195
196 distance[0] = - (p.z() / v.z());
197
198 G4ThreeVector xx = p + distance[0]*v;
199 gxx[0] = ComputeGlobalPoint(xx);
200
201 if (validate == kValidateWithTol)
202 {
203 areacode[0] = GetAreaCode(xx);
204 if (!IsOutside(areacode[0]))
205 {
206 if (distance[0] >= 0) { isvalid[0] = true; }
207 }
208 }
209 else if (validate == kValidateWithoutTol)
210 {
211 areacode[0] = GetAreaCode(xx, false);
212 if (IsInside(areacode[0]))
213 {
214 if (distance[0] >= 0) { isvalid[0] = true; }
215 }
216 }
217 else // kDontValidate
218 {
219 areacode[0] = sInside;
220 if (distance[0] >= 0) { isvalid[0] = true; }
221 }
222
223 fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
224 isvalid[0], 1, validate, &gp, &gv);
225
226#ifdef G4TWISTDEBUG
227 G4cerr << "ERROR - G4TwistTrapFlatSide::DistanceToSurface(p,v)" << G4endl;
228 G4cerr << " Name : " << GetName() << G4endl;
229 G4cerr << " xx : " << xx << G4endl;
230 G4cerr << " gxx[0] : " << gxx[0] << G4endl;
231 G4cerr << " dist[0] : " << distance[0] << G4endl;
232 G4cerr << " areacode[0] : " << areacode[0] << G4endl;
233 G4cerr << " isvalid[0] : " << isvalid[0] << G4endl;
234#endif
235 return 1;
236}
CLHEP::Hep3Vector G4ThreeVector
int G4int
Definition G4Types.hh:85
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 G4TwistTrapFlatSide::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 241 of file G4TwistTrapFlatSide.cc.

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

◆ GetNormal()

G4ThreeVector G4TwistTrapFlatSide::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 104 of file G4TwistTrapFlatSide.cc.

106{
107 if (isGlobal)
108 {
110 }
111 return fCurrentNormal.normal;
112}
G4ThreeVector ComputeGlobalDirection(const G4ThreeVector &lp) const

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