Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-09 08:29:38

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 // Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
0033 //         Oliver Link (CERN), 13.11.2003 - 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 /**
0042  * @brief G4TwistTubsFlatSide describes a twisted boundary surface for
0043  * a cylinder.
0044  */
0045 
0046 class G4TwistTubsSide : public G4VTwistSurface
0047 {
0048   public:
0049    
0050     /**
0051      * Constructs a cylinder twisted boundary surface, given its parameters.
0052      *  @param[in] name The surface name.
0053      *  @param[in] rot Rotation: 0.5*(phi-width segment).
0054      *  @param[in] tlate Translation.
0055      *  @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
0056      *  @param[in] kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
0057      *  @param[in] axis0 X axis.
0058      *  @param[in] axis1 Z axis.
0059      *  @param[in] axis0min Minimum in X.
0060      *  @param[in] axis1min Minimum in Z.
0061      *  @param[in] axis0max Maximum in X.
0062      *  @param[in] axis1max Maximum in Z.
0063      */
0064     G4TwistTubsSide(const G4String&         name,
0065                     const G4RotationMatrix& rot,   // 0.5*(phi-width segment)
0066                     const G4ThreeVector&    tlate,
0067                           G4int    handedness, // R-hand = 1, L-hand = -1
0068                     const G4double kappa,      // tan(TwistAngle/2)/fZHalfLen
0069                     const EAxis    axis0 = kXAxis,
0070                     const EAxis    axis1 = kZAxis,
0071                           G4double axis0min = -kInfinity,
0072                           G4double axis1min = -kInfinity,
0073                           G4double axis0max = kInfinity,
0074                           G4double axis1max = kInfinity );
0075 
0076     /**
0077      * Alternative Construct for a cylinder twisted boundary surface.
0078      *  @param[in] name The surface name.
0079      *  @param[in] EndInnerRadius Inner-hype radius at z=0.
0080      *  @param[in] EndOuterRadius Outer-hype radius at z=0.
0081      *  @param[in] DPhi Phi angle.
0082      *  @param[in] EndPhi Total Phi.
0083      *  @param[in] EndZ Z length.
0084      *  @param[in] InnerRadius Inner radius.
0085      *  @param[in] OuterRadius Outer radius.
0086      *  @param[in] Kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
0087      *  @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
0088      */
0089     G4TwistTubsSide(const G4String& name,
0090                           G4double  EndInnerRadius[2],
0091                           G4double  EndOuterRadius[2],
0092                           G4double  DPhi,
0093                           G4double  EndPhi[2],
0094                           G4double  EndZ[2], 
0095                           G4double  InnerRadius,
0096                           G4double  OuterRadius,
0097                           G4double  Kappa,
0098                           G4int     handedness);
0099 
0100     /**
0101      * Default destructor.
0102      */
0103     ~G4TwistTubsSide() override = default;
0104 
0105     /**
0106      * Returns a normal vector at a surface (or very close to the surface)
0107      * point at 'p'.
0108      *  @param[in] p The point where computing the normal.
0109      *  @param[in] isGlobal If true, it returns the normal in global coordinates.
0110      *  @returns The normal vector.
0111      */
0112     G4ThreeVector GetNormal(const G4ThreeVector& p,
0113                                   G4bool isGlobal = false) override ;   
0114 
0115     /**
0116      * Returns the distance to surface, given point 'gp' and direction 'gv'.
0117      *  @param[in] gp The point from where computing the distance.
0118      *  @param[in] gv The direction along which computing the distance.
0119      *  @param[out] gxx Vector of global points based on number of solutions.
0120      *  @param[out] distance The distance vector based on number of solutions.
0121      *  @param[out] areacode The location vector based on number of solutions.
0122      *  @param[out] isvalid Validity vector based on number of solutions.
0123      *  @param[in] validate Adopted validation criteria.
0124      *  @returns The number of solutions.
0125      */
0126     G4int DistanceToSurface(const G4ThreeVector& gp,
0127                             const G4ThreeVector& gv,
0128                                   G4ThreeVector  gxx[],
0129                                   G4double  distance[],
0130                                   G4int     areacode[],
0131                                   G4bool    isvalid[],
0132                             EValidate validate = kValidateWithTol) override;
0133 
0134     /**
0135      * Returns the safety distance to surface, given point 'gp'.
0136      *  @param[in] gp The point from where computing the safety distance.
0137      *  @param[out] gxx Vector of global points based on number of solutions.
0138      *  @param[out] distance The distance vector based on number of solutions.
0139      *  @param[out] areacode The location vector based on number of solutions.
0140      *  @returns The number of solutions.
0141      */
0142     G4int DistanceToSurface(const G4ThreeVector& gp,
0143                                   G4ThreeVector  gxx[],
0144                                   G4double       distance[],
0145                                   G4int          areacode[]) override;
0146 
0147     /**
0148      * Get projection at p.z() on the surface.
0149      */
0150     inline G4ThreeVector ProjectAtPXPZ(const G4ThreeVector& p,
0151                                              G4bool isglobal = false) const ;
0152 
0153     G4TwistTubsSide(__void__&);
0154       // Fake default constructor for usage restricted to direct object
0155       // persistency for clients requiring preallocation of memory for
0156       // persistifiable objects.
0157 
0158   private:
0159 
0160     /**
0161      * Returns point on surface given 'x' and 'z'.
0162      */
0163     inline G4ThreeVector SurfacePoint(G4double x, G4double z,
0164                                       G4bool isGlobal = false) override ;  
0165 
0166     /**
0167      * Internal accessors.
0168      */
0169     inline G4double GetBoundaryMin(G4double phi) override ;
0170     inline G4double GetBoundaryMax(G4double phi) override ;
0171     inline G4double GetSurfaceArea() override ;
0172     void GetFacets( G4int m, G4int n, G4double xyz[][3],
0173                     G4int faces[][4], G4int iside ) override ;
0174 
0175     /**
0176      * Internal method to compute the distance to a plane.
0177      */
0178     G4double DistanceToPlane(const G4ThreeVector& p,
0179                              const G4ThreeVector& A,
0180                              const G4ThreeVector& B,
0181                              const G4ThreeVector& C,
0182                              const G4ThreeVector& D,
0183                              const G4int parity,
0184                                    G4ThreeVector& xx,
0185                                    G4ThreeVector& n);
0186 
0187     /**
0188      * Returns the area code for point 'xx' using or not surface tolerance.
0189      */
0190     G4int GetAreaCode(const G4ThreeVector& xx, 
0191                             G4bool withTol = true) override;
0192 
0193     /**
0194      * Setters.
0195      */
0196     void SetCorners() override;
0197     void SetCorners( G4double endInnerRad[2],
0198                      G4double endOuterRad[2],
0199                      G4double endPhi[2],
0200                      G4double endZ[2] ) ;
0201     void SetBoundaries() override;
0202 
0203   private:
0204 
0205     G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
0206 };   
0207 
0208 
0209 //========================================================
0210 // inline functions
0211 //========================================================
0212 
0213 inline
0214 G4ThreeVector G4TwistTubsSide::ProjectAtPXPZ(const G4ThreeVector& p, 
0215                                                    G4bool isglobal) const 
0216 {
0217   // Get Rho at p.z() on Hyperbolic Surface.
0218   G4ThreeVector tmpp;
0219   if (isglobal) { tmpp = fRot.inverse()*p - fTrans; }
0220   else          { tmpp = p; }
0221   G4ThreeVector xx(p.x(), p.x() * fKappa * p.z(), p.z());
0222   if (isglobal) { return (fRot * xx + fTrans); }
0223   return xx;
0224 }
0225 
0226 inline
0227 G4ThreeVector
0228 G4TwistTubsSide::SurfacePoint(G4double x, G4double z, G4bool isGlobal)
0229 {
0230   G4ThreeVector SurfPoint( x , x * fKappa * z , z ) ;
0231 
0232   if (isGlobal) { return (fRot * SurfPoint + fTrans); }
0233   return SurfPoint;
0234 }
0235 
0236 inline
0237 G4double G4TwistTubsSide::GetBoundaryMin(G4double)
0238 {
0239   return  fAxisMin[0] ;  // inner radius at z = 0
0240 }
0241 
0242 inline
0243 G4double G4TwistTubsSide::GetBoundaryMax(G4double)
0244 {
0245   return  fAxisMax[0] ;  // outer radius at z = 0
0246 }
0247 
0248 inline
0249 G4double G4TwistTubsSide::GetSurfaceArea()
0250 {
0251   // approximation only
0252   return ( fAxisMax[0] - fAxisMin[0] ) * ( fAxisMax[1] - fAxisMin[1] ) ;
0253 }
0254 
0255 #endif