ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UParaboloid.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4UParaboloid.cc
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 for G4UParaboloid wrapper class
27 //
28 // 19.08.2015 Guilherme Lima, FNAL
29 // --------------------------------------------------------------------
30 
31 #include "G4Paraboloid.hh"
32 #include "G4UParaboloid.hh"
33 
34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
35 
36 #include "G4AffineTransform.hh"
37 #include "G4VPVParameterisation.hh"
38 #include "G4PhysicalConstants.hh"
39 #include "G4BoundingEnvelope.hh"
40 #include "G4Polyhedron.hh"
41 
43 //
44 // Constructor - check & set half widths
45 
46 
47 G4UParaboloid::G4UParaboloid(const G4String& pName,
48  G4double dz,
49  G4double rlo,
50  G4double rhi )
51  : Base_t(pName, rlo, rhi, dz)
52 { }
53 
55 //
56 // Fake default constructor - sets only member data and allocates memory
57 // for usage restricted to object persistency.
58 
59 G4UParaboloid::G4UParaboloid( __void__& a )
60  : Base_t(a)
61 { }
62 
64 //
65 // Destructor
66 
67 G4UParaboloid::~G4UParaboloid() { }
68 
70 //
71 // Copy constructor
72 
73 G4UParaboloid::G4UParaboloid(const G4UParaboloid& rhs)
74  : Base_t(rhs)
75 { }
76 
78 //
79 // Assignment operator
80 
81 G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
82 {
83  // Check assignment to self
84  //
85  if (this == &rhs) { return *this; }
86 
87  // Copy base class data
88  //
89  Base_t::operator=(rhs);
90 
91  return *this;
92 }
93 
95 //
96 // Accessors
97 
98 G4double G4UParaboloid::GetZHalfLength() const
99 {
100  return GetDz();
101 }
102 
103 G4double G4UParaboloid::GetRadiusMinusZ() const
104 {
105  return GetRlo();
106 }
107 
108 G4double G4UParaboloid::GetRadiusPlusZ() const
109 {
110  return GetRhi();
111 }
112 
114 //
115 // Modifiers
116 
117 void G4UParaboloid::SetZHalfLength(G4double dz)
118 {
119  SetDz(dz);
120 }
121 
122 void G4UParaboloid::SetRadiusMinusZ(G4double r1)
123 {
124  SetRlo(r1);
125 }
126 
127 void G4UParaboloid::SetRadiusPlusZ(G4double r2)
128 {
129  SetRhi(r2);
130 }
131 
133 //
134 // Make a clone of the object
135 
136 G4VSolid* G4UParaboloid::Clone() const
137 {
138  return new G4UParaboloid(*this);
139 }
140 
142 //
143 // Get bounding box
144 
145 void G4UParaboloid::BoundingLimits(G4ThreeVector& pMin,
146  G4ThreeVector& pMax) const
147 {
148  static G4bool checkBBox = true;
149 
150  G4double r2 = GetRadiusPlusZ();
151  G4double dz = GetZHalfLength();
152  pMin.set(-r2,-r2,-dz);
153  pMax.set( r2, r2, dz);
154 
155  // Check correctness of the bounding box
156  //
157  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
158  {
159  std::ostringstream message;
160  message << "Bad bounding box (min >= max) for solid: "
161  << GetName() << " !"
162  << "\npMin = " << pMin
163  << "\npMax = " << pMax;
164  G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
165  JustWarning, message);
166  StreamInfo(G4cout);
167  }
168 
169  // Check consistency of bounding boxes
170  //
171  if (checkBBox)
172  {
173  U3Vector vmin, vmax;
174  Extent(vmin,vmax);
175  if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
176  std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
177  std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
178  std::abs(pMax.x()-vmax.x()) > kCarTolerance ||
179  std::abs(pMax.y()-vmax.y()) > kCarTolerance ||
180  std::abs(pMax.z()-vmax.z()) > kCarTolerance)
181  {
182  std::ostringstream message;
183  message << "Inconsistency in bounding boxes for solid: "
184  << GetName() << " !"
185  << "\nBBox min: wrapper = " << pMin << " solid = " << vmin
186  << "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
187  G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
188  JustWarning, message);
189  checkBBox = false;
190  }
191  }
192 }
193 
195 //
196 // Calculate extent under transform and specified limit
197 
198 G4bool
199 G4UParaboloid::CalculateExtent(const EAxis pAxis,
200  const G4VoxelLimits& pVoxelLimit,
201  const G4AffineTransform& pTransform,
202  G4double& pMin, G4double& pMax) const
203 {
204  G4ThreeVector bmin, bmax;
205 
206  // Get bounding box
207  BoundingLimits(bmin,bmax);
208 
209  // Find extent
210  G4BoundingEnvelope bbox(bmin,bmax);
211  return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
212 }
213 
215 //
216 // CreatePolyhedron
217 //
218 G4Polyhedron* G4UParaboloid::CreatePolyhedron() const
219 {
220  return new G4PolyhedronParaboloid(GetRadiusMinusZ(),
221  GetRadiusPlusZ(),
222  GetZHalfLength(), 0., twopi);
223 }
224 
225 #endif // G4GEOM_USE_USOLIDS