Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4VTwistedFaceted
0027 //
0028 // Class description:
0029 //
0030 //  G4VTwistedFaceted is an abstract base class for twisted boxoids:
0031 //  G4TwistedTrd, G4TwistedTrap and G4TwistedBox
0032 
0033 // Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
0034 // --------------------------------------------------------------------
0035 #ifndef G4VTWISTEDFACETED_HH
0036 #define G4VTWISTEDFACETED_HH
0037 
0038 #include "G4VSolid.hh"
0039 #include "G4TwoVector.hh"
0040 #include "G4TwistTrapAlphaSide.hh"
0041 #include "G4TwistTrapParallelSide.hh"
0042 #include "G4TwistBoxSide.hh"
0043 #include "G4TwistTrapFlatSide.hh"
0044 
0045 class G4SolidExtentList;
0046 class G4ClippablePolygon;
0047 
0048 class G4VTwistedFaceted: public G4VSolid
0049 {
0050   public:
0051 
0052     G4VTwistedFaceted(const G4String& pname,    // Name of instance
0053                             G4double PhiTwist,  // twist angle
0054                             G4double pDz,       // half z lenght
0055                             G4double pTheta,  // direction between end planes
0056                             G4double pPhi,    // defined by polar & azim. angles
0057                             G4double pDy1,    // half y length at -pDz
0058                             G4double pDx1,    // half x length at -pDz,-pDy
0059                             G4double pDx2,    // half x length at -pDz,+pDy
0060                             G4double pDy2,    // half y length at +pDz
0061                             G4double pDx3,    // half x length at +pDz,-pDy
0062                             G4double pDx4,    // half x length at +pDz,+pDy
0063                             G4double pAlph    // tilt angle at +pDz
0064                      );
0065 
0066     virtual ~G4VTwistedFaceted();
0067 
0068     void ComputeDimensions(      G4VPVParameterisation*,
0069                            const G4int,
0070                            const G4VPhysicalVolume*  ) override;
0071 
0072     void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override;
0073 
0074     G4bool CalculateExtent(const EAxis              pAxis,
0075                            const G4VoxelLimits&     pVoxelLimit,
0076                            const G4AffineTransform& pTransform,
0077                                  G4double&          pMin,
0078                                  G4double&          pMax ) const override;
0079 
0080     G4double DistanceToIn (const G4ThreeVector& p,
0081                            const G4ThreeVector& v ) const override;
0082 
0083     G4double DistanceToIn (const G4ThreeVector& p ) const override;
0084 
0085     G4double DistanceToOut(const G4ThreeVector& p,
0086                            const G4ThreeVector& v,
0087                            const G4bool         calcnorm  = false,
0088                                  G4bool* validnorm = nullptr,
0089                                  G4ThreeVector*  n = nullptr ) const override;
0090 
0091     G4double DistanceToOut(const G4ThreeVector& p) const override;
0092 
0093     EInside Inside (const G4ThreeVector& p) const override;
0094 
0095     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0096 
0097     G4ThreeVector GetPointOnSurface() const override;
0098     G4ThreeVector GetPointInSolid(G4double z) const;
0099 
0100     G4double GetCubicVolume() override;
0101     G4double GetSurfaceArea() override;
0102 
0103     void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0104     G4Polyhedron* CreatePolyhedron   () const override;
0105     G4Polyhedron* GetPolyhedron      () const override;
0106 
0107     std::ostream &StreamInfo(std::ostream& os) const override;
0108 
0109     // accessors
0110 
0111     inline G4double GetTwistAngle() const { return fPhiTwist; }
0112 
0113     inline G4double GetDx1   () const { return fDx1   ; }
0114     inline G4double GetDx2   () const { return fDx2   ; }
0115     inline G4double GetDx3   () const { return fDx3   ; }
0116     inline G4double GetDx4   () const { return fDx4   ; }
0117     inline G4double GetDy1   () const { return fDy1   ; }
0118     inline G4double GetDy2   () const { return fDy2   ; }
0119     inline G4double GetDz    () const { return fDz    ; }
0120     inline G4double GetPhi   () const { return fPhi   ; }
0121     inline G4double GetTheta () const { return fTheta ; }
0122     inline G4double GetAlpha () const { return fAlph  ; }
0123 
0124     inline G4double Xcoef(G4double u, G4double phi, G4double ftg) const;
0125       // For calculating the w(u) function
0126 
0127     inline G4double GetValueA(G4double phi) const;
0128     inline G4double GetValueB(G4double phi) const;
0129     inline G4double GetValueD(G4double phi) const;
0130 
0131     G4VisExtent     GetExtent    () const override;
0132     G4GeometryType  GetEntityType() const override;
0133 
0134     G4VTwistedFaceted(__void__&);
0135       // Fake default constructor for usage restricted to direct object
0136       // persistency for clients requiring preallocation of memory for
0137       // persistifiable objects.
0138 
0139     G4VTwistedFaceted(const G4VTwistedFaceted& rhs);
0140     G4VTwistedFaceted& operator=(const G4VTwistedFaceted& rhs);
0141       // Copy constructor and assignment operator.
0142 
0143   protected:
0144 
0145     mutable G4bool fRebuildPolyhedron = false;
0146     mutable G4Polyhedron* fpPolyhedron = nullptr;  // polyhedron for vis
0147 
0148     G4double fCubicVolume = 0.0; // volume of the solid
0149     G4double fSurfaceArea = 0.0; // area of the solid
0150 
0151   private:
0152 
0153     double GetLateralFaceArea(const G4TwoVector& p1,
0154                               const G4TwoVector& p2,
0155                               const G4TwoVector& p3,
0156                               const G4TwoVector& p4) const;
0157     void CreateSurfaces();
0158 
0159   private:
0160 
0161     G4double fTheta;
0162     G4double fPhi ;
0163 
0164     G4double fDy1;
0165     G4double fDx1;
0166     G4double fDx2;
0167 
0168     G4double fDy2;
0169     G4double fDx3;
0170     G4double fDx4;
0171 
0172     G4double fDz;        // Half-length along the z axis
0173 
0174     G4double fDx ;       // maximum side in x
0175     G4double fDy ;       // maximum side in y
0176 
0177     G4double fAlph ;
0178     G4double fTAlph ;    // std::tan(fAlph)
0179 
0180     G4double fdeltaX ;
0181     G4double fdeltaY ;
0182 
0183     G4double fPhiTwist;  // twist angle ( dphi in surface equation)
0184 
0185     G4VTwistSurface* fLowerEndcap ;  // surface of -ve z
0186     G4VTwistSurface* fUpperEndcap ;  // surface of +ve z
0187 
0188     G4VTwistSurface* fSide0 ;    // Twisted Side at phi = 0 deg
0189     G4VTwistSurface* fSide90 ;   // Twisted Side at phi = 90 deg
0190     G4VTwistSurface* fSide180 ;  // Twisted Side at phi = 180 deg
0191     G4VTwistSurface* fSide270 ;  // Twisted Side at phi = 270 deg
0192 
0193 };
0194 
0195 //=====================================================================
0196 
0197 inline
0198 G4double G4VTwistedFaceted::GetValueA(G4double phi) const
0199 {
0200   return ( fDx4 + fDx2  + ( fDx4 - fDx2 ) * ( 2 * phi ) / fPhiTwist  ) ;
0201 }
0202 
0203 inline
0204 G4double G4VTwistedFaceted::GetValueD(G4double phi) const
0205 {
0206   return ( fDx3 + fDx1  + ( fDx3 - fDx1 ) * ( 2 * phi ) / fPhiTwist  ) ;
0207 }
0208 
0209 inline
0210 G4double G4VTwistedFaceted::GetValueB(G4double phi) const
0211 {
0212   return ( fDy2 + fDy1  + ( fDy2 - fDy1 ) * ( 2 * phi ) / fPhiTwist ) ;
0213 }
0214 
0215 inline
0216 G4double G4VTwistedFaceted::Xcoef(G4double u, G4double phi, G4double ftg) const
0217 {
0218   return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4.
0219     - u*( ( GetValueD(phi)-GetValueA(phi) ) / ( 2 * GetValueB(phi) ) - ftg );
0220 }
0221 
0222 #endif