Geant4 10.7.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 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 43 of file G4ErrorCylSurfaceTarget.cc.

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

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

◆ ~G4ErrorCylSurfaceTarget()

G4ErrorCylSurfaceTarget::~G4ErrorCylSurfaceTarget ( )

Definition at line 79 of file G4ErrorCylSurfaceTarget.cc.

80{
81}

Member Function Documentation

◆ Dump()

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

Implements G4ErrorSurfaceTarget.

Definition at line 220 of file G4ErrorCylSurfaceTarget.cc.

221{
222 G4cout << msg << " radius " << fradius
223 << " centre " << ftransform.NetTranslation()
224 << " rotation " << ftransform.NetRotation() << G4endl;
225}
#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 119 of file G4ErrorCylSurfaceTarget.cc.

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

88{
89 if( dir.mag() == 0. )
90 {
91 G4Exception("G4ErrorCylSurfaceTarget::GetDistanceFromPoint()",
92 "GeomMgt0003", FatalException, "Direction is zero !");
93 }
94
95 //----- Get intersection point
96 G4ThreeVector localPoint = ftransform.TransformPoint( point );
97 G4ThreeVector localDir = ftransform.TransformAxis( dir );
98 G4ThreeVector inters = IntersectLocal(localPoint, localDir);
99
100 G4double dist = (localPoint-inters).mag();
101
102#ifdef G4VERBOSE
104 {
105 G4cout << " G4ErrorCylSurfaceTarget::GetDistanceFromPoint():" << G4endl
106 << " Global point " << point << " dir " << dir << G4endl
107 << " Intersection " << inters << G4endl
108 << " Distance " << dist << G4endl;
109 Dump( " CylSurface: " );
110 }
111#endif
112
113 return dist;
114}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
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 192 of file G4ErrorCylSurfaceTarget.cc.

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

◆ IntersectLocal()

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

Definition at line 139 of file G4ErrorCylSurfaceTarget.cc.

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

Referenced by GetDistanceFromPoint().


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