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