G4Cons.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: G4Cons.icc 69788 2013-05-15 12:06:57Z gcosmo $
00028 //
00029 // --------------------------------------------------------------------
00030 // GEANT 4 inline definitions file
00031 //
00032 // G4Cons.icc
00033 //
00034 // Implementation of inline methods of G4Cons
00035 // --------------------------------------------------------------------
00036 
00037 inline
00038 G4double G4Cons::GetInnerRadiusMinusZ() const
00039 {
00040   return fRmin1 ;
00041 }
00042 
00043 inline
00044 G4double G4Cons::GetOuterRadiusMinusZ() const
00045 {
00046   return fRmax1 ;
00047 }
00048 
00049 inline
00050 G4double G4Cons::GetInnerRadiusPlusZ() const
00051 {
00052   return fRmin2 ;
00053 }
00054 
00055 inline
00056 G4double G4Cons::GetOuterRadiusPlusZ() const
00057 {
00058   return fRmax2 ;
00059 }
00060 
00061 inline
00062 G4double G4Cons::GetZHalfLength() const
00063 {
00064   return fDz ;
00065 }
00066 
00067 inline  
00068 G4double G4Cons::GetStartPhiAngle() const
00069 {
00070   return fSPhi ;
00071 }
00072 
00073 inline
00074 G4double G4Cons::GetDeltaPhiAngle() const
00075 {
00076   return fDPhi;
00077 }
00078 
00079 inline
00080 void G4Cons::Initialize()
00081 {
00082   fCubicVolume = 0.;
00083   fSurfaceArea = 0.;
00084   fpPolyhedron = 0;
00085 }
00086 
00087 inline 
00088 void G4Cons::InitializeTrigonometry()
00089 {
00090   G4double hDPhi = 0.5*fDPhi;                       // half delta phi
00091   G4double cPhi  = fSPhi + hDPhi; 
00092   G4double ePhi  = fSPhi + fDPhi;
00093 
00094   sinCPhi    = std::sin(cPhi);
00095   cosCPhi    = std::cos(cPhi);
00096   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
00097   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
00098   sinSPhi = std::sin(fSPhi);
00099   cosSPhi = std::cos(fSPhi);
00100   sinEPhi = std::sin(ePhi);
00101   cosEPhi = std::cos(ePhi);
00102 }
00103 
00104 inline void G4Cons::CheckSPhiAngle(G4double sPhi)
00105 {
00106   // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
00107 
00108   if ( sPhi < 0 )
00109   {
00110     fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
00111   }
00112   else
00113   {
00114     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
00115   }
00116   if ( fSPhi+fDPhi > CLHEP::twopi )
00117   {
00118     fSPhi -= CLHEP::twopi ;
00119   }
00120 }
00121 
00122 inline void G4Cons::CheckDPhiAngle(G4double dPhi)
00123 {
00124   fPhiFullCone = true;
00125   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
00126   {
00127     fDPhi=CLHEP::twopi;
00128     fSPhi=0;
00129   }
00130   else
00131   {
00132     fPhiFullCone = false;
00133     if ( dPhi > 0 )
00134     {
00135       fDPhi = dPhi;
00136     }
00137     else
00138     {
00139       std::ostringstream message;
00140       message << "Invalid dphi." << G4endl
00141               << "Negative or zero delta-Phi (" << dPhi << ") in solid: "
00142               << GetName();
00143       G4Exception("G4Cons::CheckDPhiAngle()", "GeomSolids0002",
00144                   FatalException, message);
00145     }
00146   }
00147 }
00148 
00149 inline void G4Cons::CheckPhiAngles(G4double sPhi, G4double dPhi)
00150 {
00151   CheckDPhiAngle(dPhi);
00152   if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
00153   InitializeTrigonometry();
00154 }
00155 
00156 inline
00157 void G4Cons::SetInnerRadiusMinusZ( G4double Rmin1 )
00158 {
00159   fRmin1= Rmin1 ;
00160   Initialize();
00161 }
00162 
00163 inline
00164 void G4Cons::SetOuterRadiusMinusZ( G4double Rmax1 )
00165 {
00166   fRmax1= Rmax1 ;
00167   Initialize();
00168 }
00169 
00170 inline
00171 void G4Cons::SetInnerRadiusPlusZ ( G4double Rmin2 )
00172 {
00173   fRmin2= Rmin2 ;
00174   Initialize();
00175 }
00176 
00177 inline
00178 void G4Cons::SetOuterRadiusPlusZ ( G4double Rmax2 )
00179 {
00180   fRmax2= Rmax2 ;
00181   Initialize();
00182 }
00183 
00184 inline
00185 void G4Cons::SetZHalfLength ( G4double newDz )
00186 {
00187   fDz= newDz ;
00188   Initialize();
00189 }
00190 
00191 inline
00192 void G4Cons::SetStartPhiAngle ( G4double newSPhi, G4bool compute )
00193 {
00194   // Flag 'compute' can be used to explicitely avoid recomputation of
00195   // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
00196 
00197   CheckSPhiAngle(newSPhi);
00198   fPhiFullCone = false;
00199   if (compute)  { InitializeTrigonometry(); }
00200   Initialize();
00201 }
00202 
00203 void G4Cons::SetDeltaPhiAngle ( G4double newDPhi )
00204 {
00205   CheckPhiAngles(fSPhi, newDPhi);
00206   Initialize();
00207 }
00208 
00209 // Old access methods ...
00210 
00211 inline
00212 G4double G4Cons::GetRmin1() const
00213 {
00214   return GetInnerRadiusMinusZ();
00215 }
00216 
00217 inline
00218 G4double G4Cons::GetRmax1() const
00219 {
00220   return GetOuterRadiusMinusZ();
00221 }
00222 
00223 inline
00224 G4double G4Cons::GetRmin2() const
00225 {
00226   return GetInnerRadiusPlusZ();
00227 }
00228 
00229 inline
00230 G4double G4Cons::GetRmax2() const
00231 {
00232   return GetOuterRadiusPlusZ();
00233 }
00234 
00235 inline  
00236 G4double G4Cons::GetDz() const
00237 {
00238   return GetZHalfLength();
00239 }
00240 
00241 inline
00242 G4double G4Cons::GetSPhi() const
00243 {
00244   return GetStartPhiAngle();
00245 }
00246 
00247 inline
00248 G4double G4Cons::GetDPhi() const
00249 {
00250   return GetDeltaPhiAngle();
00251 }
00252 
00253 inline
00254 G4double G4Cons::GetCubicVolume()
00255 {
00256   if(fCubicVolume != 0.) {;}
00257   else   
00258   {
00259     G4double Rmean, rMean, deltaR, deltar;
00260 
00261     Rmean  = 0.5*(fRmax1+fRmax2);
00262     deltaR = fRmax1-fRmax2;
00263 
00264     rMean  = 0.5*(fRmin1+fRmin2);
00265     deltar = fRmin1-fRmin2;
00266     fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean
00267                             +(deltaR*deltaR-deltar*deltar)/12); 
00268   }
00269   return fCubicVolume;
00270 }
00271 
00272 inline
00273 G4double G4Cons::GetSurfaceArea()
00274 {
00275   if(fSurfaceArea != 0.) {;}
00276   else   
00277   {
00278     G4double mmin, mmax, dmin, dmax;
00279 
00280     mmin= (fRmin1+fRmin2)*0.5;
00281     mmax= (fRmax1+fRmax2)*0.5;
00282     dmin= (fRmin2-fRmin1);
00283     dmax= (fRmax2-fRmax1);
00284     
00285     fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz)
00286                          + mmax * std::sqrt(dmax*dmax+4*fDz*fDz)
00287                          + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1
00288                                +fRmax2*fRmax2-fRmin2*fRmin2 ));
00289     if(!fPhiFullCone)
00290     {
00291       fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin);
00292     }
00293   }
00294   return fSurfaceArea;
00295 }

Generated on Mon May 27 17:47:57 2013 for Geant4 by  doxygen 1.4.7