[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 | // |
---|
[921] | 27 | // $Id: G4Cons.icc,v 1.8 2008/11/06 10:55:40 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-02-cand-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 |
---|
[921] | 39 | void G4Cons::Initialise() |
---|
| 40 | { |
---|
| 41 | fCubicVolume= 0.; |
---|
| 42 | fSurfaceArea= 0.; |
---|
| 43 | fpPolyhedron = 0; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | inline |
---|
| 47 | void G4Cons::InitializeTrigonometry() |
---|
| 48 | { |
---|
| 49 | G4double hDPhi = 0.5*fDPhi; // half delta phi |
---|
| 50 | G4double cPhi = fSPhi + hDPhi; |
---|
| 51 | G4double ePhi = fSPhi + fDPhi; |
---|
| 52 | |
---|
| 53 | sinCPhi = std::sin(cPhi); |
---|
| 54 | cosCPhi = std::cos(cPhi); |
---|
| 55 | cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi |
---|
| 56 | cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance); |
---|
| 57 | sinSPhi = std::sin(fSPhi); |
---|
| 58 | cosSPhi = std::cos(fSPhi); |
---|
| 59 | sinEPhi = std::sin(ePhi); |
---|
| 60 | cosEPhi = std::cos(ePhi); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | inline |
---|
[831] | 64 | G4double G4Cons::GetInnerRadiusMinusZ() const |
---|
| 65 | { |
---|
| 66 | return fRmin1 ; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | inline |
---|
| 70 | G4double G4Cons::GetOuterRadiusMinusZ() const |
---|
| 71 | { |
---|
| 72 | return fRmax1 ; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | inline |
---|
| 76 | G4double G4Cons::GetInnerRadiusPlusZ() const |
---|
| 77 | { |
---|
| 78 | return fRmin2 ; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | inline |
---|
| 82 | G4double G4Cons::GetOuterRadiusPlusZ() const |
---|
| 83 | { |
---|
| 84 | return fRmax2 ; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | inline |
---|
| 88 | G4double G4Cons::GetZHalfLength() const |
---|
| 89 | { |
---|
| 90 | return fDz ; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | inline |
---|
| 94 | G4double G4Cons::GetStartPhiAngle() const |
---|
| 95 | { |
---|
| 96 | return fSPhi ; |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | inline |
---|
| 100 | G4double G4Cons::GetDeltaPhiAngle() const |
---|
| 101 | { |
---|
| 102 | return fDPhi; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | inline |
---|
| 106 | void G4Cons::SetInnerRadiusMinusZ( G4double Rmin1 ) |
---|
| 107 | { |
---|
| 108 | fRmin1= Rmin1 ; |
---|
[921] | 109 | Initialise(); |
---|
[831] | 110 | } |
---|
| 111 | |
---|
| 112 | inline |
---|
| 113 | void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 ) |
---|
| 114 | { |
---|
| 115 | fRmax1= Rmax1 ; |
---|
[921] | 116 | Initialise(); |
---|
[831] | 117 | } |
---|
| 118 | |
---|
| 119 | inline |
---|
| 120 | void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 ) |
---|
| 121 | { |
---|
| 122 | fRmin2= Rmin2 ; |
---|
[921] | 123 | Initialise(); |
---|
[831] | 124 | } |
---|
| 125 | |
---|
| 126 | inline |
---|
| 127 | void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 ) |
---|
| 128 | { |
---|
| 129 | fRmax2= Rmax2 ; |
---|
[921] | 130 | Initialise(); |
---|
[831] | 131 | } |
---|
| 132 | |
---|
| 133 | inline |
---|
| 134 | void G4Cons::SetZHalfLength ( G4double newDz ) |
---|
| 135 | { |
---|
| 136 | fDz= newDz ; |
---|
[921] | 137 | Initialise(); |
---|
[831] | 138 | } |
---|
| 139 | |
---|
| 140 | inline |
---|
| 141 | void G4Cons::SetStartPhiAngle ( G4double newSPhi ) |
---|
| 142 | { |
---|
| 143 | fSPhi= newSPhi; |
---|
[921] | 144 | Initialise(); |
---|
| 145 | InitializeTrigonometry(); |
---|
[831] | 146 | } |
---|
| 147 | |
---|
| 148 | void G4Cons::SetDeltaPhiAngle ( G4double newDPhi ) |
---|
| 149 | { |
---|
[921] | 150 | if ( newDPhi >= twopi-kAngTolerance*0.5 ) |
---|
| 151 | { |
---|
| 152 | fPhiFullCone = true; |
---|
| 153 | } |
---|
| 154 | else if ( newDPhi > 0 ) |
---|
| 155 | { |
---|
| 156 | fPhiFullCone = false; |
---|
| 157 | } |
---|
| 158 | else |
---|
| 159 | { |
---|
| 160 | G4cerr << "ERROR - G4Cons()::SetDeltaPhiAngle() : " << GetName() << G4endl |
---|
| 161 | << " Negative delta-Phi ! - " << newDPhi << G4endl; |
---|
| 162 | G4Exception("G4Cons::SetDeltaPhiAngle()", "InvalidSetup", |
---|
| 163 | FatalException, "Invalid dphi."); |
---|
| 164 | } |
---|
[831] | 165 | fDPhi= newDPhi; |
---|
[921] | 166 | Initialise(); |
---|
| 167 | InitializeTrigonometry(); |
---|
[831] | 168 | } |
---|
| 169 | |
---|
| 170 | // Old access methods ... |
---|
| 171 | |
---|
| 172 | inline |
---|
| 173 | G4double G4Cons::GetRmin1() const |
---|
| 174 | { |
---|
| 175 | return GetInnerRadiusMinusZ(); |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | inline |
---|
| 179 | G4double G4Cons::GetRmax1() const |
---|
| 180 | { |
---|
| 181 | return GetOuterRadiusMinusZ(); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | inline |
---|
| 185 | G4double G4Cons::GetRmin2() const |
---|
| 186 | { |
---|
| 187 | return GetInnerRadiusPlusZ(); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | inline |
---|
| 191 | G4double G4Cons::GetRmax2() const |
---|
| 192 | { |
---|
| 193 | return GetOuterRadiusPlusZ(); |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | inline |
---|
| 197 | G4double G4Cons::GetDz() const |
---|
| 198 | { |
---|
| 199 | return GetZHalfLength(); |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | inline |
---|
| 203 | G4double G4Cons::GetSPhi() const |
---|
| 204 | { |
---|
| 205 | return GetStartPhiAngle(); |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | inline |
---|
| 209 | G4double G4Cons::GetDPhi() const |
---|
| 210 | { |
---|
| 211 | return GetDeltaPhiAngle(); |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | inline |
---|
| 215 | G4double G4Cons::GetCubicVolume() |
---|
| 216 | { |
---|
| 217 | if(fCubicVolume != 0.) {;} |
---|
| 218 | else |
---|
| 219 | { |
---|
| 220 | G4double Rmean, rMean, deltaR, deltar; |
---|
| 221 | |
---|
| 222 | Rmean = 0.5*(fRmax1+fRmax2); |
---|
| 223 | deltaR = fRmax1-fRmax2; |
---|
| 224 | |
---|
| 225 | rMean = 0.5*(fRmin1+fRmin2); |
---|
| 226 | deltar = fRmin1-fRmin2; |
---|
| 227 | fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean |
---|
| 228 | +(deltaR*deltaR-deltar*deltar)/12); |
---|
| 229 | } |
---|
| 230 | return fCubicVolume; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | inline |
---|
| 234 | G4double G4Cons::GetSurfaceArea() |
---|
| 235 | { |
---|
| 236 | if(fSurfaceArea != 0.) {;} |
---|
| 237 | else |
---|
| 238 | { |
---|
| 239 | G4double mmin, mmax, dmin, dmax; |
---|
| 240 | |
---|
| 241 | mmin= (fRmin1+fRmin2)*0.5; |
---|
| 242 | mmax= (fRmax1+fRmax2)*0.5; |
---|
| 243 | dmin= (fRmin2-fRmin1); |
---|
| 244 | dmax= (fRmax2-fRmax1); |
---|
| 245 | |
---|
| 246 | fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz) |
---|
| 247 | + mmax * std::sqrt(dmax*dmax+4*fDz*fDz) |
---|
| 248 | + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1 |
---|
| 249 | +fRmax2*fRmax2-fRmin2*fRmin2 )); |
---|
[921] | 250 | if(!fPhiFullCone) |
---|
[831] | 251 | { |
---|
| 252 | fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin); |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | return fSurfaceArea; |
---|
| 256 | } |
---|