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