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.1 2002/10/28 11:43:03 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-05-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 ; 75 } 81 } 76 82 77 inline 83 inline 78 G4double G4Cons::GetCosStartPhi() const << 84 void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 ) 79 { 85 { 80 return cosSPhi; << 86 fRmax1= Rmax1 ; 81 } 87 } 82 88 83 inline 89 inline 84 G4double G4Cons::GetSinEndPhi() const << 90 void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 ) 85 { 91 { 86 return sinEPhi; << 92 fRmin2= Rmin2 ; 87 } 93 } 88 94 89 inline 95 inline 90 G4double G4Cons::GetCosEndPhi() const << 96 void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 ) 91 { 97 { 92 return cosEPhi; << 98 fRmax2= Rmax2 ; 93 } 99 } 94 100 95 inline 101 inline 96 void G4Cons::Initialize() << 102 void G4Cons::SetZHalfLength ( G4double newDz ) 97 { 103 { 98 fCubicVolume = 0.; << 104 fDz= newDz ; 99 fSurfaceArea = 0.; << 100 fRebuildPolyhedron = true; << 101 } 105 } 102 106 103 inline 107 inline 104 void G4Cons::InitializeTrigonometry() << 108 void G4Cons::SetStartPhiAngle ( G4double newSPhi ) 105 { << 106 G4double hDPhi = 0.5*fDPhi; << 107 G4double cPhi = fSPhi + hDPhi; << 108 G4double ePhi = fSPhi + fDPhi; << 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 } << 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 } << 138 << 139 inline void G4Cons::CheckDPhiAngle(G4double dP << 140 { 109 { 141 fPhiFullCone = true; << 110 fSPhi= newSPhi; 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 } 111 } 165 112 166 inline void G4Cons::CheckPhiAngles(G4double sP << 113 void G4Cons::SetDeltaPhiAngle ( G4double newDPhi ) 167 { << 168 CheckDPhiAngle(dPhi); << 169 if ( (fDPhi<CLHEP::twopi) && ((sPhi) != 0.0) << 170 InitializeTrigonometry(); << 171 } << 172 << 173 inline << 174 void G4Cons::SetInnerRadiusMinusZ( G4double Rm << 175 { 114 { 176 fRmin1= Rmin1 ; << 115 fDPhi= newDPhi; 177 Initialize(); << 178 } 116 } 179 117 180 inline << 118 // Old access methods ... 181 void G4Cons::SetOuterRadiusMinusZ( G4double Rm << 182 { << 183 fRmax1= Rmax1 ; << 184 Initialize(); << 185 } << 186 119 187 inline 120 inline 188 void G4Cons::SetInnerRadiusPlusZ ( G4double Rm << 121 G4double G4Cons::GetRmin1() const 189 { 122 { 190 fRmin2= Rmin2 ; << 123 return GetInnerRadiusMinusZ(); 191 Initialize(); << 192 } 124 } 193 125 194 inline 126 inline 195 void G4Cons::SetOuterRadiusPlusZ ( G4double Rm << 127 G4double G4Cons::GetRmax1() const 196 { 128 { 197 fRmax2= Rmax2 ; << 129 return GetOuterRadiusMinusZ(); 198 Initialize(); << 199 } 130 } 200 131 201 inline 132 inline 202 void G4Cons::SetZHalfLength ( G4double newDz ) << 133 G4double G4Cons::GetRmin2() const 203 { 134 { 204 fDz= newDz ; << 135 return GetInnerRadiusPlusZ(); 205 Initialize(); << 206 } 136 } 207 137 208 inline 138 inline 209 void G4Cons::SetStartPhiAngle ( G4double newSP << 139 G4double G4Cons::GetRmax2() const 210 { 140 { 211 // Flag 'compute' can be used to explicitely << 141 return GetOuterRadiusPlusZ(); 212 // trigonometry in case SetDeltaPhiAngle() i << 213 << 214 CheckSPhiAngle(newSPhi); << 215 fPhiFullCone = false; << 216 if (compute) { InitializeTrigonometry(); } << 217 Initialize(); << 218 } 142 } 219 143 220 void G4Cons::SetDeltaPhiAngle ( G4double newDP << 144 inline >> 145 G4double G4Cons::GetDz() const 221 { 146 { 222 CheckPhiAngles(fSPhi, newDPhi); << 147 return GetZHalfLength(); 223 Initialize(); << 224 } 148 } 225 149 226 inline 150 inline 227 G4double G4Cons::GetCubicVolume() << 151 G4double G4Cons::GetSPhi() const 228 { 152 { 229 if(fCubicVolume != 0.) {;} << 153 return GetStartPhiAngle(); 230 else << 231 { << 232 G4double Rmean, rMean, deltaR, deltar; << 233 << 234 Rmean = 0.5*(fRmax1+fRmax2); << 235 deltaR = fRmax1-fRmax2; << 236 << 237 rMean = 0.5*(fRmin1+fRmin2); << 238 deltar = fRmin1-fRmin2; << 239 fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMea << 240 +(deltaR*deltaR-de << 241 } << 242 return fCubicVolume; << 243 } 154 } 244 155 245 inline 156 inline 246 G4double G4Cons::GetSurfaceArea() << 157 G4double G4Cons::GetDPhi() const 247 { 158 { 248 if(fSurfaceArea != 0.) {;} << 159 return GetDeltaPhiAngle(); 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 } 160 } 269 161