Geant4  10.03
G4Paraboloid.icc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4Paraboloid.icc 83572 2014-09-01 15:23:27Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 inline definitions file
32 //
33 // G4Paraboloid.icc
34 //
35 // Implementation of inline methods of G4Paraboloid
36 // --------------------------------------------------------------------
37 
38 inline
39 G4double G4Paraboloid::GetZHalfLength() const
40 {
41  return dz;
42 }
43 
44 inline
45 G4double G4Paraboloid::GetRadiusPlusZ() const
46 {
47  return r2;
48 }
49 
50 inline
51 G4double G4Paraboloid::GetRadiusMinusZ() const
52 {
53  return r1;
54 }
55 
56 inline
57 void G4Paraboloid::SetZHalfLength(G4double pDz)
58 {
59  if(pDz <= 0)
60  {
61  G4Exception("G4Paraboloid::SetZHalfLength()", "GeomSolids0002",
62  FatalException, "Invalid dimensions.");
63  }
64  else
65  {
66  dz = pDz;
67  k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
68  k2 = (sqr(r2) + sqr(r1)) / 2;
69 
70  // This informs GetSurfaceArea() and GetCubicVolume() that it needs
71  // to recalculate buffered value.
72  //
73  fSurfaceArea = 0.;
74  fCubicVolume = 0.;
75  fRebuildPolyhedron = true;
76  }
77 }
78 
79 inline
80 void G4Paraboloid::SetRadiusPlusZ(G4double pR2)
81 {
82  if(pR2 <= 0 || pR2 <= r1)
83  {
84  G4Exception("G4Paraboloid::SetRadiusPlusZ()", "GeomSolids0002",
85  FatalException, "Invalid dimensions.");
86  }
87  else
88  {
89  r2 = pR2;
90  k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
91  k2 = (sqr(r2) + sqr(r1)) / 2;
92 
93  // This informs GetSurfaceArea() and GetCubicVolume() that it needs
94  // to recalculate buffered value.
95  //
96  fSurfaceArea = 0.;
97  fCubicVolume = 0.;
98  fRebuildPolyhedron = true;
99  }
100 }
101 
102 inline
103 void G4Paraboloid::SetRadiusMinusZ(G4double pR1)
104 {
105  if(pR1 < 0 || pR1 >= r2)
106  {
107  G4Exception("G4Paraboloid::SetRadiusMinusZ()", "GeomSolids0002",
108  FatalException, "Invalid dimensions.");
109  }
110  else
111  {
112  r1 = pR1;
113  k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
114  k2 = (sqr(r2) + sqr(r1)) / 2;
115 
116  // This informs GetSurfaceArea() and GetCubicVolume() that it needs
117  // to recalculate buffered value.
118  //
119  fSurfaceArea = 0.;
120  fCubicVolume = 0.;
121  fRebuildPolyhedron = true;
122  }
123 }
124 
125 inline
126 G4double G4Paraboloid::GetCubicVolume()
127 {
128  if(fCubicVolume != 0 ) {;}
129  else
130  {
131  fCubicVolume = CLHEP::twopi * k2 * dz;
132  }
133  return fCubicVolume;
134 }
135 
136 
137 inline
138 G4double G4Paraboloid::CalculateSurfaceArea() const
139 {
140  G4double h1, h2, A1, A2;
141 
142  h1 = k2/k1 + dz;
143  h2 = k2/k1 - dz;
144 
145  // Calculate surface area for the paraboloid full paraboloid
146  // cutoff at z = dz (not the cutoff area though).
147 
148  A1 = sqr(r2) + 4 * sqr(h1);
149  A1 *= sqr(A1); // Sets A1 = A1^3
150  A1 = CLHEP::pi * r2 /6 / sqr(h1) * ( std::sqrt(A1) - r2 * r2 * r2);
151 
152  // Calculate surface area for the paraboloid full paraboloid
153  // cutoff at z = -dz (not the cutoff area though).
154 
155  A2 = sqr(r1) + 4 * sqr(h2);
156  A2 *= sqr(A2);// Sets A2 = A2^3
157 
158  if(h2 != 0)
159  { A2 = CLHEP::pi * r1 /6 / sqr(h2) * ( std::sqrt(A2) - r1 * r1 * r1); }
160  else
161  { A2 = 0.; }
162 
163  return fSurfaceArea = A1 - A2 + (sqr(r1) + sqr(r2))*CLHEP::pi;
164 }
165 
166 inline
167 G4double G4Paraboloid::GetSurfaceArea()
168 {
169  if(fSurfaceArea == 0.) CalculateSurfaceArea();
170 
171  return fSurfaceArea;
172 }