Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:06

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // Implementation of inline methods of G4Sphere
0027 // --------------------------------------------------------------------
0028 
0029 inline
0030 G4double G4Sphere::GetInnerRadius() const
0031 {
0032   return fRmin;
0033 }
0034 
0035 inline
0036 G4double G4Sphere::GetOuterRadius() const
0037 {
0038   return fRmax;
0039 }
0040 
0041 inline
0042 G4double G4Sphere::GetStartPhiAngle() const
0043 {
0044   return fSPhi;
0045 }
0046 
0047 inline
0048 G4double G4Sphere::GetDeltaPhiAngle() const
0049 {
0050   return fDPhi;
0051 }
0052 
0053 inline
0054 G4double G4Sphere::GetStartThetaAngle() const
0055 {
0056   return fSTheta;
0057 }
0058 
0059 G4double G4Sphere::GetDeltaThetaAngle() const
0060 {
0061   return fDTheta;
0062 }
0063 
0064 inline
0065 G4double G4Sphere::GetSinStartPhi () const
0066 {
0067   return sinSPhi;
0068 }
0069 
0070 inline
0071 G4double G4Sphere::GetCosStartPhi () const
0072 {
0073   return cosSPhi;
0074 }
0075 
0076 inline
0077 G4double G4Sphere::GetSinEndPhi () const
0078 {
0079   return sinEPhi;
0080 }
0081 
0082 inline
0083 G4double G4Sphere::GetCosEndPhi () const
0084 {
0085   return cosEPhi;
0086 }
0087 
0088 inline
0089 G4double G4Sphere::GetSinStartTheta () const
0090 {
0091   return sinSTheta;
0092 }
0093 
0094 inline
0095 G4double G4Sphere::GetCosStartTheta () const
0096 {
0097   return cosSTheta;
0098 }
0099 
0100 inline
0101 G4double G4Sphere::GetSinEndTheta () const
0102 {
0103   return sinETheta;
0104 }
0105 
0106 inline
0107 G4double G4Sphere::GetCosEndTheta () const
0108 {
0109   return cosETheta;
0110 }
0111 
0112 inline
0113 void G4Sphere::Initialize()
0114 {
0115   fCubicVolume = 0.;
0116   fSurfaceArea = 0.;
0117   fRebuildPolyhedron = true;
0118 }
0119 
0120 inline
0121 void G4Sphere::InitializePhiTrigonometry()
0122 {
0123   hDPhi = 0.5*fDPhi;                       // half delta phi
0124   cPhi  = fSPhi + hDPhi;
0125   ePhi  = fSPhi + fDPhi;
0126 
0127   sinCPhi    = std::sin(cPhi);
0128   cosCPhi    = std::cos(cPhi);
0129   cosHDPhi   = std::cos(hDPhi);
0130   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
0131   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
0132   sinSPhi = std::sin(fSPhi);
0133   cosSPhi = std::cos(fSPhi);
0134   sinEPhi = std::sin(ePhi);
0135   cosEPhi = std::cos(ePhi);
0136 }
0137 
0138 inline
0139 void G4Sphere::InitializeThetaTrigonometry()
0140 {
0141   eTheta  = fSTheta + fDTheta;
0142 
0143   sinSTheta = std::sin(fSTheta);
0144   cosSTheta = std::cos(fSTheta);
0145   sinETheta = std::sin(eTheta);
0146   cosETheta = std::cos(eTheta);
0147 
0148   tanSTheta  = sinSTheta/cosSTheta;
0149   tanSTheta2 = tanSTheta*tanSTheta;
0150   tanETheta  = sinETheta/cosETheta;
0151   tanETheta2 = tanETheta*tanETheta;
0152 }
0153 
0154 inline
0155 void G4Sphere::CheckThetaAngles(G4double sTheta, G4double dTheta)
0156 {
0157   if ( (sTheta<0) || (sTheta>CLHEP::pi) )
0158   {
0159     std::ostringstream message;
0160     message << "sTheta outside 0-PI range." << G4endl
0161             << "Invalid starting Theta angle for solid: " << GetName();
0162     G4Exception("G4Sphere::CheckThetaAngles()", "GeomSolids0002",
0163                 FatalException, message);
0164   }
0165   else
0166   {
0167     fSTheta=sTheta;
0168   }
0169   if ( dTheta+sTheta >= CLHEP::pi )
0170   {
0171     fDTheta=CLHEP::pi-sTheta;
0172   }
0173   else if ( dTheta > 0 )
0174   {
0175     fDTheta=dTheta;
0176   }
0177   else
0178   {
0179     std::ostringstream message;
0180     message << "Invalid dTheta." << G4endl
0181             << "Negative delta-Theta (" << dTheta << "), for solid: "
0182             << GetName();
0183     G4Exception("G4Sphere::CheckThetaAngles()", "GeomSolids0002",
0184                 FatalException, message);
0185   }
0186   fFullThetaSphere = fDTheta-fSTheta >= CLHEP::pi;
0187   fFullSphere = fFullPhiSphere && fFullThetaSphere;
0188 
0189   InitializeThetaTrigonometry();
0190 }
0191 
0192 inline
0193 void G4Sphere::CheckSPhiAngle(G4double sPhi)
0194 {
0195   // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
0196 
0197   if ( sPhi < 0 )
0198   {
0199     fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
0200   }
0201   else
0202   {
0203     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
0204   }
0205   if ( fSPhi+fDPhi > CLHEP::twopi )
0206   {
0207     fSPhi -= CLHEP::twopi ;
0208   }
0209 }
0210 
0211 inline
0212 void G4Sphere::CheckDPhiAngle(G4double dPhi)
0213 {
0214   fFullPhiSphere = true;
0215   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
0216   {
0217     fDPhi=CLHEP::twopi;
0218   }
0219   else
0220   {
0221     fFullPhiSphere = false;
0222     if ( dPhi > 0 )
0223     {
0224       fDPhi = dPhi;
0225     }
0226     else
0227     {
0228       std::ostringstream message;
0229       message << "Invalid dphi." << G4endl
0230               << "Negative delta-Phi (" << dPhi << "), for solid: "
0231               << GetName();
0232       G4Exception("G4Sphere::CheckDPhiAngle()", "GeomSolids0002",
0233                   FatalException, message);
0234     }
0235   }
0236 }
0237 
0238 inline
0239 void G4Sphere::CheckPhiAngles(G4double sPhi, G4double dPhi)
0240 {
0241   CheckDPhiAngle(dPhi);
0242   if (!fFullPhiSphere && (sPhi != 0.0)) { CheckSPhiAngle(sPhi); }
0243   fFullSphere = fFullPhiSphere && fFullThetaSphere;
0244 
0245   InitializePhiTrigonometry();
0246 }
0247 
0248 inline
0249 void G4Sphere::SetInnerRadius(G4double newRmin)
0250 {
0251   fRmin= newRmin;
0252   fRminTolerance = (fRmin) != 0.0 ? std::max( kRadTolerance, fEpsilon*fRmin ) : 0;
0253   Initialize();
0254 }
0255 
0256 inline
0257 void G4Sphere::SetOuterRadius(G4double newRmax)
0258 {
0259   fRmax= newRmax;
0260   fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax );
0261   Initialize();
0262 }
0263 
0264 inline
0265 void G4Sphere::SetStartPhiAngle(G4double newSPhi, G4bool compute)
0266 {
0267   // Flag 'compute' can be used to explicitely avoid recomputation of
0268   // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
0269 
0270   CheckSPhiAngle(newSPhi);
0271   fFullPhiSphere = false;
0272   if (compute)  { InitializePhiTrigonometry(); }
0273   Initialize();
0274 }
0275 
0276 inline
0277 void G4Sphere::SetDeltaPhiAngle(G4double newDPhi)
0278 {
0279   CheckPhiAngles(fSPhi, newDPhi);
0280   Initialize();
0281 }
0282 
0283 inline
0284 void G4Sphere::SetStartThetaAngle(G4double newSTheta)
0285 {
0286   CheckThetaAngles(newSTheta, fDTheta);
0287   Initialize();
0288 }
0289 
0290 inline
0291 void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
0292 {
0293   CheckThetaAngles(fSTheta, newDTheta);
0294   Initialize();
0295 }