G4Tubs.icc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4Tubs.icc 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 // --------------------------------------------------------------------
00030 // GEANT 4 inline definitions file
00031 //
00032 // G4Tubs.icc
00033 //
00034 // Implementation of inline methods of G4Tubs
00035 // --------------------------------------------------------------------
00036 
00037 inline
00038 G4double G4Tubs::GetInnerRadius () const
00039 {
00040   return fRMin;
00041 }
00042 
00043 inline
00044 G4double G4Tubs::GetOuterRadius () const
00045 {
00046   return fRMax;
00047 }
00048 
00049 inline
00050 G4double G4Tubs::GetZHalfLength () const
00051 {
00052   return fDz;
00053 }
00054 
00055 inline
00056 G4double G4Tubs::GetStartPhiAngle () const
00057 {
00058   return fSPhi;
00059 }
00060 
00061 inline
00062 G4double G4Tubs::GetDeltaPhiAngle () const
00063 {
00064   return fDPhi;
00065 }
00066 
00067 inline 
00068 void G4Tubs::Initialize()
00069 {
00070   fCubicVolume = 0.;
00071   fSurfaceArea = 0.;
00072   fpPolyhedron = 0;
00073 }
00074 
00075 inline 
00076 void G4Tubs::InitializeTrigonometry()
00077 {
00078   G4double hDPhi = 0.5*fDPhi;                       // half delta phi
00079   G4double cPhi  = fSPhi + hDPhi; 
00080   G4double ePhi  = fSPhi + fDPhi;
00081 
00082   sinCPhi    = std::sin(cPhi);
00083   cosCPhi    = std::cos(cPhi);
00084   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
00085   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
00086   sinSPhi = std::sin(fSPhi);
00087   cosSPhi = std::cos(fSPhi);
00088   sinEPhi = std::sin(ePhi);
00089   cosEPhi = std::cos(ePhi);
00090 }
00091 
00092 inline void G4Tubs::CheckSPhiAngle(G4double sPhi)
00093 {
00094   // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
00095 
00096   if ( sPhi < 0 )
00097   {
00098     fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
00099   }
00100   else
00101   {
00102     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
00103   }
00104   if ( fSPhi+fDPhi > CLHEP::twopi )
00105   {
00106     fSPhi -= CLHEP::twopi ;
00107   }
00108 }
00109 
00110 inline void G4Tubs::CheckDPhiAngle(G4double dPhi)
00111 {
00112   fPhiFullTube = true;
00113   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
00114   {
00115     fDPhi=CLHEP::twopi;
00116     fSPhi=0;
00117   }
00118   else
00119   {
00120     fPhiFullTube = false;
00121     if ( dPhi > 0 )
00122     {
00123       fDPhi = dPhi;
00124     }
00125     else
00126     {
00127       std::ostringstream message;
00128       message << "Invalid dphi." << G4endl
00129               << "Negative or zero delta-Phi (" << dPhi << "), for solid: "
00130               << GetName();
00131       G4Exception("G4Tubs::CheckDPhiAngle()", "GeomSolids0002",
00132                   FatalException, message);
00133     }
00134   }
00135 }
00136 
00137 inline void G4Tubs::CheckPhiAngles(G4double sPhi, G4double dPhi)
00138 {
00139   CheckDPhiAngle(dPhi);
00140   if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
00141   InitializeTrigonometry();
00142 }
00143 
00144 inline
00145 void G4Tubs::SetInnerRadius (G4double newRMin)
00146 {
00147   if ( newRMin < 0 ) // Check radii
00148   {
00149     std::ostringstream message;
00150     message << "Invalid radii." << G4endl
00151             << "Invalid values for radii in solid " << GetName() << G4endl
00152             << "        newRMin = " << newRMin
00153             << ", fRMax = " << fRMax << G4endl
00154             << "        Negative inner radius!";
00155     G4Exception("G4Tubs::SetInnerRadius()", "GeomSolids0002",
00156                 FatalException, message);
00157   }
00158   fRMin= newRMin;
00159   Initialize();
00160 }
00161 
00162 inline
00163 void G4Tubs::SetOuterRadius (G4double newRMax)
00164 {
00165   if ( newRMax <= 0 ) // Check radii
00166   {
00167     std::ostringstream message;
00168     message << "Invalid radii." << G4endl
00169             << "Invalid values for radii in solid " << GetName() << G4endl
00170             << "        fRMin = " << fRMin
00171             << ", newRMax = " << newRMax << G4endl
00172             << "        Invalid outer radius!";
00173     G4Exception("G4Tubs::SetOuterRadius()", "GeomSolids0002",
00174                 FatalException, message);
00175   }
00176   fRMax= newRMax;
00177   Initialize();
00178 }
00179 
00180 inline
00181 void G4Tubs::SetZHalfLength (G4double newDz)
00182 {
00183   if (newDz<=0) // Check z-len
00184   {
00185     std::ostringstream message;
00186     message << "Invalid Z half-length." << G4endl
00187             << "Negative Z half-length (" << newDz << "), for solid: "
00188             << GetName();
00189     G4Exception("G4Tubs::SetZHalfLength()", "GeomSolids0002",
00190                 FatalException, message);
00191   }
00192   fDz= newDz;
00193   Initialize();
00194 }
00195 
00196 inline
00197 void G4Tubs::SetStartPhiAngle (G4double newSPhi, G4bool compute)
00198 {
00199   // Flag 'compute' can be used to explicitely avoid recomputation of
00200   // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
00201 
00202   CheckSPhiAngle(newSPhi);
00203   fPhiFullTube = false;
00204   if (compute)  { InitializeTrigonometry(); }
00205   Initialize();
00206 }
00207 
00208 inline
00209 void G4Tubs::SetDeltaPhiAngle (G4double newDPhi)
00210 {
00211   CheckPhiAngles(fSPhi, newDPhi);
00212   Initialize();
00213 }
00214 
00215 //  Older names for access functions
00216 
00217 inline
00218 G4double G4Tubs::GetRMin () const
00219 {
00220   return GetInnerRadius();
00221 }
00222 
00223 inline
00224 G4double G4Tubs::GetRMax () const
00225 {
00226   return GetOuterRadius();
00227 }
00228 
00229 inline
00230 G4double G4Tubs::GetDz () const
00231 {
00232   return GetZHalfLength()  ;
00233 }
00234 
00235 inline
00236 G4double G4Tubs::GetSPhi () const
00237 {
00238   return GetStartPhiAngle();
00239 }
00240 
00241 inline
00242 G4double G4Tubs::GetDPhi () const
00243 {
00244   return GetDeltaPhiAngle();
00245 }
00246 
00247 inline
00248 G4double G4Tubs::GetCubicVolume()
00249 {
00250   if(fCubicVolume != 0.) {;}
00251   else   { fCubicVolume = fDPhi*fDz*(fRMax*fRMax-fRMin*fRMin); }
00252   return fCubicVolume;
00253 }
00254 
00255 inline
00256 G4double G4Tubs::GetSurfaceArea()
00257 {
00258   if(fSurfaceArea != 0.) {;}
00259   else
00260   {
00261     fSurfaceArea = fDPhi*(fRMin+fRMax)*(2*fDz+fRMax-fRMin);
00262     if (!fPhiFullTube)
00263     {
00264       fSurfaceArea = fSurfaceArea + 4*fDz*(fRMax-fRMin);
00265     }
00266   }
00267   return fSurfaceArea;
00268 }

Generated on Mon May 27 17:50:04 2013 for Geant4 by  doxygen 1.4.7