Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:57

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 // G4PolyconeSide
0027 //
0028 // Class description:
0029 //
0030 //   Class implmenting a face that represents one conical side
0031 //   of a polycone:
0032 //
0033 //   G4PolyconeSide( const G4PolyconeSideRZ *prevRZ,
0034 //                   const G4PolyconeSideRZ *tail,
0035 //                   const G4PolyconeSideRZ *head,
0036 //                   const G4PolyconeSideRZ *nextRZ,
0037 //                         G4double phiStart, G4double deltaPhi, 
0038 //                         G4bool phiIsOpen, G4bool isAllBehind=false )
0039 //
0040 //   Values for r1,z1 and r2,z2 should be specified in clockwise
0041 //   order in (r,z).
0042 
0043 // Author: David C. Williams (davidw@scipp.ucsc.edu)
0044 // --------------------------------------------------------------------
0045 #ifndef G4POLYCONESIDE_HH
0046 #define G4POLYCONESIDE_HH
0047 
0048 #include "G4VCSGface.hh"
0049 
0050 class G4IntersectingCone;
0051 
0052 struct G4PolyconeSideRZ
0053 {
0054   G4double r, z;  // start of vector
0055 };
0056 
0057 // ----------------------------------------------------------------------------
0058 // MT-specific utility code 
0059 
0060 #include "G4GeomSplitter.hh"
0061 
0062 // The class G4PlSideData is introduced to encapsulate the
0063 // fields of the class G4PolyconeSide that may not be read-only.
0064 //
0065 class G4PlSideData
0066 {
0067   public:
0068 
0069     void initialize()
0070     {
0071       fPhix = 0.; fPhiy = 0.; fPhiz = 0.; fPhik = 0.;
0072     }
0073 
0074     G4double fPhix=0., fPhiy=0., fPhiz=0., fPhik=0.;   // Cached values for phi
0075 };
0076 
0077 // The type G4PlSideManager is introduced to 
0078 // encapsulate the methods used by both the master thread and 
0079 // worker threads to allocate memory space for the fields encapsulated
0080 // by the class G4PlSideData.
0081 //
0082 using G4PlSideManager = G4GeomSplitter<G4PlSideData>;
0083 
0084 //
0085 // ----------------------------------------------------------------------------
0086 
0087 class G4PolyconeSide : public G4VCSGface
0088 {
0089   public:
0090 
0091     G4PolyconeSide( const G4PolyconeSideRZ* prevRZ,
0092                     const G4PolyconeSideRZ* tail,
0093                     const G4PolyconeSideRZ* head,
0094                     const G4PolyconeSideRZ* nextRZ,
0095                           G4double phiStart, G4double deltaPhi, 
0096                           G4bool phiIsOpen, G4bool isAllBehind = false );
0097     ~G4PolyconeSide() override;
0098   
0099     G4PolyconeSide( const G4PolyconeSide& source );
0100     G4PolyconeSide& operator=( const G4PolyconeSide& source );
0101   
0102     G4bool Intersect(const G4ThreeVector& p, const G4ThreeVector& v,  
0103                            G4bool outgoing, G4double surfTolerance,
0104                            G4double& distance, G4double &distFromSurface,
0105                            G4ThreeVector& normal, G4bool& isAllBehind) override;
0106 
0107     G4double Distance( const G4ThreeVector& p, G4bool outgoing ) override;
0108   
0109     EInside Inside( const G4ThreeVector& p, G4double tolerance, 
0110                           G4double* bestDistance ) override;
0111   
0112     G4ThreeVector Normal( const G4ThreeVector& p,
0113                                 G4double* bestDistance ) override;
0114 
0115     G4double Extent( const G4ThreeVector axis ) override;
0116 
0117     void CalculateExtent( const EAxis axis, 
0118                           const G4VoxelLimits& voxelLimit,
0119                           const G4AffineTransform& tranform,
0120                                 G4SolidExtentList& extentList ) override;
0121 
0122     G4VCSGface* Clone() override { return new G4PolyconeSide( *this ); }
0123 
0124     G4double SurfaceArea() override;
0125     G4ThreeVector GetPointOnFace() override;
0126   
0127     G4PolyconeSide(__void__&);
0128       // Fake default constructor for usage restricted to direct object
0129       // persistency for clients requiring preallocation of memory for
0130       // persistifiable objects.
0131 
0132     inline G4int GetInstanceID() const  { return instanceID; }
0133       // Returns the instance ID.
0134 
0135     static const G4PlSideManager& GetSubInstanceManager();
0136       // Returns the private data instance manager.
0137 
0138   protected:
0139 
0140     G4double DistanceAway( const G4ThreeVector& p, G4bool opposite,
0141                                  G4double& distOutside2,
0142                                  G4double* rzNorm = nullptr );
0143       
0144     G4double DistanceAway( const G4ThreeVector& p, G4double& distOutside2,
0145                                  G4double* edgeRZnorm );
0146 
0147     G4bool PointOnCone( const G4ThreeVector& hit, G4double normSign,
0148                         const G4ThreeVector& p,
0149                         const G4ThreeVector& v, G4ThreeVector& normal );
0150 
0151     void CopyStuff( const G4PolyconeSide& source );
0152   
0153     static void FindLineIntersect( G4double x1, G4double y1,
0154                                    G4double tx1, G4double ty1,
0155                                    G4double x2, G4double y2,
0156                                    G4double tx2, G4double ty2,
0157                                    G4double& x, G4double& y );
0158 
0159     G4double GetPhi( const G4ThreeVector& p );
0160 
0161   protected:
0162 
0163     G4double r[2], z[2]; // r, z parameters, in specified order
0164     G4double startPhi,   // Start phi (0 to 2pi), if phiIsOpen
0165              deltaPhi;   // Delta phi (0 to 2pi), if phiIsOpen
0166     G4bool phiIsOpen = false; // True if there is a phi slice
0167     G4bool allBehind = false; // True if the entire solid is "behind" this face
0168   
0169     G4IntersectingCone* cone = nullptr;  // Our intersecting utility class
0170   
0171     G4double rNorm, zNorm;  // Normal to surface in r,z space
0172     G4double rS, zS;        // Unit vector along surface in r,z space
0173     G4double length;        // Length of face in r,z space
0174     G4double prevRS,
0175              prevZS;        // Unit vector along previous polyconeSide
0176     G4double nextRS,
0177              nextZS;        // Unit vector along next polyconeSide
0178   
0179     G4double rNormEdge[2],
0180              zNormEdge[2];  // Normal to edges
0181 
0182     G4int ncorners = 0;
0183     G4ThreeVector* corners = nullptr; // The coordinates of the corners
0184                                       // (if phiIsOpen)
0185   private:
0186 
0187     G4double kCarTolerance;       // Geometrical surface thickness
0188     G4double fSurfaceArea = 0.0;  // Used for surface calculation 
0189 
0190     G4int instanceID;
0191       // This field is used as instance ID.
0192     G4GEOM_DLL static G4PlSideManager subInstanceManager;
0193       // This field helps to use the class G4PlSideManager introduced above.
0194 };
0195 
0196 #endif