All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
trkf::SurfYZPlane Class Reference

#include <SurfYZPlane.h>

Inheritance diagram for trkf::SurfYZPlane:
trkf::SurfPlane trkf::Surface trkf::SurfWireX

Public Member Functions

 SurfYZPlane ()
 Default constructor. More...
 
 SurfYZPlane (double x0, double y0, double z0, double phi)
 Initializing constructor. More...
 
virtual ~SurfYZPlane ()
 Destructor. More...
 
double x0 () const
 X origin. More...
 
double y0 () const
 Y origin. More...
 
double z0 () const
 Z origin. More...
 
double phi () const
 Rotation angle about x-axis. More...
 
virtual Surfaceclone () const
 Clone method. More...
 
virtual bool isTrackValid (const TrackVector &vec) const
 Surface-specific tests of validity of track parameters. More...
 
virtual void toLocal (const double xyz[3], double uvw[3]) const
 Transform global to local coordinates. More...
 
virtual void toGlobal (const double uvw[3], double xyz[3]) const
 Transform local to global coordinates. More...
 
virtual void getPosition (const TrackVector &vec, double xyz[3]) const
 Get position of track. More...
 
virtual void getMomentum (const TrackVector &vec, double mom[3], TrackDirection dir=UNKNOWN) const
 Get momentum vector of track. More...
 
virtual bool isParallel (const Surface &surf) const
 Test whether two surfaces are parallel, within tolerance. More...
 
virtual double distanceTo (const Surface &surf) const
 Find perpendicular forward distance to a parallel surface. More...
 
virtual bool isEqual (const Surface &surf) const
 Test two surfaces for equality, within tolerance. More...
 
virtual std::ostream & Print (std::ostream &out) const
 Printout. More...
 
- Public Member Functions inherited from trkf::SurfPlane
 SurfPlane ()
 Default constructor. More...
 
virtual ~SurfPlane ()
 Destructor. More...
 
double PointingError (const TrackVector &vec, const TrackError &err) const
 Get pointing error of track. More...
 
void getStartingError (TrackError &err) const
 Get starting error matrix for Kalman filter. More...
 
- Public Member Functions inherited from trkf::Surface
 Surface ()
 Default constructor. More...
 
virtual ~Surface ()
 Destructor. More...
 
virtual TrackVector getDiff (const TrackVector &vec1, const TrackVector &vec2) const
 Calculate difference of two track parameter vectors. More...
 
virtual TrackDirection getDirection (const TrackVector &, TrackDirection dir=UNKNOWN) const
 Get direction of track (default UNKNOWN). More...
 

Private Attributes

double fX0
 X origin. More...
 
double fY0
 Y origin. More...
 
double fZ0
 Z origin. More...
 
double fPhi
 Rotation angle about x-axis. More...
 

Static Private Attributes

static double fPhiTolerance = 1.e-10
 Phi tolerance for parallel. More...
 
static double fSepTolerance = 1.e-6
 Separation tolerance for equal. More...
 

Additional Inherited Members

- Public Types inherited from trkf::Surface
enum  TrackDirection { FORWARD, BACKWARD, UNKNOWN }
 Track direction enum. More...
 

Detailed Description

Definition at line 46 of file SurfYZPlane.h.

Constructor & Destructor Documentation

trkf::SurfYZPlane::SurfYZPlane ( )

Default constructor.

Definition at line 24 of file SurfYZPlane.cxx.

24  :
25  fX0(0.),
26  fY0(0.),
27  fZ0(0.),
28  fPhi(0.)
29  {}
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
double fZ0
Z origin.
Definition: SurfYZPlane.h:107
double fX0
X origin.
Definition: SurfYZPlane.h:105
double fY0
Y origin.
Definition: SurfYZPlane.h:106
trkf::SurfYZPlane::SurfYZPlane ( double  x0,
double  y0,
double  z0,
double  phi 
)

Initializing constructor.

Initializing constructor.

Arguments:

x0, y0, z0 - Global coordinates of local origin. phi - Rotation angle about x-axis.

Definition at line 38 of file SurfYZPlane.cxx.

