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