Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Para Class Reference

#include <G4Para.hh>

Inheritance diagram for G4Para:
Collaboration diagram for G4Para:

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)
 
void Extent (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
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)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

Additional Inherited Members

- 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
 
- Protected Attributes inherited from G4CSGSolid
G4double fCubicVolume
 
G4double fSurfaceArea
 
G4bool fRebuildPolyhedron
 
G4PolyhedronfpPolyhedron
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 77 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 102 of file G4Para.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4Para::G4Para ( const G4String pName,
const G4ThreeVector  pt[8] 
)

Definition at line 125 of file G4Para.cc.

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

Here is the call graph for this function:

G4Para::~G4Para ( )
virtual

Definition at line 167 of file G4Para.cc.

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

Definition at line 158 of file G4Para.cc.

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

Definition at line 175 of file G4Para.cc.

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

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 263 of file G4Para.cc.

267 {
268  G4ThreeVector bmin, bmax;
269  G4bool exist;
270 
271  // Check bounding box (bbox)
272  //
273  Extent(bmin,bmax);
274  G4BoundingEnvelope bbox(bmin,bmax);
275 #ifdef G4BBOX_EXTENT
276  if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
277 #endif
278  if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
279  {
280  return exist = (pMin < pMax) ? true : false;
281  }
282 
283  // Set bounding envelope (benv) and calculate extent
284  //
285  G4double dz = GetZHalfLength();
286  G4double dx = GetXHalfLength();
287  G4double dy = GetYHalfLength();
288 
289  G4double x0 = dz*fTthetaCphi;
290  G4double x1 = dy*GetTanAlpha();
291  G4double y0 = dz*fTthetaSphi;
292 
293  G4ThreeVectorList baseA(4), baseB(4);
294  baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
295  baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
296  baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
297  baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
298 
299  baseB[0].set(+x0-x1-dx, y0-dy, dz);
300  baseB[1].set(+x0-x1+dx, y0-dy, dz);
301  baseB[2].set(+x0+x1+dx, y0+dy, dz);
302  baseB[3].set(+x0+x1-dx, y0+dy, dz);
303 
304  std::vector<const G4ThreeVectorList *> polygons(2);
305  polygons[0] = &baseA;
306  polygons[1] = &baseB;
307 
308  G4BoundingEnvelope benv(bmin,bmax,polygons);
309  exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
310  return exist;
311 }
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
G4double GetXHalfLength() const
G4double GetTanAlpha() const
G4double GetZHalfLength() const
double G4double
Definition: G4Types.hh:76
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Para.cc:221
G4double GetYHalfLength() const

Here is the call graph for this function:

G4VSolid * G4Para::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1029 of file G4Para.cc.

1030 {
1031  return new G4Para(*this);
1032 }
G4Para(const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
Definition: G4Para.cc:102

Here is the call graph for this function:

void G4Para::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 210 of file G4Para.cc.

213 {
214  p->ComputeDimensions(*this,n,pRep);
215 }
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const

Here is the call graph for this function:

G4Polyhedron * G4Para::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1171 of file G4Para.cc.

1172 {
1173  G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
1174  G4double alpha = std::atan(fTalpha);
1175  G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
1176  +fTthetaSphi*fTthetaSphi));
1177 
1178  return new G4PolyhedronPara(fDx, fDy, fDz, alpha, theta, phi);
1179 }
double G4double
Definition: G4Types.hh:76
static const G4double alpha
void G4Para::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 1166 of file G4Para.cc.

1167 {
1168  scene.AddSolid (*this);
1169 }
virtual void AddSolid(const G4Box &)=0

Here is the call graph for this function:

G4double G4Para::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 517 of file G4Para.cc.

