2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
6 // ********************************************************************
7 // * License and Disclaimer *
9 // * The Geant4 software is copyright of the Copyright Holders of *
10 // * the Geant4 Collaboration. It is provided under the terms and *
11 // * conditions of the Geant4 Software License, included in the file *
12 // * LICENSE and available at http://cern.ch/geant4/license . These *
13 // * include a list of copyright holders. *
15 // * Neither the authors of this software system, nor their employing *
16 // * institutes,nor the agencies providing financial support for this *
17 // * work make any representation or warranty, express or implied, *
18 // * regarding this software system or assume any liability for its *
19 // * use. Please see the license in the file LICENSE and URL above *
20 // * for the full disclaimer and the limitation of liability. *
22 // * This code implementation is the result of the scientific and *
23 // * technical work of the GEANT4 collaboration. *
24 // * By using, copying, modifying or distributing the software (or *
25 // * any work based on the software) you agree to acknowledge its *
26 // * use in resulting scientific publications, and indicate your *
27 // * acceptance of all terms of the Geant4 Software license. *
28 // ********************************************************************
32 // --------------------------------------------------------------------
33 // GEANT 4 inline definitions file
37 // Implementation of inline methods of G4ShiftedCone
38 // --------------------------------------------------------------------
41 G4double G4ShiftedCone::GetInnerRadiusMinusZ() const
47 G4double G4ShiftedCone::GetOuterRadiusMinusZ() const
53 G4double G4ShiftedCone::GetInnerRadiusPlusZ() const
59 G4double G4ShiftedCone::GetOuterRadiusPlusZ() const
65 G4double G4ShiftedCone::GetZHalfLength() const
71 G4double G4ShiftedCone::GetZ1() const
73 return fZshift - fDz ;
77 G4double G4ShiftedCone::GetZ2() const
79 return fZshift + fDz ;
83 G4double G4ShiftedCone::GetStartPhiAngle() const
89 G4double G4ShiftedCone::GetDeltaPhiAngle() const
91 return CLHEP::twopi; //fDPhi;
95 G4double G4ShiftedCone::GetSinStartPhi() const
101 G4double G4ShiftedCone::GetCosStartPhi() const
103 return 1.;// cosSPhi;
107 G4double G4ShiftedCone::GetSinEndPhi() const
109 return 0.;// sinEPhi;
113 G4double G4ShiftedCone::GetCosEndPhi() const
119 void G4ShiftedCone::Initialize()
123 fRebuildPolyhedron = true;
128 void G4ShiftedCone::InitializeTrigonometry()
130 G4double hDPhi = 0.5*fDPhi; // half delta phi
131 G4double cPhi = fSPhi + hDPhi;
132 G4double ePhi = fSPhi + fDPhi;
134 sinCPhi = std::sin(cPhi);
135 cosCPhi = std::cos(cPhi);
136 cosHDPhiIT = std::cos(hDPhi - 0.5*kAngTolerance); // inner/outer tol half dphi
137 cosHDPhiOT = std::cos(hDPhi + 0.5*kAngTolerance);
138 sinSPhi = std::sin(fSPhi);
139 cosSPhi = std::cos(fSPhi);
140 sinEPhi = std::sin(ePhi);
141 cosEPhi = std::cos(ePhi);
144 inline void G4ShiftedCone::CheckSPhiAngle(G4double sPhi)
146 // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
150 fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
154 fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
156 if ( fSPhi+fDPhi > CLHEP::twopi )
158 fSPhi -= CLHEP::twopi ;
162 inline void G4ShiftedCone::CheckDPhiAngle(G4double dPhi)
165 if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
172 fPhiFullCone = false;
179 std::ostringstream message;
180 message << "Invalid dphi." << G4endl
181 << "Negative or zero delta-Phi (" << dPhi << ") in solid: "
183 G4Exception("G4ShiftedCone::CheckDPhiAngle()", "GeomSolids0002",
184 FatalException, message);
189 inline void G4ShiftedCone::CheckPhiAngles(G4double sPhi, G4double dPhi)
191 CheckDPhiAngle(dPhi);
192 if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
193 InitializeTrigonometry();
198 void G4ShiftedCone::SetInnerRadiusMinusZ( G4double Rmin1 )
205 void G4ShiftedCone::SetOuterRadiusMinusZ( G4double Rmax1 )
212 void G4ShiftedCone::SetInnerRadiusPlusZ ( G4double Rmin2 )
219 void G4ShiftedCone::SetOuterRadiusPlusZ ( G4double Rmax2 )
226 void G4ShiftedCone::SetZHalfLength ( G4double newDz )
234 void G4ShiftedCone::SetStartPhiAngle ( G4double newSPhi, G4bool compute )
236 // Flag 'compute' can be used to explicitely avoid recomputation of
237 // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
239 CheckSPhiAngle(newSPhi);
240 fPhiFullCone = false;
241 if (compute) { InitializeTrigonometry(); }
245 void G4ShiftedCone::SetDeltaPhiAngle ( G4double newDPhi )
247 CheckPhiAngles(fSPhi, newDPhi);
251 // Old access methods ...
254 G4double G4ShiftedCone::GetRmin1() const
256 return GetInnerRadiusMinusZ();
260 G4double G4ShiftedCone::GetRmax1() const
262 return GetOuterRadiusMinusZ();
266 G4double G4ShiftedCone::GetRmin2() const
268 return GetInnerRadiusPlusZ();
272 G4double G4ShiftedCone::GetRmax2() const
274 return GetOuterRadiusPlusZ();
278 G4double G4ShiftedCone::GetDz() const
280 return GetZHalfLength();
284 G4double G4ShiftedCone::GetSPhi() const
286 return GetStartPhiAngle();
290 G4double G4ShiftedCone::GetDPhi() const
292 return GetDeltaPhiAngle();
296 G4double G4ShiftedCone::GetCubicVolume()
298 if(fCubicVolume != 0.) {;}
301 G4double Rmean, rMean, deltaR, deltar;
303 Rmean = 0.5*(fRmax1+fRmax2);
304 deltaR = fRmax1-fRmax2;
306 rMean = 0.5*(fRmin1+fRmin2);
307 deltar = fRmin1-fRmin2;
308 fCubicVolume = GetDeltaPhiAngle()*fDz*(Rmean*Rmean-rMean*rMean
309 +(deltaR*deltaR-deltar*deltar)/12);
315 G4double G4ShiftedCone::GetSurfaceArea()
317 if(fSurfaceArea != 0.) {;}
320 G4double mmin, mmax, dmin, dmax;
322 mmin= (fRmin1+fRmin2)*0.5;
323 mmax= (fRmax1+fRmax2)*0.5;
324 dmin= (fRmin2-fRmin1);
325 dmax= (fRmax2-fRmax1);
327 fSurfaceArea = GetDeltaPhiAngle()*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz)
328 + mmax * std::sqrt(dmax*dmax+4*fDz*fDz)
329 + 0.5*(fRmax1*fRmax1-fRmin1*fRmin1
330 +fRmax2*fRmax2-fRmin2*fRmin2 ));
333 fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin);