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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/solids/CSG/include/G4Sphere.icc (Version 11.3.0) and /geometry/solids/CSG/include/G4Sphere.icc (Version 9.4.p1)


  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: G4Sphere.icc,v 1.11 2009-05-13 11:23:00 gcosmo Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-04-patch-01 $
                                                   >>  29 //
                                                   >>  30 // --------------------------------------------------------------------
                                                   >>  31 // GEANT 4 inline definitions file
                                                   >>  32 //
                                                   >>  33 // G4Sphere.icc
                                                   >>  34 //
 26 // Implementation of inline methods of G4Spher     35 // Implementation of inline methods of G4Sphere
 27 // -------------------------------------------     36 // --------------------------------------------------------------------
 28                                                    37 
 29 inline                                             38 inline
                                                   >>  39 G4double G4Sphere::GetInsideRadius() const
                                                   >>  40 {
                                                   >>  41   return fRmin;
                                                   >>  42 }
                                                   >>  43 
                                                   >>  44 inline
 30 G4double G4Sphere::GetInnerRadius() const          45 G4double G4Sphere::GetInnerRadius() const
 31 {                                                  46 {
 32   return fRmin;                                    47   return fRmin;
 33 }                                                  48 }
 34                                                    49 
 35 inline                                             50 inline
 36 G4double G4Sphere::GetOuterRadius() const          51 G4double G4Sphere::GetOuterRadius() const
 37 {                                                  52 {
 38   return fRmax;                                    53   return fRmax;
 39 }                                                  54 }
 40                                                    55 
 41 inline                                             56 inline
 42 G4double G4Sphere::GetStartPhiAngle() const        57 G4double G4Sphere::GetStartPhiAngle() const
 43 {                                                  58 {
 44   return fSPhi;                                    59   return fSPhi;
 45 }                                                  60 }
 46                                                    61 
 47 inline                                             62 inline
 48 G4double G4Sphere::GetDeltaPhiAngle() const        63 G4double G4Sphere::GetDeltaPhiAngle() const
 49 {                                                  64 {
 50   return fDPhi;                                    65   return fDPhi;
 51 }                                                  66 }
 52                                                    67 
 53 inline                                             68 inline
 54 G4double G4Sphere::GetStartThetaAngle() const      69 G4double G4Sphere::GetStartThetaAngle() const
 55 {                                                  70 {
 56   return fSTheta;                                  71   return fSTheta;
 57 }                                                  72 }
 58                                                    73 
 59 G4double G4Sphere::GetDeltaThetaAngle() const      74 G4double G4Sphere::GetDeltaThetaAngle() const
 60 {                                                  75 {
 61   return fDTheta;                                  76   return fDTheta;
 62 }                                                  77 }
 63                                                    78 
 64 inline                                         <<  79 inline 
 65 G4double G4Sphere::GetSinStartPhi () const     << 
 66 {                                              << 
 67   return sinSPhi;                              << 
 68 }                                              << 
 69                                                << 
 70 inline                                         << 
 71 G4double G4Sphere::GetCosStartPhi () const     << 
 72 {                                              << 
 73   return cosSPhi;                              << 
 74 }                                              << 
 75                                                << 
 76 inline                                         << 
 77 G4double G4Sphere::GetSinEndPhi () const       << 
 78 {                                              << 
 79   return sinEPhi;                              << 
 80 }                                              << 
 81                                                << 
 82 inline                                         << 
 83 G4double G4Sphere::GetCosEndPhi () const       << 
 84 {                                              << 
 85   return cosEPhi;                              << 
 86 }                                              << 
 87                                                << 
 88 inline                                         << 
 89 G4double G4Sphere::GetSinStartTheta () const   << 
 90 {                                              << 
 91   return sinSTheta;                            << 
 92 }                                              << 
 93                                                << 
 94 inline                                         << 
 95 G4double G4Sphere::GetCosStartTheta () const   << 
 96 {                                              << 
 97   return cosSTheta;                            << 
 98 }                                              << 
 99                                                << 
