Geant4 9.6.0
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 ()
 
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 ()
 
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 ()
 
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 ()
 
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 52 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 46 of file G4ErrorCylSurfaceTarget.cc.

50 : fradius(radius)
51{
53
54 ftransform = G4AffineTransform( rotm.inverse(), -trans );
55#ifdef G4VERBOSE
57 Dump( " $$$ creating G4ErrorCylSurfaceTarget ");
58 }
59#endif
60}
@ 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 64 of file G4ErrorCylSurfaceTarget.cc.

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

◆ ~G4ErrorCylSurfaceTarget()

G4ErrorCylSurfaceTarget::~G4ErrorCylSurfaceTarget ( )

Definition at line 81 of file G4ErrorCylSurfaceTarget.cc.

82{
83}

Member Function Documentation

◆ Dump()

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

Implements G4ErrorSurfaceTarget.

Definition at line 222 of file G4ErrorCylSurfaceTarget.cc.

223{
224 G4cout << msg << " radius " << fradius
225 << " centre " << ftransform.NetTranslation()
226 << " rotation " << ftransform.NetRotation() << G4endl;
227}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT 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 121 of file G4ErrorCylSurfaceTarget.cc.

123{
124 G4ThreeVector localPoint = ftransform.TransformPoint( point );
125
126#ifdef G4VERBOSE
128 {
129 G4cout << " G4ErrorCylSurfaceTarget::GetDistanceFromPoint:" << G4endl
130 << " Global point " << point << G4endl
131 << " Distance " << fradius - localPoint.perp() << G4endl;
132 Dump( " CylSurface: " );
133 }
134#endif
135
136 return fradius - localPoint.perp();
137}
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 87 of file G4ErrorCylSurfaceTarget.cc.

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

◆ GetTangentPlane()

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

Implements G4ErrorSurfaceTarget.

Definition at line 194 of file G4ErrorCylSurfaceTarget.cc.

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

◆ IntersectLocal()

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

Definition at line 141 of file G4ErrorCylSurfaceTarget.cc.

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

Referenced by GetDistanceFromPoint().


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