519 {
520  G4double snxt; // snxt = default return value
521  G4double smin,smax;
522  G4double tmin,tmax;
523  G4double yt,vy,xt,vx;
524  G4double max;
525  //
526  // Z Intersection range
527  //
528  if (v.z()>0)
529  {
530  max=fDz-p.z();
531  if (max>kCarTolerance*0.5)
532  {
533  smax=max/v.z();
534  smin=(-fDz-p.z())/v.z();
535  }
536  else
537  {
538  return snxt=kInfinity;
539  }
540  }
541  else if (v.z()<0)
542  {
543  max=-fDz-p.z();
544  if (max<-kCarTolerance*0.5)
545  {
546  smax=max/v.z();
547  smin=(fDz-p.z())/v.z();
548  }
549  else
550  {
551  return snxt=kInfinity;
552  }
553  }
554  else
555  {
556  if (std::fabs(p.z())<=fDz) // Inside
557  {
558  smin=0;
559  smax=kInfinity;
560  }
561  else
562  {
563  return snxt=kInfinity;
564  }
565  }
566 
567  //
568  // Y G4Parallel planes intersection
569  //
570 
571  yt=p.y()-fTthetaSphi*p.z();
572  vy=v.y()-fTthetaSphi*v.z();
573 
574  if (vy>0)
575  {
576  max=fDy-yt;
577  if (max>kCarTolerance*0.5)
578  {
579  tmax=max/vy;
580  tmin=(-fDy-yt)/vy;
581  }
582  else
583  {
584  return snxt=kInfinity;
585  }
586  }
587  else if (vy<0)
588  {
589  max=-fDy-yt;
590  if (max<-kCarTolerance*0.5)
591  {
592  tmax=max/vy;
593  tmin=(fDy-yt)/vy;
594  }
595  else
596  {
597  return snxt=kInfinity;
598  }
599  }
600  else
601  {
602  if (std::fabs(yt)<=fDy)
603  {
604  tmin=0;
605  tmax=kInfinity;
606  }
607  else
608  {
609  return snxt=kInfinity;
610  }
611  }
612 
613  // Re-Calc valid intersection range
614  //
615  if (tmin>smin) smin=tmin;
616  if (tmax<smax) smax=tmax;
617  if (smax<=smin)
618  {
619  return snxt=kInfinity;
620  }
621  else
622  {
623  //
624  // X G4Parallel planes intersection
625  //
626  xt=p.x()-fTthetaCphi*p.z()-fTalpha*yt;
627  vx=v.x()-fTthetaCphi*v.z()-fTalpha*vy;
628  if (vx>0)
629  {
630  max=fDx-xt;
631  if (max>kCarTolerance*0.5)
632  {
633  tmax=max/vx;
634  tmin=(-fDx-xt)/vx;
635  }
636  else
637  {
638  return snxt=kInfinity;
639  }
640  }
641  else if (vx<0)
642  {
643  max=-fDx-xt;
644  if (max<-kCarTolerance*0.5)
645  {
646  tmax=max/vx;
647  tmin=(fDx-xt)/vx;
648  }
649  else
650  {
651  return snxt=kInfinity;
652  }
653  }
654  else
655  {
656  if (std::fabs(xt)<=fDx)
657  {
658  tmin=0;
659  tmax=kInfinity;
660  }
661  else
662  {
663  return snxt=kInfinity;
664  }
665  }
666  if (tmin>smin) smin=tmin;
667  if (tmax<smax) smax=tmax;
668  }
669 
670  if (smax>0&&smin<smax)
671  {
672  if (smin>0)
673  {
674  snxt=smin;
675  }
676  else
677  {
678  snxt=0;
679  }
680  }
681  else
682  {
683  snxt=kInfinity;
684  }
685  return snxt;
686 }
static const G4double kInfinity
Definition: geomdefs.hh:42
double x() const
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:307
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double G4Para::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 693 of file G4Para.cc.

694 {
695  G4double safe=0.0;
696  G4double distz1,distz2,disty1,disty2,distx1,distx2;
697  G4double trany,cosy,tranx,cosx;
698 
699  // Z planes
700  //
701  distz1=p.z()-fDz;
702  distz2=-fDz-p.z();
703  if (distz1>distz2)
704  {
705  safe=distz1;
706  }
707  else
708  {
709  safe=distz2;
710  }
711 
712  trany=p.y()-fTthetaSphi*p.z(); // Transformed y into `box' system
713 
714  // Transformed x into `box' system
715  //
716  cosy=1.0/std::sqrt(1.0+fTthetaSphi*fTthetaSphi);
717  disty1=(trany-fDy)*cosy;
718  disty2=(-fDy-trany)*cosy;
719 
720  if (disty1>safe) safe=disty1;
721  if (disty2>safe) safe=disty2;
722 
723  tranx=p.x()-fTthetaCphi*p.z()-fTalpha*trany;
724  cosx=1.0/std::sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
725  distx1=(tranx-fDx)*cosx;
726  distx2=(-fDx-tranx)*cosx;
727 
728  if (distx1>safe) safe=distx1;
729  if (distx2>safe) safe=distx2;
730 
731  if (safe<0) safe=0;
732  return safe;
733 }
double x() const
double z() const
double y() const
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

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 740 of file G4Para.cc.

