Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UParaboloid.cc
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:$
28 //
29 // Implementation for G4UParaboloid wrapper class
30 //
31 // 19-08-2015 Guilherme Lima, FNAL
32 //
33 // --------------------------------------------------------------------
34 
35 #include "G4Paraboloid.hh"
36 #include "G4UParaboloid.hh"
37 
38 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
39 
40 #include "G4AffineTransform.hh"
41 #include "G4VPVParameterisation.hh"
42 #include "G4PhysicalConstants.hh"
43 #include "G4BoundingEnvelope.hh"
44 #include "G4Polyhedron.hh"
45 
47 //
48 // Constructor - check & set half widths
49 
50 
51 G4UParaboloid::G4UParaboloid(const G4String& pName,
52  G4double dz,
53  G4double rlo,
54  G4double rhi )
55  : G4USolid(pName, new UParaboloid(pName, rlo, rhi, dz))
56 { }
57 
59 //
60 // Fake default constructor - sets only member data and allocates memory
61 // for usage restricted to object persistency.
62 
63 G4UParaboloid::G4UParaboloid( __void__& a )
64  : G4USolid(a)
65 { }
66 
68 //
69 // Destructor
70 
71 G4UParaboloid::~G4UParaboloid() { }
72 
74 //
75 // Copy constructor
76 
77 G4UParaboloid::G4UParaboloid(const G4UParaboloid& rhs)
78  : G4USolid(rhs)
79 { }
80 
82 //
83 // Assignment operator
84 
85 G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
86 {
87  // Check assignment to self
88  //
89  if (this == &rhs) { return *this; }
90 
91  // Copy base class data
92  //
93  G4USolid::operator=(rhs);
94 
95  return *this;
96 }
97 
99 //
100 // Accessors
101 
102 G4double G4UParaboloid::GetZHalfLength() const
103 {
104  return GetShape()->GetDz();
105 }
106 
107 G4double G4UParaboloid::GetRadiusMinusZ() const
108 {
109  return GetShape()->GetRlo();
110 }
111 
112 G4double G4UParaboloid::GetRadiusPlusZ() const
113 {
114  return GetShape()->GetRhi();
115 }
116 
118 //
119 // Make a clone of the object
120 
121 G4VSolid* G4UParaboloid::Clone() const
122 {
123  return new G4UParaboloid(*this);
124 }
125 
127 //
128 // Get bounding box
129 
130 void G4UParaboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
131 {
132  static G4bool checkBBox = true;
133 
134  G4double r2 = GetRadiusPlusZ();
135  G4double dz = GetZHalfLength();
136  pMin.set(-r2,-r2,-dz);
137  pMax.set( r2, r2, dz);
138 
139  // Check correctness of the bounding box
140  //
141  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
142  {
143  std::ostringstream message;
144  message << "Bad bounding box (min >= max) for solid: "
145  << GetName() << " !"
146  << "\npMin = " << pMin
147  << "\npMax = " << pMax;
148  G4Exception("G4UParaboloid::Extent()", "GeomMgt0001", JustWarning, message);
149  StreamInfo(G4cout);
150  }
151 
152  // Check consistency of bounding boxes
153  //
154  if (checkBBox)
155  {
156  UVector3 vmin, vmax;
157  GetShape()->Extent(vmin,vmax);
158  if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
159  std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
160  std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
161  std::abs(pMax.x()-vmax.x()) > kCarTolerance ||
162  std::abs(pMax.y()-vmax.y()) > kCarTolerance ||
163  std::abs(pMax.z()-vmax.z()) > kCarTolerance)
164  {
165  std::ostringstream message;
166  message << "Inconsistency in bounding boxes for solid: "
167  << GetName() << " !"
168  << "\nBBox min: wrapper = " << pMin << " solid = " << vmin
169  << "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
170  G4Exception("G4UParaboloid::Extent()", "GeomMgt0001", JustWarning, message);
171  checkBBox = false;
172  }
173  }
174 }
175 
177 //
178 // Calculate extent under transform and specified limit
179 
180 G4bool
181 G4UParaboloid::CalculateExtent(const EAxis pAxis,
182  const G4VoxelLimits& pVoxelLimit,
183  const G4AffineTransform& pTransform,
184  G4double& pMin, G4double& pMax) const
185 {
186  G4ThreeVector bmin, bmax;
187 
188  // Get bounding box
189  Extent(bmin,bmax);
190 
191  // Find extent
192  G4BoundingEnvelope bbox(bmin,bmax);
193  return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
194 }
195 
197 //
198 // CreatePolyhedron
199 //
200 G4Polyhedron* G4UParaboloid::CreatePolyhedron() const
201 {
202  return new G4PolyhedronParaboloid(GetRadiusMinusZ(),
203  GetRadiusPlusZ(),
204  GetZHalfLength(), 0., twopi);
205 }
206 
207 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
double x() const
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
double z() const
static constexpr double twopi
Definition: G4SIunits.hh:76
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
const G4double kCarTolerance
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
EAxis
Definition: geomdefs.hh:54
double y() const
double G4double
Definition: G4Types.hh:76