38  :
39  fX0(x0),
40  fY0(y0),
41  fZ0(z0),
42  fPhi(phi)
43  {}
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
double z0() const
Z origin.
Definition: SurfYZPlane.h:62
double x0() const
X origin.
Definition: SurfYZPlane.h:60
double y0() const
Y origin.
Definition: SurfYZPlane.h:61
double phi() const
Rotation angle about x-axis.
Definition: SurfYZPlane.h:63
double fZ0
Z origin.
Definition: SurfYZPlane.h:107
double fX0
X origin.
Definition: SurfYZPlane.h:105
double fY0
Y origin.
Definition: SurfYZPlane.h:106
trkf::SurfYZPlane::~SurfYZPlane ( )
virtual

Destructor.

Definition at line 46 of file SurfYZPlane.cxx.

47  {}

Member Function Documentation

Surface * trkf::SurfYZPlane::clone ( ) const
virtual

Clone method.

Implements trkf::Surface.

Definition at line 50 of file SurfYZPlane.cxx.

51  {
52  return new SurfYZPlane(*this);
53  }
SurfYZPlane()
Default constructor.
Definition: SurfYZPlane.cxx:24
double trkf::SurfYZPlane::distanceTo ( const Surface surf) const
virtual

Find perpendicular forward distance to a parallel surface.

Find perpendicular forward distance to a parallel surface.

Throw an exception if the other surface is not parallel.

Assuming the other surface is parallel, the distance is simply the w-coordinate of the other surface, and is signed.

Arguments:

surf - Other surface.

Returned value: Distance.

Implements trkf::Surface.

Definition at line 218 of file SurfYZPlane.cxx.

219  {
220  // Check if the other surface is parallel to this one.
221 
222  bool parallel = isParallel(surf);
223  if(!parallel)
224  throw cet::exception("SurfYZPlane") << "Attempt to find distance to non-parallel surface.\n";
225 
226  // Find the origin of the other surface in global coordinates,
227  // then convert to our local coordinates.
228 
229  double otheruvw[3] = {0., 0., 0.};
230  double xyz[3];
231  double myuvw[3];
232  surf.toGlobal(otheruvw, xyz);
233  toLocal(xyz, myuvw);
234 
235  // Distance is local w-coordinate of other surface origin.
236 
237  return myuvw[2];
238  }
virtual bool isParallel(const Surface &surf) const
Test whether two surfaces are parallel, within tolerance.
virtual void toLocal(const double xyz[3], double uvw[3]) const
Transform global to local coordinates.
Definition: SurfYZPlane.cxx:68
void trkf::SurfYZPlane::getMomentum ( const TrackVector vec,
double  mom[3],
TrackDirection  dir = UNKNOWN 
) const
virtual

Get momentum vector of track.

Get momentum vector of track.

Arguments:

vec - Track state vector. mom - Momentum vector in global coordinate system. dir - Track direction.

Implements trkf::Surface.

Definition at line 135 of file SurfYZPlane.cxx.

137  {
138 
139  // Get momentum.
140 
141  double invp = std::abs(vec(4));
142  double p = 1. / std::max(invp, 1.e-3); // Capped at 1000. GeV/c.
143 
144  // Get track slope parameters.
145 
146  double dudw = vec(2);
147  double dvdw = vec(3);
148 
149  // Calculate dw/ds.
150 
151  double dwds = 1. / std::sqrt(1. + dudw*dudw + dvdw*dvdw);
152  TrackDirection realdir = getDirection(vec, dir); // Should be same as original direction.
153  if(realdir == BACKWARD)
154  dwds = -dwds;
155  else if(realdir != FORWARD)
156  throw cet::exception("SurfYZPlane") << "Track direction not specified.\n";
157 
158  // Calculate momentum vector in local coordinate system.
159 
160  double pu = p * dudw * dwds;
161  double pv = p * dvdw * dwds;
162  double pw = p * dwds;
163 
164  // Rotate momentum to global coordinte system.
165 
166  double sinphi = std::sin(fPhi);
167  double cosphi = std::cos(fPhi);
168 
169  mom[0] = pu;
170  mom[1] = pv * cosphi - pw * sinphi;
171  mom[2] = pv * sinphi + pw * cosphi;
172 
173  return;
174  }
TrackDirection
Track direction enum.
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
pdgs p
Definition: selectors.fcl:22
T abs(T value)
tuple dir
Definition: dropbox.py:28
do i e
virtual TrackDirection getDirection(const TrackVector &, TrackDirection dir=UNKNOWN) const
Get direction of track (default UNKNOWN).
void trkf::SurfYZPlane::getPosition ( const TrackVector vec,
double  xyz[3] 
) const
virtual

