00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 inline
00038 G4double G4Sphere::GetInsideRadius() const
00039 {
00040 return fRmin;
00041 }
00042
00043 inline
00044 G4double G4Sphere::GetInnerRadius() const
00045 {
00046 return fRmin;
00047 }
00048
00049 inline
00050 G4double G4Sphere::GetOuterRadius() const
00051 {
00052 return fRmax;
00053 }
00054
00055 inline
00056 G4double G4Sphere::GetStartPhiAngle() const
00057 {
00058 return fSPhi;
00059 }
00060
00061 inline
00062 G4double G4Sphere::GetDeltaPhiAngle() const
00063 {
00064 return fDPhi;
00065 }
00066
00067 inline
00068 G4double G4Sphere::GetStartThetaAngle() const
00069 {
00070 return fSTheta;
00071 }
00072
00073 G4double G4Sphere::GetDeltaThetaAngle() const
00074 {
00075 return fDTheta;
00076 }
00077
00078 inline
00079 void G4Sphere::Initialize()
00080 {
00081 fCubicVolume = 0.;
00082 fSurfaceArea = 0.;
00083 fpPolyhedron = 0;
00084 }
00085
00086 inline
00087 void G4Sphere::InitializePhiTrigonometry()
00088 {
00089 hDPhi = 0.5*fDPhi;
00090 cPhi = fSPhi + hDPhi;
00091 ePhi = fSPhi + fDPhi;
00092
00093 sinCPhi = std::sin(cPhi);
00094 cosCPhi = std::cos(cPhi);
00095 cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance);
00096 cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
00097 sinSPhi = std::sin(fSPhi);
00098 cosSPhi = std::cos(fSPhi);
00099 sinEPhi = std::sin(ePhi);
00100 cosEPhi = std::cos(ePhi);
00101 }
00102
00103 inline
00104 void G4Sphere::InitializeThetaTrigonometry()
00105 {
00106 eTheta = fSTheta + fDTheta;
00107
00108 sinSTheta = std::sin(fSTheta);
00109 cosSTheta = std::cos(fSTheta);
00110 sinETheta = std::sin(eTheta);
00111 cosETheta = std::cos(eTheta);
00112
00113 tanSTheta = std::tan(fSTheta);
00114 tanSTheta2 = tanSTheta*tanSTheta;
00115 tanETheta = std::tan(eTheta);
00116 tanETheta2 = tanETheta*tanETheta;
00117 }
00118
00119 inline
00120 void G4Sphere::CheckThetaAngles(G4double sTheta, G4double dTheta)
00121 {
00122 if ( (sTheta<0) || (sTheta>CLHEP::pi) )
00123 {
00124 std::ostringstream message;
00125 message << "sTheta outside 0-PI range." << G4endl
00126 << "Invalid starting Theta angle for solid: " << GetName();
00127 G4Exception("G4Sphere::CheckThetaAngles()", "GeomSolids0002",
00128 FatalException, message);
00129 }
00130 else
00131 {
00132 fSTheta=sTheta;
00133 }
00134 if ( dTheta+sTheta >= CLHEP::pi )
00135 {
00136 fDTheta=CLHEP::pi-sTheta;
00137 }
00138 else if ( dTheta > 0 )
00139 {
00140 fDTheta=dTheta;
00141 }
00142 else
00143 {
00144 std::ostringstream message;
00145 message << "Invalid dTheta." << G4endl
00146 << "Negative delta-Theta (" << dTheta << "), for solid: "
00147 << GetName();
00148 G4Exception("G4Sphere::CheckThetaAngles()", "GeomSolids0002",
00149 FatalException, message);
00150 }
00151 if ( fDTheta-fSTheta < CLHEP::pi ) { fFullThetaSphere = false; }
00152 else { fFullThetaSphere = true ; }
00153 fFullSphere = fFullPhiSphere && fFullThetaSphere;
00154
00155 InitializeThetaTrigonometry();
00156 }
00157
00158 inline
00159 void G4Sphere::CheckSPhiAngle(G4double sPhi)
00160 {
00161
00162
00163 if ( sPhi < 0 )
00164 {
00165 fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
00166 }
00167 else
00168 {
00169 fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
00170 }
00171 if ( fSPhi+fDPhi > CLHEP::twopi )
00172 {
00173 fSPhi -= CLHEP::twopi ;
00174 }
00175 }
00176
00177 inline
00178 void G4Sphere::CheckDPhiAngle(G4double dPhi)
00179 {
00180 fFullPhiSphere = true;
00181 if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
00182 {
00183 fDPhi=CLHEP::twopi;
00184 fSPhi=0;
00185 }
00186 else
00187 {
00188 fFullPhiSphere = false;
00189 if ( dPhi > 0 )
00190 {
00191 fDPhi = dPhi;
00192 }
00193 else
00194 {
00195 std::ostringstream message;
00196 message << "Invalid dphi." << G4endl
00197 << "Negative delta-Phi (" << dPhi << "), for solid: "
00198 << GetName();
00199 G4Exception("G4Sphere::CheckDPhiAngle()", "GeomSolids0002",
00200 FatalException, message);
00201 }
00202 }
00203 }
00204
00205 inline
00206 void G4Sphere::CheckPhiAngles(G4double sPhi, G4double dPhi)
00207 {
00208 CheckDPhiAngle(dPhi);
00209 if (!fFullPhiSphere && sPhi) { CheckSPhiAngle(sPhi); }
00210 fFullSphere = fFullPhiSphere && fFullThetaSphere;
00211
00212 InitializePhiTrigonometry();
00213 }
00214
00215 inline
00216 void G4Sphere::SetInsideRadius(G4double newRmin)
00217 {
00218 fRmin= newRmin;
00219 fRminTolerance = (fRmin) ? std::max( kRadTolerance, fEpsilon*fRmin ) : 0;
00220 Initialize();
00221 }
00222
00223 inline
00224 void G4Sphere::SetInnerRadius(G4double newRmin)
00225 {
00226 SetInsideRadius(newRmin);
00227 }
00228
00229 inline
00230 void G4Sphere::SetOuterRadius(G4double newRmax)
00231 {
00232 fRmax= newRmax;
00233 fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax );
00234 Initialize();
00235 }
00236
00237 inline
00238 void G4Sphere::SetStartPhiAngle(G4double newSPhi, G4bool compute)
00239 {
00240
00241
00242
00243 CheckSPhiAngle(newSPhi);
00244 fFullPhiSphere = false;
00245 if (compute) { InitializePhiTrigonometry(); }
00246 Initialize();
00247 }
00248
00249 inline
00250 void G4Sphere::SetDeltaPhiAngle(G4double newDPhi)
00251 {
00252 CheckPhiAngles(fSPhi, newDPhi);
00253 Initialize();
00254 }
00255
00256 inline
00257 void G4Sphere::SetStartThetaAngle(G4double newSTheta)
00258 {
00259 CheckThetaAngles(newSTheta, fDTheta);
00260 Initialize();
00261 }
00262
00263 inline
00264 void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
00265 {
00266 CheckThetaAngles(fSTheta, newDTheta);
00267 Initialize();
00268 }
00269
00270
00271
00272 inline
00273 G4double G4Sphere::GetRmin() const
00274 {
00275 return GetInsideRadius();
00276 }
00277
00278 inline
00279 G4double G4Sphere::GetRmax() const
00280 {
00281 return GetOuterRadius();
00282 }
00283
00284 inline
00285 G4double G4Sphere::GetSPhi() const
00286 {
00287 return GetStartPhiAngle();
00288 }
00289
00290 inline
00291 G4double G4Sphere::GetDPhi() const
00292 {
00293 return GetDeltaPhiAngle();
00294 }
00295
00296 inline
00297 G4double G4Sphere::GetSTheta() const
00298 {
00299 return GetStartThetaAngle();
00300 }
00301
00302 inline
00303 G4double G4Sphere::GetDTheta() const
00304 {
00305 return GetDeltaThetaAngle();
00306 }
00307
00308 inline
00309 G4double G4Sphere::GetCubicVolume()
00310 {
00311 if(fCubicVolume != 0.) {;}
00312 else { fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
00313 (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.; }
00314 return fCubicVolume;
00315 }