Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:09:59

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