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 // >> 27 // >> 28 // -------------------------------------------------------------------- >> 29 // GEANT 4 inline definitions file >> 30 // >> 31 // G4CutTubs.icc >> 32 // 26 // Implementation of inline methods of G4CutTu 33 // Implementation of inline methods of G4CutTubs 27 // ------------------------------------------- 34 // -------------------------------------------------------------------- 28 35 29 inline 36 inline 30 G4double G4CutTubs::GetInnerRadius () const 37 G4double G4CutTubs::GetInnerRadius () const 31 { 38 { 32 return fRMin; 39 return fRMin; 33 } 40 } 34 41 35 inline 42 inline 36 G4double G4CutTubs::GetOuterRadius () const 43 G4double G4CutTubs::GetOuterRadius () const 37 { 44 { 38 return fRMax; 45 return fRMax; 39 } 46 } 40 47 41 inline 48 inline 42 G4double G4CutTubs::GetZHalfLength () const 49 G4double G4CutTubs::GetZHalfLength () const 43 { 50 { 44 return fDz; 51 return fDz; 45 } 52 } 46 53 47 inline 54 inline 48 G4double G4CutTubs::GetStartPhiAngle () const 55 G4double G4CutTubs::GetStartPhiAngle () const 49 { 56 { 50 return fSPhi; 57 return fSPhi; 51 } 58 } 52 59 53 inline 60 inline 54 G4double G4CutTubs::GetDeltaPhiAngle () const 61 G4double G4CutTubs::GetDeltaPhiAngle () const 55 { 62 { 56 return fDPhi; 63 return fDPhi; 57 } 64 } 58 65 59 inline 66 inline 60 G4double G4CutTubs::GetSinStartPhi () const 67 G4double G4CutTubs::GetSinStartPhi () const 61 { 68 { 62 return sinSPhi; 69 return sinSPhi; 63 } 70 } 64 71 65 inline 72 inline 66 G4double G4CutTubs::GetCosStartPhi () const 73 G4double G4CutTubs::GetCosStartPhi () const 67 { 74 { 68 return cosSPhi; 75 return cosSPhi; 69 } 76 } 70 77 71 inline 78 inline 72 G4double G4CutTubs::GetSinEndPhi () const 79 G4double G4CutTubs::GetSinEndPhi () const 73 { 80 { 74 return sinEPhi; 81 return sinEPhi; 75 } 82 } 76 83 77 inline 84 inline 78 G4double G4CutTubs::GetCosEndPhi () const 85 G4double G4CutTubs::GetCosEndPhi () const 79 { 86 { 80 return cosEPhi; 87 return cosEPhi; 81 } 88 } 82 89 83 inline 90 inline 84 G4ThreeVector G4CutTubs::GetLowNorm () const 91 G4ThreeVector G4CutTubs::GetLowNorm () const 85 { 92 { 86 return fLowNorm; 93 return fLowNorm; 87 } 94 } 88 95 89 inline 96 inline 90 G4ThreeVector G4CutTubs::GetHighNorm () const 97 G4ThreeVector G4CutTubs::GetHighNorm () const 91 { 98 { 92 return fHighNorm; 99 return fHighNorm; 93 } 100 } 94 101 95 inline 102 inline 96 void G4CutTubs::Initialize() 103 void G4CutTubs::Initialize() 97 { 104 { 98 fZMin = 0.; << 99 fZMax = 0.; << 100 fCubicVolume = 0.; 105 fCubicVolume = 0.; 101 fSurfaceArea = 0.; 106 fSurfaceArea = 0.; 102 fRebuildPolyhedron = true; 107 fRebuildPolyhedron = true; 103 } 108 } 104 109 105 inline 110 inline 106 void G4CutTubs::InitializeTrigonometry() 111 void G4CutTubs::InitializeTrigonometry() 107 { 112 { 108 G4double hDPhi = 0.5*fDPhi; 113 G4double hDPhi = 0.5*fDPhi; // half delta phi 109 G4double cPhi = fSPhi + hDPhi; 114 G4double cPhi = fSPhi + hDPhi; 110 G4double ePhi = fSPhi + fDPhi; 115 G4double ePhi = fSPhi + fDPhi; 111 116 112 sinCPhi = std::sin(cPhi); 117 sinCPhi = std::sin(cPhi); 113 cosCPhi = std::cos(cPhi); 118 cosCPhi = std::cos(cPhi); 114 cosHDPhi = std::cos(hDPhi); << 115 cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolera 119 cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi 116 cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolera 120 cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance); 117 sinSPhi = std::sin(fSPhi); 121 sinSPhi = std::sin(fSPhi); 118 cosSPhi = std::cos(fSPhi); 122 cosSPhi = std::cos(fSPhi); 119 sinEPhi = std::sin(ePhi); 123 sinEPhi = std::sin(ePhi); 120 cosEPhi = std::cos(ePhi); 124 cosEPhi = std::cos(ePhi); 121 } 125 } 122 126 123 inline void G4CutTubs::CheckSPhiAngle(G4double 127 inline void G4CutTubs::CheckSPhiAngle(G4double sPhi) 124 { 128 { 125 // Ensure fSphi in 0-2PI or -2PI-0 range if 129 // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0 126 130 127 if ( sPhi < 0 ) 131 if ( sPhi < 0 ) 128 { 132 { 129 fSPhi = CLHEP::twopi - std::fmod(std::fabs 133 fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi); 130 } 134 } 131 else 135 else 132 { 136 { 133 fSPhi = std::fmod(sPhi,CLHEP::twopi) ; 137 fSPhi = std::fmod(sPhi,CLHEP::twopi) ; 134 } 138 } 135 if ( fSPhi+fDPhi > CLHEP::twopi ) 139 if ( fSPhi+fDPhi > CLHEP::twopi ) 136 { 140 { 137 fSPhi -= CLHEP::twopi ; 141 fSPhi -= CLHEP::twopi ; 138 } 142 } 139 } 143 } 140 144 141 inline void G4CutTubs::CheckDPhiAngle(G4double 145 inline void G4CutTubs::CheckDPhiAngle(G4double dPhi) 142 { 146 { 143 fPhiFullCutTube = true; 147 fPhiFullCutTube = true; 144 if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 148 if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 ) 145 { 149 { 146 fDPhi=CLHEP::twopi; 150 fDPhi=CLHEP::twopi; 147 fSPhi=0; 151 fSPhi=0; 148 } 152 } 149 else 153 else 150 { 154 { 151 fPhiFullCutTube = false; 155 fPhiFullCutTube = false; 152 if ( dPhi > 0 ) 156 if ( dPhi > 0 ) 153 { 157 { 154 fDPhi = dPhi; 158 fDPhi = dPhi; 155 } 159 } 156 else 160 else 157 { 161 { 158 std::ostringstream message; 162 std::ostringstream message; 159 message << "Invalid dphi." << G4endl 163 message << "Invalid dphi." << G4endl 160 << "Negative or zero delta-Phi ( 164 << "Negative or zero delta-Phi (" << dPhi << "), for solid: " 161 << GetName(); 165 << GetName(); 162 G4Exception("G4CutTubs::CheckDPhiAngle() 166 G4Exception("G4CutTubs::CheckDPhiAngle()", "GeomSolids0002", 163 FatalException, message); 167 FatalException, message); 164 } 168 } 165 } 169 } 166 } 170 } 167 171 168 inline void G4CutTubs::CheckPhiAngles(G4double 172 inline void G4CutTubs::CheckPhiAngles(G4double sPhi, G4double dPhi) 169 { 173 { 170 CheckDPhiAngle(dPhi); 174 CheckDPhiAngle(dPhi); 171 if ( (fDPhi<CLHEP::twopi) && ((sPhi) != 0.0) << 175 if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); } 172 InitializeTrigonometry(); 176 InitializeTrigonometry(); 173 } 177 } 174 178 175 inline 179 inline 176 void G4CutTubs::SetInnerRadius (G4double newRM 180 void G4CutTubs::SetInnerRadius (G4double newRMin) 177 { 181 { 178 if ( newRMin < 0 ) // Check radii 182 if ( newRMin < 0 ) // Check radii 179 { 183 { 180 std::ostringstream message; 184 std::ostringstream message; 181 message << "Invalid radii." << G4endl 185 message << "Invalid radii." << G4endl 182 << "Invalid values for radii in so 186 << "Invalid values for radii in solid " << GetName() << G4endl 183 << " newRMin = " << newRMin 187 << " newRMin = " << newRMin 184 << ", fRMax = " << fRMax << G4endl 188 << ", fRMax = " << fRMax << G4endl 185 << " Negative inner radius! 189 << " Negative inner radius!"; 186 G4Exception("G4CutTubs::SetInnerRadius()", 190 G4Exception("G4CutTubs::SetInnerRadius()", "GeomSolids0002", 187 FatalException, message); 191 FatalException, message); 188 } 192 } 189 fRMin= newRMin; 193 fRMin= newRMin; 190 Initialize(); 194 Initialize(); 191 } 195 } 192 196 193 inline 197 inline 194 void G4CutTubs::SetOuterRadius (G4double newRM 198 void G4CutTubs::SetOuterRadius (G4double newRMax) 195 { 199 { 196 if ( newRMax <= 0 ) // Check radii 200 if ( newRMax <= 0 ) // Check radii 197 { 201 { 198 std::ostringstream message; 202 std::ostringstream message; 199 message << "Invalid radii." << G4endl 203 message << "Invalid radii." << G4endl 200 << "Invalid values for radii in so 204 << "Invalid values for radii in solid " << GetName() << G4endl 201 << " fRMin = " << fRMin 205 << " fRMin = " << fRMin 202 << ", newRMax = " << newRMax << G4 206 << ", newRMax = " << newRMax << G4endl 203 << " Invalid outer radius!" 207 << " Invalid outer radius!"; 204 G4Exception("G4CutTubs::SetOuterRadius()", 208 G4Exception("G4CutTubs::SetOuterRadius()", "GeomSolids0002", 205 FatalException, message); 209 FatalException, message); 206 } 210 } 207 fRMax= newRMax; 211 fRMax= newRMax; 208 Initialize(); 212 Initialize(); 209 } 213 } 210 214 211 inline 215 inline 212 void G4CutTubs::SetZHalfLength (G4double newDz 216 void G4CutTubs::SetZHalfLength (G4double newDz) 213 { 217 { 214 if (newDz<=0) // Check z-len 218 if (newDz<=0) // Check z-len 215 { 219 { 216 std::ostringstream message; 220 std::ostringstream message; 217 message << "Invalid Z half-length." << G4e 221 message << "Invalid Z half-length." << G4endl 218 << "Negative Z half-length (" << n 222 << "Negative Z half-length (" << newDz << "), for solid: " 219 << GetName(); 223 << GetName(); 220 G4Exception("G4CutTubs::SetZHalfLength()", 224 G4Exception("G4CutTubs::SetZHalfLength()", "GeomSolids0002", 221 FatalException, message); 225 FatalException, message); 222 } 226 } 223 fDz= newDz; 227 fDz= newDz; 224 Initialize(); 228 Initialize(); 225 } 229 } 226 230 227 inline 231 inline 228 void G4CutTubs::SetStartPhiAngle (G4double new 232 void G4CutTubs::SetStartPhiAngle (G4double newSPhi, G4bool compute) 229 { 233 { 230 // Flag 'compute' can be used to explicitely 234 // Flag 'compute' can be used to explicitely avoid recomputation of 231 // trigonometry in case SetDeltaPhiAngle() i 235 // trigonometry in case SetDeltaPhiAngle() is invoked afterwards 232 236 233 CheckSPhiAngle(newSPhi); 237 CheckSPhiAngle(newSPhi); 234 fPhiFullCutTube = false; 238 fPhiFullCutTube = false; 235 if (compute) { InitializeTrigonometry(); } 239 if (compute) { InitializeTrigonometry(); } 236 Initialize(); 240 Initialize(); 237 } 241 } 238 242 239 inline 243 inline 240 void G4CutTubs::SetDeltaPhiAngle (G4double new 244 void G4CutTubs::SetDeltaPhiAngle (G4double newDPhi) 241 { 245 { 242 CheckPhiAngles(fSPhi, newDPhi); 246 CheckPhiAngles(fSPhi, newDPhi); 243 Initialize(); 247 Initialize(); >> 248 } >> 249 >> 250 // Older names for access functions >> 251 >> 252 inline >> 253 G4double G4CutTubs::GetRMin () const >> 254 { >> 255 return GetInnerRadius(); >> 256 } >> 257 >> 258 inline >> 259 G4double G4CutTubs::GetRMax () const >> 260 { >> 261 return GetOuterRadius(); >> 262 } >> 263 >> 264 inline >> 265 G4double G4CutTubs::GetDz () const >> 266 { >> 267 return GetZHalfLength(); >> 268 } >> 269 >> 270 inline >> 271 G4double G4CutTubs::GetSPhi () const >> 272 { >> 273 return GetStartPhiAngle(); >> 274 } >> 275 >> 276 inline >> 277 G4double G4CutTubs::GetDPhi () const >> 278 { >> 279 return GetDeltaPhiAngle(); >> 280 } >> 281 >> 282 inline G4double G4CutTubs::GetCubicVolume() >> 283 { >> 284 if (fCubicVolume == 0.) { fCubicVolume = G4VSolid::GetCubicVolume(); } >> 285 return fCubicVolume; >> 286 } >> 287 >> 288 inline G4double G4CutTubs::GetSurfaceArea() >> 289 { >> 290 if (fSurfaceArea == 0.) { fSurfaceArea = G4VSolid::GetSurfaceArea(); } >> 291 return fSurfaceArea; 244 } 292 } 245 293