Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4TwistTubsSide 26 // G4TwistTubsSide 27 // 27 // 28 // Class description: 28 // Class description: 29 // 29 // 30 // Class describing a twisted boundary surface 30 // Class describing a twisted boundary surface for a cylinder. 31 31 32 // 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepbu 32 // 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created 33 // 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), 33 // 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4 34 // from original version in Jupi 34 // from original version in Jupiter-2.5.02 application. 35 // ------------------------------------------- 35 // -------------------------------------------------------------------- 36 #ifndef G4TWISTTUBSSIDE_HH 36 #ifndef G4TWISTTUBSSIDE_HH 37 #define G4TWISTTUBSSIDE_HH 37 #define G4TWISTTUBSSIDE_HH 38 38 39 #include "G4VTwistSurface.hh" 39 #include "G4VTwistSurface.hh" 40 40 41 class G4TwistTubsSide : public G4VTwistSurface 41 class G4TwistTubsSide : public G4VTwistSurface 42 { 42 { 43 public: 43 public: 44 44 45 G4TwistTubsSide(const G4String& na 45 G4TwistTubsSide(const G4String& name, 46 const G4RotationMatrix& ro 46 const G4RotationMatrix& rot, // 0.5*(phi-width segment) 47 const G4ThreeVector& tl 47 const G4ThreeVector& tlate, 48 G4int handedness, 48 G4int handedness, // R-hand = 1, L-hand = -1 49 const G4double kappa, 49 const G4double kappa, // tan(TwistAngle/2)/fZHalfLen 50 const EAxis axis0 = kXA 50 const EAxis axis0 = kXAxis, 51 const EAxis axis1 = kZA 51 const EAxis axis1 = kZAxis, 52 G4double axis0min = 52 G4double axis0min = -kInfinity, 53 G4double axis1min = 53 G4double axis1min = -kInfinity, 54 G4double axis0max = 54 G4double axis0max = kInfinity, 55 G4double axis1max = 55 G4double axis1max = kInfinity ); 56 56 57 G4TwistTubsSide(const G4String& name, 57 G4TwistTubsSide(const G4String& name, 58 G4double EndInnerRa 58 G4double EndInnerRadius[2], 59 G4double EndOuterRa 59 G4double EndOuterRadius[2], 60 G4double DPhi, 60 G4double DPhi, 61 G4double EndPhi[2], 61 G4double EndPhi[2], 62 G4double EndZ[2], 62 G4double EndZ[2], 63 G4double InnerRadiu 63 G4double InnerRadius, 64 G4double OuterRadiu 64 G4double OuterRadius, 65 G4double Kappa, 65 G4double Kappa, 66 G4int handedness 66 G4int handedness); 67 67 68 ~G4TwistTubsSide() override; 68 ~G4TwistTubsSide() override; 69 69 70 G4ThreeVector GetNormal(const G4ThreeVecto 70 G4ThreeVector GetNormal(const G4ThreeVector& xx, 71 G4bool isGlo 71 G4bool isGlobal = false) override ; 72 72 73 G4int DistanceToSurface(const G4ThreeVecto 73 G4int DistanceToSurface(const G4ThreeVector& gp, 74 const G4ThreeVecto 74 const G4ThreeVector& gv, 75 G4ThreeVecto 75 G4ThreeVector gxx[], 76 G4double di 76 G4double distance[], 77 G4int ar 77 G4int areacode[], 78 G4bool is 78 G4bool isvalid[], 79 EValidate validate 79 EValidate validate = kValidateWithTol) override; 80 80 81 G4int DistanceToSurface(const G4ThreeVecto 81 G4int DistanceToSurface(const G4ThreeVector& gp, 82 G4ThreeVecto 82 G4ThreeVector gxx[], 83 G4double 83 G4double distance[], 84 G4int 84 G4int areacode[]) override; 85 85 86 inline G4ThreeVector ProjectAtPXPZ(const G 86 inline G4ThreeVector ProjectAtPXPZ(const G4ThreeVector& p, 87 G 87 G4bool isglobal = false) const ; 88 88 89 inline G4ThreeVector SurfacePoint(G4double 89 inline G4ThreeVector SurfacePoint(G4double, G4double, 90 G4bool i 90 G4bool isGlobal = false) override ; 91 inline G4double GetBoundaryMin(G4double ph 91 inline G4double GetBoundaryMin(G4double phi) override ; 92 inline G4double GetBoundaryMax(G4double ph 92 inline G4double GetBoundaryMax(G4double phi) override ; 93 inline G4double GetSurfaceArea() override 93 inline G4double GetSurfaceArea() override ; 94 void GetFacets( G4int m, G4int n, G4double 94 void GetFacets( G4int m, G4int n, G4double xyz[][3], 95 G4int faces[][4], G4int is 95 G4int faces[][4], G4int iside ) override ; 96 96 97 G4TwistTubsSide(__void__&); 97 G4TwistTubsSide(__void__&); 98 // Fake default constructor for usage re 98 // Fake default constructor for usage restricted to direct object 99 // persistency for clients requiring pre 99 // persistency for clients requiring preallocation of memory for 100 // persistifiable objects. 100 // persistifiable objects. 101 101 102 private: 102 private: 103 103 104 G4double DistanceToPlane(const G4ThreeVect 104 G4double DistanceToPlane(const G4ThreeVector& p, 105 const G4ThreeVect 105 const G4ThreeVector& A, 106 const G4ThreeVect 106 const G4ThreeVector& B, 107 const G4ThreeVect 107 const G4ThreeVector& C, 108 const G4ThreeVect 108 const G4ThreeVector& D, 109 const G4int 109 const G4int parity, 110 G4ThreeVect 110 G4ThreeVector& xx, 111 G4ThreeVect 111 G4ThreeVector& n); 112 112 113 G4int GetAreaCode(const G4ThreeVector& xx, 113 G4int GetAreaCode(const G4ThreeVector& xx, 114 G4bool wit 114 G4bool withTol = true) override; 115 115 116 void SetCorners() override; 116 void SetCorners() override; 117 117 118 void SetCorners( G4double endInnerRad[2], 118 void SetCorners( G4double endInnerRad[2], 119 G4double endOuterRad[2], 119 G4double endOuterRad[2], 120 G4double endPhi[2], 120 G4double endPhi[2], 121 G4double endZ[2] ) ; 121 G4double endZ[2] ) ; 122 122 123 void SetBoundaries() override; 123 void SetBoundaries() override; 124 124 125 private: 125 private: 126 126 127 G4double fKappa; // std::ta 127 G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ; 128 }; 128 }; 129 129 130 130 131 //============================================ 131 //======================================================== 132 // inline functions 132 // inline functions 133 //============================================ 133 //======================================================== 134 134 135 inline 135 inline 136 G4ThreeVector G4TwistTubsSide::ProjectAtPXPZ(c 136 G4ThreeVector G4TwistTubsSide::ProjectAtPXPZ(const G4ThreeVector& p, 137 137 G4bool isglobal) const 138 { 138 { 139 // Get Rho at p.z() on Hyperbolic Surface. 139 // Get Rho at p.z() on Hyperbolic Surface. 140 G4ThreeVector tmpp; 140 G4ThreeVector tmpp; 141 if (isglobal) { tmpp = fRot.inverse()*p - fT 141 if (isglobal) { tmpp = fRot.inverse()*p - fTrans; } 142 else { tmpp = p; } 142 else { tmpp = p; } 143 G4ThreeVector xx(p.x(), p.x() * fKappa * p.z 143 G4ThreeVector xx(p.x(), p.x() * fKappa * p.z(), p.z()); 144 if (isglobal) { return (fRot * xx + fTrans); 144 if (isglobal) { return (fRot * xx + fTrans); } 145 return xx; 145 return xx; 146 } 146 } 147 147 148 inline 148 inline 149 G4ThreeVector 149 G4ThreeVector 150 G4TwistTubsSide::SurfacePoint(G4double x, G4do 150 G4TwistTubsSide::SurfacePoint(G4double x, G4double z, G4bool isGlobal) 151 { 151 { 152 G4ThreeVector SurfPoint( x , x * fKappa * z 152 G4ThreeVector SurfPoint( x , x * fKappa * z , z ) ; 153 153 154 if (isGlobal) { return (fRot * SurfPoint + f 154 if (isGlobal) { return (fRot * SurfPoint + fTrans); } 155 return SurfPoint; 155 return SurfPoint; 156 } 156 } 157 157 158 inline 158 inline 159 G4double G4TwistTubsSide::GetBoundaryMin(G4dou 159 G4double G4TwistTubsSide::GetBoundaryMin(G4double) 160 { 160 { 161 return fAxisMin[0] ; // inner radius at z 161 return fAxisMin[0] ; // inner radius at z = 0 162 } 162 } 163 163 164 inline 164 inline 165 G4double G4TwistTubsSide::GetBoundaryMax(G4dou 165 G4double G4TwistTubsSide::GetBoundaryMax(G4double) 166 { 166 { 167 return fAxisMax[0] ; // outer radius at z 167 return fAxisMax[0] ; // outer radius at z = 0 168 } 168 } 169 169 170 inline 170 inline 171 G4double G4TwistTubsSide::GetSurfaceArea() 171 G4double G4TwistTubsSide::GetSurfaceArea() 172 { 172 { 173 // approximation only 173 // approximation only 174 return ( fAxisMax[0] - fAxisMin[0] ) * ( fAx 174 return ( fAxisMax[0] - fAxisMin[0] ) * ( fAxisMax[1] - fAxisMin[1] ) ; 175 } 175 } 176 176 177 #endif 177 #endif 178 178