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[ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // G4TwistTrapAlphaSide
 27 //
 28 // Class description:
 29 //
 30 // Class describing a twisted boundary surface for a trapezoid.
 31 
 32 // Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
 33 // --------------------------------------------------------------------
 34 #ifndef G4TWISTTRAPALPHASIDE_HH
 35 #define G4TWISTTRAPALPHASIDE_HH
 36 
 37 #include "G4VTwistSurface.hh"
 38 
 39 #include <vector>
 40 
 41 class G4TwistTrapAlphaSide : public G4VTwistSurface
 42 {
 43   public:
 44    
 45     G4TwistTrapAlphaSide(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     ~G4TwistTrapAlphaSide() override;
 61    
 62     G4ThreeVector  GetNormal(const G4ThreeVector& xx,
 63                                            G4bool isGlobal = false) override ;   
 64    
 65     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) override;
 72                                                   
 73     G4int DistanceToSurface(const G4ThreeVector& gp,
 74                                   G4ThreeVector  gxx[],
 75                                   G4double       distance[],
 76                                   G4int          areacode[]) override;
 77 
 78     G4TwistTrapAlphaSide(__void__&);
 79       // Fake default constructor for usage restricted to direct object
 80       // persistency for clients requiring preallocation of memory for
 81       // persistifiable objects.
 82 
 83   private:
 84 
 85     G4int GetAreaCode(const G4ThreeVector& xx, 
 86                             G4bool withTol = true) override;
 87     void SetCorners() override;
 88     void SetBoundaries() override;
 89 
 90     void GetPhiUAtX(const G4ThreeVector& p, G4double& phi, G4double& u);
 91     G4ThreeVector ProjectPoint(const G4ThreeVector& p,
 92                                      G4bool isglobal = false);
 93 
 94     inline G4ThreeVector SurfacePoint(G4double phi, G4double u,
 95                                       G4bool isGlobal = false ) override;
 96     inline G4double GetBoundaryMin(G4double phi) override;
 97     inline G4double GetBoundaryMax(G4double phi) override;
 98     inline G4double GetSurfaceArea() override;
 99     void GetFacets( G4int m, G4int n, G4double xyz[][3],
100                     G4int faces[][4], G4int iside ) override;
101 
102     inline G4ThreeVector NormAng(G4double phi, G4double u);
103     inline G4double GetValueA(G4double phi);
104     inline G4double GetValueB(G4double phi);
105     inline G4double GetValueD(G4double phi);
106     inline G4double Xcoef(G4double u,G4double phi);
107       // To calculate the w(u) function
108 
109   private:
110 
111     G4double fTheta;   
112     G4double fPhi ;
113 
114     G4double fDy1;   
115     G4double fDx1;     
116     G4double fDx2;     
117 
118     G4double fDy2;   
119     G4double fDx3;     
120     G4double fDx4;     
121 
122     G4double fDz;         // Half-length along the z axis
123 
124     G4double fAlph;
125     G4double fTAlph;      // std::tan(fAlph)
126     
127     G4double fPhiTwist;   // twist angle (dphi in surface equation)
128 
129     G4double fAngleSide;
130 
131     G4double fDx4plus2;  // fDx4 + fDx2  == a2/2 + a1/2
132     G4double fDx4minus2; // fDx4 - fDx2          -
133     G4double fDx3plus1;  // fDx3 + fDx1  == d2/2 + d1/2
134     G4double fDx3minus1; // fDx3 - fDx1          -
135     G4double fDy2plus1;  // fDy2 + fDy1  == b2/2 + b1/2
136     G4double fDy2minus1; // fDy2 - fDy1          -
137     G4double fa1md1;     // 2 fDx2 - 2 fDx1  == a1 - d1
138     G4double fa2md2;     // 2 fDx4 - 2 fDx3 
139 
140     G4double fdeltaX;
141     G4double fdeltaY;
142 };   
143 
144 //========================================================
145 // inline functions
146 //========================================================
147 
148 inline
149 G4double G4TwistTrapAlphaSide::GetValueA(G4double phi)
150 {
151   return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist  ) ;
152 }
153 
154 inline
155 G4double G4TwistTrapAlphaSide::GetValueD(G4double phi) 
156 {
157   return ( fDx3plus1 + fDx3minus1 * ( 2 * phi) / fPhiTwist  ) ;
158 } 
159 
160 inline 
161 G4double G4TwistTrapAlphaSide::GetValueB(G4double phi) 
162 {
163   return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
164 }
165 
166 
167 inline
168 G4double G4TwistTrapAlphaSide::Xcoef(G4double u, G4double phi)
169 {
170   
171   return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4. 
172     - u*( ( GetValueD(phi)-GetValueA(phi) )/( 2 * GetValueB(phi) ) - fTAlph );
173 
174 }
175 
176 inline G4ThreeVector
177 G4TwistTrapAlphaSide::SurfacePoint(G4double phi, G4double u , G4bool isGlobal)
178 {
179   // function to calculate a point on the surface, given by parameters phi,u
180 
181   G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
182                           - u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
183                             Xcoef(u,phi) * std::sin(phi)
184                           + u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
185                             2*fDz*phi/fPhiTwist  );
186   if (isGlobal) { return (fRot * SurfPoint + fTrans); }
187   return SurfPoint;
188 }
189 
190 inline
191 G4double G4TwistTrapAlphaSide::GetBoundaryMin(G4double phi)
192 {
193   return -0.5*GetValueB(phi) ;
194 }
195 
196 inline
197 G4double G4TwistTrapAlphaSide::GetBoundaryMax(G4double phi)
198 {
199   return 0.5*GetValueB(phi) ;
200 }
201 
202 inline
203 G4double G4TwistTrapAlphaSide::GetSurfaceArea()
204 {
205   return (fDz*(std::sqrt(16*fDy1*fDy1
206              + (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
207              + std::sqrt(16*fDy2*fDy2 + (fa2md2 + 4*fDy2*fTAlph)
208                                       * (fa2md2 + 4*fDy2*fTAlph))))/2. ;
209 }
210 
211 inline
212 G4ThreeVector G4TwistTrapAlphaSide::NormAng( G4double phi, G4double u ) 
213 {
214   // function to calculate the norm at a given point on the surface
215   // replace a1-d1
216 
217   G4ThreeVector nvec ( fDy1* fDz*(4*fDy1*std::cos(phi)
218                      + (fa1md1 + 4*fDy1*fTAlph)*std::sin(phi)),
219                        -(fDy1* fDz*((fa1md1 + 4*fDy1*fTAlph)*std::cos(phi)
220                      - 4*fDy1*std::sin(phi))),
221                        (fDy1*(-8*(fDx3minus1 + fDx4minus2)*fDy1
222                                 + fa1md1*(fDx2 + fDx3plus1 + fDx4)*fPhiTwist
223                                 + 4*(fDx2 + fDx3plus1 + fDx4)*fDy1*fPhiTwist
224                                 *fTAlph + 2*(fDx3minus1 + fDx4minus2)
225                                 *(fa1md1 + 4*fDy1*fTAlph)*phi)
226                                 + fPhiTwist*(16*fDy1*fDy1
227                                 + (fa1md1 + 4*fDy1*fTAlph)
228                                 *(fa1md1 + 4*fDy1*fTAlph))*u
229                                 + 4*fDy1*(fa1md1*fdeltaY - 4*fdeltaX*fDy1
230                                 + 4*fdeltaY*fDy1*fTAlph)* std::cos(phi)
231                                 - 4*fDy1*(fa1md1*fdeltaX + 4*fDy1*(fdeltaY
232                                 + fdeltaX*fTAlph))*std::sin(phi))/ 8. ) ;
233   return nvec.unit();
234 }
235 
236 #endif
237