Belle II Software development
ExtCylSurfaceTarget Class Reference

Defines a closed cylinder for the geant4e "target", the surface that encloses the volume within which track extrapolation is done. More...

#include <ExtCylSurfaceTarget.h>

Inheritance diagram for ExtCylSurfaceTarget:

Public Member Functions

 ExtCylSurfaceTarget (const G4double &, const G4double &, const G4double &)
 Construct the closed cylindrical surface No coordinate transformations allowed: cylinder is coaxial with z axis.
 
 ~ExtCylSurfaceTarget ()
 Destructor.
 
virtual G4ThreeVector IntersectLocal (const G4ThreeVector &point, const G4ThreeVector &direc) const
 Return the intersection of the cylinder with the line defined in local (cylinder) coordinates by point and direc.
 
virtual G4double GetDistanceFromPoint (const G4ThreeVector &point, const G4ThreeVector &direc) const
 Get the distance from a point to the cylinder along direc.
 
virtual G4double GetDistanceFromPoint (const G4ThreeVector &point) const
 Get the shortest distance from a point to the cylinder.
 
virtual G4Plane3D GetTangentPlane (const G4ThreeVector &point) const
 Get the plane tangent to the cylinder at a given point.
 
virtual void Dump (const G4String &msg) const
 Dump the cylinder parameters.
 

Private Attributes

G4double m_radius
 Cylinder radius.
 
G4double m_zmin
 Cylinder minimum-z coordinate.
 
G4double m_zmax
 Cylinder maximum-z coordinate.
 
G4double m_tolerance
 Tolerance for distance between a point and cylinder's curved surface.
 

Detailed Description

Defines a closed cylinder for the geant4e "target", the surface that encloses the volume within which track extrapolation is done.

Definition at line 28 of file ExtCylSurfaceTarget.h.

Constructor & Destructor Documentation

◆ ExtCylSurfaceTarget()

ExtCylSurfaceTarget ( const G4double &  radius,
const G4double &  zmin,
const G4double &  zmax 
)

Construct the closed cylindrical surface No coordinate transformations allowed: cylinder is coaxial with z axis.

Definition at line 20 of file ExtCylSurfaceTarget.cc.

22 :
23 m_radius(radius),
24 m_zmin(zmin),
25 m_zmax(zmax),
26 m_tolerance(1000.0 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance())
27{
28 theType = G4ErrorTarget_CylindricalSurface;
29 B2DEBUG(1, "Simulation::ExtCylSurfaceTarget created with radius "
30 << m_radius << " zmin " << zmin << " zmax " << zmax);
31}
G4double m_tolerance
Tolerance for distance between a point and cylinder's curved surface.
G4double m_zmax
Cylinder maximum-z coordinate.
G4double m_zmin
Cylinder minimum-z coordinate.

◆ ~ExtCylSurfaceTarget()

Destructor.

Definition at line 33 of file ExtCylSurfaceTarget.cc.

34{
35}

Member Function Documentation

◆ Dump()

void Dump ( const G4String &  msg) const
virtual

Dump the cylinder parameters.

Dump the cylinder parameters: EMPTY STUB

Definition at line 120 of file ExtCylSurfaceTarget.cc.

121{
122}

◆ GetDistanceFromPoint() [1/2]

G4double GetDistanceFromPoint ( const G4ThreeVector &  point) const
virtual

Get the shortest distance from a point to the cylinder.

Definition at line 62 of file ExtCylSurfaceTarget.cc.

63{
64
65 G4double dist = m_radius - point.perp();
66 dist = fmin(dist, point.z() - m_zmin);
67 dist = fmin(dist, m_zmax - point.z());
68
69 B2DEBUG(300, "Simulation::ExtCylSurfaceTarget::GetDistanceFromPoint(): Global point "
70 << point << " minimum distance " << dist);
71
72 return dist;
73}

◆ GetDistanceFromPoint() [2/2]

G4double GetDistanceFromPoint ( const G4ThreeVector &  point,
const G4ThreeVector &  direc 
) const
virtual

Get the distance from a point to the cylinder along direc.

Definition at line 37 of file ExtCylSurfaceTarget.cc.

