[831] | 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 | // |
---|
[1228] | 27 | // $Id: G4Cons.icc,v 1.11 2009/06/09 16:08:23 gcosmo Exp $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[831] | 29 | // |
---|
| 30 | // -------------------------------------------------------------------- |
---|
| 31 | // GEANT 4 inline definitions file |
---|
| 32 | // |
---|
| 33 | // G4Cons.icc |
---|
| 34 | // |
---|
| 35 | // Implementation of inline methods of G4Cons |
---|
| 36 | // -------------------------------------------------------------------- |
---|
| 37 | |
---|
| 38 | inline |
---|
| 39 | G4double G4Cons::GetInnerRadiusMinusZ() const |
---|
| 40 | { |
---|
| 41 | return fRmin1 ; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | inline |
---|
| 45 | G4double G4Cons::GetOuterRadiusMinusZ() const |
---|
| 46 | { |
---|
| 47 | return fRmax1 ; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | inline |
---|
| 51 | G4double G4Cons::GetInnerRadiusPlusZ() const |
---|
| 52 | { |
---|
| 53 | return fRmin2 ; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | inline |
---|
| 57 | G4double G4Cons::GetOuterRadiusPlusZ() const |
---|
| 58 | { |
---|
| 59 | return fRmax2 ; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | inline |
---|
| 63 | G4double G4Cons::GetZHalfLength() const |
---|
| 64 | { |
---|
| 65 | return fDz ; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | inline |
---|
| 69 | G4double G4Cons::GetStartPhiAngle() const |
---|
| 70 | { |
---|
| 71 | return fSPhi ; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | inline |
---|
| 75 | G4double G4Cons::GetDeltaPhiAngle() const |
---|
| 76 | { |
---|
| 77 | return fDPhi; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | inline |
---|
[1228] | 81 | void G4Cons::Initialize() |
---|
| 82 | { |
---|
| 83 | fCubicVolume = 0.; |
---|
| 84 | fSurfaceArea = 0.; |
---|
| 85 | fpPolyhedron = 0; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | inline |
---|
| 89 | void G4Cons::InitializeTrigonometry() |
---|
| 90 | { |
---|
| 91 | G4double hDPhi = 0.5*fDPhi; // half delta phi |
---|
| 92 | G4double cPhi = fSPhi + hDPhi; |
---|
| 93 | G4double ePhi = fSPhi + fDPhi; |
---|
| 94 | |
---|
| 95 | sinCPhi = std::sin(cPhi); |
---|
| 96 | cosCPhi = std::cos(cPhi); |
---|
| 97 | cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi |
---|
| 98 | cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance); |
---|
| 99 | sinSPhi = std::sin(fSPhi); |
---|
| 100 | cosSPhi = std::cos(fSPhi); |
---|
| 101 | sinEPhi = std::sin(ePhi); |
---|
| 102 | cosEPhi = std::cos(ePhi); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | inline void G4Cons::CheckSPhiAngle(G4double sPhi) |
---|
| 106 | { |
---|
| 107 | // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0 |
---|
| 108 | |
---|
| 109 | if ( sPhi < 0 ) |
---|
| 110 | { |
---|
| 111 | fSPhi = twopi - std::fmod(std::fabs(sPhi),twopi); |
---|
| 112 | } |
---|
| 113 | else |
---|
| 114 | { |
---|
| 115 | fSPhi = std::fmod(sPhi,twopi) ; |
---|
| 116 | } |
---|
| 117 | if ( fSPhi+fDPhi > twopi ) |
---|
| 118 | { |
---|
| 119 | fSPhi -= twopi ; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | inline void G4Cons::CheckDPhiAngle(G4double dPhi) |
---|
| 124 | { |
---|
| 125 | fPhiFullCone = true; |
---|
| 126 | if ( dPhi >= twopi-kAngTolerance*0.5 ) |
---|
| 127 | { |
---|
| 128 | fDPhi=twopi; |
---|
| 129 | fSPhi=0; |
---|
| 130 | } |
---|
| 131 | else |
---|
| 132 | { |
---|
| 133 | fPhiFullCone = false; |
---|
| 134 | if ( dPhi > 0 ) |
---|
| 135 | { |
---|
| 136 | fDPhi = dPhi; |
---|
| 137 | } |
---|
| 138 | else |
---|
| 139 | { |
---|
| 140 | G4cerr << "ERROR - G4Cons()::CheckDPhiAngle()" << G4endl |
---|
| 141 | << " Negative or zero delta-Phi (" << dPhi << ") in solid: " |
---|
| 142 | << GetName() << G4endl; |
---|
| 143 | G4Exception("G4Cons::CheckDPhiAngle()", "InvalidSetup", |
---|
| 144 | FatalException, "Invalid dphi."); |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | inline void G4Cons::CheckPhiAngles(G4double sPhi, G4double dPhi) |
---|
| 150 | { |
---|
| 151 | CheckDPhiAngle(dPhi); |
---|
| 152 | if ( (fDPhi<twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); } |
---|
| 153 | InitializeTrigonometry(); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | inline |
---|
[831] | 157 | void G4Cons::SetInnerRadiusMinusZ( G4double Rmin1 ) |
---|
| 158 | { |
---|
| 159 | fRmin1= Rmin1 ; |
---|
[1228] | 160 | Initialize(); |
---|
[831] | 161 | } |
---|
| 162 | |
---|
| 163 | inline |
---|
| 164 | void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 ) |
---|
| 165 | { |
---|
| 166 | fRmax1= Rmax1 ; |
---|
[1228] | 167 | Initialize(); |
---|
[831] | 168 | } |
---|
| 169 | |
---|
| 170 | inline |
---|
| 171 | void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 ) |
---|
| 172 | { |
---|
| 173 | fRmin2= Rmin2 ; |
---|
[1228] | 174 | Initialize(); |
---|
[831] | 175 | } |
---|
| 176 | |
---|
| 177 | inline |
---|
| 178 | void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 ) |
---|
| 179 | { |
---|
| 180 | fRmax2= Rmax2 ; |
---|
[1228] | 181 | Initialize(); |
---|
[831] | 182 | } |
---|
| 183 | |
---|
| 184 | inline |
---|
| 185 | void G4Cons::SetZHalfLength ( G4double newDz ) |
---|
| 186 | { |
---|
| 187 | fDz= newDz ; |
---|
[1228] | 188 | Initialize(); |
---|
[831] | 189 | } |
---|
| 190 | |
---|
| 191 | inline |
---|
[1228] | 192 | void G4Cons::SetStartPhiAngle ( G4double newSPhi, G4bool compute ) |
---|
[831] | 193 | { |
---|
[1228] | 194 | // Flag 'compute' can be used to explicitely avoid recomputation of |
---|
| 195 | // trigonometry in case SetDeltaPhiAngle() is invoked afterwards |
---|
| 196 | |
---|
| 197 | CheckSPhiAngle(newSPhi); |
---|
| 198 | fPhiFullCone = false; |
---|
| 199 | if (compute) { InitializeTrigonometry(); } |
---|
| 200 | Initialize(); |
---|
[831] | 201 | } |
---|
| 202 | |
---|
| 203 | void G4Cons::SetDeltaPhiAngle ( G4double newDPhi ) |
---|
| 204 | { |
---|
[1228] | 205 | CheckPhiAngles(fSPhi, newDPhi); |
---|
| 206 | Initialize(); |
---|
[831] | 207 | } |
---|
| 208 | |
---|
| 209 | // Old access methods ... |
---|
| 210 | |
---|
| 211 | inline |
---|
| 212 | G4double G4Cons::GetRmin1() const |
---|
| 213 | { |
---|
| 214 | return GetInnerRadiusMinusZ(); |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | inline |
---|
| 218 | G4double G4Cons::GetRmax1() const |
---|
| 219 | { |
---|
| 220 | return GetOuterRadiusMinusZ(); |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | inline |
---|
| 224 | G4double G4Cons::GetRmin2() const |
---|
| 225 | { |
---|
| 226 | return GetInnerRadiusPlusZ(); |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | inline |
---|
| 230 | G4double G4Cons::GetRmax2() const |
---|
| 231 | { |
---|
| 232 | return GetOuterRadiusPlusZ(); |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | inline |
---|
| 236 | G4double G4Cons::GetDz() const |
---|
| 237 | { |
---|
| 238 | return GetZHalfLength(); |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | inline |
---|
| 242 | G4double G4Cons::GetSPhi() const |
---|
| 243 | { |
---|
| 244 | return GetStartPhiAngle(); |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | inline |
---|
| 248 | G4double G4Cons::GetDPhi() const |
---|
| 249 | { |
---|
| 250 | return GetDeltaPhiAngle(); |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | inline |
---|
| 254 | G4double G4Cons::GetCubicVolume() |
---|
| 255 | { |
---|
| 256 | if(fCubicVolume != 0.) {;} |
---|
| 257 | else |
---|
| 258 | { |
---|
| 259 | G4double Rmean, rMean, deltaR, deltar; |
---|
| 260 | |
---|
| 261 | Rmean = 0.5*(fRmax1+fRmax2); |
---|
| 262 | deltaR = fRmax1-fRmax2; |
---|
| 263 | |
---|
| 264 | rMean = 0.5*(fRmin1+fRmin2); |
---|
| 265 | deltar = fRmin1-fRmin2; |
---|
| 266 | fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean |
---|
| 267 | +(deltaR*deltaR-deltar*deltar)/12); |
---|
| 268 | } |
---|
| 269 | return fCubicVolume; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | inline |
---|
| 273 | G4double G4Cons::GetSurfaceArea() |
---|
| 274 | { |
---|
| 275 | if(fSurfaceArea != 0.) {;} |
---|
| 276 | else |
---|
| 277 | { |
---|
| 278 | G4double mmin, mmax, dmin, dmax; |
---|
| 279 | |
---|
| 280 | mmin= (fRmin1+fRmin2)*0.5; |
---|
| 281 | mmax= (fRmax1+fRmax2)*0.5; |
---|
| 282 | dmin= (fRmin2-fRmin1); |
---|
| 283 | dmax= (fRmax2-fRmax1); |
---|
| 284 | |
---|
| 285 | fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz) |
---|
| 286 | + mmax * std::sqrt(dmax*dmax+4*fDz*fDz) |
---|
| 287 | + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1 |
---|
| 288 | +fRmax2*fRmax2-fRmin2*fRmin2 )); |
---|
[921] | 289 | if(!fPhiFullCone) |
---|
[831] | 290 | { |
---|
| 291 | fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin); |
---|
| 292 | } |
---|
| 293 | } |
---|
| 294 | return fSurfaceArea; |
---|
| 295 | } |
---|