Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TwistBoxSide.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4TwistBoxSide
27//
28// Class description:
29//
30// G4TwistBoxSide describes a twisted boundary surface for a trapezoid.
31
32// Author: 27-Oct-2004 - O.Link ([email protected])
33// --------------------------------------------------------------------
34#ifndef G4TWISTBOXSIDE_HH
35#define G4TWISTBOXSIDE_HH
36
37#include "G4VTwistSurface.hh"
38
39#include <vector>
40
42{
43 public: // with description
44
45 G4TwistBoxSide(const G4String& name,
46 G4double PhiTwist, // twist angle
47 G4double pDz, // half z lenght
48 G4double pTheta, // direction between end planes
49 G4double pPhi, // by polar and azimutal angles
50 G4double pDy1, // half y length at -pDz
51 G4double pDx1, // half x length at -pDz,-pDy
52 G4double pDx2, // half x length at -pDz,+pDy
53 G4double pDy2, // half y length at +pDz
54 G4double pDx3, // half x length at +pDz,-pDy
55 G4double pDx4, // half x length at +pDz,+pDy
56 G4double pAlph, // tilt angle at +pDz
57 G4double AngleSide // parity
58 );
59
60 virtual ~G4TwistBoxSide();
61
62 virtual G4ThreeVector GetNormal(const G4ThreeVector& xx,
63 G4bool isGlobal = false) ;
64
65 virtual G4int DistanceToSurface(const G4ThreeVector& gp,
66 const G4ThreeVector& gv,
67 G4ThreeVector gxx[],
68 G4double distance[],
69 G4int areacode[],
70 G4bool isvalid[],
71 EValidate validate = kValidateWithTol);
72
73 virtual G4int DistanceToSurface(const G4ThreeVector& gp,
74 G4ThreeVector gxx[],
75 G4double distance[],
76 G4int areacode[]);
77
78 public: // without description
79
80 G4TwistBoxSide(__void__&);
81 // Fake default constructor for usage restricted to direct object
82 // persistency for clients requiring preallocation of memory for
83 // persistifiable objects.
84
85 private:
86
87 virtual G4int GetAreaCode(const G4ThreeVector& xx,
88 G4bool withTol = true);
89 virtual void SetCorners();
90 virtual void SetBoundaries();
91
92 void GetPhiUAtX(G4ThreeVector p, G4double& phi, G4double& u);
93 G4ThreeVector ProjectPoint(const G4ThreeVector& p,
94 G4bool isglobal = false);
95
96 virtual G4ThreeVector SurfacePoint(G4double phi, G4double u,
97 G4bool isGlobal = false);
98 virtual G4double GetBoundaryMin(G4double phi);
99 virtual G4double GetBoundaryMax(G4double phi);
100 virtual G4double GetSurfaceArea();
101 virtual void GetFacets( G4int m, G4int n, G4double xyz[][3],
102 G4int faces[][4], G4int iside );
103
104 inline G4double GetValueA(G4double phi);
105 inline G4double GetValueB(G4double phi);
106 inline G4ThreeVector NormAng(G4double phi, G4double u);
107 inline G4double Xcoef(G4double u, G4double phi);
108 // To calculate the w(u) function
109
110 private:
111
112 G4double fTheta;
113 G4double fPhi ;
114
115 G4double fDy1;
116 G4double fDx1;
117 G4double fDx2;
118
119 G4double fDy2;
120 G4double fDx3;
121 G4double fDx4;
122
123 G4double fDz; // Half-length along the z axis
124
125 G4double fAlph;
126 G4double fTAlph; // std::tan(fAlph)
127
128 G4double fPhiTwist; // twist angle ( dphi in surface equation)
129
130 G4double fAngleSide;
131
132 G4double fdeltaX;
133 G4double fdeltaY;
134
135 G4double fDx4plus2; // fDx4 + fDx2 == a2/2 + a1/2
136 G4double fDx4minus2; // fDx4 - fDx2 -
137 G4double fDx3plus1; // fDx3 + fDx1 == d2/2 + d1/2
138 G4double fDx3minus1; // fDx3 - fDx1 -
139 G4double fDy2plus1; // fDy2 + fDy1 == b2/2 + b1/2
140 G4double fDy2minus1; // fDy2 - fDy1 -
141 G4double fa1md1; // 2 fDx2 - 2 fDx1 == a1 - d1
142 G4double fa2md2; // 2 fDx4 - 2 fDx3
143};
144
145//========================================================
146// inline functions
147//========================================================
148
149inline
150G4double G4TwistBoxSide::GetValueA(G4double phi)
151{
152 return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist ) ;
153}
154
155
156inline
157G4double G4TwistBoxSide::GetValueB(G4double phi)
158{
159 return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
160}
161
162inline
163G4double G4TwistBoxSide::Xcoef(G4double u, G4double phi)
164{
165
166 return GetValueA(phi)/2. + u*fTAlph ;
167
168}
169
170inline G4ThreeVector
171G4TwistBoxSide::SurfacePoint( G4double phi, G4double u, G4bool isGlobal )
172{
173 // function to calculate a point on the surface, given by parameters phi,u
174
175 G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
176 - u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
177 Xcoef(u,phi) * std::sin(phi)
178 + u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
179 2*fDz*phi/fPhiTwist );
180
181 if (isGlobal) { return (fRot * SurfPoint + fTrans); }
182 return SurfPoint;
183}
184
185inline
186G4double G4TwistBoxSide::GetBoundaryMin(G4double phi)
187{
188 return -0.5*GetValueB(phi) ;
189}
190
191inline
192G4double G4TwistBoxSide::GetBoundaryMax(G4double phi)
193{
194 return 0.5*GetValueB(phi) ;
195}
196
197inline
198G4double G4TwistBoxSide::GetSurfaceArea()
199{
200 return (fDz*(std::sqrt(16*fDy1*fDy1
201 + (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
202 + std::sqrt(16*fDy1*fDy1 + (fa2md2 + 4*fDy1*fTAlph)
203 * (fa2md2 + 4*fDy1*fTAlph))))/2. ;
204}
205
206inline
207G4ThreeVector G4TwistBoxSide::NormAng( G4double phi, G4double u )
208{
209 // function to calculate the norm at a given point on the surface
210 // replace a1-d1
211
212 G4ThreeVector nvec( 4*fDz*(std::cos(phi) + fTAlph*std::sin(phi)) ,
213 4*fDz*(-(fTAlph*std::cos(phi)) + std::sin(phi)),
214 (fDx2 + fDx4)*fPhiTwist*fTAlph
215 + 2*fDx4minus2*(-1 + fTAlph*phi)
216 + 2*fPhiTwist*(1 + fTAlph*fTAlph)*u
217 - 2*(fdeltaX - fdeltaY*fTAlph)*std::cos(phi)
218 - 2*(fdeltaY + fdeltaX*fTAlph)*std::sin(phi) );
219 return nvec.unit();
220}
221
222#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
virtual ~G4TwistBoxSide()
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal=false)
G4RotationMatrix fRot
G4ThreeVector fTrans