Geant4  10.01.p02
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 //
27 // $Id: G4TwistBoxSide.hh 66356 2012-12-18 09:02:32Z gcosmo $
28 //
29 // --------------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 //
33 // G4TwistBoxSide
34 //
35 // Class description:
36 //
37 // Class describing a twisted boundary surface for a trapezoid.
38 
39 // Author:
40 //
41 // 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
42 //
43 // --------------------------------------------------------------------
44 #ifndef __G4TWISTBOXSIDE__
45 #define __G4TWISTBOXSIDE__
46 
47 #include "G4VTwistSurface.hh"
48 
49 #include <vector>
50 
52 {
53  public: // with description
54 
56  G4double PhiTwist, // twist angle
57  G4double pDz, // half z lenght
58  G4double pTheta, // direction between end planes
59  G4double pPhi, // by polar and azimutal angles
60  G4double pDy1, // half y length at -pDz
61  G4double pDx1, // half x length at -pDz,-pDy
62  G4double pDx2, // half x length at -pDz,+pDy
63  G4double pDy2, // half y length at +pDz
64  G4double pDx3, // half x length at +pDz,-pDy
65  G4double pDx4, // half x length at +pDz,+pDy
66  G4double pAlph, // tilt angle at +pDz
67  G4double AngleSide // parity
68  );
69 
70  virtual ~G4TwistBoxSide();
71 
72  virtual G4ThreeVector GetNormal(const G4ThreeVector &xx,
73  G4bool isGlobal = false) ;
74 
75  virtual G4int DistanceToSurface(const G4ThreeVector &gp,
76  const G4ThreeVector &gv,
77  G4ThreeVector gxx[],
78  G4double distance[],
79  G4int areacode[],
80  G4bool isvalid[],
81  EValidate validate = kValidateWithTol);
82 
83  virtual G4int DistanceToSurface(const G4ThreeVector &gp,
84  G4ThreeVector gxx[],
85  G4double distance[],
86  G4int areacode[]);
87 
88  public: // without description
89 
90  G4TwistBoxSide(__void__&);
91  // Fake default constructor for usage restricted to direct object
92  // persistency for clients requiring preallocation of memory for
93  // persistifiable objects.
94 
95  private:
96 
97  virtual G4int GetAreaCode(const G4ThreeVector &xx,
98  G4bool withTol = true);
99  virtual void SetCorners();
100  virtual void SetBoundaries();
101 
102  void GetPhiUAtX(G4ThreeVector p, G4double &phi, G4double &u);
104  G4bool isglobal = false);
105 
107  G4bool isGlobal = false);
108  virtual G4double GetBoundaryMin(G4double phi);
109  virtual G4double GetBoundaryMax(G4double phi);
110  virtual G4double GetSurfaceArea();
111  virtual void GetFacets( G4int m, G4int n, G4double xyz[][3],
112  G4int faces[][4], G4int iside );
113 
114  inline G4double GetValueA(G4double phi);
115  inline G4double GetValueB(G4double phi);
116  inline G4ThreeVector NormAng(G4double phi, G4double u);
117  inline G4double Xcoef(G4double u,G4double phi);
118  // To calculate the w(u) function
119 
120  private:
121 
124 
128 
132 
133  G4double fDz; // Half-length along the z axis
134 
136  G4double fTAlph; // std::tan(fAlph)
137 
138  G4double fPhiTwist; // twist angle ( dphi in surface equation)
139 
141 
144 
145  G4double fDx4plus2; // fDx4 + fDx2 == a2/2 + a1/2
146  G4double fDx4minus2; // fDx4 - fDx2 -
147  G4double fDx3plus1; // fDx3 + fDx1 == d2/2 + d1/2
148  G4double fDx3minus1; // fDx3 - fDx1 -
149  G4double fDy2plus1; // fDy2 + fDy1 == b2/2 + b1/2
150  G4double fDy2minus1; // fDy2 - fDy1 -
151  G4double fa1md1; // 2 fDx2 - 2 fDx1 == a1 - d1
152  G4double fa2md2; // 2 fDx4 - 2 fDx3
153 };
154 
155 //========================================================
156 // inline functions
157 //========================================================
158 
159 inline
161 {
162  return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist ) ;
163 }
164 
165 
166 inline
168 {
169  return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
170 }
171 
172 inline
174 {
175 
176  return GetValueA(phi)/2. + u*fTAlph ;
177 
178 }
179 
180 inline G4ThreeVector
182 {
183  // function to calculate a point on the surface, given by parameters phi,u
184 
185  G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
186  - u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
187  Xcoef(u,phi) * std::sin(phi)
188  + u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
189  2*fDz*phi/fPhiTwist );
190 
191  if (isGlobal) { return (fRot * SurfPoint + fTrans); }
192  return SurfPoint;
193 }
194 
195 inline
197 {
198  return -0.5*GetValueB(phi) ;
199 }
200 
201 inline
203 {
204  return 0.5*GetValueB(phi) ;
205 }
206 
207 inline
209 {
210  return (fDz*(std::sqrt(16*fDy1*fDy1
211  + (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
212  + std::sqrt(16*fDy1*fDy1 + (fa2md2 + 4*fDy1*fTAlph)
213  * (fa2md2 + 4*fDy1*fTAlph))))/2. ;
214 }
215 
216 inline
218 {
219  // function to calculate the norm at a given point on the surface
220  // replace a1-d1
221 
222  G4ThreeVector nvec( 4*fDz*(std::cos(phi) + fTAlph*std::sin(phi)) ,
223  4*fDz*(-(fTAlph*std::cos(phi)) + std::sin(phi)),
225  + 2*fDx4minus2*(-1 + fTAlph*phi)
226  + 2*fPhiTwist*(1 + fTAlph*fTAlph)*u
227  - 2*(fdeltaX - fdeltaY*fTAlph)*std::cos(phi)
228  - 2*(fdeltaY + fdeltaX*fTAlph)*std::sin(phi) );
229  return nvec.unit();
230 }
231 
232 #endif
virtual G4double GetSurfaceArea()
virtual G4ThreeVector SurfacePoint(G4double phi, G4double u, G4bool isGlobal=false)
CLHEP::Hep3Vector G4ThreeVector
G4String name
Definition: TRTMaterials.hh:40
G4double GetValueA(G4double phi)
virtual G4double GetBoundaryMin(G4double phi)
virtual G4int GetAreaCode(const G4ThreeVector &xx, G4bool withTol=true)
G4TwistBoxSide(const G4String &name, G4double PhiTwist, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlph, G4double AngleSide)
int G4int
Definition: G4Types.hh:78
G4RotationMatrix fRot
G4ThreeVector fTrans
bool G4bool
Definition: G4Types.hh:79
virtual G4double GetBoundaryMax(G4double phi)
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)
const G4int n
virtual G4int DistanceToSurface(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector gxx[], G4double distance[], G4int areacode[], G4bool isvalid[], EValidate validate=kValidateWithTol)
void GetPhiUAtX(G4ThreeVector p, G4double &phi, G4double &u)
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal=false)
G4double Xcoef(G4double u, G4double phi)
virtual void SetBoundaries()
virtual ~G4TwistBoxSide()
static const double m
Definition: G4SIunits.hh:110
G4ThreeVector ProjectPoint(const G4ThreeVector &p, G4bool isglobal=false)
double G4double
Definition: G4Types.hh:76
G4double GetValueB(G4double phi)
G4ThreeVector NormAng(G4double phi, G4double u)
virtual void SetCorners()