Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:15

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4TwistTubsSide
0027 //
0028 // Class description:
0029 //
0030 // Class describing a twisted boundary surface for a cylinder.
0031 
0032 // 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created
0033 // 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
0034 //               from original version in Jupiter-2.5.02 application.
0035 // --------------------------------------------------------------------
0036 #ifndef G4TWISTTUBSSIDE_HH
0037 #define G4TWISTTUBSSIDE_HH
0038 
0039 #include "G4VTwistSurface.hh"
0040 
0041 class G4TwistTubsSide : public G4VTwistSurface
0042 {
0043   public:
0044    
0045     G4TwistTubsSide(const G4String&         name,
0046                     const G4RotationMatrix& rot,   // 0.5*(phi-width segment)
0047                     const G4ThreeVector&    tlate,
0048                           G4int    handedness, // R-hand = 1, L-hand = -1
0049                     const G4double kappa,      // tan(TwistAngle/2)/fZHalfLen
0050                     const EAxis    axis0 = kXAxis,
0051                     const EAxis    axis1 = kZAxis,
0052                           G4double axis0min = -kInfinity,
0053                           G4double axis1min = -kInfinity,
0054                           G4double axis0max = kInfinity,
0055                           G4double axis1max = kInfinity );
0056 
0057     G4TwistTubsSide(const G4String& name,
0058                           G4double  EndInnerRadius[2],
0059                           G4double  EndOuterRadius[2],
0060                           G4double  DPhi,
0061                           G4double  EndPhi[2],
0062                           G4double  EndZ[2], 
0063                           G4double  InnerRadius,
0064                           G4double  OuterRadius,
0065                           G4double  Kappa,
0066                           G4int     handedness);
0067 
0068    ~G4TwistTubsSide() override;
0069 
0070     G4ThreeVector GetNormal(const G4ThreeVector& xx,
0071                                   G4bool isGlobal = false) override ;   
0072 
0073     G4int DistanceToSurface(const G4ThreeVector& gp,
0074                             const G4ThreeVector& gv,
0075                                   G4ThreeVector  gxx[],
0076                                   G4double  distance[],
0077                                   G4int     areacode[],
0078                                   G4bool    isvalid[],
0079                             EValidate validate = kValidateWithTol) override;
0080 
0081     G4int DistanceToSurface(const G4ThreeVector& gp,
0082                                   G4ThreeVector  gxx[],
0083                                   G4double       distance[],
0084                                   G4int          areacode[]) override;
0085 
0086     inline G4ThreeVector ProjectAtPXPZ(const G4ThreeVector& p,
0087                                              G4bool isglobal = false) const ;
0088 
0089     inline G4ThreeVector SurfacePoint(G4double, G4double,
0090                                       G4bool isGlobal = false) override ;  
0091     inline G4double GetBoundaryMin(G4double phi) override ;
0092     inline G4double GetBoundaryMax(G4double phi) override ;
0093     inline G4double GetSurfaceArea() override ;
0094     void GetFacets( G4int m, G4int n, G4double xyz[][3],
0095                     G4int faces[][4], G4int iside ) override ;
0096 
0097     G4TwistTubsSide(__void__&);
0098       // Fake default constructor for usage restricted to direct object
0099       // persistency for clients requiring preallocation of memory for
0100       // persistifiable objects.
0101 
0102   private:
0103 
0104     G4double DistanceToPlane(const G4ThreeVector& p,
0105                              const G4ThreeVector& A,
0106                              const G4ThreeVector& B,
0107                              const G4ThreeVector& C,
0108                              const G4ThreeVector& D,
0109                              const G4int          parity,
0110                                    G4ThreeVector& xx,
0111                                    G4ThreeVector& n);
0112 
0113     G4int GetAreaCode(const G4ThreeVector& xx, 
0114                             G4bool         withTol = true) override;
0115 
0116     void SetCorners() override;
0117 
0118     void SetCorners( G4double endInnerRad[2],
0119                      G4double endOuterRad[2],
0120                      G4double endPhi[2],
0121                      G4double endZ[2] ) ;
0122 
0123     void SetBoundaries() override;
0124 
0125   private:
0126 
0127     G4double       fKappa;          // std::tan(TwistedAngle/2)/HalfLenZ;
0128 };   
0129 
0130 
0131 //========================================================
0132 // inline functions
0133 //========================================================
0134 
0135 inline
0136 G4ThreeVector G4TwistTubsSide::ProjectAtPXPZ(const G4ThreeVector& p, 
0137                                                    G4bool isglobal) const 
0138 {
0139   // Get Rho at p.z() on Hyperbolic Surface.
0140   G4ThreeVector tmpp;
0141   if (isglobal) { tmpp = fRot.inverse()*p - fTrans; }
0142   else          { tmpp = p; }
0143   G4ThreeVector xx(p.x(), p.x() * fKappa * p.z(), p.z());
0144   if (isglobal) { return (fRot * xx + fTrans); }
0145   return xx;
0146 }
0147 
0148 inline
0149 G4ThreeVector
0150 G4TwistTubsSide::SurfacePoint(G4double x, G4double z, G4bool isGlobal)
0151 {
0152   G4ThreeVector SurfPoint( x , x * fKappa * z , z ) ;
0153 
0154   if (isGlobal) { return (fRot * SurfPoint + fTrans); }
0155   return SurfPoint;
0156 }
0157 
0158 inline
0159 G4double G4TwistTubsSide::GetBoundaryMin(G4double)
0160 {
0161   return  fAxisMin[0] ;  // inner radius at z = 0
0162 }
0163 
0164 inline
0165 G4double G4TwistTubsSide::GetBoundaryMax(G4double)
0166 {
0167   return  fAxisMax[0] ;  // outer radius at z = 0
0168 }
0169 
0170 inline
0171 G4double G4TwistTubsSide::GetSurfaceArea()
0172 {
0173   // approximation only
0174   return ( fAxisMax[0] - fAxisMin[0] ) * ( fAxisMax[1] - fAxisMin[1] ) ;
0175 }
0176 
0177 #endif