Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:05

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 G4CutTubs
0027 // --------------------------------------------------------------------
0028 
0029 inline
0030 G4double G4CutTubs::GetInnerRadius () const
0031 {
0032   return fRMin;
0033 }
0034 
0035 inline
0036 G4double G4CutTubs::GetOuterRadius () const
0037 {
0038   return fRMax;
0039 }
0040 
0041 inline
0042 G4double G4CutTubs::GetZHalfLength () const
0043 {
0044   return fDz;
0045 }
0046 
0047 inline
0048 G4double G4CutTubs::GetStartPhiAngle () const
0049 {
0050   return fSPhi;
0051 }
0052 
0053 inline
0054 G4double G4CutTubs::GetDeltaPhiAngle () const
0055 {
0056   return fDPhi;
0057 }
0058 
0059 inline
0060 G4double G4CutTubs::GetSinStartPhi () const
0061 {
0062   return sinSPhi;
0063 }
0064 
0065 inline
0066 G4double G4CutTubs::GetCosStartPhi () const
0067 {
0068   return cosSPhi;
0069 }
0070 
0071 inline
0072 G4double G4CutTubs::GetSinEndPhi () const
0073 {
0074   return sinEPhi;
0075 }
0076 
0077 inline
0078 G4double G4CutTubs::GetCosEndPhi () const
0079 {
0080   return cosEPhi;
0081 }
0082 
0083 inline
0084 G4ThreeVector G4CutTubs::GetLowNorm () const
0085 {
0086   return fLowNorm;
0087 }
0088 
0089 inline
0090 G4ThreeVector G4CutTubs::GetHighNorm () const
0091 {
0092   return fHighNorm;
0093 }
0094 
0095 inline
0096 void G4CutTubs::Initialize()
0097 {
0098   fZMin = 0.;
0099   fZMax = 0.;
0100   fCubicVolume = 0.;
0101   fSurfaceArea = 0.;
0102   fRebuildPolyhedron = true;
0103 }
0104 
0105 inline
0106 void G4CutTubs::InitializeTrigonometry()
0107 {
0108   G4double hDPhi = 0.5*fDPhi;                       // half delta phi
0109   G4double cPhi  = fSPhi + hDPhi;
0110   G4double ePhi  = fSPhi + fDPhi;
0111 
0112   sinCPhi    = std::sin(cPhi);
0113   cosCPhi    = std::cos(cPhi);
0114   cosHDPhi   = std::cos(hDPhi);
0115   cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
0116   cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
0117   sinSPhi = std::sin(fSPhi);
0118   cosSPhi = std::cos(fSPhi);
0119   sinEPhi = std::sin(ePhi);
0120   cosEPhi = std::cos(ePhi);
0121 }
0122 
0123 inline void G4CutTubs::CheckSPhiAngle(G4double sPhi)
0124 {
0125   // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
0126 
0127   if ( sPhi < 0 )
0128   {
0129     fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
0130   }
0131   else
0132   {
0133     fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
0134   }
0135   if ( fSPhi+fDPhi > CLHEP::twopi )
0136   {
0137     fSPhi -= CLHEP::twopi ;
0138   }
0139 }
0140 
0141 inline void G4CutTubs::CheckDPhiAngle(G4double dPhi)
0142 {
0143   fPhiFullCutTube = true;
0144   if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
0145   {
0146     fDPhi=CLHEP::twopi;
0147     fSPhi=0;
0148   }
0149   else
0150   {
0151     fPhiFullCutTube = false;
0152     if ( dPhi > 0 )
0153     {
0154       fDPhi = dPhi;
0155     }
0156     else
0157     {
0158       std::ostringstream message;
0159       message << "Invalid dphi." << G4endl
0160               << "Negative or zero delta-Phi (" << dPhi << "), for solid: "
0161               << GetName();
0162       G4Exception("G4CutTubs::CheckDPhiAngle()", "GeomSolids0002",
0163                   FatalException, message);
0164     }
0165   }
0166 }
0167 
0168 inline void G4CutTubs::CheckPhiAngles(G4double sPhi, G4double dPhi)
0169 {
0170   CheckDPhiAngle(dPhi);
0171   if ( (fDPhi<CLHEP::twopi) && ((sPhi) != 0.0) ) { CheckSPhiAngle(sPhi); }
0172   InitializeTrigonometry();
0173 }
0174 
0175 inline
0176 void G4CutTubs::SetInnerRadius (G4double newRMin)
0177 {
0178   if ( newRMin < 0 ) // Check radii
0179   {
0180     std::ostringstream message;
0181     message << "Invalid radii." << G4endl
0182             << "Invalid values for radii in solid " << GetName() << G4endl
0183             << "        newRMin = " << newRMin
0184             << ", fRMax = " << fRMax << G4endl
0185             << "        Negative inner radius!";
0186     G4Exception("G4CutTubs::SetInnerRadius()", "GeomSolids0002",
0187                 FatalException, message);
0188   }
0189   fRMin= newRMin;
0190   Initialize();
0191 }
0192 
0193 inline
0194 void G4CutTubs::SetOuterRadius (G4double newRMax)
0195 {
0196   if ( newRMax <= 0 ) // Check radii
0197   {
0198     std::ostringstream message;
0199     message << "Invalid radii." << G4endl
0200             << "Invalid values for radii in solid " << GetName() << G4endl
0201             << "        fRMin = " << fRMin
0202             << ", newRMax = " << newRMax << G4endl
0203             << "        Invalid outer radius!";
0204     G4Exception("G4CutTubs::SetOuterRadius()", "GeomSolids0002",
0205                 FatalException, message);
0206   }
0207   fRMax= newRMax;
0208   Initialize();
0209 }
0210 
0211 inline
0212 void G4CutTubs::SetZHalfLength (G4double newDz)
0213 {
0214   if (newDz<=0) // Check z-len
0215   {
0216     std::ostringstream message;
0217     message << "Invalid Z half-length." << G4endl
0218             << "Negative Z half-length (" << newDz << "), for solid: "
0219             << GetName();
0220     G4Exception("G4CutTubs::SetZHalfLength()", "GeomSolids0002",
0221                 FatalException, message);
0222   }
0223   fDz= newDz;
0224   Initialize();
0225 }
0226 
0227 inline
0228 void G4CutTubs::SetStartPhiAngle (G4double newSPhi, G4bool compute)
0229 {
0230   // Flag 'compute' can be used to explicitely avoid recomputation of
0231   // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
0232 
0233   CheckSPhiAngle(newSPhi);
0234   fPhiFullCutTube = false;
0235   if (compute)  { InitializeTrigonometry(); }
0236   Initialize();
0237 }
0238 
0239 inline
0240 void G4CutTubs::SetDeltaPhiAngle (G4double newDPhi)
0241 {
0242   CheckPhiAngles(fSPhi, newDPhi);
0243   Initialize();
0244 }