Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-14 08:36:07

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 // G4TwistBoxSide
0027 //
0028 // Class description:
0029 //
0030 // G4TwistBoxSide describes a twisted boundary surface for a trapezoid.
0031 
0032 // Author: Oliver Link (CERN), 27.10.2004 - Created
0033 // --------------------------------------------------------------------
0034 #ifndef G4TWISTBOXSIDE_HH
0035 #define G4TWISTBOXSIDE_HH
0036 
0037 #include "G4VTwistSurface.hh"
0038 
0039 #include <vector>
0040 
0041 /**
0042  * @brief G4TwistBoxSide describes a twisted boundary surface for a trapezoid.
0043  */
0044 
0045 class G4TwistBoxSide : public G4VTwistSurface
0046 {
0047   public:
0048    
0049     /**
0050      * Constructs a trapezoid twisted boundary surface, given its parameters.
0051      *  @param[in] name The surface name.
0052      *  @param[in] PhiTwist The twist angle.
0053      *  @param[in] pDz Half z length.
0054      *  @param[in] pTheta Direction between end planes - polar angle.
0055      *  @param[in] pPhi Direction between end planes - azimuthal angle.
0056      *  @param[in] pDy1 Half y length at -pDz.
0057      *  @param[in] pDx1 Half x length at -pDz,-pDy.
0058      *  @param[in] pDx2 Half x length at -pDz,+pDy.
0059      *  @param[in] pDy2 Half y length at +pDz.
0060      *  @param[in] pDx3 Half x length at +pDz,-pDy.
0061      *  @param[in] pDx4 Half x length at +pDz,+pDy.
0062      *  @param[in] pAlph Tilt angle at +pDz.
0063      *  @param[in] AngleSide Parity.
0064      */
0065     G4TwistBoxSide(const G4String& name,
0066                          G4double  PhiTwist, // twist angle
0067                          G4double  pDz,      // half z length
0068                          G4double  pTheta,   // direction between end planes
0069                          G4double  pPhi,     // by polar and azimuthal angles
0070                          G4double  pDy1,     // half y length at -pDz
0071                          G4double  pDx1,     // half x length at -pDz,-pDy
0072                          G4double  pDx2,     // half x length at -pDz,+pDy
0073                          G4double  pDy2,     // half y length at +pDz
0074                          G4double  pDx3,     // half x length at +pDz,-pDy
0075                          G4double  pDx4,     // half x length at +pDz,+pDy
0076                          G4double  pAlph,    // tilt angle at +pDz
0077                          G4double  AngleSide // parity
0078                    );
0079   
0080     /**
0081      * Default destructor.
0082      */
0083     ~G4TwistBoxSide() override = default;
0084    
0085     /**
0086      * Returns a normal vector at a surface (or very close to the surface)
0087      * point at 'p'.
0088      *  @param[in] p The point where computing the normal.
0089      *  @param[in] isGlobal If true, it returns the normal in global coordinates.
0090      *  @returns The normal vector.
0091      */
0092     G4ThreeVector GetNormal(const G4ThreeVector& p,
0093                                   G4bool isGlobal = false) override ;   
0094    
0095     /**
0096      * Returns the distance to surface, given point 'gp' and direction 'gv'.
0097      *  @param[in] gp The point from where computing the distance.
0098      *  @param[in] gv The direction along which computing the distance.
0099      *  @param[out] gxx Vector of global points based on number of solutions.
0100      *  @param[out] distance The distance vector based on number of solutions.
0101      *  @param[out] areacode The location vector based on number of solutions.
0102      *  @param[out] isvalid Validity vector based on number of solutions.
0103      *  @param[in] validate Adopted validation criteria.
0104      *  @returns The number of solutions.
0105      */
0106     G4int DistanceToSurface(const G4ThreeVector& gp,
0107                             const G4ThreeVector& gv,
0108                                   G4ThreeVector gxx[],
0109                                   G4double distance[],
0110                                   G4int areacode[],
0111                                   G4bool isvalid[],
0112                             EValidate validate = kValidateWithTol) override;
0113                                                   
0114     /**
0115      * Returns the safety distance to surface, given point 'gp'.
0116      *  @param[in] gp The point from where computing the safety distance.
0117      *  @param[out] gxx Vector of global points based on number of solutions.
0118      *  @param[out] distance The distance vector based on number of solutions.
0119      *  @param[out] areacode The location vector based on number of solutions.
0120      *  @returns The number of solutions.
0121      */
0122     G4int DistanceToSurface(const G4ThreeVector& gp,
0123                                   G4ThreeVector gxx[],
0124                                   G4double distance[],
0125                                   G4int areacode[]) override;
0126 
0127     /**
0128      * Fake default constructor for usage restricted to direct object
0129      * persistency for clients requiring preallocation of memory for
0130      * persistifiable objects.
0131      */
0132     G4TwistBoxSide(__void__&);
0133 
0134   private:
0135 
0136     /**
0137      * Returns the area code for point 'xx' using or not surface tolerance.
0138      */
0139     G4int GetAreaCode(const G4ThreeVector& xx, 
0140                             G4bool withTol = true) override;
0141 
0142     /**
0143      * Setters.
0144      */
0145     void SetCorners() override;
0146     void SetBoundaries() override;
0147 
0148     /**
0149      * Finds the closest point on surface for a given point 'p', returning
0150      * 'phi' and 'u'.
0151      */
0152     void GetPhiUAtX(const G4ThreeVector& p, G4double& phi, G4double& u);
0153 
0154     /**
0155      * Returns projection on surface of a given point 'p'.
0156      */
0157     G4ThreeVector ProjectPoint(const G4ThreeVector& p,
0158                                      G4bool isglobal = false);
0159 
0160     /**
0161      * Returns point on surface given 'phi' and 'u'.
0162      */
0163     inline G4ThreeVector SurfacePoint(G4double phi, G4double u,
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     inline G4double GetValueA(G4double phi);
0175     inline G4double GetValueB(G4double phi);
0176     inline G4ThreeVector NormAng(G4double phi, G4double u);
0177     inline G4double Xcoef(G4double u, G4double phi);
0178       // To calculate the w(u) function
0179 
0180   private:
0181 
0182     G4double fTheta;   
0183     G4double fPhi ;
0184 
0185     G4double fDy1;   
0186     G4double fDx1;     
0187     G4double fDx2;     
0188 
0189     G4double fDy2;   
0190     G4double fDx3;     
0191     G4double fDx4;     
0192 
0193     G4double fDz;         // Half-length along the z axis
0194 
0195     G4double fAlph;
0196     G4double fTAlph;      // std::tan(fAlph)
0197     
0198     G4double fPhiTwist;   // twist angle ( dphi in surface equation)
0199 
0200     G4double fAngleSide;
0201 
0202     G4double fdeltaX;
0203     G4double fdeltaY;
0204 
0205     G4double fDx4plus2;   // fDx4 + fDx2  == a2/2 + a1/2
0206     G4double fDx4minus2;  // fDx4 - fDx2          -
0207     G4double fDx3plus1;   // fDx3 + fDx1  == d2/2 + d1/2
0208     G4double fDx3minus1;  // fDx3 - fDx1          -
0209     G4double fDy2plus1;   // fDy2 + fDy1  == b2/2 + b1/2
0210     G4double fDy2minus1;  // fDy2 - fDy1          -
0211     G4double fa1md1;      // 2 fDx2 - 2 fDx1  == a1 - d1
0212     G4double fa2md2;      // 2 fDx4 - 2 fDx3
0213 };   
0214 
0215 //========================================================
0216 // inline functions
0217 //========================================================
0218 
0219 #include "G4TwistBoxSide.icc"
0220 
0221 #endif