39{
40 if (fabs(dir.mag() - 1.0) > 1.0E-10) {
41 B2FATAL("Simulation::ExtCylSurfaceTarget::GetDistanceFromPoint() direction is not a unit vector: " << dir);
42 }
43
44 // Get distance to intersection point with the cylinder's curved surface
45 // should be negative if outside! G4double dist = (point - IntersectLocal(point, dir)).mag();
46 G4double dist = (IntersectLocal(point, dir) - point) * dir;
47
48 // Get intersection point with the plane at either zmin or zmax
49 G4double dirz = dir.z();
50 if (dirz < -1.0E-10) {
51 dist = fmin(dist, (m_zmin - point.z()) / dirz);
52 } else if (dirz > 1.0E-10) {
53 dist = fmin(dist, (m_zmax - point.z()) / dirz);
54 }
55
56 B2DEBUG(300, "Simulation::ExtCylSurfaceTarget::GetDistanceFromPoint(): Global point "
57 << point << " dir " << dir << " distance " << dist);
58
59 return dist;
60}
virtual G4ThreeVector IntersectLocal(const G4ThreeVector &point, const G4ThreeVector &direc) const
Return the intersection of the cylinder with the line defined in local (cylinder) coordinates by poin...

◆ GetTangentPlane()

G4Plane3D GetTangentPlane ( const G4ThreeVector &  point) const
virtual

Get the plane tangent to the cylinder at a given point.

Definition at line 106 of file ExtCylSurfaceTarget.cc.

107{
108 // check that point is at the cylinder's curved surface
109 if (fabs(point.perp() - m_radius) > m_tolerance) {
110 B2ERROR("Simulation::ExtCylSurfaceTarget::GetTangentPlane(): point "
111 << point << " is not at surface; radial distance is " << point.perp() - m_radius);
112 }
113
114 G4Normal3D normal(point);
115
116 return G4Plane3D(normal, point);
117}

◆ IntersectLocal()

G4ThreeVector IntersectLocal ( const G4ThreeVector &  point,
const G4ThreeVector &  direc 
) const
virtual

Return the intersection of the cylinder with the line defined in local (cylinder) coordinates by point and direc.

Definition at line 75 of file ExtCylSurfaceTarget.cc.

77{
78 // localDir has already been verified to be a unit vector
79 G4double eqa = localDir.x() * localDir.x() + localDir.y() * localDir.y();
80 G4double eqb = 2.0 * (localPoint.x() * localDir.x() + localPoint.y() * localDir.y());
81 G4double eqc = localPoint.x() * localPoint.x() + localPoint.y() * localPoint.y()
83 G4double eqaInside = (localPoint.perp() > m_radius) ? -eqa : eqa;
84
85 G4ThreeVector intersection = localPoint;
86 if (eqaInside > 0.0) {
87 intersection += localDir * ((-eqb + sqrt(eqb * eqb - 4.0 * eqa * eqc)) / (2.0 * eqa));
88 } else if (eqaInside < 0.0) {
89 intersection += localDir * ((-eqb - sqrt(eqb * eqb - 4.0 * eqa * eqc)) / (2.0 * eqa));
90 } else {
91 if (eqb != 0.0) {
92 intersection -= localDir * (eqc / eqb);
93 } else {
94 B2WARNING("Simulation::ExtCylSurfaceTarget::IntersectLocal(): localPoint "
95 << localPoint << " localDir " << localDir << " does not intersect with cylinder");
96 intersection = localDir * kInfinity;
97 }
98 }
99
100 B2DEBUG(300, "Simulation::ExtCylSurfaceTarget::IntersectLocal(): localPoint "
101 << localPoint << " localDir " << localDir << " radial intersection " << intersection.perp());
102
103 return intersection;
104}
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

Member Data Documentation

◆ m_radius

G4double m_radius
private

Cylinder radius.

Definition at line 60 of file ExtCylSurfaceTarget.h.

◆ m_tolerance

G4double m_tolerance
private

Tolerance for distance between a point and cylinder's curved surface.

Definition at line 69 of file ExtCylSurfaceTarget.h.

◆ m_zmax

G4double m_zmax
private

Cylinder maximum-z coordinate.

Definition at line 66 of file ExtCylSurfaceTarget.h.

◆ m_zmin

G4double m_zmin
private

Cylinder minimum-z coordinate.

Definition at line 63 of file ExtCylSurfaceTarget.h.


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