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