Geant4-11
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// Implementation of inline methods of G4Paraboloid
27// --------------------------------------------------------------------
28
29inline
30G4double G4Paraboloid::GetZHalfLength() const
31{
32 return dz;
33}
34
35inline
36G4double G4Paraboloid::GetRadiusPlusZ() const
37{
38 return r2;
39}
40
41inline
42G4double G4Paraboloid::GetRadiusMinusZ() const
43{
44 return r1;
45}
46
47inline
48void G4Paraboloid::SetZHalfLength(G4double pDz)
49{
50 if(pDz <= 0)
51 {
52 G4Exception("G4Paraboloid::SetZHalfLength()", "GeomSolids0002",
53 FatalException, "Invalid dimensions.");
54 }
55 else
56 {
57 dz = pDz;
58 k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
59 k2 = (sqr(r2) + sqr(r1)) / 2;
60
61 // This informs GetSurfaceArea() and GetCubicVolume() that it needs
62 // to recalculate buffered value.
63 //
64 fSurfaceArea = 0.;
65 fCubicVolume = 0.;
66 fRebuildPolyhedron = true;
67 }
68}
69
70inline
71void G4Paraboloid::SetRadiusPlusZ(G4double pR2)
72{
73 if(pR2 <= 0 || pR2 <= r1)
74 {
75 G4Exception("G4Paraboloid::SetRadiusPlusZ()", "GeomSolids0002",
76 FatalException, "Invalid dimensions.");
77 }
78 else
79 {
80 r2 = pR2;
81 k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
82 k2 = (sqr(r2) + sqr(r1)) / 2;
83
84 // This informs GetSurfaceArea() and GetCubicVolume() that it needs
85 // to recalculate buffered value.
86 //
87 fSurfaceArea = 0.;
88 fCubicVolume = 0.;
89 fRebuildPolyhedron = true;
90 }
91}
92
93inline
94void G4Paraboloid::SetRadiusMinusZ(G4double pR1)
95{
96 if(pR1 < 0 || pR1 >= r2)
97 {
98 G4Exception("G4Paraboloid::SetRadiusMinusZ()", "GeomSolids0002",
99 FatalException, "Invalid dimensions.");
100 }
101 else
102 {
103 r1 = pR1;
104 k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
105 k2 = (sqr(r2) + sqr(r1)) / 2;
106
107 // This informs GetSurfaceArea() and GetCubicVolume() that it needs
108 // to recalculate buffered value.
109 //
110 fSurfaceArea = 0.;
111 fCubicVolume = 0.;
112 fRebuildPolyhedron = true;
113 }
114}
115
116inline
117G4double G4Paraboloid::GetCubicVolume()
118{
119 if(fCubicVolume != 0. ) {;}
120 else
121 {
122 fCubicVolume = CLHEP::twopi * k2 * dz;
123 }
124 return fCubicVolume;
125}
126
127
128inline
129G4double G4Paraboloid::CalculateSurfaceArea() const
130{
131 G4double h1, h2, A1, A2;
132
133 h1 = k2/k1 + dz;
134 h2 = k2/k1 - dz;
135
136 // Calculate surface area for the paraboloid full paraboloid
137 // cutoff at z = dz (not the cutoff area though).
138
139 A1 = sqr(r2) + 4 * sqr(h1);
140 A1 *= sqr(A1); // Sets A1 = A1^3
141 A1 = CLHEP::pi * r2 /6 / sqr(h1) * ( std::sqrt(A1) - r2 * r2 * r2);
142
143 // Calculate surface area for the paraboloid full paraboloid
144 // cutoff at z = -dz (not the cutoff area though).
145
146 A2 = sqr(r1) + 4 * sqr(h2);
147 A2 *= sqr(A2);// Sets A2 = A2^3
148
149 if(h2 != 0)
150 { A2 = CLHEP::pi * r1 /6 / sqr(h2) * ( std::sqrt(A2) - r1 * r1 * r1); }
151 else
152 { A2 = 0.; }
153
154 return fSurfaceArea = A1 - A2 + (sqr(r1) + sqr(r2))*CLHEP::pi;
155}
156
157inline
158G4double G4Paraboloid::GetSurfaceArea()
159{
160 if(fSurfaceArea == 0.) CalculateSurfaceArea();
161
162 return fSurfaceArea;
163}