Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ErrorCylSurfaceTarget Class Reference

#include <G4ErrorCylSurfaceTarget.hh>

+ Inheritance diagram for G4ErrorCylSurfaceTarget:

Public Member Functions

 G4ErrorCylSurfaceTarget (const G4double &radius, const G4ThreeVector &trans=G4ThreeVector(), const G4RotationMatrix &rotm=G4RotationMatrix())
 
 G4ErrorCylSurfaceTarget (const G4double &radius, const G4AffineTransform &trans)
 
 ~G4ErrorCylSurfaceTarget ()=default
 
virtual G4ThreeVector IntersectLocal (const G4ThreeVector &point, const G4ThreeVector &direc) const
 
virtual G4double GetDistanceFromPoint (const G4ThreeVector &point, const G4ThreeVector &direc) const
 
virtual G4double GetDistanceFromPoint (const G4ThreeVector &point) const
 
virtual G4Plane3D GetTangentPlane (const G4ThreeVector &point) const
 
virtual void Dump (const G4String &msg) const
 
- Public Member Functions inherited from G4ErrorSurfaceTarget
 G4ErrorSurfaceTarget ()
 
virtual ~G4ErrorSurfaceTarget ()=default
 
virtual double GetDistanceFromPoint (const G4ThreeVector &point, const G4ThreeVector &direc) const =0
 
virtual double GetDistanceFromPoint (const G4ThreeVector &point) const =0
 
virtual G4Plane3D GetTangentPlane (const G4ThreeVector &point) const =0
 
virtual void Dump (const G4String &msg) const =0
 
- Public Member Functions inherited from G4ErrorTanPlaneTarget
 G4ErrorTanPlaneTarget ()
 
virtual ~G4ErrorTanPlaneTarget ()=default
 
virtual G4Plane3D GetTangentPlane (const G4ThreeVector &point) const =0
 
virtual void Dump (const G4String &msg) const =0
 
- Public Member Functions inherited from G4ErrorTarget
 G4ErrorTarget ()
 
virtual ~G4ErrorTarget ()=default
 
virtual G4double GetDistanceFromPoint (const G4ThreeVector &, const G4ThreeVector &) const
 
virtual G4double GetDistanceFromPoint (const G4ThreeVector &) const
 
virtual G4bool TargetReached (const G4Step *)
 
virtual void Dump (const G4String &msg) const =0
 
G4ErrorTargetType GetType () const
 

Additional Inherited Members

- Protected Attributes inherited from G4ErrorTarget
G4ErrorTargetType theType
 

Detailed Description

Definition at line 44 of file G4ErrorCylSurfaceTarget.hh.

Constructor & Destructor Documentation

◆ G4ErrorCylSurfaceTarget() [1/2]

G4ErrorCylSurfaceTarget::G4ErrorCylSurfaceTarget ( const G4double radius,
const G4ThreeVector trans = G4ThreeVector(),
const G4RotationMatrix rotm = G4RotationMatrix() 
)

Definition at line 44 of file G4ErrorCylSurfaceTarget.cc.

48 : fradius(radius)
49{
51
52 ftransform = G4AffineTransform( rotm.inverse(), -trans );
53#ifdef G4VERBOSE
55 {
56 Dump( " $$$ creating G4ErrorCylSurfaceTarget ");
57 }
58#endif
59}
@ G4ErrorTarget_CylindricalSurface
HepRotation inverse() const
virtual void Dump(const G4String &msg) const
G4ErrorTargetType theType

◆ G4ErrorCylSurfaceTarget() [2/2]

G4ErrorCylSurfaceTarget::G4ErrorCylSurfaceTarget ( const G4double radius,
const G4AffineTransform trans 
)

Definition at line 63 of file G4ErrorCylSurfaceTarget.cc.

66 : fradius(radius), ftransform(trans.Inverse())
67{
69
70#ifdef G4VERBOSE
72 {
73 Dump( " $$$ creating G4ErrorCylSurfaceTarget ");
74 }
75#endif
76}
G4AffineTransform Inverse() const

◆ ~G4ErrorCylSurfaceTarget()

G4ErrorCylSurfaceTarget::~G4ErrorCylSurfaceTarget ( )
default

Member Function Documentation

◆ Dump()

void G4ErrorCylSurfaceTarget::Dump ( const G4String msg) const
virtual

Implements G4ErrorSurfaceTarget.

Definition at line 215 of file G4ErrorCylSurfaceTarget.cc.

216{
217 G4cout << msg << " radius " << fradius
218 << " centre " << ftransform.NetTranslation()
219 << " rotation " << ftransform.NetRotation() << G4endl;
220}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4ThreeVector NetTranslation() const
G4RotationMatrix NetRotation() const

Referenced by G4ErrorCylSurfaceTarget(), GetDistanceFromPoint(), and IntersectLocal().

◆ GetDistanceFromPoint() [1/2]

G4double G4ErrorCylSurfaceTarget::GetDistanceFromPoint ( const G4ThreeVector point) const
virtual

Implements G4ErrorSurfaceTarget.

Definition at line 114 of file G4ErrorCylSurfaceTarget.cc.

116{
117 G4ThreeVector localPoint = ftransform.TransformPoint( point );
118
119#ifdef G4VERBOSE
121 {
122 G4cout << " G4ErrorCylSurfaceTarget::GetDistanceFromPoint:" << G4endl
123 << " Global point " << point << G4endl
124 << " Distance " << fradius - localPoint.perp() << G4endl;
125 Dump( " CylSurface: " );
126 }
127#endif
128
129 return fradius - localPoint.perp();
130}
double perp() const
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const

◆ GetDistanceFromPoint() [2/2]

G4double G4ErrorCylSurfaceTarget::GetDistanceFromPoint ( const G4ThreeVector point,
const G4ThreeVector direc 
) const
virtual

Implements G4ErrorSurfaceTarget.

Definition at line 80 of file G4ErrorCylSurfaceTarget.cc.

83{
84 if( dir.mag() == 0. )
85 {
86 G4Exception("G4ErrorCylSurfaceTarget::GetDistanceFromPoint()",
87 "GeomMgt0003", FatalException, "Direction is zero !");
88 }
89
90 //----- Get intersection point
91 G4ThreeVector localPoint = ftransform.TransformPoint( point );
92 G4ThreeVector localDir = ftransform.TransformAxis( dir );
93 G4ThreeVector inters = IntersectLocal(localPoint, localDir);
94
95 G4double dist = (localPoint-inters).mag();
96
97#ifdef G4VERBOSE
99 {
100 G4cout << " G4ErrorCylSurfaceTarget::GetDistanceFromPoint():" << G4endl
101 << " Global point " << point << " dir " << dir << G4endl
102 << " Intersection " << inters << G4endl
103 << " Distance " << dist << G4endl;
104 Dump( " CylSurface: " );
105 }
106#endif
107
108 return dist;
109}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
virtual G4ThreeVector IntersectLocal(const G4ThreeVector &point, const G4ThreeVector &direc) const

◆ GetTangentPlane()

G4Plane3D G4ErrorCylSurfaceTarget::GetTangentPlane ( const G4ThreeVector point) const
virtual

Implements G4ErrorSurfaceTarget.

Definition at line 187 of file G4ErrorCylSurfaceTarget.cc.

189{
190 G4ThreeVector localPoint = ftransform.TransformPoint( point );
191
192 // check that point is at cylinder surface
193 //
194 if( std::fabs( localPoint.perp() - fradius )
196 {
197 std::ostringstream message;
198 message << "Local point not at surface !" << G4endl
199 << " Point: " << point << ", local: " << localPoint
200 << G4endl
201 << " is not at surface, but far away by: "
202 << localPoint.perp() - fradius << " !";
203 G4Exception("G4ErrorCylSurfaceTarget::GetTangentPlane()",
204 "GeomMgt1002", JustWarning, message);
205 }
206
207 G4Normal3D normal = localPoint - ftransform.NetTranslation();
208
209 return G4Plane3D( normal, point );
210}
@ JustWarning
HepGeom::Plane3D< G4double > G4Plane3D
Definition: G4Plane3D.hh:34
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()

◆ IntersectLocal()

G4ThreeVector G4ErrorCylSurfaceTarget::IntersectLocal ( const G4ThreeVector point,
const G4ThreeVector direc 
) const
virtual

Definition at line 134 of file G4ErrorCylSurfaceTarget.cc.

137{
138 G4double eqa = localDir.x()*localDir.x()+localDir.y()*localDir.y();
139 G4double eqb = 2*(localPoint.x()*localDir.x()+localPoint.y()*localDir.y());
140 G4double eqc = -fradius*fradius+localPoint.x()*localPoint.x()
141 +localPoint.y()*localPoint.y();
142 G4int inside = (localPoint.perp() > fradius) ? -1 : 1;
144
145 if( eqa*inside > 0. )
146 {
147 lambda = (-eqb + std::sqrt(eqb*eqb-4*eqa*eqc) ) / (2.*eqa);
148 }
149 else if( eqa*inside < 0. )
150 {
151 lambda = (-eqb - std::sqrt(eqb*eqb-4*eqa*eqc) ) / (2.*eqa);
152 }
153 else
154 {
155 if( eqb != 0. )
156 {
157 lambda = -eqc/eqb;
158 }
159 else
160 {
161 std::ostringstream message;
162 message << "Intersection not possible !" << G4endl
163 << " Point: " << localPoint << ", direction: "
164 << localDir;
165 Dump( " CylSurface: " );
166 G4Exception("G4ErrorCylSurfaceTarget::IntersectLocal()",
167 "GeomMgt1002", JustWarning, message);
168 lambda = kInfinity;
169 }
170 }
171
172 G4ThreeVector inters = localPoint + lambda*localDir/localDir.mag();
173
174#ifdef G4VERBOSE
175 if(G4ErrorPropagatorData::verbose() >= 4 ) {
176 G4cout << " G4ErrorCylSurfaceTarget::IntersectLocal " << inters << " "
177 << inters.perp() << " localPoint " << localPoint << " localDir "
178 << localDir << G4endl;
179 }
180#endif
181
182 return inters;
183}
int G4int
Definition: G4Types.hh:85

Referenced by GetDistanceFromPoint().


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