Geant4  10.00.p01
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 66356 2012-12-18 09:02:32Z 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  }
76 }
77 
78 inline
79 void G4Paraboloid::SetRadiusPlusZ(G4double pR2)
80 {
81  if(pR2 <= 0 || pR2 <= r1)
82  {
83  G4Exception("G4Paraboloid::SetRadiusPlusZ()", "GeomSolids0002",
84  FatalException, "Invalid dimensions.");
85  }
86  else
87  {
88  r2 = pR2;
89  k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
90  k2 = (sqr(r2) + sqr(r1)) / 2;
91 
92  // This informs GetSurfaceArea() and GetCubicVolume() that it needs
93  // to recalculate buffered value.
94  //
95  fSurfaceArea = 0.;
96  fCubicVolume = 0.;
97  }
98 }
99 
100 inline
101 void G4Paraboloid::SetRadiusMinusZ(G4double pR1)
102 {
103  if(pR1 < 0 || pR1 >= r2)
104  {
105  G4Exception("G4Paraboloid::SetRadiusMinusZ()", "GeomSolids0002",
106  FatalException, "Invalid dimensions.");
107  }
108  else
109  {
110  r1 = pR1;
111  k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
112  k2 = (sqr(r2) + sqr(r1)) / 2;
113 
114  // This informs GetSurfaceArea() and GetCubicVolume() that it needs
115  // to recalculate buffered value.
116  //
117  fSurfaceArea = 0.;
118  fCubicVolume = 0.;
119  }
120 }
121 
122 inline
123 G4double G4Paraboloid::GetCubicVolume()
124 {
125  if(fCubicVolume != 0 ) {;}
126  else
127  {
128  fCubicVolume = CLHEP::twopi * k2 * dz;
129  }
130  return fCubicVolume;
131 }
132 
133 
134 inline
135 G4double G4Paraboloid::CalculateSurfaceArea() const
136 {
137  G4double h1, h2, A1, A2;
138 
139  h1 = k2/k1 + dz;
140  h2 = k2/k1 - dz;
141 
142  // Calculate surface area for the paraboloid full paraboloid
143  // cutoff at z = dz (not the cutoff area though).
144 
145  A1 = sqr(r2) + 4 * sqr(h1);
146  A1 *= sqr(A1); // Sets A1 = A1^3
147  A1 = CLHEP::pi * r2 /6 / sqr(h1) * ( std::sqrt(A1) - r2 * r2 * r2);
148 
149  // Calculate surface area for the paraboloid full paraboloid
150  // cutoff at z = -dz (not the cutoff area though).
151 
152  A2 = sqr(r1) + 4 * sqr(h2);
153  A2 *= sqr(A2);// Sets A2 = A2^3
154 
155  if(h2 != 0)
156  { A2 = CLHEP::pi * r1 /6 / sqr(h2) * ( std::sqrt(A2) - r1 * r1 * r1); }
157  else
158  { A2 = 0.; }
159 
160  return fSurfaceArea = A1 - A2 + (sqr(r1) + sqr(r2))*CLHEP::pi;
161 }
162 
163 inline
164 G4double G4Paraboloid::GetSurfaceArea()
165 {
166  if(fSurfaceArea == 0.) CalculateSurfaceArea();
167 
168  return fSurfaceArea;
169 }