G4TwistTrapAlphaSide.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4TwistTrapAlphaSide.hh 67011 2013-01-29 16:17:41Z gcosmo $
00028 // 
00029 // --------------------------------------------------------------------
00030 // GEANT 4 class header file
00031 //
00032 //
00033 // G4TwistTrapAlphaSide
00034 //
00035 // Class description:
00036 //
00037 //  Class describing a twisted boundary surface for a trapezoid.
00038 
00039 // Author:
00040 //
00041 //   27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
00042 //
00043 // --------------------------------------------------------------------
00044 #ifndef __G4TWISTTRAPALPHASIDE__
00045 #define __G4TWISTTRAPALPHASIDE__
00046 
00047 #include "G4VTwistSurface.hh"
00048 
00049 #include <vector>
00050 
00051 class G4TwistTrapAlphaSide : public G4VTwistSurface
00052 {
00053   public:  // with description
00054    
00055     G4TwistTrapAlphaSide(const G4String &name,
00056                                G4double  PhiTwist, // twist angle
00057                                G4double  pDz,      // half z lenght
00058                                G4double  pTheta, // direction between end planes
00059                                G4double  pPhi,   // by polar and azimutal angles
00060                                G4double  pDy1,     // half y length at -pDz
00061                                G4double  pDx1,     // half x length at -pDz,-pDy
00062                                G4double  pDx2,     // half x length at -pDz,+pDy
00063                                G4double  pDy2,     // half y length at +pDz
00064                                G4double  pDx3,     // half x length at +pDz,-pDy
00065                                G4double  pDx4,     // half x length at +pDz,+pDy
00066                                G4double  pAlph,    // tilt angle at +pDz
00067                                G4double  AngleSide // parity
00068                          );
00069   
00070     virtual ~G4TwistTrapAlphaSide();
00071    
00072     virtual G4ThreeVector  GetNormal(const G4ThreeVector &xx,
00073                                            G4bool isGlobal = false) ;   
00074    
00075     virtual G4int DistanceToSurface(const G4ThreeVector &gp,
00076                                     const G4ThreeVector &gv,
00077                                           G4ThreeVector  gxx[],
00078                                           G4double  distance[],
00079                                           G4int     areacode[],
00080                                           G4bool    isvalid[],
00081                                     EValidate validate = kValidateWithTol);
00082                                                   
00083     virtual G4int DistanceToSurface(const G4ThreeVector &gp,
00084                                           G4ThreeVector  gxx[],
00085                                           G4double       distance[],
00086                                           G4int          areacode[]);
00087 
00088 
00089   public:  // without description
00090 
00091     G4TwistTrapAlphaSide(__void__&);
00092       // Fake default constructor for usage restricted to direct object
00093       // persistency for clients requiring preallocation of memory for
00094       // persistifiable objects.
00095 
00096   private:
00097 
00098     virtual G4int GetAreaCode(const G4ThreeVector &xx, 
00099                                     G4bool         withTol = true);
00100     virtual void SetCorners();
00101     virtual void SetBoundaries();
00102 
00103     void GetPhiUAtX(G4ThreeVector p, G4double &phi, G4double &u);
00104     G4ThreeVector ProjectPoint(const G4ThreeVector &p,
00105                                      G4bool isglobal = false);
00106 
00107     virtual G4ThreeVector SurfacePoint(G4double phi, G4double u,
00108                                        G4bool isGlobal = false );
00109     virtual G4double GetBoundaryMin(G4double phi);
00110     virtual G4double GetBoundaryMax(G4double phi);
00111     virtual G4double GetSurfaceArea();
00112     virtual void GetFacets( G4int m, G4int n, G4double xyz[][3],
00113                             G4int faces[][4], G4int iside );
00114 
00115     inline G4ThreeVector NormAng(G4double phi, G4double u);
00116     inline G4double GetValueA(G4double phi);
00117     inline G4double GetValueB(G4double phi);
00118     inline G4double GetValueD(G4double phi);
00119     inline G4double Xcoef(G4double u,G4double phi);
00120       // To calculate the w(u) function
00121 
00122   private:
00123 
00124     G4double fTheta;   
00125     G4double fPhi ;
00126 
00127     G4double fDy1;   
00128     G4double fDx1;     
00129     G4double fDx2;     
00130 
00131     G4double fDy2;   
00132     G4double fDx3;     
00133     G4double fDx4;     
00134 
00135     G4double fDz;         // Half-length along the z axis
00136 
00137     G4double fAlph;
00138     G4double fTAlph;      // std::tan(fAlph)
00139     
00140     G4double fPhiTwist;   // twist angle (dphi in surface equation)
00141 
00142     G4double fAngleSide;
00143 
00144     G4double fDx4plus2;  // fDx4 + fDx2  == a2/2 + a1/2
00145     G4double fDx4minus2; // fDx4 - fDx2          -
00146     G4double fDx3plus1;  // fDx3 + fDx1  == d2/2 + d1/2
00147     G4double fDx3minus1; // fDx3 - fDx1          -
00148     G4double fDy2plus1;  // fDy2 + fDy1  == b2/2 + b1/2
00149     G4double fDy2minus1; // fDy2 - fDy1          -
00150     G4double fa1md1;     // 2 fDx2 - 2 fDx1  == a1 - d1
00151     G4double fa2md2;     // 2 fDx4 - 2 fDx3 
00152 
00153     G4double fdeltaX;
00154     G4double fdeltaY;
00155 };   
00156 
00157 //========================================================
00158 // inline functions
00159 //========================================================
00160 
00161 inline
00162 G4double G4TwistTrapAlphaSide::GetValueA(G4double phi)
00163 {
00164   return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist  ) ;
00165 }
00166 
00167 inline
00168 G4double G4TwistTrapAlphaSide::GetValueD(G4double phi) 
00169 {
00170   return ( fDx3plus1 + fDx3minus1 * ( 2 * phi) / fPhiTwist  ) ;
00171 } 
00172 
00173 inline 
00174 G4double G4TwistTrapAlphaSide::GetValueB(G4double phi) 
00175 {
00176   return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
00177 }
00178 
00179 
00180 inline
00181 G4double G4TwistTrapAlphaSide::Xcoef(G4double u, G4double phi)
00182 {
00183   
00184   return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4. 
00185     - u*( ( GetValueD(phi)-GetValueA(phi) )/( 2 * GetValueB(phi) ) - fTAlph );
00186 
00187 }
00188 
00189 inline G4ThreeVector
00190 G4TwistTrapAlphaSide::SurfacePoint(G4double phi, G4double u , G4bool isGlobal)
00191 {
00192   // function to calculate a point on the surface, given by parameters phi,u
00193 
00194   G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
00195                           - u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
00196                             Xcoef(u,phi) * std::sin(phi)
00197                           + u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
00198                             2*fDz*phi/fPhiTwist  );
00199   if (isGlobal) { return (fRot * SurfPoint + fTrans); }
00200   return SurfPoint;
00201 }
00202 
00203 inline
00204 G4double G4TwistTrapAlphaSide::GetBoundaryMin(G4double phi)
00205 {
00206   return -0.5*GetValueB(phi) ;
00207 }
00208 
00209 inline
00210 G4double G4TwistTrapAlphaSide::GetBoundaryMax(G4double phi)
00211 {
00212   return 0.5*GetValueB(phi) ;
00213 }
00214 
00215 inline
00216 G4double G4TwistTrapAlphaSide::GetSurfaceArea()
00217 {
00218   return (fDz*(std::sqrt(16*fDy1*fDy1
00219              + (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
00220              + std::sqrt(16*fDy2*fDy2 + (fa2md2 + 4*fDy2*fTAlph)
00221                                       * (fa2md2 + 4*fDy2*fTAlph))))/2. ;
00222 }
00223 
00224 inline
00225 G4ThreeVector G4TwistTrapAlphaSide::NormAng( G4double phi, G4double u ) 
00226 {
00227   // function to calculate the norm at a given point on the surface
00228   // replace a1-d1
00229 
00230   G4ThreeVector nvec ( fDy1* fDz*(4*fDy1*std::cos(phi)
00231                      + (fa1md1 + 4*fDy1*fTAlph)*std::sin(phi)),
00232                        -(fDy1* fDz*((fa1md1 + 4*fDy1*fTAlph)*std::cos(phi)
00233                      - 4*fDy1*std::sin(phi))),
00234                        (fDy1*(-8*(fDx3minus1 + fDx4minus2)*fDy1
00235                                 + fa1md1*(fDx2 + fDx3plus1 + fDx4)*fPhiTwist
00236                                 + 4*(fDx2 + fDx3plus1 + fDx4)*fDy1*fPhiTwist
00237                                 *fTAlph + 2*(fDx3minus1 + fDx4minus2)
00238                                 *(fa1md1 + 4*fDy1*fTAlph)*phi)
00239                                 + fPhiTwist*(16*fDy1*fDy1
00240                                 + (fa1md1 + 4*fDy1*fTAlph)
00241                                 *(fa1md1 + 4*fDy1*fTAlph))*u
00242                                 + 4*fDy1*(fa1md1*fdeltaY - 4*fdeltaX*fDy1
00243                                 + 4*fdeltaY*fDy1*fTAlph)* std::cos(phi)
00244                                 - 4*fDy1*(fa1md1*fdeltaX + 4*fDy1*(fdeltaY
00245                                 + fdeltaX*fTAlph))*std::sin(phi))/ 8. ) ;
00246     return nvec.unit();
00247 }
00248 
00249 #endif

Generated on Mon May 27 17:50:04 2013 for Geant4 by  doxygen 1.4.7