100 inline                                         << 
101 G4double G4Sphere::GetSinEndTheta () const     << 
102 {                                              << 
103   return sinETheta;                            << 
104 }                                              << 
105                                                << 
106 inline                                         << 
107 G4double G4Sphere::GetCosEndTheta () const     << 
108 {                                              << 
109   return cosETheta;                            << 
110 }                                              << 
111                                                << 
112 inline                                         << 
113 void G4Sphere::Initialize()                        80 void G4Sphere::Initialize()
114 {                                                  81 {
115   fCubicVolume = 0.;                               82   fCubicVolume = 0.;
116   fSurfaceArea = 0.;                               83   fSurfaceArea = 0.;
117   fRebuildPolyhedron = true;                   <<  84   fpPolyhedron = 0;
118 }                                                  85 }
119                                                    86 
120 inline                                             87 inline
121 void G4Sphere::InitializePhiTrigonometry()         88 void G4Sphere::InitializePhiTrigonometry()
122 {                                                  89 {
123   hDPhi = 0.5*fDPhi;                       //      90   hDPhi = 0.5*fDPhi;                       // half delta phi
124   cPhi  = fSPhi + hDPhi;                       <<  91   cPhi  = fSPhi + hDPhi; 
125   ePhi  = fSPhi + fDPhi;                           92   ePhi  = fSPhi + fDPhi;
126                                                    93 
127   sinCPhi    = std::sin(cPhi);                     94   sinCPhi    = std::sin(cPhi);
128   cosCPhi    = std::cos(cPhi);                     95   cosCPhi    = std::cos(cPhi);
129   cosHDPhi   = std::cos(hDPhi);                << 
130   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolera     96   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
131   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolera     97   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
132   sinSPhi = std::sin(fSPhi);                       98   sinSPhi = std::sin(fSPhi);
133   cosSPhi = std::cos(fSPhi);                       99   cosSPhi = std::cos(fSPhi);
134   sinEPhi = std::sin(ePhi);                       100   sinEPhi = std::sin(ePhi);
135   cosEPhi = std::cos(ePhi);                       101   cosEPhi = std::cos(ePhi);
136 }                                                 102 }
137                                                   103 
138 inline                                            104 inline
139 void G4Sphere::InitializeThetaTrigonometry()      105 void G4Sphere::InitializeThetaTrigonometry()
140 {                                                 106 {
141   eTheta  = fSTheta + fDTheta;                    107   eTheta  = fSTheta + fDTheta;
142                                                   108 
143   sinSTheta = std::sin(fSTheta);                  109   sinSTheta = std::sin(fSTheta);
144   cosSTheta = std::cos(fSTheta);                  110   cosSTheta = std::cos(fSTheta);
145   sinETheta = std::sin(eTheta);                   111   sinETheta = std::sin(eTheta);
146   cosETheta = std::cos(eTheta);                   112   cosETheta = std::cos(eTheta);
147                                                   113 
148   tanSTheta  = sinSTheta/cosSTheta;            << 114   tanSTheta  = std::tan(fSTheta);
149   tanSTheta2 = tanSTheta*tanSTheta;               115   tanSTheta2 = tanSTheta*tanSTheta;
150   tanETheta  = sinETheta/cosETheta;            << 116   tanETheta  = std::tan(eTheta);
151   tanETheta2 = tanETheta*tanETheta;               117   tanETheta2 = tanETheta*tanETheta;
152 }                                                 118 }
153                                                   119 
154 inline                                            120 inline
155 void G4Sphere::CheckThetaAngles(G4double sThet    121 void G4Sphere::CheckThetaAngles(G4double sTheta, G4double dTheta)
156 {                                                 122 {
157   if ( (sTheta<0) || (sTheta>CLHEP::pi) )      << 123   if ( (sTheta<0) || (sTheta>pi) )
158   {                                               124   {
159     std::ostringstream message;                << 125     G4cerr << "ERROR - G4Sphere()::CheckThetaAngles()" << G4endl
160     message << "sTheta outside 0-PI range." << << 126            << "        Invalid starting Theta angle for solid: " << GetName()
161             << "Invalid starting Theta angle f << 127            << G4endl;
162     G4Exception("G4Sphere::CheckThetaAngles()" << 128     G4Exception("G4Sphere::CheckThetaAngles()", "InvalidSetup",
163                 FatalException, message);      << 129                 FatalException, "sTheta outside 0-PI range.");
164   }                                               130   }
165   else                                            131   else
166   {                                               132   {
167     fSTheta=sTheta;                               133     fSTheta=sTheta;
168   }                                               134   }
169   if ( dTheta+sTheta >= CLHEP::pi )            << 135   if ( dTheta+sTheta >= pi )
170   {                                               136   {
171     fDTheta=CLHEP::pi-sTheta;                  << 137     fDTheta=pi-sTheta;
172   }                                               138   }
173   else if ( dTheta > 0 )                          139   else if ( dTheta > 0 )
174   {                                               140   {
175     fDTheta=dTheta;                               141     fDTheta=dTheta;
176   }                                               142   }
177   else                                            143   else
178   {                                               144   {
179     std::ostringstream message;                << 145     G4cerr << "ERROR - G4Sphere()::CheckThetaAngles(): " << G4endl
180     message << "Invalid dTheta." << G4endl     << 146            << "        Negative delta-Theta (" << dTheta << "), for solid: "
181             << "Negative delta-Theta (" << dTh << 147            << GetName() << G4endl;
182             << GetName();                      << 148     G4Exception("G4Sphere::CheckThetaAngles()", "InvalidSetup",
183     G4Exception("G4Sphere::CheckThetaAngles()" << 149                 FatalException, "Invalid dTheta.");
184                 FatalException, message);      << 
185   }                                               150   }
186   fFullThetaSphere = fDTheta-fSTheta >= CLHEP: << 151   if ( fDTheta-fSTheta < pi ) { fFullThetaSphere = false; }
                                                   >> 152   else                        { fFullThetaSphere = true ; }
187   fFullSphere = fFullPhiSphere && fFullThetaSp    153   fFullSphere = fFullPhiSphere && fFullThetaSphere;
188                                                   154 
189   InitializeThetaTrigonometry();                  155   InitializeThetaTrigonometry();
190 }                                                 156 }
191                                                   157 
192 inline                                            158 inline
193 void G4Sphere::CheckSPhiAngle(G4double sPhi)      159 void G4Sphere::CheckSPhiAngle(G4double sPhi)
194 {                                                 160 {
195   // Ensure fSphi in 0-2PI or -2PI-0 range if     161   // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
196                                                   162 
197   if ( sPhi < 0 )                                 163   if ( sPhi < 0 )
198   {                                               164   {
199     fSPhi = CLHEP::twopi - std::fmod(std::fabs << 165     fSPhi = twopi - std::fmod(std::fabs(sPhi),twopi);
200   }                                               166   }
201   else                                            167   else
202   {                                               168   {
203     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;     << 169     fSPhi = std::fmod(sPhi,twopi) ;
204   }                                               170   }
205   if ( fSPhi+fDPhi > CLHEP::twopi )            << 171   if ( fSPhi+fDPhi > twopi )
206   {                                               172   {
207     fSPhi -= CLHEP::twopi ;                    << 173     fSPhi -= twopi ;
208   }                                               174   }
209 }                                                 175 }
210                                                   176 
211 inline                                            177 inline
212 void G4Sphere::CheckDPhiAngle(G4double dPhi)      178 void G4Sphere::CheckDPhiAngle(G4double dPhi)
213 {                                                 179 {
214   fFullPhiSphere = true;                          180   fFullPhiSphere = true;
215   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5  << 181   if ( dPhi >= twopi-kAngTolerance*0.5 )
216   {                                               182   {
217     fDPhi=CLHEP::twopi;                        << 183     fDPhi=twopi;
                                                   >> 184     fSPhi=0;
218   }                                               185   }
219   else                                            186   else
220   {                                               187   {
221     fFullPhiSphere = false;                       188     fFullPhiSphere = false;
222     if ( dPhi > 0 )                               189     if ( dPhi > 0 )
223     {                                             190     {
224       fDPhi = dPhi;                               191       fDPhi = dPhi;
225     }                                             192     }
226     else                                          193     else
227     {                                             194     {
228       std::ostringstream message;              << 195       G4cerr << "ERROR - G4Sphere()::CheckDPhiAngle(): " << GetName() << G4endl
229       message << "Invalid dphi." << G4endl     << 196              << "        Negative delta-Phi ! - "
230               << "Negative delta-Phi (" << dPh << 197              << dPhi << G4endl;
231               << GetName();                    << 198       G4Exception("G4Sphere::CheckDPhiAngle()", "InvalidSetup",
232       G4Exception("G4Sphere::CheckDPhiAngle()" << 199                   FatalException, "Invalid dphi.");
233                   FatalException, message);    << 
234     }                                             200     }
235   }                                               201   }
236 }                                                 202 }
237                                                   203 
238 inline                                            204 inline
239 void G4Sphere::CheckPhiAngles(G4double sPhi, G    205 void G4Sphere::CheckPhiAngles(G4double sPhi, G4double dPhi)
240 {                                                 206 {
241   CheckDPhiAngle(dPhi);                           207   CheckDPhiAngle(dPhi);
242   if (!fFullPhiSphere && (sPhi != 0.0)) { Chec << 208   if (!fFullPhiSphere && sPhi) { CheckSPhiAngle(sPhi); }
243   fFullSphere = fFullPhiSphere && fFullThetaSp    209   fFullSphere = fFullPhiSphere && fFullThetaSphere;
244                                                   210 
245   InitializePhiTrigonometry();                    211   InitializePhiTrigonometry();
246 }                                                 212 }
247                                                   213 
248 inline                                            214 inline
                                                   >> 215 void G4Sphere::SetInsideRadius(G4double newRmin)
                                                   >> 216 {
                                                   >> 217   fRmin= newRmin;
                                                   >> 218   Initialize();
                                                   >> 219 }
                                                   >> 220 
                                                   >> 221 inline
249 void G4Sphere::SetInnerRadius(G4double newRmin    222 void G4Sphere::SetInnerRadius(G4double newRmin)
250 {                                                 223 {
251   fRmin= newRmin;                                 224   fRmin= newRmin;
252   fRminTolerance = (fRmin) != 0.0 ? std::max(  << 
253   Initialize();                                   225   Initialize();
254 }                                                 226 }
255                                                   227 
256 inline                                            228 inline
257 void G4Sphere::SetOuterRadius(G4double newRmax    229 void G4Sphere::SetOuterRadius(G4double newRmax)
258 {                                                 230 {
259   fRmax= newRmax;                                 231   fRmax= newRmax;
260   fRmaxTolerance = std::max( kRadTolerance, fE << 
261   Initialize();                                   232   Initialize();
262 }                                                 233 }
263                                                   234 
264 inline                                            235 inline
265 void G4Sphere::SetStartPhiAngle(G4double newSP    236 void G4Sphere::SetStartPhiAngle(G4double newSPhi, G4bool compute)
266 {                                                 237 {
267   // Flag 'compute' can be used to explicitely    238   // Flag 'compute' can be used to explicitely avoid recomputation of
268   // trigonometry in case SetDeltaPhiAngle() i    239   // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
269                                                   240 
270   CheckSPhiAngle(newSPhi);                        241   CheckSPhiAngle(newSPhi);
271   fFullPhiSphere = false;                         242   fFullPhiSphere = false;
272   if (compute)  { InitializePhiTrigonometry();    243   if (compute)  { InitializePhiTrigonometry(); }
273   Initialize();                                   244   Initialize();
274 }                                                 245 }
275                                                   246 
276 inline                                            247 inline
277 void G4Sphere::SetDeltaPhiAngle(G4double newDP    248 void G4Sphere::SetDeltaPhiAngle(G4double newDPhi)
278 {                                                 249 {
279   CheckPhiAngles(fSPhi, newDPhi);                 250   CheckPhiAngles(fSPhi, newDPhi);
280   Initialize();                                   251   Initialize();
281 }                                                 252 }
282                                                   253 
283 inline                                            254 inline
284 void G4Sphere::SetStartThetaAngle(G4double new    255 void G4Sphere::SetStartThetaAngle(G4double newSTheta)
285 {                                                 256 {
286   CheckThetaAngles(newSTheta, fDTheta);           257   CheckThetaAngles(newSTheta, fDTheta);
287   Initialize();                                   258   Initialize();
288 }                                                 259 }
289                                                   260 
290 inline                                            261 inline
291 void G4Sphere::SetDeltaThetaAngle(G4double new    262 void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
292 {                                                 263 {
293   CheckThetaAngles(fSTheta, newDTheta);           264   CheckThetaAngles(fSTheta, newDTheta);
294   Initialize();                                   265   Initialize();
                                                   >> 266 }
                                                   >> 267 
                                                   >> 268 // Old access functions
                                                   >> 269 
                                                   >> 270 inline
                                                   >> 271 G4double G4Sphere::GetRmin() const 
                                                   >> 272 {
                                                   >> 273   return GetInsideRadius();
                                                   >> 274 }
                                                   >> 275 
                                                   >> 276 inline
                                                   >> 277 G4double G4Sphere::GetRmax() const
                                                   >> 278 {
                                                   >> 279   return GetOuterRadius();
                                                   >> 280 }
                                                   >> 281 
                                                   >> 282 inline
                                                   >> 283 G4double G4Sphere::GetSPhi() const
                                                   >> 284 {
                                                   >> 285   return GetStartPhiAngle();
                                                   >> 286 }
                                                   >> 287 
                                                   >> 288 inline
                                                   >> 289 G4double G4Sphere::GetDPhi() const
                                                   >> 290 {
                                                   >> 291   return GetDeltaPhiAngle();
                                                   >> 292 }
                                                   >> 293 
                                                   >> 294 inline
                                                   >> 295 G4double G4Sphere::GetSTheta() const
                                                   >> 296 {
                                                   >> 297   return GetStartThetaAngle();
                                                   >> 298 }
                                                   >> 299 
                                                   >> 300 inline
                                                   >> 301 G4double G4Sphere::GetDTheta() const
                                                   >> 302 {
                                                   >> 303   return GetDeltaThetaAngle();
                                                   >> 304 }
                                                   >> 305 
                                                   >> 306 inline
                                                   >> 307 G4double G4Sphere::GetCubicVolume()
                                                   >> 308 {
                                                   >> 309   if(fCubicVolume != 0.) {;}
                                                   >> 310   else { fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
                                                   >> 311                               (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.; }
                                                   >> 312   return fCubicVolume;
295 }                                                 313 }
296                                                   314