743 {
744  ESide side = kUndef;
745  G4double snxt; // snxt = return value
746  G4double max,tmax;
747  G4double yt,vy,xt,vx;
748 
749  G4double ycomp,calpha,salpha,tntheta,cosntheta;
750 
751  //
752  // Z Intersections
753  //
754 
755  if (v.z()>0)
756  {
757  max=fDz-p.z();
758  if (max>kCarTolerance*0.5)
759  {
760  snxt=max/v.z();
761  side=kPZ;
762  }
763  else
764  {
765  if (calcNorm)
766  {
767  *validNorm=true;
768  *n=G4ThreeVector(0,0,1);
769  }
770  return snxt=0;
771  }
772  }
773  else if (v.z()<0)
774  {
775  max=-fDz-p.z();
776  if (max<-kCarTolerance*0.5)
777  {
778  snxt=max/v.z();
779  side=kMZ;
780  }
781  else
782  {
783  if (calcNorm)
784  {
785  *validNorm=true;
786  *n=G4ThreeVector(0,0,-1);
787  }
788  return snxt=0;
789  }
790  }
791  else
792  {
793  snxt=kInfinity;
794  }
795 
796  //
797  // Y plane intersection
798  //
799 
800  yt=p.y()-fTthetaSphi*p.z();
801  vy=v.y()-fTthetaSphi*v.z();
802 
803  if (vy>0)
804  {
805  max=fDy-yt;
806  if (max>kCarTolerance*0.5)
807  {
808  tmax=max/vy;
809  if (tmax<snxt)
810  {
811  snxt=tmax;
812  side=kPY;
813  }
814  }
815  else
816  {
817  if (calcNorm)
818  {
819  *validNorm=true; // Leaving via plus Y
820  ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
821  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
822  }
823  return snxt=0;
824  }
825  }
826  else if (vy<0)
827  {
828  max=-fDy-yt;
829  if (max<-kCarTolerance*0.5)
830  {
831  tmax=max/vy;
832  if (tmax<snxt)
833  {
834  snxt=tmax;
835  side=kMY;
836  }
837  }
838  else
839  {
840  if (calcNorm)
841  {
842  *validNorm=true; // Leaving via minus Y
843  ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
844  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
845  }
846  return snxt=0;
847  }
848  }
849 
850  //
851  // X plane intersection
852  //
853 
854  xt=p.x()-fTthetaCphi*p.z()-fTalpha*yt;
855  vx=v.x()-fTthetaCphi*v.z()-fTalpha*vy;
856  if (vx>0)
857  {
858  max=fDx-xt;
859  if (max>kCarTolerance*0.5)
860  {
861  tmax=max/vx;
862  if (tmax<snxt)
863  {
864  snxt=tmax;
865  side=kPX;
866  }
867  }
868  else
869  {
870  if (calcNorm)
871  {
872  *validNorm=true; // Leaving via plus X
873  calpha=1/std::sqrt(1+fTalpha*fTalpha);
874  salpha=-calpha*fTalpha; // NOTE: actually use MINUS std::sin(alpha)
875  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
876  cosntheta=1/std::sqrt(1+tntheta*tntheta);
877  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
878  }
879  return snxt=0;
880  }
881  }
882  else if (vx<0)
883  {
884  max=-fDx-xt;
885  if (max<-kCarTolerance*0.5)
886  {
887  tmax=max/vx;
888  if (tmax<snxt)
889  {
890  snxt=tmax;
891  side=kMX;
892  }
893  }
894  else
895  {
896  if (calcNorm)
897  {
898  *validNorm=true; // Leaving via minus X
899  calpha=1/std::sqrt(1+fTalpha*fTalpha);
900  salpha=-calpha*fTalpha; // NOTE: actually use MINUS std::sin(alpha)
901  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
902  cosntheta=-1/std::sqrt(1+tntheta*tntheta);
903  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
904  }
905  return snxt=0;
906  }
907  }
908 
909  if (calcNorm)
910  {
911  *validNorm=true;
912  switch (side)
913  {
914  case kMZ:
915  *n=G4ThreeVector(0,0,-1);
916  break;
917  case kPZ:
918  *n=G4ThreeVector(0,0,1);
919  break;
920  case kMY:
921  ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
922  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
923  break;
924  case kPY:
925  ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
926  *n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
927  break;
928  case kMX:
929  calpha=1/std::sqrt(1+fTalpha*fTalpha);
930  salpha=-calpha*fTalpha; // NOTE: actually use MINUS std::sin(alpha)
931  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
932  cosntheta=-1/std::sqrt(1+tntheta*tntheta);
933  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
934  break;
935  case kPX:
936  calpha=1/std::sqrt(1+fTalpha*fTalpha);
937  salpha=-calpha*fTalpha; // NOTE: actually use MINUS std::sin(alpha)
938  tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
939  cosntheta=1/std::sqrt(1+tntheta*tntheta);
940  *n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
941  break;
942  default:
943  DumpInfo();
944  G4Exception("G4Para::DistanceToOut(p,v,..)",
945  "GeomSolids1002",JustWarning,
946  "Undefined side for valid surface normal to solid.");
947  break;
948  }
949  }
950  return snxt;
951 }
Definition: G4Para.cc:64
Definition: G4Cons.cc:76
static const G4double kInfinity
Definition: geomdefs.hh:42
CLHEP::Hep3Vector G4ThreeVector
double x() const
Definition: G4Para.cc:64
double z() const
void DumpInfo() const
Definition: G4Para.cc:64
Definition: G4Para.cc:64
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double y() const
Definition: G4Cons.cc:76
G4double kCarTolerance
Definition: G4VSolid.hh:307
ESide
Definition: G4Cons.cc:76
double G4double
Definition: G4Types.hh:76
Definition: G4Para.cc:64