Get position of track.

Get position of track.

Arguments:

vec - Track state vector. xyz - Position in global coordinate system.

Implements trkf::Surface.

Definition at line 112 of file SurfYZPlane.cxx.

113  {
114  // Get position in local coordinate system.
115 
116  double uvw[3];
117  uvw[0] = vec(0);
118  uvw[1] = vec(1);
119  uvw[2] = 0.;
120 
121  // Transform to global coordinate system.
122 
123  toGlobal(uvw, xyz);
124  return;
125  }
virtual void toGlobal(const double uvw[3], double xyz[3]) const
Transform local to global coordinates.
Definition: SurfYZPlane.cxx:90
bool trkf::SurfYZPlane::isEqual ( const Surface surf) const
virtual

Test two surfaces for equality, within tolerance.

Test two surfaces for equality, within tolerance. Here equal is defined as having all surface parameters the same, not just having the surfaces coincide spatially, so that the local coordinate systems are the same between the two surfaces.

Arguments:

surf - Other surface.

Returned values: true if equal.

Implements trkf::Surface.

Definition at line 251 of file SurfYZPlane.cxx.

252  {
253  bool result = false;
254 
255  // Test if the other surface is a SurfYZPlane.
256 
257  const SurfYZPlane* psurf = dynamic_cast<const SurfYZPlane*>(&surf);
258  if(psurf != 0) {
259 
260  // Test whether surface parameters are the same within tolerance.
261 
262  double delta_phi = TVector2::Phi_mpi_pi(fPhi - psurf->phi());
263  double dx = fX0 - psurf->x0();
264  double dy = fY0 - psurf->y0();
265  double dz = fZ0 - psurf->z0();
266  if(std::abs(delta_phi) <= fPhiTolerance &&
267  std::abs(dx) <= fSepTolerance &&
268  std::abs(dy) <= fSepTolerance &&
269  std::abs(dz) <= fSepTolerance)
270  result = true;
271  }
272  return result;
273  }
static double fSepTolerance
Separation tolerance for equal.
Definition: SurfYZPlane.h:101
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
static double fPhiTolerance
Phi tolerance for parallel.
Definition: SurfYZPlane.h:100
T abs(T value)
SurfYZPlane()
Default constructor.
Definition: SurfYZPlane.cxx:24
double fZ0
Z origin.
Definition: SurfYZPlane.h:107
double fX0
X origin.
Definition: SurfYZPlane.h:105
double fY0
Y origin.
Definition: SurfYZPlane.h:106
bool trkf::SurfYZPlane::isParallel ( const Surface surf) const
virtual

Test whether two surfaces are parallel, within tolerance.

Test whether two surfaces are parallel, within tolerance. This method will only return true if the other surface is a SurfYZPlane.

Arguments:

surf - Other surface.

Returned value: true if parallel.

Implements trkf::Surface.

Definition at line 186 of file SurfYZPlane.cxx.

187  {
188  bool result = false;
189 
190  // Test if the other surface is a SurfYZPlane.
191 
192  const SurfYZPlane* psurf = dynamic_cast<const SurfYZPlane*>(&surf);
193  if(psurf != 0) {
194 
195  // Test whether surface angle parameters are the same
196  // within tolerance.
197 
198  double delta_phi = TVector2::Phi_mpi_pi(fPhi - psurf->phi());
199  if(std::abs(delta_phi) <= fPhiTolerance)
200  result = true;
201  }
202  return result;
203  }
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
static double fPhiTolerance
Phi tolerance for parallel.
Definition: SurfYZPlane.h:100
T abs(T value)
SurfYZPlane()
Default constructor.
Definition: SurfYZPlane.cxx:24
bool trkf::SurfYZPlane::isTrackValid ( const TrackVector vec) const
virtual

Surface-specific tests of validity of track parameters.

Implements trkf::Surface.

Definition at line 56 of file SurfYZPlane.cxx.

57  {
58  return true;
59  }
double trkf::SurfYZPlane::phi ( ) const
inline

Rotation angle about x-axis.

Definition at line 63 of file SurfYZPlane.h.

std::ostream & trkf::SurfYZPlane::Print ( std::ostream &  out) const
virtual

