Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4Cons.icc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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