Here is the call graph for this function:

G4double G4Para::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 958 of file G4Para.cc.

959 {
960  G4double safe=0.0;
961  G4double distz1,distz2,disty1,disty2,distx1,distx2;
962  G4double trany,cosy,tranx,cosx;
963 
964 #ifdef G4CSGDEBUG
965  if( Inside(p) == kOutside )
966  {
967  G4int oldprc = G4cout.precision(16) ;
968  G4cout << G4endl ;
969  DumpInfo();
970  G4cout << "Position:" << G4endl << G4endl ;
971  G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
972  G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
973  G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
974  G4cout.precision(oldprc) ;
975  G4Exception("G4Para::DistanceToOut(p)", "GeomSolids1002",
976  JustWarning, "Point p is outside !?" );
977  }
978 #endif
979 
980  // Z planes
981  //
982  distz1=fDz-p.z();
983  distz2=fDz+p.z();
984  if (distz1<distz2)
985  {
986  safe=distz1;
987  }
988  else
989  {
990  safe=distz2;
991  }
992 
993  trany=p.y()-fTthetaSphi*p.z(); // Transformed y into `box' system
994 
995  // Transformed x into `box' system
996  //
997  cosy=1.0/std::sqrt(1.0+fTthetaSphi*fTthetaSphi);
998  disty1=(fDy-trany)*cosy;
999  disty2=(fDy+trany)*cosy;
1000 
1001  if (disty1<safe) safe=disty1;
1002  if (disty2<safe) safe=disty2;
1003 
1004  tranx=p.x()-fTthetaCphi*p.z()-fTalpha*trany;
1005  cosx=1.0/std::sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
1006  distx1=(fDx-tranx)*cosx;
1007  distx2=(fDx+tranx)*cosx;
1008 
1009  if (distx1<safe) safe=distx1;
1010  if (distx2<safe) safe=distx2;
1011 
1012  if (safe<0) safe=0;
1013  return safe;
1014 }
EInside Inside(const G4ThreeVector &p) const
Definition: G4Para.cc:317
static constexpr double mm
Definition: G4SIunits.hh:115
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

