ATLAS Offline Software
G4ShiftedCone.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // ********************************************************************
7 // * License and Disclaimer *
8 // * *
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. *
14 // * *
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. *
21 // * *
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 // ********************************************************************
29 //
30 //
31 //
32 // --------------------------------------------------------------------
33 // GEANT 4 inline definitions file
34 //
35 // G4ShiftedCone.icc
36 //
37 // Implementation of inline methods of G4ShiftedCone
38 // --------------------------------------------------------------------
39 
40 inline
41 G4double G4ShiftedCone::GetInnerRadiusMinusZ() const
42 {
43  return fRmin1 ;
44 }
45 
46 inline
47 G4double G4ShiftedCone::GetOuterRadiusMinusZ() const
48 {
49  return fRmax1 ;
50 }
51 
52 inline
53 G4double G4ShiftedCone::GetInnerRadiusPlusZ() const
54 {
55  return fRmin2 ;
56 }
57 
58 inline
59 G4double G4ShiftedCone::GetOuterRadiusPlusZ() const
60 {
61  return fRmax2 ;
62 }
63 
64 inline
65 G4double G4ShiftedCone::GetZHalfLength() const
66 {
67  return fDz ;
68 }
69 
70 inline
71 G4double G4ShiftedCone::GetZ1() const
72 {
73  return fZshift - fDz ;
74 }
75 
76 inline
77 G4double G4ShiftedCone::GetZ2() const
78 {
79  return fZshift + fDz ;
80 }
81 
82 inline
83 G4double G4ShiftedCone::GetStartPhiAngle() const
84 {
85  return 0.; // fSPhi ;
86 }
87 
88 inline
89 G4double G4ShiftedCone::GetDeltaPhiAngle() const
90 {
91  return CLHEP::twopi; //fDPhi;
92 }
93 
94 inline
95 G4double G4ShiftedCone::GetSinStartPhi() const
96 {
97  return 0.; //sinSPhi;
98 }
99 
100 inline
101 G4double G4ShiftedCone::GetCosStartPhi() const
102 {
103  return 1.;// cosSPhi;
104 }
105 
106 inline
107 G4double G4ShiftedCone::GetSinEndPhi() const
108 {
109  return 0.;// sinEPhi;
110 }
111 
112 inline
113 G4double G4ShiftedCone::GetCosEndPhi() const
114 {
115  return 1.;//cosEPhi;
116 }
117 
118 inline
119 void G4ShiftedCone::Initialize()
120 {
121  fCubicVolume = 0.;
122  fSurfaceArea = 0.;
123  fRebuildPolyhedron = true;
124 }
125 
126 /*
127 inline
128 void G4ShiftedCone::InitializeTrigonometry()
129 {
130  G4double hDPhi = 0.5*fDPhi; // half delta phi
131  G4double cPhi = fSPhi + hDPhi;
132  G4double ePhi = fSPhi + fDPhi;
133 
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);
142 }
143 
144 inline void G4ShiftedCone::CheckSPhiAngle(G4double sPhi)
145 {
146  // Ensure fSphi in 0-2PI or -2PI-0 range if shape crosses 0
147 
148  if ( sPhi < 0 )
149  {
150  fSPhi = CLHEP::twopi - std::fmod(std::fabs(sPhi),CLHEP::twopi);
151  }
152  else
153  {
154  fSPhi = std::fmod(sPhi,CLHEP::twopi) ;
155  }
156  if ( fSPhi+fDPhi > CLHEP::twopi )
157  {
158  fSPhi -= CLHEP::twopi ;
159  }
160 }
161 
162 inline void G4ShiftedCone::CheckDPhiAngle(G4double dPhi)
163 {
164  fPhiFullCone = true;
165  if ( dPhi >= CLHEP::twopi-kAngTolerance*0.5 )
166  {
167  fDPhi=CLHEP::twopi;
168  fSPhi=0;
169  }
170  else
171  {
172  fPhiFullCone = false;
173  if ( dPhi > 0 )
174  {
175  fDPhi = dPhi;
176  }
177  else
178  {
179  std::ostringstream message;
180  message << "Invalid dphi." << G4endl
181  << "Negative or zero delta-Phi (" << dPhi << ") in solid: "
182  << GetName();
183  G4Exception("G4ShiftedCone::CheckDPhiAngle()", "GeomSolids0002",
184  FatalException, message);
185  }
186  }
187 }
188 
189 inline void G4ShiftedCone::CheckPhiAngles(G4double sPhi, G4double dPhi)
190 {
191  CheckDPhiAngle(dPhi);
192  if ( (fDPhi<CLHEP::twopi) && (sPhi) ) { CheckSPhiAngle(sPhi); }
193  InitializeTrigonometry();
194 }
195 */
196 
197 inline
198 void G4ShiftedCone::SetInnerRadiusMinusZ( G4double Rmin1 )
199 {
200  fRmin1= Rmin1 ;
201  Initialize();
202 }
203 
204 inline
205 void G4ShiftedCone::SetOuterRadiusMinusZ( G4double Rmax1 )
206 {
207  fRmax1= Rmax1 ;
208  Initialize();
209 }
210 
211 inline
212 void G4ShiftedCone::SetInnerRadiusPlusZ ( G4double Rmin2 )
213 {
214  fRmin2= Rmin2 ;
215  Initialize();
216 }
217 
218 inline
219 void G4ShiftedCone::SetOuterRadiusPlusZ ( G4double Rmax2 )
220 {
221  fRmax2= Rmax2 ;
222  Initialize();
223 }
224 
225 /*inline
226 void G4ShiftedCone::SetZHalfLength ( G4double newDz )
227 {
228  fDz= newDz ;
229  Initialize();
230 }*/
231 
232 /*
233 inline
234 void G4ShiftedCone::SetStartPhiAngle ( G4double newSPhi, G4bool compute )
235 {
236  // Flag 'compute' can be used to explicitely avoid recomputation of
237  // trigonometry in case SetDeltaPhiAngle() is invoked afterwards
238 
239  CheckSPhiAngle(newSPhi);
240  fPhiFullCone = false;
241  if (compute) { InitializeTrigonometry(); }
242  Initialize();
243 }
244 
245 void G4ShiftedCone::SetDeltaPhiAngle ( G4double newDPhi )
246 {
247  CheckPhiAngles(fSPhi, newDPhi);
248  Initialize();
249 }
250 */
251 // Old access methods ...
252 
253 inline
254 G4double G4ShiftedCone::GetRmin1() const
255 {
256  return GetInnerRadiusMinusZ();
257 }
258 
259 inline
260 G4double G4ShiftedCone::GetRmax1() const
261 {
262  return GetOuterRadiusMinusZ();
263 }
264 
265 inline
266 G4double G4ShiftedCone::GetRmin2() const
267 {
268  return GetInnerRadiusPlusZ();
269 }
270 
271 inline
272 G4double G4ShiftedCone::GetRmax2() const
273 {
274  return GetOuterRadiusPlusZ();
275 }
276 /*
277 inline
278 G4double G4ShiftedCone::GetDz() const
279 {
280  return GetZHalfLength();
281 }
282 
283 inline
284 G4double G4ShiftedCone::GetSPhi() const
285 {
286  return GetStartPhiAngle();
287 }
288 
289 inline
290 G4double G4ShiftedCone::GetDPhi() const
291 {
292  return GetDeltaPhiAngle();
293 }
294 */
295 inline
296 G4double G4ShiftedCone::GetCubicVolume()
297 {
298  if(fCubicVolume != 0.) {;}
299  else
300  {
301  G4double Rmean, rMean, deltaR, deltar;
302 
303  Rmean = 0.5*(fRmax1+fRmax2);
304  deltaR = fRmax1-fRmax2;
305 
306  rMean = 0.5*(fRmin1+fRmin2);
307  deltar = fRmin1-fRmin2;
308  fCubicVolume = GetDeltaPhiAngle()*fDz*(Rmean*Rmean-rMean*rMean
309  +(deltaR*deltaR-deltar*deltar)/12);
310  }
311  return fCubicVolume;
312 }
313 
314 inline
315 G4double G4ShiftedCone::GetSurfaceArea()
316 {
317  if(fSurfaceArea != 0.) {;}
318  else
319  {
320  G4double mmin, mmax, dmin, dmax;
321 
322  mmin= (fRmin1+fRmin2)*0.5;
323  mmax= (fRmax1+fRmax2)*0.5;
324  dmin= (fRmin2-fRmin1);
325  dmax= (fRmax2-fRmax1);
326 
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 ));
331 /* if(!fPhiFullCone)
332  {
333  fSurfaceArea = fSurfaceArea+4*fDz*(mmax-mmin);
334  }*/
335  }
336  return fSurfaceArea;
337 }