G4TwistBoxSide.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: G4TwistBoxSide.hh 67011 2013-01-29 16:17:41Z gcosmo $
00028 // 
00029 // --------------------------------------------------------------------
00030 // GEANT 4 class header file
00031 //
00032 //
00033 // G4TwistBoxSide
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 __G4TWISTBOXSIDE__
00045 #define __G4TWISTBOXSIDE__
00046 
00047 #include "G4VTwistSurface.hh"
00048 
00049 #include <vector>
00050 
00051 class G4TwistBoxSide : public G4VTwistSurface
00052 {
00053   public:  // with description
00054    
00055     G4TwistBoxSide(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 ~G4TwistBoxSide();
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     G4TwistBoxSide(__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 G4double GetValueA(G4double phi);
00115     inline G4double GetValueB(G4double phi);
00116     inline G4ThreeVector NormAng(G4double phi, G4double u);
00117     inline G4double Xcoef(G4double u,G4double phi);
00118       // To calculate the w(u) function
00119 
00120   private:
00121 
00122     G4double fTheta;   
00123     G4double fPhi ;
00124 
00125     G4double fDy1;   
00126     G4double fDx1;     
00127     G4double fDx2;     
00128 
00129     G4double fDy2;   
00130     G4double fDx3;     
00131     G4double fDx4;     
00132 
00133     G4double fDz;         // Half-length along the z axis
00134 
00135     G4double fAlph;
00136     G4double fTAlph;      // std::tan(fAlph)
00137     
00138     G4double fPhiTwist;   // twist angle ( dphi in surface equation)
00139 
00140     G4double fAngleSide;
00141 
00142     G4double fdeltaX;
00143     G4double fdeltaY;
00144 
00145     G4double fDx4plus2;   // fDx4 + fDx2  == a2/2 + a1/2
00146     G4double fDx4minus2;  // fDx4 - fDx2          -
00147     G4double fDx3plus1;   // fDx3 + fDx1  == d2/2 + d1/2
00148     G4double fDx3minus1;  // fDx3 - fDx1          -
00149     G4double fDy2plus1;   // fDy2 + fDy1  == b2/2 + b1/2
00150     G4double fDy2minus1;  // fDy2 - fDy1          -
00151     G4double fa1md1;      // 2 fDx2 - 2 fDx1  == a1 - d1
00152     G4double fa2md2;      // 2 fDx4 - 2 fDx3
00153 };   
00154 
00155 //========================================================
00156 // inline functions
00157 //========================================================
00158 
00159 inline
00160 G4double G4TwistBoxSide::GetValueA(G4double phi)
00161 {
00162   return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist  ) ;
00163 }
00164 
00165 
00166 inline 
00167 G4double G4TwistBoxSide::GetValueB(G4double phi) 
00168 {
00169   return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
00170 }
00171 
00172 inline
00173 G4double G4TwistBoxSide::Xcoef(G4double u, G4double phi)
00174 {
00175   
00176   return GetValueA(phi)/2. + u*fTAlph    ;
00177 
00178 }
00179 
00180 inline G4ThreeVector
00181 G4TwistBoxSide::SurfacePoint( G4double phi, G4double u, G4bool isGlobal ) 
00182 {
00183   // function to calculate a point on the surface, given by parameters phi,u
00184 
00185   G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
00186                           - u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
00187                             Xcoef(u,phi) * std::sin(phi)
00188                           + u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
00189                             2*fDz*phi/fPhiTwist  );
00190 
00191   if (isGlobal) { return (fRot * SurfPoint + fTrans); }
00192   return SurfPoint;
00193 }
00194 
00195 inline
00196 G4double G4TwistBoxSide::GetBoundaryMin(G4double phi)
00197 {
00198   return -0.5*GetValueB(phi) ;
00199 }
00200 
00201 inline
00202 G4double G4TwistBoxSide::GetBoundaryMax(G4double phi)
00203 {
00204   return 0.5*GetValueB(phi) ;
00205 }
00206 
00207 inline
00208 G4double G4TwistBoxSide::GetSurfaceArea()
00209 {
00210   return (fDz*(std::sqrt(16*fDy1*fDy1
00211          + (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
00212          + std::sqrt(16*fDy1*fDy1 + (fa2md2 + 4*fDy1*fTAlph)
00213          * (fa2md2 + 4*fDy1*fTAlph))))/2. ;
00214 }
00215 
00216 inline
00217 G4ThreeVector G4TwistBoxSide::NormAng( G4double phi, G4double u ) 
00218 {
00219   // function to calculate the norm at a given point on the surface
00220   // replace a1-d1
00221 
00222   G4ThreeVector nvec( 4*fDz*(std::cos(phi) + fTAlph*std::sin(phi)) ,
00223                       4*fDz*(-(fTAlph*std::cos(phi)) + std::sin(phi)),
00224                       (fDx2 + fDx4)*fPhiTwist*fTAlph
00225                                    + 2*fDx4minus2*(-1 + fTAlph*phi)
00226                                    + 2*fPhiTwist*(1 + fTAlph*fTAlph)*u
00227                                 - 2*(fdeltaX - fdeltaY*fTAlph)*std::cos(phi)
00228                                 - 2*(fdeltaY + fdeltaX*fTAlph)*std::sin(phi) );
00229   return nvec.unit();
00230 }
00231 
00232 #endif

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