Here is the call graph for this function:

void G4Para::Extent ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 221 of file G4Para.cc.

222 {
223  G4double dz = GetZHalfLength();
224  G4double dx = GetXHalfLength();
225  G4double dy = GetYHalfLength();
226 
227  G4double x0 = dz*fTthetaCphi;
228  G4double x1 = dy*GetTanAlpha();
229  G4double xmin =
230  std::min(
231  std::min(
232  std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
233  G4double xmax =
234  std::max(
235  std::max(
236  std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
237 
238  G4double y0 = dz*fTthetaSphi;
239  G4double ymin = std::min(-y0-dy,y0-dy);
240  G4double ymax = std::max(-y0+dy,y0+dy);
241 
242  pMin.set(xmin,ymin,-dz);
243  pMax.set(xmax,ymax, dz);
244 
245  // Check correctness of the bounding box
246  //
247  if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
248  {
249  std::ostringstream message;
250  message << "Bad bounding box (min >= max) for solid: "
251  << GetName() << " !"
252  << "\npMin = " << pMin
253  << "\npMax = " << pMax;
254  G4Exception("G4Para::Extent()", "GeomMgt0001", JustWarning, message);
255  DumpInfo();
256  }
257 }
void set(double x, double y, double z)
G4String GetName() const
double x() const
double z() const
void DumpInfo() const
G4double GetXHalfLength() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double GetTanAlpha() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
double y() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double GetZHalfLength() const
double G4double
Definition: G4Types.hh:76
G4double GetYHalfLength() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4Para::GetCubicVolume ( )
inlinevirtual

Reimplemented from G4VSolid.

G4GeometryType G4Para::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 1020 of file G4Para.cc.

1021 {
1022  return G4String("G4Para");
1023 }
G4ThreeVector G4Para::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1115 of file G4Para.cc.

1116 {
1117  G4ThreeVector One, Two, Three, Four, Five, Six;
1118  G4ThreeVector pt[8] ;
1119  G4double chose, aOne, aTwo, aThree, aFour, aFive, aSix;
1120 
1121  pt[0] = G4ThreeVector(-fDz*fTthetaCphi-fDy*fTalpha-fDx,
1122  -fDz*fTthetaSphi-fDy, -fDz);
1123  pt[1] = G4ThreeVector(-fDz*fTthetaCphi-fDy*fTalpha+fDx,
1124  -fDz*fTthetaSphi-fDy, -fDz);
1125  pt[2] = G4ThreeVector(-fDz*fTthetaCphi+fDy*fTalpha-fDx,
1126  -fDz*fTthetaSphi+fDy, -fDz);
1127  pt[3] = G4ThreeVector(-fDz*fTthetaCphi+fDy*fTalpha+fDx,
1128  -fDz*fTthetaSphi+fDy, -fDz);
1129  pt[4] = G4ThreeVector(+fDz*fTthetaCphi-fDy*fTalpha-fDx,
1130  +fDz*fTthetaSphi-fDy, +fDz);
1131  pt[5] = G4ThreeVector(+fDz*fTthetaCphi-fDy*fTalpha+fDx,
1132  +fDz*fTthetaSphi-fDy, +fDz);
1133  pt[6] = G4ThreeVector(+fDz*fTthetaCphi+fDy*fTalpha-fDx,
1134  +fDz*fTthetaSphi+fDy, +fDz);
1135  pt[7] = G4ThreeVector(+fDz*fTthetaCphi+fDy*fTalpha+fDx,
1136  +fDz*fTthetaSphi+fDy, +fDz);
1137 
1138  // make sure we provide the points in a clockwise fashion
1139 
1140  One = GetPointOnPlane(pt[0],pt[1],pt[3],pt[2], aOne);
1141  Two = GetPointOnPlane(pt[4],pt[5],pt[7],pt[6], aTwo);
1142  Three = GetPointOnPlane(pt[6],pt[7],pt[3],pt[2], aThree);
1143  Four = GetPointOnPlane(pt[4],pt[5],pt[1],pt[0], aFour);
1144  Five = GetPointOnPlane(pt[0],pt[2],pt[6],pt[4], aFive);
1145  Six = GetPointOnPlane(pt[1],pt[3],pt[7],pt[5], aSix);
1146 
1147  chose = G4RandFlat::shoot(0.,aOne+aTwo+aThree+aFour+aFive+aSix);
1148 
1149  if( (chose>=0.) && (chose<aOne) )
1150  { return One; }
1151  else if(chose>=aOne && chose<aOne+aTwo)
1152  { return Two; }
1153  else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
1154  { return Three; }
1155  else if(chose>=aOne+aTwo+aThree && chose<aOne+aTwo+aThree+aFour)
1156  { return Four; }
1157  else if(chose>=aOne+aTwo+aThree+aFour && chose<aOne+aTwo+aThree+aFour+aFive)
1158  { return Five; }
1159  return Six;
1160 }
ThreeVector shoot(const G4int Ap, const G4int Af)
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double G4Para::GetSurfaceArea ( )
inlinevirtual

Reimplemented from G4VSolid.

G4ThreeVector G4Para::GetSymAxis ( ) const
inline

Here is the caller graph for this function:

G4double G4Para::GetTanAlpha ( ) const
inline

Here is the caller graph for this function:

G4double G4Para::GetXHalfLength ( ) const
inline

Here is the caller graph for this function:

G4double G4Para::GetYHalfLength ( ) const
inline

Here is the caller graph for this function:

G4double G4Para::GetZHalfLength ( ) const
inline

Here is the caller graph for this function:

EInside G4Para::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 317 of file G4Para.cc.

318 {
319  G4double xt, yt, yt1;
320  EInside in = kOutside;
321 
322  yt1 = p.y() - fTthetaSphi*p.z();
323  yt = std::fabs(yt1) ;
324 
325  // xt = std::fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt );
326 
327  xt = std::fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt1 );
328 
329  if ( std::fabs( p.z() ) <= fDz - kCarTolerance*0.5)
330  {
331  if (yt <= fDy - kCarTolerance*0.5)
332  {
333  if ( xt <= fDx - kCarTolerance*0.5 ) in = kInside;
334  else if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
335  }
336  else if ( yt <= fDy + kCarTolerance*0.5)
337  {
338  if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
339  }
340  }
341  else if ( std::fabs(p.z()) <= fDz + kCarTolerance*0.5 )
342  {
343  if ( yt <= fDy + kCarTolerance*0.5)
344  {
345  if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
346  }
347  }
348  return in;
349 }
double x() const
double z() const
EInside
Definition: geomdefs.hh:58
double y() const
G4double kCarTolerance
Definition: G4VSolid.hh:307
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4Para & G4Para::operator= ( const G4Para rhs)

Definition at line 186 of file G4Para.cc.

187 {
188  // Check assignment to self
189  //
190  if (this == &rhs) { return *this; }
191 
192  // Copy base class data
193  //
195 
196  // Copy data
197  //
198  fDx = rhs.fDx; fDy = rhs.fDy; fDz = rhs.fDz;
199  fTalpha = rhs.fTalpha; fTthetaCphi = rhs.fTthetaCphi;
200  fTthetaSphi = rhs.fTthetaSphi;
201 
202  return *this;
203 }
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:91

Here is the call graph for this function:

void G4Para::SetAllParameters ( G4double  pDx,
G4double  pDy,
G4double  pDz,
G4double  pAlpha,
G4double  pTheta,
G4double  pPhi 
)

Definition at line 74 of file G4Para.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4Para::SetAlpha ( G4double  alpha)
inline
void G4Para::SetTanAlpha ( G4double  val)
inline
void G4Para::SetThetaAndPhi ( double  pTheta,
double  pPhi 
)
inline
void G4Para::SetXHalfLength ( G4double  val)
inline
void G4Para::SetYHalfLength ( G4double  val)
inline
void G4Para::SetZHalfLength ( G4double  val)
inline
std::ostream & G4Para::StreamInfo ( std::ostream &  os) const
virtual

Reimplemented from G4CSGSolid.

Definition at line 1038 of file G4Para.cc.

1039 {
1040  G4int oldprc = os.precision(16);
1041  os << "-----------------------------------------------------------\n"
1042  << " *** Dump for solid - " << GetName() << " ***\n"
1043  << " ===================================================\n"
1044  << " Solid type: G4Para\n"
1045  << " Parameters: \n"
1046  << " half length X: " << fDx/mm << " mm \n"
1047  << " half length Y: " << fDy/mm << " mm \n"
1048  << " half length Z: " << fDz/mm << " mm \n"
1049  << " std::tan(alpha) : " << fTalpha/degree << " degrees \n"
1050  << " std::tan(theta)*std::cos(phi): " << fTthetaCphi/degree
1051  << " degrees \n"
1052  << " std::tan(theta)*std::sin(phi): " << fTthetaSphi/degree
1053  << " degrees \n"
1054  << "-----------------------------------------------------------\n";
1055  os.precision(oldprc);
1056 
1057  return os;
1058 }
G4String GetName() const
static constexpr double mm
Definition: G4SIunits.hh:115
int G4int
Definition: G4Types.hh:78
static constexpr double degree
Definition: G4SIunits.hh:144

Here is the call graph for this function:

G4ThreeVector G4Para::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 356 of file G4Para.cc.

357 {
358  G4ThreeVector norm, sumnorm(0.,0.,0.);
359  G4int noSurfaces = 0;
360  G4double distx,disty,distz;
361  G4double newpx,newpy,xshift;
362  G4double calpha,salpha; // Sin/Cos(alpha) - needed to recalc G4Parameter
363  G4double tntheta,cosntheta; // tan and cos of normal's theta component
364  G4double ycomp;
365  G4double delta = 0.5*kCarTolerance;
366 
367  newpx = p.x()-fTthetaCphi*p.z();
368  newpy = p.y()-fTthetaSphi*p.z();
369 
370  calpha = 1/std::sqrt(1+fTalpha*fTalpha);
371  salpha = -calpha*fTalpha; // NOTE: using MINUS std::sin(alpha)
372 
373  // xshift = newpx*calpha+newpy*salpha;
374  xshift = newpx - newpy*fTalpha;
375 
376  // distx = std::fabs(std::fabs(xshift)-fDx*calpha);
377  distx = std::fabs(std::fabs(xshift)-fDx);
378  disty = std::fabs(std::fabs(newpy)-fDy);
379  distz = std::fabs(std::fabs(p.z())-fDz);
380 
381  tntheta = fTthetaCphi*calpha + fTthetaSphi*salpha;
382  cosntheta = 1/std::sqrt(1+tntheta*tntheta);
383  ycomp = 1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
384 
385  G4ThreeVector nX = G4ThreeVector( calpha*cosntheta,
386  salpha*cosntheta,
387  -tntheta*cosntheta);
388  G4ThreeVector nY = G4ThreeVector( 0, ycomp,-fTthetaSphi*ycomp);
389  G4ThreeVector nZ = G4ThreeVector( 0, 0, 1.0);
390 
391  if (distx <= delta)
392  {
393  noSurfaces ++;
394  if ( xshift >= 0.) {sumnorm += nX;}
395  else {sumnorm -= nX;}
396  }
397  if (disty <= delta)
398  {
399  noSurfaces ++;
400  if ( newpy >= 0.) {sumnorm += nY;}
401  else {sumnorm -= nY;}
402  }
403  if (distz <= delta)
404  {
405  noSurfaces ++;
406  if ( p.z() >= 0.) {sumnorm += nZ;}
407  else {sumnorm -= nZ;}
408  }
409  if ( noSurfaces == 0 )
410  {
411 #ifdef G4CSGDEBUG
412  G4Exception("G4Para::SurfaceNormal(p)", "GeomSolids1002",
413  JustWarning, "Point p is not on surface !?" );
414 #endif
415  norm = ApproxSurfaceNormal(p);
416  }
417  else if ( noSurfaces == 1 ) {norm = sumnorm;}
418  else {norm = sumnorm.unit();}
419 
420  return norm;
421 }
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:307
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:


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