G4TwistTrapParallelSide.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: G4TwistTrapParallelSide.hh 69790 2013-05-15 12:39:10Z gcosmo $
00028 // 
00029 // --------------------------------------------------------------------
00030 // GEANT 4 class header file
00031 //
00032 //
00033 // G4TwistTrapParallelSide
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 __G4TWISTTRAPPARALLELSIDE__
00045 #define __G4TWISTTRAPPARALLELSIDE__
00046 
00047 #include "G4VTwistSurface.hh"
00048 
00049 #include <vector>
00050 
00051 class G4TwistTrapParallelSide : public G4VTwistSurface
00052 {
00053   public:  // with description
00054    
00055     G4TwistTrapParallelSide(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 ~G4TwistTrapParallelSide();
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   public:  // without description
00089 
00090     G4TwistTrapParallelSide(__void__&);
00091       // Fake default constructor for usage restricted to direct object
00092       // persistency for clients requiring preallocation of memory for
00093       // persistifiable objects.
00094 
00095   private:
00096 
00097     virtual G4int GetAreaCode(const G4ThreeVector &xx, 
00098                                     G4bool         withTol = true);
00099     virtual void SetCorners();
00100     virtual void SetBoundaries();
00101 
00102     void GetPhiUAtX(G4ThreeVector p, G4double &phi, G4double &u);
00103     G4ThreeVector ProjectPoint(const G4ThreeVector &p,
00104                                      G4bool isglobal = false);
00105 
00106     virtual G4ThreeVector SurfacePoint(G4double phi, G4double u,
00107                                        G4bool isGlobal = false);
00108     virtual G4double GetBoundaryMin(G4double phi);
00109     virtual G4double GetBoundaryMax(G4double phi);
00110     virtual G4double GetSurfaceArea();
00111     virtual void GetFacets( G4int m, G4int n, G4double xyz[][3],
00112                             G4int faces[][4], G4int iside );
00113 
00114     inline G4ThreeVector NormAng(G4double phi, G4double u);
00115     inline G4double GetValueB(G4double phi) ;
00116     inline G4double Xcoef(G4double u);
00117       // To calculate the w(u) function
00118 
00119   private:
00120 
00121     G4double fTheta;   
00122     G4double fPhi ;
00123 
00124     G4double fDy1;   
00125     G4double fDx1;     
00126     G4double fDx2;     
00127 
00128     G4double fDy2;   
00129     G4double fDx3;     
00130     G4double fDx4;     
00131 
00132     G4double fDz;         // Half-length along the z axis
00133 
00134     G4double fAlph;
00135     G4double fTAlph;      // std::tan(fAlph)
00136     
00137     G4double fPhiTwist;   // twist angle ( dphi in surface equation)
00138 
00139     G4double fAngleSide;
00140 
00141     G4double fdeltaX;
00142     G4double fdeltaY;
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 
00154 //========================================================
00155 // inline functions
00156 //========================================================
00157 
00158 
00159 inline 
00160 G4double G4TwistTrapParallelSide::GetValueB(G4double phi) 
00161 {
00162   return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
00163 }
00164 
00165 inline
00166 G4double G4TwistTrapParallelSide::Xcoef(G4double phi)
00167 {
00168   return GetValueB(phi)/2. ;
00169 }
00170 
00171 inline G4ThreeVector
00172 G4TwistTrapParallelSide::
00173 SurfacePoint( G4double phi, G4double u, G4bool isGlobal ) 
00174 {
00175   // function to calculate a point on the surface, given by parameters phi,u
00176 
00177   G4ThreeVector SurfPoint ( u*std::cos(phi) - Xcoef(phi)*std::sin(phi)
00178                           + fdeltaX*phi/fPhiTwist,
00179                             u*std::sin(phi) + Xcoef(phi)*std::cos(phi)
00180                           + fdeltaY*phi/fPhiTwist,
00181                             2*fDz*phi/fPhiTwist  );
00182   if (isGlobal) { return (fRot * SurfPoint + fTrans); }
00183   return SurfPoint;
00184 }
00185 
00186 
00187 inline
00188 G4double G4TwistTrapParallelSide::GetBoundaryMin(G4double phi)
00189 {
00190   return  -(fPhiTwist*(fDx2 + fDx4 - fDy2plus1*fTAlph)
00191           + 2*fDx4minus2*phi - 2*fDy2minus1*fTAlph*phi)/(2.*fPhiTwist) ;
00192 }
00193 
00194 inline
00195 G4double G4TwistTrapParallelSide::GetBoundaryMax(G4double phi)
00196 {
00197   return (fDx2 + fDx4 + fDy2plus1*fTAlph)/ 2.
00198        + ((fDx4minus2 + fDy2minus1*fTAlph)*phi)/fPhiTwist ;
00199 }
00200 
00201 inline
00202 G4double  G4TwistTrapParallelSide::GetSurfaceArea()
00203 {
00204   return 2*fDx4plus2*fDz ;
00205 }
00206 
00207 inline
00208 G4ThreeVector G4TwistTrapParallelSide::NormAng( G4double phi, G4double u ) 
00209 {
00210   // function to calculate the norm at a given point on the surface
00211   // replace a1-d1
00212 
00213   G4ThreeVector nvec(-2*fDz*std::sin(phi) ,
00214                       2*fDz*std::cos(phi) ,
00215                      -(fDy2minus1 + fPhiTwist*u + fdeltaY*std::cos(phi)
00216                      -fdeltaX*std::sin(phi))) ;
00217   return nvec.unit();
00218 }
00219 
00220 #endif

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