Printout.

Implements trkf::Surface.

Definition at line 276 of file SurfYZPlane.cxx.

277  {
278  out << "SurfYZPlane{ x0=" << fX0 << ", y0=" << fY0 << ", z0=" << fZ0 << ", phi=" << fPhi << "}";
279  return out;
280  }
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
double fZ0
Z origin.
Definition: SurfYZPlane.h:107
double fX0
X origin.
Definition: SurfYZPlane.h:105
double fY0
Y origin.
Definition: SurfYZPlane.h:106
void trkf::SurfYZPlane::toGlobal ( const double  uvw[3],
double  xyz[3] 
) const
virtual

Transform local to global coordinates.

Transform local to global coordinates.

Arguments:

uvw - Cartesian coordinates in local coordinate system. xyz - Cartesian coordinates in global coordinate system.

Implements trkf::Surface.

Definition at line 90 of file SurfYZPlane.cxx.

91  {
92  double sinphi = std::sin(fPhi);
93  double cosphi = std::cos(fPhi);
94 
95  // x = x0 + u
96  xyz[0] = fX0 + uvw[0];
97 
98  // y = y0 + v*cos(phi) - w*sin(phi)
99  xyz[1] = fY0 + uvw[1] * cosphi - uvw[2] * sinphi;
100 
101  // z = z0 + v*sin(phi) + w*cos(phi)
102  xyz[2] = fZ0 + uvw[1] * sinphi + uvw[2] * cosphi;
103  }
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
double fZ0
Z origin.
Definition: SurfYZPlane.h:107
double fX0
X origin.
Definition: SurfYZPlane.h:105
double fY0
Y origin.
Definition: SurfYZPlane.h:106
void trkf::SurfYZPlane::toLocal ( const double  xyz[3],
double  uvw[3] 
) const
virtual

Transform global to local coordinates.

Transform global to local coordinates.

Arguments:

xyz - Cartesian coordinates in global coordinate system. uvw - Cartesian coordinates in local coordinate system.

Implements trkf::Surface.

Definition at line 68 of file SurfYZPlane.cxx.

69  {
70  double sinphi = std::sin(fPhi);
71  double cosphi = std::cos(fPhi);
72 
73  // u = x-x0
74  uvw[0] = xyz[0] - fX0;
75 
76  // v = (y-y0)*cos(phi) + (z-z0)*sin(phi)
77  uvw[1] = (xyz[1] - fY0) * cosphi + (xyz[2] - fZ0) * sinphi;
78 
79  // w = -(y-y0)*sin(phi) + (z-z0)*cos(phi)
80  uvw[2] = -(xyz[1] - fY0) * sinphi + (xyz[2] - fZ0) * cosphi;
81  }
double fPhi
Rotation angle about x-axis.
Definition: SurfYZPlane.h:108
double fZ0
Z origin.
Definition: SurfYZPlane.h:107
double fX0
X origin.
Definition: SurfYZPlane.h:105
double fY0
Y origin.
Definition: SurfYZPlane.h:106
double trkf::SurfYZPlane::x0 ( ) const
inline

X origin.

Definition at line 60 of file SurfYZPlane.h.

double trkf::SurfYZPlane::y0 ( ) const
inline

Y origin.

Definition at line 61 of file SurfYZPlane.h.

double trkf::SurfYZPlane::z0 ( ) const
inline

Z origin.

Definition at line 62 of file SurfYZPlane.h.

Member Data Documentation

double trkf::SurfYZPlane::fPhi
private

Rotation angle about x-axis.

Definition at line 108 of file SurfYZPlane.h.

double trkf::SurfYZPlane::fPhiTolerance = 1.e-10
staticprivate

Phi tolerance for parallel.

Definition at line 100 of file SurfYZPlane.h.

double trkf::SurfYZPlane::fSepTolerance = 1.e-6
staticprivate

Separation tolerance for equal.

Definition at line 101 of file SurfYZPlane.h.

double trkf::SurfYZPlane::fX0
private

X origin.

Definition at line 105 of file SurfYZPlane.h.

double trkf::SurfYZPlane::fY0
private

Y origin.

Definition at line 106 of file SurfYZPlane.h.

double trkf::SurfYZPlane::fZ0
private

Z origin.

Definition at line 107 of file SurfYZPlane.h.


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