Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // >> 24 // $Id: G4Sphere.icc,v 1.1 2002/10/28 11:43:04 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-05-01 $ >> 26 // >> 27 // -------------------------------------------------------------------- >> 28 // GEANT 4 inline definitions file >> 29 // >> 30 // G4Sphere.icc >> 31 // 26 // Implementation of inline methods of G4Spher 32 // Implementation of inline methods of G4Sphere 27 // ------------------------------------------- 33 // -------------------------------------------------------------------- 28 34 29 inline 35 inline 30 G4double G4Sphere::GetInnerRadius() const << 36 G4double G4Sphere::GetInsideRadius() const 31 { 37 { 32 return fRmin; 38 return fRmin; 33 } 39 } 34 40 35 inline 41 inline 36 G4double G4Sphere::GetOuterRadius() const 42 G4double G4Sphere::GetOuterRadius() const 37 { 43 { 38 return fRmax; 44 return fRmax; 39 } 45 } 40 46 41 inline 47 inline 42 G4double G4Sphere::GetStartPhiAngle() const 48 G4double G4Sphere::GetStartPhiAngle() const 43 { 49 { 44 return fSPhi; 50 return fSPhi; 45 } 51 } 46 52 47 inline 53 inline 48 G4double G4Sphere::GetDeltaPhiAngle() const 54 G4double G4Sphere::GetDeltaPhiAngle() const 49 { 55 { 50 return fDPhi; 56 return fDPhi; 51 } 57 } 52 58 53 inline 59 inline 54 G4double G4Sphere::GetStartThetaAngle() const 60 G4double G4Sphere::GetStartThetaAngle() const 55 { 61 { 56 return fSTheta; 62 return fSTheta; 57 } 63 } 58 64 59 G4double G4Sphere::GetDeltaThetaAngle() const 65 G4double G4Sphere::GetDeltaThetaAngle() const 60 { 66 { 61 return fDTheta; 67 return fDTheta; 62 } 68 } 63 69 64 inline 70 inline 65 G4double G4Sphere::GetSinStartPhi () const << 71 void G4Sphere::SetInsideRadius(G4double newRmin) 66 { << 67 return sinSPhi; << 68 } << 69 << 70 inline << 71 G4double G4Sphere::GetCosStartPhi () const << 72 { << 73 return cosSPhi; << 74 } << 75 << 76 inline << 77 G4double G4Sphere::GetSinEndPhi () const << 78 { << 79 return sinEPhi; << 80 } << 81 << 82 inline << 83 G4double G4Sphere::GetCosEndPhi () const << 84 { << 85 return cosEPhi; << 86 } << 87 << 88 inline << 89 G4double G4Sphere::GetSinStartTheta () const << 90 { << 91 return sinSTheta; << 92 } << 93 << 94 inline << 95 G4double G4Sphere::GetCosStartTheta () const << 96 { << 97 return cosSTheta; << 98 } << 99 << 100 inline << 101 G4double G4Sphere::GetSinEndTheta () const << 102 { 72 { 103 return sinETheta; << 73 fRmin= newRmin; 104 } << 105 << 106 inline << 107 G4double G4Sphere::GetCosEndTheta () const << 108 { << 109 return cosETheta; << 110 } << 111 << 112 inline << 113 void G4Sphere::Initialize() << 114 { << 115 fCubicVolume = 0.; << 116 fSurfaceArea = 0.; << 117 fRebuildPolyhedron = true; << 118 } 74 } 119 75 120 inline 76 inline 121 void G4Sphere::InitializePhiTrigonometry() << 77 void G4Sphere::SetOuterRadius(G4double newRmax) 122 { 78 { 123 hDPhi = 0.5*fDPhi; // << 79 fRmax= newRmax; 124 cPhi = fSPhi + hDPhi; << 125 ePhi = fSPhi + fDPhi; << 126 << 127 sinCPhi = std::sin(cPhi); << 128 cosCPhi = std::cos(cPhi); << 129 cosHDPhi = std::cos(hDPhi); << 130 cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolera << 131 cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolera << 132 sinSPhi = std::sin(fSPhi); << 133 cosSPhi = std::cos(fSPhi); << 134 sinEPhi = std::sin(ePhi); << 135 cosEPhi = std::cos(ePhi); << 136 } 80 } 137 81 138 inline 82 inline 139 void G4Sphere::InitializeThetaTrigonometry() << 83 void G4Sphere::SetStartPhiAngle(G4double newSphi) 140 { 84 { 141 eTheta = fSTheta + fDTheta; << 85 fSPhi= newSphi; 142 << 143 sinSTheta = std::sin(fSTheta); << 144 cosSTheta = std::cos(fSTheta); << 145 sinETheta = std::sin(eTheta); << 146 cosETheta = std::cos(eTheta); << 147 << 148 tanSTheta = sinSTheta/cosSTheta; << 149 tanSTheta2 = tanSTheta*tanSTheta; << 150 tanETheta = sinETheta/cosETheta; << 151 tanETheta2 = tanETheta*tanETheta; << 152 } 86 } 153 87 154 inline 88 inline 155 void G4Sphere::CheckThetaAngles(G4double sThet << 89 void G4Sphere::SetDeltaPhiAngle(G4double newDphi) 156 { 90 { 157 if ( (sTheta<0) || (sTheta>CLHEP::pi) ) << 91 fDPhi= newDphi; 158 { << 159 std::ostringstream message; << 160 message << "sTheta outside 0-PI range." << << 161 << "Invalid starting Theta angle f << 162 G4Exception("G4Sphere::CheckThetaAngles()" << 163 FatalException, message); << 164 } << 165 else << 166 { << 167 fSTheta=sTheta; << 168 } << 169 if ( dTheta+sTheta >= CLHEP::pi ) << 170 { << 171 fDTheta=CLHEP::pi-sTheta; << 172 } << 173 else if ( dTheta > 0 ) << 174 { << 175 fDTheta=dTheta; << 176 } << 177 else << 178 { << 179 std::ostringstream message; << 180 message << "Invalid dTheta." << G4endl << 181 << "Negative delta-Theta (" << dTh << 182 << GetName(); << 183 G4Exception("G4Sphere::CheckThetaAngles()" << 184 FatalException, message); << 185 } << 186 fFullThetaSphere = fDTheta-fSTheta >= CLHEP: << 187 fFullSphere = fFullPhiSphere && fFullThetaSp << 188 << 189 InitializeThetaTrigonometry(); << 190 } 92 } 191 93 192 inline 94 inline 193 void G4Sphere::CheckSPhiAngle(G4double sPhi) << 95 void G4Sphere::SetStartThetaAngle(G4double newSTheta) 194 { 96 { 195 // Ensure fSphi in 0-2PI or -2PI-0 range if << 97 fSTheta=newSTheta; 196 << 197 if ( sPhi < 0 ) << 198 { << 199 fSPhi = CLHEP::twopi - std::fmod(std::fabs << 200 } << 201 else << 202 { << 203 fSPhi = std::fmod(sPhi,CLHEP::twopi) ; << 204 } << 205 if ( fSPhi+fDPhi > CLHEP::twopi ) << 206 { << 207 fSPhi -= CLHEP::twopi ; << 208 } << 209 } 98 } 210 99 211 inline 100 inline 212 void G4Sphere::CheckDPhiAngle(G4double dPhi) << 101 void G4Sphere::SetDeltaThetaAngle(G4double newDTheta) 213 { 102 { 214 fFullPhiSphere = true; << 103 fDTheta=newDTheta; 215 if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 << 216 { << 217 fDPhi=CLHEP::twopi; << 218 } << 219 else << 220 { << 221 fFullPhiSphere = false; << 222 if ( dPhi > 0 ) << 223 { << 224 fDPhi = dPhi; << 225 } << 226 else << 227 { << 228 std::ostringstream message; << 229 message << "Invalid dphi." << G4endl << 230 << "Negative delta-Phi (" << dPh << 231 << GetName(); << 232 G4Exception("G4Sphere::CheckDPhiAngle()" << 233 FatalException, message); << 234 } << 235 } << 236 } 104 } 237 105 238 inline << 106 // Old access functions 239 void G4Sphere::CheckPhiAngles(G4double sPhi, G << 240 { << 241 CheckDPhiAngle(dPhi); << 242 if (!fFullPhiSphere && (sPhi != 0.0)) { Chec << 243 fFullSphere = fFullPhiSphere && fFullThetaSp << 244 << 245 InitializePhiTrigonometry(); << 246 } << 247 107 248 inline 108 inline 249 void G4Sphere::SetInnerRadius(G4double newRmin << 109 G4double G4Sphere::GetRmin() const 250 { 110 { 251 fRmin= newRmin; << 111 return GetInsideRadius(); 252 fRminTolerance = (fRmin) != 0.0 ? std::max( << 253 Initialize(); << 254 } 112 } 255 113 256 inline 114 inline 257 void G4Sphere::SetOuterRadius(G4double newRmax << 115 G4double G4Sphere::GetRmax() const 258 { 116 { 259 fRmax= newRmax; << 117 return GetOuterRadius(); 260 fRmaxTolerance = std::max( kRadTolerance, fE << 261 Initialize(); << 262 } 118 } 263 119 264 inline 120 inline 265 void G4Sphere::SetStartPhiAngle(G4double newSP << 121 G4double G4Sphere::GetSPhi() const 266 { 122 { 267 // Flag 'compute' can be used to explicitely << 123 return GetStartPhiAngle(); 268 // trigonometry in case SetDeltaPhiAngle() i << 269 << 270 CheckSPhiAngle(newSPhi); << 271 fFullPhiSphere = false; << 272 if (compute) { InitializePhiTrigonometry(); << 273 Initialize(); << 274 } 124 } 275 125 276 inline 126 inline 277 void G4Sphere::SetDeltaPhiAngle(G4double newDP << 127 G4double G4Sphere::GetDPhi() const 278 { 128 { 279 CheckPhiAngles(fSPhi, newDPhi); << 129 return GetDeltaPhiAngle(); 280 Initialize(); << 281 } 130 } 282 131 283 inline 132 inline 284 void G4Sphere::SetStartThetaAngle(G4double new << 133 G4double G4Sphere::GetSTheta() const 285 { 134 { 286 CheckThetaAngles(newSTheta, fDTheta); << 135 return GetStartThetaAngle(); 287 Initialize(); << 288 } 136 } 289 137 290 inline 138 inline 291 void G4Sphere::SetDeltaThetaAngle(G4double new << 139 G4double G4Sphere::GetDTheta() const 292 { 140 { 293 CheckThetaAngles(fSTheta, newDTheta); << 141 return GetDeltaThetaAngle(); 294 Initialize(); << 295 } 142 } 296 143