Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions
G4Para Class Reference

#include <G4Para.hh>

Inheritance diagram for G4Para:
G4CSGSolid G4VSolid

Public Member Functions

 G4Para (const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
 
 G4Para (const G4String &pName, const G4ThreeVector pt[8])
 
virtual ~G4Para ()
 
G4double GetZHalfLength () const
 
G4ThreeVector GetSymAxis () const
 
G4double GetYHalfLength () const
 
G4double GetXHalfLength () const
 
G4double GetTanAlpha () const
 
void SetXHalfLength (G4double val)
 
void SetYHalfLength (G4double val)
 
void SetZHalfLength (G4double val)
 
void SetAlpha (G4double alpha)
 
void SetTanAlpha (G4double val)
 
void SetThetaAndPhi (double pTheta, double pPhi)
 
void SetAllParameters (G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
EInside Inside (const G4ThreeVector &p) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
G4GeometryType GetEntityType () const
 
G4ThreeVector GetPointOnSurface () const
 
G4VSolidClone () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4PolyhedronCreatePolyhedron () const
 
 G4Para (__void__ &)
 
 G4Para (const G4Para &rhs)
 
G4Paraoperator= (const G4Para &rhs)
 
- Public Member Functions inherited from G4CSGSolid
 G4CSGSolid (const G4String &pName)
 
virtual ~G4CSGSolid ()
 
virtual G4PolyhedronGetPolyhedron () const
 
 G4CSGSolid (__void__ &)
 
 G4CSGSolid (const G4CSGSolid &rhs)
 
G4CSGSolidoperator= (const G4CSGSolid &rhs)
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
void DumpInfo () const
 
virtual G4VisExtent GetExtent () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 

Protected Member Functions

G4ThreeVectorListCreateRotatedVertices (const G4AffineTransform &pTransform) const
 
- Protected Member Functions inherited from G4CSGSolid
G4double GetRadiusInRing (G4double rmin, G4double rmax) const
 
- Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

Additional Inherited Members

- Protected Attributes inherited from G4CSGSolid
G4double fCubicVolume
 
G4double fSurfaceArea
 
G4PolyhedronfpPolyhedron
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 76 of file G4Para.hh.

Constructor & Destructor Documentation

G4Para::G4Para ( const G4String pName,
G4double  pDx,
G4double  pDy,
G4double  pDz,
G4double  pAlpha,
G4double  pTheta,
G4double  pPhi 
)

Definition at line 100 of file G4Para.cc.

References FatalException, G4endl, G4Exception(), G4VSolid::GetName(), and SetAllParameters().

Referenced by Clone().

103  : G4CSGSolid(pName)
104 {
105  if ((pDx<=0) || (pDy<=0) || (pDz<=0))
106  {
107  std::ostringstream message;
108  message << "Invalid Length Parameters for Solid: " << GetName() << G4endl
109  << " pDx, pDy, pDz = "
110  << pDx << ", " << pDy << ", " << pDz;
111  G4Exception("G4Para::G4Para()", "GeomSolids0002",
112  FatalException, message);
113  }
114  SetAllParameters( pDx, pDy, pDz, pAlpha, pTheta, pPhi);
115 }
G4String GetName() const
void SetAllParameters(G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
Definition: G4Para.cc:71
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42
#define G4endl
Definition: G4ios.hh:61
G4Para::G4Para ( const G4String pName,
const G4ThreeVector  pt[8] 
)

Definition at line 123 of file G4Para.cc.

References FatalException, G4CSGSolid::fCubicVolume, G4CSGSolid::fpPolyhedron, G4CSGSolid::fSurfaceArea, G4Exception(), G4VSolid::GetName(), test::x, and z.

125  : G4CSGSolid(pName)
126 {
127  if (!( pt[0].z()<0 && pt[0].z()==pt[1].z() && pt[0].z()==pt[2].z() &&
128  pt[0].z()==pt[3].z() && pt[4].z()>0 && pt[4].z()==pt[5].z() &&
129  pt[4].z()==pt[6].z() && pt[4].z()==pt[7].z() &&
130  (pt[0].z()+pt[4].z())==0 &&
131  pt[0].y()==pt[1].y() && pt[2].y()==pt[3].y() &&
132  pt[4].y()==pt[5].y() && pt[6].y()==pt[7].y() &&
133  ( pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y() ) == 0 &&
134  ( pt[0].x() + pt[1].x() + pt[4].x() + pt[5].x() ) == 0) )
135  {
136  std::ostringstream message;
137  message << "Invalid vertice coordinates for Solid: " << GetName();
138  G4Exception("G4Para::G4Para()", "GeomSolids0002",
139  FatalException, message);
140  }
141  fDx = ((pt[3]).x()-(pt[2]).x())*0.5;
142  fDy = ((pt[2]).y()-(pt[1]).y())*0.5;
143  fDz = (pt[7]).z();
144  fTalpha = ((pt[2]).x()+(pt[3]).x()-(pt[1]).x()-(pt[0]).x())*0.25/fDy ;
145  fTthetaCphi = ((pt[4]).x()+fDy*fTalpha+fDx)/fDz ;
146  fTthetaSphi = ((pt[4]).y()+fDy)/fDz ;
147  fCubicVolume = 0.;
148  fSurfaceArea = 0.;
149  fpPolyhedron = 0;
150 }
G4String GetName() const
G4double z
Definition: TRTMaterials.hh:39
G4double fCubicVolume
Definition: G4CSGSolid.hh:78
G4double fSurfaceArea
Definition: G4CSGSolid.hh:79
G4Polyhedron * fpPolyhedron
Definition: G4CSGSolid.hh:80
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42
G4Para::~G4Para ( )
virtual

Definition at line 166 of file G4Para.cc.

167 {
168 }
G4Para::G4Para ( __void__ &  a)

Definition at line 157 of file G4Para.cc.

158  : G4CSGSolid(a), fDx(0.), fDy(0.), fDz(0.),
159  fTalpha(0.), fTthetaCphi(0.), fTthetaSphi(0.)
160 {
161 }
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42
G4Para::G4Para ( const G4Para rhs)

Definition at line 174 of file G4Para.cc.

175  : G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz),
176  fTalpha(rhs.fTalpha), fTthetaCphi(rhs.fTthetaCphi),
177  fTthetaSphi(rhs.fTthetaSphi)
178 {
179 }
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:42

Member Function Documentation

G4bool G4Para::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Definition at line 221 of file G4Para.cc.

References G4VSolid::ClipBetweenSections(), G4VSolid::ClipCrossSection(), CreateRotatedVertices(), G4VoxelLimits::GetMaxExtent(), G4VoxelLimits::GetMaxXExtent(), G4VoxelLimits::GetMaxYExtent(), G4VoxelLimits::GetMaxZExtent(), G4VoxelLimits::GetMinExtent(), G4VoxelLimits::GetMinXExtent(), G4VoxelLimits::GetMinYExtent(), G4VoxelLimits::GetMinZExtent(), Inside(), G4AffineTransform::Inverse(), G4AffineTransform::IsRotated(), G4VoxelLimits::IsXLimited(), G4VoxelLimits::IsYLimited(), G4VoxelLimits::IsZLimited(), G4VSolid::kCarTolerance, kOutside, kXAxis, kYAxis, kZAxis, G4AffineTransform::NetTranslation(), G4AffineTransform::TransformPoint(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), z, and CLHEP::Hep3Vector::z().

225 {
226  G4bool flag;
227 
228  if (!pTransform.IsRotated())
229  {
230  // Special case handling for unrotated trapezoids
231  // Compute z/x/y/ mins and maxs respecting limits, with early returns
232  // if outside limits. Then switch() on pAxis
233 
234  G4int i ;
235  G4double xoffset,xMin,xMax;
236  G4double yoffset,yMin,yMax;
237  G4double zoffset,zMin,zMax;
238  G4double temp[8] ; // some points for intersection with zMin/zMax
239 
240  xoffset=pTransform.NetTranslation().x();
241  yoffset=pTransform.NetTranslation().y();
242  zoffset=pTransform.NetTranslation().z();
243 
244  G4ThreeVector pt[8]; // vertices after translation
245  pt[0]=G4ThreeVector(xoffset-fDz*fTthetaCphi-fDy*fTalpha-fDx,
246  yoffset-fDz*fTthetaSphi-fDy,zoffset-fDz);
247  pt[1]=G4ThreeVector(xoffset-fDz*fTthetaCphi-fDy*fTalpha+fDx,
248  yoffset-fDz*fTthetaSphi-fDy,zoffset-fDz);
249  pt[2]=G4ThreeVector(xoffset-fDz*fTthetaCphi+fDy*fTalpha-fDx,
250  yoffset-fDz*fTthetaSphi+fDy,zoffset-fDz);
251  pt[3]=G4ThreeVector(xoffset-fDz*fTthetaCphi+fDy*fTalpha+fDx,
252  yoffset-fDz*fTthetaSphi+fDy,zoffset-fDz);
253  pt[4]=G4ThreeVector(xoffset+fDz*fTthetaCphi-fDy*fTalpha-fDx,
254  yoffset+fDz*fTthetaSphi-fDy,zoffset+fDz);
255  pt[5]=G4ThreeVector(xoffset+fDz*fTthetaCphi-fDy*fTalpha+fDx,
256  yoffset+fDz*fTthetaSphi-fDy,zoffset+fDz);
257  pt[6]=G4ThreeVector(xoffset+fDz*fTthetaCphi+fDy*fTalpha-fDx,
258  yoffset+fDz*fTthetaSphi+fDy,zoffset+fDz);
259  pt[7]=G4ThreeVector(xoffset+fDz*fTthetaCphi+fDy*fTalpha+fDx,
260  yoffset+fDz*fTthetaSphi+fDy,zoffset+fDz);
261  zMin=zoffset-fDz;
262  zMax=zoffset+fDz;
263  if ( pVoxelLimit.IsZLimited() )
264  {
265  if ( (zMin>pVoxelLimit.GetMaxZExtent()+kCarTolerance)
266  || (zMax<pVoxelLimit.GetMinZExtent()-kCarTolerance) )
267  {
268  return false;
269  }
270  else
271  {
272  if (zMin<pVoxelLimit.GetMinZExtent())
273  {
274  zMin=pVoxelLimit.GetMinZExtent();
275  }
276  if (zMax>pVoxelLimit.GetMaxZExtent())
277  {
278  zMax=pVoxelLimit.GetMaxZExtent();
279  }
280  }
281  }
282 
283  temp[0] = pt[0].y()+(pt[4].y()-pt[0].y())
284  *(zMin-pt[0].z())/(pt[4].z()-pt[0].z()) ;
285  temp[1] = pt[0].y()+(pt[4].y()-pt[0].y())
286  *(zMax-pt[0].z())/(pt[4].z()-pt[0].z()) ;
287  temp[2] = pt[2].y()+(pt[6].y()-pt[2].y())
288  *(zMin-pt[2].z())/(pt[6].z()-pt[2].z()) ;
289  temp[3] = pt[2].y()+(pt[6].y()-pt[2].y())
290  *(zMax-pt[2].z())/(pt[6].z()-pt[2].z()) ;
291  yMax = yoffset - std::fabs(fDz*fTthetaSphi) - fDy - fDy ;
292  yMin = -yMax ;
293  for(i=0;i<4;i++)
294  {
295  if(temp[i] > yMax) yMax = temp[i] ;
296  if(temp[i] < yMin) yMin = temp[i] ;
297  }
298 
299  if (pVoxelLimit.IsYLimited())
300  {
301  if ( (yMin>pVoxelLimit.GetMaxYExtent()+kCarTolerance)
302  || (yMax<pVoxelLimit.GetMinYExtent()-kCarTolerance) )
303  {
304  return false;
305  }
306  else
307  {
308  if (yMin<pVoxelLimit.GetMinYExtent())
309  {
310  yMin=pVoxelLimit.GetMinYExtent();
311  }
312  if (yMax>pVoxelLimit.GetMaxYExtent())
313  {
314  yMax=pVoxelLimit.GetMaxYExtent();
315  }
316  }
317  }
318 
319  temp[0] = pt[0].x()+(pt[4].x()-pt[0].x())
320  *(zMin-pt[0].z())/(pt[4].z()-pt[0].z()) ;
321  temp[1] = pt[0].x()+(pt[4].x()-pt[0].x())
322  *(zMax-pt[0].z())/(pt[4].z()-pt[0].z()) ;
323  temp[2] = pt[2].x()+(pt[6].x()-pt[2].x())
324  *(zMin-pt[2].z())/(pt[6].z()-pt[2].z()) ;
325  temp[3] = pt[2].x()+(pt[6].x()-pt[2].x())
326  *(zMax-pt[2].z())/(pt[6].z()-pt[2].z()) ;
327  temp[4] = pt[3].x()+(pt[7].x()-pt[3].x())
328  *(zMin-pt[3].z())/(pt[7].z()-pt[3].z()) ;
329  temp[5] = pt[3].x()+(pt[7].x()-pt[3].x())
330  *(zMax-pt[3].z())/(pt[7].z()-pt[3].z()) ;
331  temp[6] = pt[1].x()+(pt[5].x()-pt[1].x())
332  *(zMin-pt[1].z())/(pt[5].z()-pt[1].z()) ;
333  temp[7] = pt[1].x()+(pt[5].x()-pt[1].x())
334  *(zMax-pt[1].z())/(pt[5].z()-pt[1].z()) ;
335 
336  xMax = xoffset - std::fabs(fDz*fTthetaCphi) - fDx - fDx -fDx - fDx;
337  xMin = -xMax ;
338  for(i=0;i<8;i++)
339  {
340  if(temp[i] > xMax) xMax = temp[i] ;
341  if(temp[i] < xMin) xMin = temp[i] ;
342  }
343  // xMax/Min = f(yMax/Min) ?
344  if (pVoxelLimit.IsXLimited())
345  {
346  if ( (xMin>pVoxelLimit.GetMaxXExtent()+kCarTolerance)
347  || (xMax<pVoxelLimit.GetMinXExtent()-kCarTolerance) )
348  {
349  return false;
350  }
351  else
352  {
353  if (xMin<pVoxelLimit.GetMinXExtent())
354  {
355  xMin=pVoxelLimit.GetMinXExtent();
356  }
357  if (xMax>pVoxelLimit.GetMaxXExtent())
358  {
359  xMax=pVoxelLimit.GetMaxXExtent();
360  }
361  }
362  }
363 
364  switch (pAxis)
365  {
366  case kXAxis:
367  pMin=xMin;
368  pMax=xMax;
369  break;
370  case kYAxis:
371  pMin=yMin;
372  pMax=yMax;
373  break;
374  case kZAxis:
375  pMin=zMin;
376  pMax=zMax;
377  break;
378  default:
379  break;
380  }
381 
382  pMin-=kCarTolerance;
383  pMax+=kCarTolerance;
384  flag = true;
385  }
386  else
387  {
388  // General rotated case - create and clip mesh to boundaries
389 
390  G4bool existsAfterClip=false;
391  G4ThreeVectorList *vertices;
392 
393  pMin=+kInfinity;
394  pMax=-kInfinity;
395 
396  // Calculate rotated vertex coordinates
397 
398  vertices=CreateRotatedVertices(pTransform);
399  ClipCrossSection(vertices,0,pVoxelLimit,pAxis,pMin,pMax);
400  ClipCrossSection(vertices,4,pVoxelLimit,pAxis,pMin,pMax);
401  ClipBetweenSections(vertices,0,pVoxelLimit,pAxis,pMin,pMax);
402 
403  if (pMin!=kInfinity||pMax!=-kInfinity)
404  {
405  existsAfterClip=true;
406 
407  // Add 2*tolerance to avoid precision troubles
408  //
409  pMin-=kCarTolerance;
410  pMax+=kCarTolerance;
411  }
412  else
413  {
414  // Check for case where completely enveloping clipping volume
415  // If point inside then we are confident that the solid completely
416  // envelopes the clipping volume. Hence set min/max extents according
417  // to clipping volume extents along the specified axis.
418 
419  G4ThreeVector clipCentre(
420  (pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
421  (pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
422  (pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
423 
424  if (Inside(pTransform.Inverse().TransformPoint(clipCentre))!=kOutside)
425  {
426  existsAfterClip=true;
427  pMin=pVoxelLimit.GetMinExtent(pAxis);
428  pMax=pVoxelLimit.GetMaxExtent(pAxis);
429  }
430  }
431  delete vertices ; // 'new' in the function called
432  flag = existsAfterClip ;
433  }
434  return flag;
435 }
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
Definition: G4VSolid.cc:347
EInside Inside(const G4ThreeVector &p) const
Definition: G4Para.cc:441
G4double GetMinYExtent() const
CLHEP::Hep3Vector G4ThreeVector
double x() const
G4AffineTransform Inverse() const
G4double z
Definition: TRTMaterials.hh:39
G4bool IsYLimited() const
G4bool IsRotated() const
G4ThreeVector NetTranslation() const
G4bool IsXLimited() const
int G4int
Definition: G4Types.hh:78
double z() const
G4double GetMaxXExtent() const
G4double GetMinZExtent() const
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4double GetMinXExtent() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4double GetMaxZExtent() const
double y() const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
Definition: G4Para.cc:1186
G4double GetMaxYExtent() const
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
G4double GetMaxExtent(const EAxis pAxis) const
G4bool IsZLimited() const
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
Definition: G4VSolid.cc:378
G4double GetMinExtent(const EAxis pAxis) const
G4VSolid * G4Para::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1242 of file G4Para.cc.

References G4Para().

1243 {
1244  return new G4Para(*this);
1245 }
G4Para(const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
Definition: G4Para.cc:100
void G4Para::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 209 of file G4Para.cc.

References G4VPVParameterisation::ComputeDimensions().

212 {
213  p->ComputeDimensions(*this,n,pRep);
214 }
const G4int n
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4Polyhedron * G4Para::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1384 of file G4Para.cc.

1385 {
1386  G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
1387  G4double alpha = std::atan(fTalpha);
1388  G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
1389  +fTthetaSphi*fTthetaSphi));
1390 
1391  return new G4PolyhedronPara(fDx, fDy, fDz, alpha, theta, phi);
1392 }
double G4double
Definition: G4Types.hh:76
G4ThreeVectorList * G4Para::CreateRotatedVertices ( const G4AffineTransform pTransform) const
protected

Definition at line 1186 of file G4Para.cc.

References G4VSolid::DumpInfo(), FatalException, G4Exception(), and G4AffineTransform::TransformPoint().

Referenced by CalculateExtent().

1187 {
1188  G4ThreeVectorList *vertices;
1189  vertices=new G4ThreeVectorList();
1190  if (vertices)
1191  {
1192  vertices->reserve(8);
1193  G4ThreeVector vertex0(-fDz*fTthetaCphi-fDy*fTalpha-fDx,
1194  -fDz*fTthetaSphi-fDy, -fDz);
1195  G4ThreeVector vertex1(-fDz*fTthetaCphi-fDy*fTalpha+fDx,
1196  -fDz*fTthetaSphi-fDy, -fDz);
1197  G4ThreeVector vertex2(-fDz*fTthetaCphi+fDy*fTalpha-fDx,
1198  -fDz*fTthetaSphi+fDy, -fDz);
1199  G4ThreeVector vertex3(-fDz*fTthetaCphi+fDy*fTalpha+fDx,
1200  -fDz*fTthetaSphi+fDy, -fDz);
1201  G4ThreeVector vertex4(+fDz*fTthetaCphi-fDy*fTalpha-fDx,
1202  +fDz*fTthetaSphi-fDy, +fDz);
1203  G4ThreeVector vertex5(+fDz*fTthetaCphi-fDy*fTalpha+fDx,
1204  +fDz*fTthetaSphi-fDy, +fDz);
1205  G4ThreeVector vertex6(+fDz*fTthetaCphi+fDy*fTalpha-fDx,
1206  +fDz*fTthetaSphi+fDy, +fDz);
1207  G4ThreeVector vertex7(+fDz*fTthetaCphi+fDy*fTalpha+fDx,
1208  +fDz*fTthetaSphi+fDy, +fDz);
1209 
1210  vertices->push_back(pTransform.TransformPoint(vertex0));
1211  vertices->push_back(pTransform.TransformPoint(vertex1));
1212  vertices->push_back(pTransform.TransformPoint(vertex2));
1213  vertices->push_back(pTransform.TransformPoint(vertex3));
1214  vertices->push_back(pTransform.TransformPoint(vertex4));
1215  vertices->push_back(pTransform.TransformPoint(vertex5));
1216  vertices->push_back(pTransform.TransformPoint(vertex6));
1217  vertices->push_back(pTransform.TransformPoint(vertex7));
1218  }
1219  else
1220  {
1221  DumpInfo();
1222  G4Exception("G4Para::CreateRotatedVertices()",
1223  "GeomSolids0003", FatalException,
1224  "Error in allocation of vertices. Out of memory !");
1225  }
1226  return vertices;
1227 }
void DumpInfo() const
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
void G4Para::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1379 of file G4Para.cc.

References G4VGraphicsScene::AddSolid().

1380 {
1381  scene.AddSolid (*this);
1382 }
virtual void AddSolid(const G4Box &)=0
G4double G4Para::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 649 of file G4Para.cc.

References G4VSolid::kCarTolerance, G4INCL::Math::max(), smax, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

651 {
652  G4double snxt; // snxt = default return value
653  G4double smin,smax;
654  G4double tmin,tmax;
655  G4double yt,vy,xt,vx;
656  G4double max;
657  //
658  // Z Intersection range
659  //
660  if (v.z()>0)
661  {
662  max=fDz-p.z();
663  if (max>kCarTolerance*0.5)
664  {
665  smax=max/v.z();
666  smin=(-fDz-p.z())/v.z();
667  }
668  else
669  {
670  return snxt=kInfinity;
671  }
672  }
673  else if (v.z()<0)
674  {
675  max=-fDz-p.z();
676  if (max<-kCarTolerance*0.5)
677  {
678  smax=max/v.z();
679  smin=(fDz-p.z())/v.z();
680  }
681  else
682  {
683  return snxt=kInfinity;
684  }
685  }
686  else
687  {
688  if (std::fabs(p.z())<=fDz) // Inside
689  {
690  smin=0;
691  smax=kInfinity;
692  }
693  else
694  {
695  return snxt=kInfinity;
696  }
697  }
698 
699  //
700  // Y G4Parallel planes intersection
701  //
702 
703  yt=p.y()-fTthetaSphi*p.z();
704  vy=v.y()-fTthetaSphi*v.z();
705 
706  if (vy>0)
707  {
708  max=fDy-yt;
709  if (max>kCarTolerance*0.5)
710  {
711  tmax=max/vy;
712  tmin=(-fDy-yt)/vy;
713  }
714  else
715  {
716  return snxt=kInfinity;
717  }
718  }
719  else if (vy<0)
720  {
721  max=-fDy-yt;
722  if (max<-kCarTolerance*0.5)
723  {
724  tmax=max/vy;
725  tmin=(fDy-yt)/vy;
726  }
727  else
728  {
729  return snxt=kInfinity;
730  }
731  }
732  else
733  {
734  if (std::fabs(yt)<=fDy)
735  {
736  tmin=0;
737  tmax=kInfinity;
738  }
739  else
740  {
741  return snxt=kInfinity;
742  }
743  }
744 
745  // Re-Calc valid intersection range
746  //
747  if (tmin>smin) smin=tmin;
748  if (tmax<smax) smax=tmax;
749  if (smax<=smin)
750  {
751  return snxt=kInfinity;
752  }
753  else
754  {
755  //
756  // X G4Parallel planes intersection
757  //
758  xt=p.x()-fTthetaCphi*p.z()-fTalpha*yt;
759  vx=v.x()-fTthetaCphi*v.z()-fTalpha*vy;
760  if (vx>0)
761  {
762  max=fDx-xt;
763  if (max>kCarTolerance*0.5)
764  {
765  tmax=max/vx;
766  tmin=(-fDx-xt)/vx;
767  }
768  else
769  {
770  return snxt=kInfinity;
771  }
772  }
773  else if (vx<0)
774  {
775  max=-fDx-xt;
776  if (max<-kCarTolerance*0.5)
777  {
778  tmax=max/vx;
779  tmin=(fDx-xt)/vx;
780  }
781  else
782  {
783  return snxt=kInfinity;
784  }
785  }
786  else
787  {
788  if (std::fabs(xt)<=fDx)
789  {
790  tmin=0;
791  tmax=kInfinity;
792  }
793  else
794  {
795  return snxt=kInfinity;
796  }
797  }
798  if (tmin>smin) smin=tmin;
799  if (tmax<smax) smax=tmax;
800  }
801 
802  if (smax>0&&smin<smax)
803  {
804  if (smin>0)
805  {
806  snxt=smin;
807  }
808  else
809  {
810  snxt=0;
811  }
812  }
813  else
814  {
815  snxt=kInfinity;
816  }
817  return snxt;
818 }
double x() const
const G4int smax
double z() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double y() const
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
G4double G4Para::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 825 of file G4Para.cc.

References CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

826 {
827  G4double safe=0.0;
828  G4double distz1,distz2,disty1,disty2,distx1,distx2;
829  G4double trany,cosy,tranx,cosx;
830 
831  // Z planes
832  //
833  distz1=p.z()-fDz;
834  distz2=-fDz-p.z();
835  if (distz1>distz2)
836  {
837  safe=distz1;
838  }
839  else
840  {
841  safe=distz2;
842  }
843 
844  trany=p.y()-fTthetaSphi*p.z(); // Transformed y into `box' system
845 
846  // Transformed x into `box' system
847  //
848  cosy=1.0/std::sqrt(1.0+fTthetaSphi*fTthetaSphi);
849  disty1=(trany-fDy)*cosy;
850  disty2=(-fDy-trany)*cosy;
851 
852  if (disty1>safe) safe=disty1;
853  if (disty2>safe) safe=disty2;
854 
855  tranx=p.x()-fTthetaCphi*p.z()-fTalpha*trany;
856  cosx=1.0/std::sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
857  distx1=(tranx-fDx)*cosx;
858  distx2=(-fDx-tranx)*cosx;
859 
860  if (distx1>safe) safe=distx1;
861  if (distx2>safe) safe=distx2;
862 
863  if (safe<0) safe=0;
864  return safe;
865 }
double x() const
double z() const
double y() const
double G4double
Definition: G4Types.hh:76
G4double G4Para::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = G4bool(false),
G4bool validNorm = 0,
G4ThreeVector n = 0 
) const
virtual

Implements G4VSolid.

Definition at line 872 of file G4Para.cc.

References G4VSolid::DumpInfo(), G4Exception(), JustWarning, G4VSolid::kCarTolerance, kMX, kMY, kMZ, kPX, kPY, kPZ, kUndef, G4INCL::Math::max(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

875 {
876  ESide side = kUndef;
877  G4double snxt; // snxt = return value
878  G4double max,tmax;
879  G4double yt,vy,xt,vx;
880 
881  G4double ycomp,calpha,salpha,tntheta,cosntheta;
882 
883  //
884  // Z Intersections
885  //
886 
887  if (v.z()>0)
888  {
889  max=fDz-p.z();
890  if (max>kCarTolerance*0.5)
891  {
892  snxt=max/v.z();
893  side=kPZ;
894  }
895  else
896  {
897  if (calcNorm)
898  {
899  *validNorm=true;
900  *n=G4ThreeVector(0,0,1);
901  }
902  return snxt=0;
903  }
904  }
905  else if (v.z()<0)
906  {
907  max=-fDz-p.z();
908  if (max<-kCarTolerance*0.5)
909  {
910  snxt=max/v.z();
911  side=kMZ;
912  }
913  else
914  {
915  if (calcNorm)
916  {
917  *validNorm=true;
918  *n=G4ThreeVector(0,0,-1);
919  }
920  return snxt=0;
921  }
922  }
923  else
924  {
925  snxt=kInfinity;
926  }
927 
928  //
929  // Y plane intersection
930  //
931 
932  yt=p.y()-fTthetaSphi*p.z();
933  vy=v.y()-fTthetaSphi*v.z();
934 
935  if (vy>0)
936  {
937  max=fDy-yt;
938  if (max>kCarTolerance*0.5)
939  {
940  tmax=max/vy;
941  if (tmax<snxt)
942  {
943  snxt=tmax;
944  side=kPY;
945  }
946  }
947  else
948  {
949  if (calcNorm)
950  {
951  *validNorm=true; // Leaving via plus Y
952  ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
953  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
954  }
955  return snxt=0;
956  }
957  }
958  else if (vy<0)
959  {
960  max=-fDy-yt;
961  if (max<-kCarTolerance*0.5)
962  {
963  tmax=max/vy;
964  if (tmax<snxt)
965  {
966  snxt=tmax;
967  side=kMY;
968  }
969  }
970  else
971  {
972  if (calcNorm)
973  {
974  *validNorm=true; // Leaving via minus Y
975  ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
976  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
977  }
978  return snxt=0;
979  }
980  }
981 
982  //
983  // X plane intersection
984  //
985 
986  xt=p.x()-fTthetaCphi*p.z()-fTalpha*yt;
987  vx=v.x()-fTthetaCphi*v.z()-fTalpha*vy;
988  if (vx>0)
989  {
990  max=fDx-xt;
991  if (max>kCarTolerance*0.5)
992  {
993  tmax=max/vx;
994  if (tmax<snxt)
995  {
996  snxt=tmax;
997  side=kPX;
998  }
999  }
1000  else
1001  {
1002  if (calcNorm)
1003  {
1004  *validNorm=true; // Leaving via plus X
1005  calpha=1/std::sqrt(1+fTalpha*fTalpha);
1006  if (fTalpha)
1007  {
1008  salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
1009  }
1010  else
1011  {
1012  salpha=0;
1013  }
1014  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
1015  cosntheta=1/std::sqrt(1+tntheta*tntheta);
1016  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1017  }
1018  return snxt=0;
1019  }
1020  }
1021  else if (vx<0)
1022  {
1023  max=-fDx-xt;
1024  if (max<-kCarTolerance*0.5)
1025  {
1026  tmax=max/vx;
1027  if (tmax<snxt)
1028  {
1029  snxt=tmax;
1030  side=kMX;
1031  }
1032  }
1033  else
1034  {
1035  if (calcNorm)
1036  {
1037  *validNorm=true; // Leaving via minus X
1038  calpha=1/std::sqrt(1+fTalpha*fTalpha);
1039  if (fTalpha)
1040  {
1041  salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
1042  }
1043  else
1044  {
1045  salpha=0;
1046  }
1047  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
1048  cosntheta=-1/std::sqrt(1+tntheta*tntheta);
1049  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1050  }
1051  return snxt=0;
1052  }
1053  }
1054 
1055  if (calcNorm)
1056  {
1057  *validNorm=true;
1058  switch (side)
1059  {
1060  case kMZ:
1061  *n=G4ThreeVector(0,0,-1);
1062  break;
1063  case kPZ:
1064  *n=G4ThreeVector(0,0,1);
1065  break;
1066  case kMY:
1067  ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
1068  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
1069  break;
1070  case kPY:
1071  ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
1072  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
1073  break;
1074  case kMX:
1075  calpha=1/std::sqrt(1+fTalpha*fTalpha);
1076  if (fTalpha)
1077  {
1078  salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
1079  }
1080  else
1081  {
1082  salpha=0;
1083  }
1084  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
1085  cosntheta=-1/std::sqrt(1+tntheta*tntheta);
1086  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1087  break;
1088  case kPX:
1089  calpha=1/std::sqrt(1+fTalpha*fTalpha);
1090  if (fTalpha)
1091  {
1092  salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
1093  }
1094  else
1095  {
1096  salpha=0;
1097  }
1098  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
1099  cosntheta=1/std::sqrt(1+tntheta*tntheta);
1100  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
1101  break;
1102  default:
1103  DumpInfo();
1104  G4Exception("G4Para::DistanceToOut(p,v,..)",
1105  "GeomSolids1002",JustWarning,
1106  "Undefined side for valid surface normal to solid.");
1107  break;
1108  }
1109  }
1110  return snxt;
1111 }
Definition: G4Para.cc:61
CLHEP::Hep3Vector G4ThreeVector
double x() const
Definition: G4Para.cc:61
double z() const
void DumpInfo() const
Definition: G4Para.cc:61
Definition: G4Para.cc:61
Definition: G4Para.cc:61
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Definition: G4Para.cc:61
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double y() const
G4double kCarTolerance
Definition: G4VSolid.hh:305
ESide
Definition: G4Cons.cc:68
double G4double
Definition: G4Types.hh:76
Definition: G4Para.cc:61
G4double G4Para::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 1118 of file G4Para.cc.

References G4VSolid::DumpInfo(), G4cout, G4endl, G4Exception(), Inside(), JustWarning, kOutside, python.hepunit::mm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

1119 {
1120  G4double safe=0.0;
1121  G4double distz1,distz2,disty1,disty2,distx1,distx2;
1122  G4double trany,cosy,tranx,cosx;
1123 
1124 #ifdef G4CSGDEBUG
1125  if( Inside(p) == kOutside )
1126  {
1127  G4int oldprc = G4cout.precision(16) ;
1128  G4cout << G4endl ;
1129  DumpInfo();
1130  G4cout << "Position:" << G4endl << G4endl ;
1131  G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
1132  G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
1133  G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
1134  G4cout.precision(oldprc) ;
1135  G4Exception("G4Para::DistanceToOut(p)", "GeomSolids1002",
1136  JustWarning, "Point p is outside !?" );
1137  }
1138 #endif
1139 
1140  // Z planes
1141  //
1142  distz1=fDz-p.z();
1143  distz2=fDz+p.z();
1144  if (distz1<distz2)
1145  {
1146  safe=distz1;
1147  }
1148  else
1149  {
1150  safe=distz2;
1151  }
1152 
1153  trany=p.y()-fTthetaSphi*p.z(); // Transformed y into `box' system
1154 
1155  // Transformed x into `box' system
1156  //
1157  cosy=1.0/std::sqrt(1.0+fTthetaSphi*fTthetaSphi);
1158  disty1=(fDy-trany)*cosy;
1159  disty2=(fDy+trany)*cosy;
1160 
1161  if (disty1<safe) safe=disty1;
1162  if (disty2<safe) safe=disty2;
1163 
1164  tranx=p.x()-fTthetaCphi*p.z()-fTalpha*trany;
1165  cosx=1.0/std::sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
1166  distx1=(fDx-tranx)*cosx;
1167  distx2=(fDx+tranx)*cosx;
1168 
1169  if (distx1<safe) safe=distx1;
1170  if (distx2<safe) safe=distx2;
1171 
1172  if (safe<0) safe=0;
1173  return safe;
1174 }
EInside Inside(const G4ThreeVector &p) const
Definition: G4Para.cc:441
double x() const
int G4int
Definition: G4Types.hh:78
double z() const
void DumpInfo() const
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double y() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4Para::GetCubicVolume ( )
inlinevirtual

Reimplemented from G4VSolid.

G4GeometryType G4Para::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 1233 of file G4Para.cc.

1234 {
1235  return G4String("G4Para");
1236 }
G4ThreeVector G4Para::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1328 of file G4Para.cc.

References G4INCL::DeJongSpin::shoot().

1329 {
1330  G4ThreeVector One, Two, Three, Four, Five, Six;
1331  G4ThreeVector pt[8] ;
1332  G4double chose, aOne, aTwo, aThree, aFour, aFive, aSix;
1333 
1334  pt[0] = G4ThreeVector(-fDz*fTthetaCphi-fDy*fTalpha-fDx,
1335  -fDz*fTthetaSphi-fDy, -fDz);
1336  pt[1] = G4ThreeVector(-fDz*fTthetaCphi-fDy*fTalpha+fDx,
1337  -fDz*fTthetaSphi-fDy, -fDz);
1338  pt[2] = G4ThreeVector(-fDz*fTthetaCphi+fDy*fTalpha-fDx,
1339  -fDz*fTthetaSphi+fDy, -fDz);
1340  pt[3] = G4ThreeVector(-fDz*fTthetaCphi+fDy*fTalpha+fDx,
1341  -fDz*fTthetaSphi+fDy, -fDz);
1342  pt[4] = G4ThreeVector(+fDz*fTthetaCphi-fDy*fTalpha-fDx,
1343  +fDz*fTthetaSphi-fDy, +fDz);
1344  pt[5] = G4ThreeVector(+fDz*fTthetaCphi-fDy*fTalpha+fDx,
1345  +fDz*fTthetaSphi-fDy, +fDz);
1346  pt[6] = G4ThreeVector(+fDz*fTthetaCphi+fDy*fTalpha-fDx,
1347  +fDz*fTthetaSphi+fDy, +fDz);
1348  pt[7] = G4ThreeVector(+fDz*fTthetaCphi+fDy*fTalpha+fDx,
1349  +fDz*fTthetaSphi+fDy, +fDz);
1350 
1351  // make sure we provide the points in a clockwise fashion
1352 
1353  One = GetPointOnPlane(pt[0],pt[1],pt[3],pt[2], aOne);
1354  Two = GetPointOnPlane(pt[4],pt[5],pt[7],pt[6], aTwo);
1355  Three = GetPointOnPlane(pt[6],pt[7],pt[3],pt[2], aThree);
1356  Four = GetPointOnPlane(pt[4],pt[5],pt[1],pt[0], aFour);
1357  Five = GetPointOnPlane(pt[0],pt[2],pt[6],pt[4], aFive);
1358  Six = GetPointOnPlane(pt[1],pt[3],pt[7],pt[5], aSix);
1359 
1360  chose = RandFlat::shoot(0.,aOne+aTwo+aThree+aFour+aFive+aSix);
1361 
1362  if( (chose>=0.) && (chose<aOne) )
1363  { return One; }
1364  else if(chose>=aOne && chose<aOne+aTwo)
1365  { return Two; }
1366  else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
1367  { return Three; }
1368  else if(chose>=aOne+aTwo+aThree && chose<aOne+aTwo+aThree+aFour)
1369  { return Four; }
1370  else if(chose>=aOne+aTwo+aThree+aFour && chose<aOne+aTwo+aThree+aFour+aFive)
1371  { return Five; }
1372  return Six;
1373 }
ThreeVector shoot(const G4int Ap, const G4int Af)
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:76
G4double G4Para::GetSurfaceArea ( )
inlinevirtual

Reimplemented from G4VSolid.

G4ThreeVector G4Para::GetSymAxis ( ) const
inline
G4double G4Para::GetTanAlpha ( ) const
inline
G4double G4Para::GetXHalfLength ( ) const
inline
G4double G4Para::GetYHalfLength ( ) const
inline
G4double G4Para::GetZHalfLength ( ) const
inline
EInside G4Para::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 441 of file G4Para.cc.

References G4VSolid::kCarTolerance, kInside, kOutside, kSurface, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by CalculateExtent(), and DistanceToOut().

442 {
443  G4double xt, yt, yt1;
444  EInside in = kOutside;
445 
446  yt1 = p.y() - fTthetaSphi*p.z();
447  yt = std::fabs(yt1) ;
448 
449  // xt = std::fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt );
450 
451  xt = std::fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt1 );
452 
453  if ( std::fabs( p.z() ) <= fDz - kCarTolerance*0.5)
454  {
455  if (yt <= fDy - kCarTolerance*0.5)
456  {
457  if ( xt <= fDx - kCarTolerance*0.5 ) in = kInside;
458  else if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
459  }
460  else if ( yt <= fDy + kCarTolerance*0.5)
461  {
462  if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
463  }
464  }
465  else if ( std::fabs(p.z()) <= fDz + kCarTolerance*0.5 )
466  {
467  if ( yt <= fDy + kCarTolerance*0.5)
468  {
469  if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
470  }
471  }
472  return in;
473 }
double x() const
double z() const
EInside
Definition: geomdefs.hh:58
double y() const
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
G4Para & G4Para::operator= ( const G4Para rhs)

Definition at line 185 of file G4Para.cc.

References G4CSGSolid::operator=().

186 {
187  // Check assignment to self
188  //
189  if (this == &rhs) { return *this; }
190 
191  // Copy base class data
192  //
194 
195  // Copy data
196  //
197  fDx = rhs.fDx; fDy = rhs.fDy; fDz = rhs.fDz;
198  fTalpha = rhs.fTalpha; fTthetaCphi = rhs.fTthetaCphi;
199  fTthetaSphi = rhs.fTthetaSphi;
200 
201  return *this;
202 }
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:82
void G4Para::SetAllParameters ( G4double  pDx,
G4double  pDy,
G4double  pDz,
G4double  pAlpha,
G4double  pTheta,
G4double  pPhi 
)

Definition at line 71 of file G4Para.cc.

References FatalException, G4endl, and G4Exception().

Referenced by G4ParameterisationParaX::ComputeDimensions(), G4ParameterisationParaY::ComputeDimensions(), G4ParameterisationParaZ::ComputeDimensions(), export_G4Para(), and G4Para().

73 {
74  if ( pDx > 0 && pDy > 0 && pDz > 0 )
75  {
76  fDx = pDx;
77  fDy = pDy;
78  fDz = pDz;
79  fTalpha = std::tan(pAlpha);
80  fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
81  fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
82  }
83  else
84  {
85  std::ostringstream message;
86  message << "Invalid Length Parameters for Solid: " << GetName() << G4endl
87  << " pDx, pDy, pDz = "
88  << pDx << ", " << pDy << ", " << pDz;
89  G4Exception("G4Para::SetAllParameters()", "GeomSolids0002",
90  FatalException, message);
91  }
92  fCubicVolume = 0.;
93  fSurfaceArea = 0.;
94  fpPolyhedron = 0;
95 }
G4String GetName() const
G4double fCubicVolume
Definition: G4CSGSolid.hh:78
G4double fSurfaceArea
Definition: G4CSGSolid.hh:79
G4Polyhedron * fpPolyhedron
Definition: G4CSGSolid.hh:80
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void G4Para::SetAlpha ( G4double  alpha)
inline

Referenced by export_G4Para().

void G4Para::SetTanAlpha ( G4double  val)
inline

Referenced by export_G4Para().

void G4Para::SetThetaAndPhi ( double  pTheta,
double  pPhi 
)
inline

Referenced by export_G4Para().

void G4Para::SetXHalfLength ( G4double  val)
inline

Referenced by export_G4Para().

void G4Para::SetYHalfLength ( G4double  val)
inline

Referenced by export_G4Para().

void G4Para::SetZHalfLength ( G4double  val)
inline

Referenced by export_G4Para().

std::ostream & G4Para::StreamInfo ( std::ostream &  os) const
virtual

Reimplemented from G4CSGSolid.

Definition at line 1251 of file G4Para.cc.

References python.hepunit::degree, G4VSolid::GetName(), and python.hepunit::mm.

1252 {
1253  G4int oldprc = os.precision(16);
1254  os << "-----------------------------------------------------------\n"
1255  << " *** Dump for solid - " << GetName() << " ***\n"
1256  << " ===================================================\n"
1257  << " Solid type: G4Para\n"
1258  << " Parameters: \n"
1259  << " half length X: " << fDx/mm << " mm \n"
1260  << " half length Y: " << fDy/mm << " mm \n"
1261  << " half length Z: " << fDz/mm << " mm \n"
1262  << " std::tan(alpha) : " << fTalpha/degree << " degrees \n"
1263  << " std::tan(theta)*std::cos(phi): " << fTthetaCphi/degree
1264  << " degrees \n"
1265  << " std::tan(theta)*std::sin(phi): " << fTthetaSphi/degree
1266  << " degrees \n"
1267  << "-----------------------------------------------------------\n";
1268  os.precision(oldprc);
1269 
1270  return os;
1271 }
G4String GetName() const
int G4int
Definition: G4Types.hh:78
tuple degree
Definition: hepunit.py:69
G4ThreeVector G4Para::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 480 of file G4Para.cc.

References G4Exception(), JustWarning, G4VSolid::kCarTolerance, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

481 {
482  G4ThreeVector norm, sumnorm(0.,0.,0.);
483  G4int noSurfaces = 0;
484  G4double distx,disty,distz;
485  G4double newpx,newpy,xshift;
486  G4double calpha,salpha; // Sin/Cos(alpha) - needed to recalc G4Parameter
487  G4double tntheta,cosntheta; // tan and cos of normal's theta component
488  G4double ycomp;
489  G4double delta = 0.5*kCarTolerance;
490 
491  newpx = p.x()-fTthetaCphi*p.z();
492  newpy = p.y()-fTthetaSphi*p.z();
493 
494  calpha = 1/std::sqrt(1+fTalpha*fTalpha);
495  if (fTalpha) {salpha = -calpha*fTalpha;} // NOTE: using MINUS std::sin(alpha)
496  else {salpha = 0.;}
497 
498  // xshift = newpx*calpha+newpy*salpha;
499  xshift = newpx - newpy*fTalpha;
500 
501  // distx = std::fabs(std::fabs(xshift)-fDx*calpha);
502  distx = std::fabs(std::fabs(xshift)-fDx);
503  disty = std::fabs(std::fabs(newpy)-fDy);
504  distz = std::fabs(std::fabs(p.z())-fDz);
505 
506  tntheta = fTthetaCphi*calpha + fTthetaSphi*salpha;
507  cosntheta = 1/std::sqrt(1+tntheta*tntheta);
508  ycomp = 1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
509 
510  G4ThreeVector nX = G4ThreeVector( calpha*cosntheta,
511  salpha*cosntheta,
512  -tntheta*cosntheta);
513  G4ThreeVector nY = G4ThreeVector( 0, ycomp,-fTthetaSphi*ycomp);
514  G4ThreeVector nZ = G4ThreeVector( 0, 0, 1.0);
515 
516  if (distx <= delta)
517  {
518  noSurfaces ++;
519  if ( xshift >= 0.) {sumnorm += nX;}
520  else {sumnorm -= nX;}
521  }
522  if (disty <= delta)
523  {
524  noSurfaces ++;
525  if ( newpy >= 0.) {sumnorm += nY;}
526  else {sumnorm -= nY;}
527  }
528  if (distz <= delta)
529  {
530  noSurfaces ++;
531  if ( p.z() >= 0.) {sumnorm += nZ;}
532  else {sumnorm -= nZ;}
533  }
534  if ( noSurfaces == 0 )
535  {
536 #ifdef G4CSGDEBUG
537  G4Exception("G4Para::SurfaceNormal(p)", "GeomSolids1002",
538  JustWarning, "Point p is not on surface !?" );
539 #endif
540  norm = ApproxSurfaceNormal(p);
541  }
542  else if ( noSurfaces == 1 ) {norm = sumnorm;}
543  else {norm = sumnorm.unit();}
544 
545  return norm;
546 }
CLHEP::Hep3Vector G4ThreeVector
double x() const
int G4int
Definition: G4Types.hh:78
double z() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Hep3Vector unit() const
double y() const
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76

The documentation for this class was generated from the following files: