CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TangentApproachInRPhi Class Reference

#include <TangentApproachInRPhi.h>

Inheritance diagram for TangentApproachInRPhi:
ClosestApproachOnHelices

Public Member Functions

virtual bool calculate (const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
 
virtual bool calculate (const FreeTrajectoryState &sta, const FreeTrajectoryState &stb)
 
virtual TangentApproachInRPhiclone () const
 
virtual GlobalPoint crossingPoint () const
 
virtual float distance () const
 
float perpdist () const
 
virtual std::pair< GlobalPoint,
GlobalPoint
points () const
 
virtual bool status () const
 
 TangentApproachInRPhi ()
 
std::pair
< GlobalTrajectoryParameters,
GlobalTrajectoryParameters
trajectoryParameters () const
 
- Public Member Functions inherited from ClosestApproachOnHelices
 ClosestApproachOnHelices ()
 
virtual ~ClosestApproachOnHelices ()
 

Private Member Functions

bool calculate (const TrackCharge &chargeA, const GlobalVector &momentumA, const GlobalPoint &positionA, const TrackCharge &chargeB, const GlobalVector &momentumB, const GlobalPoint &positionB, const MagneticField &magField)
 
void circleParameters (const TrackCharge &charge, const GlobalVector &momemtum, const GlobalPoint &position, double &xc, double &yc, double &r, const MagneticField &magField) const
 
GlobalTrajectoryParameters trajectoryParameters (const GlobalPoint &newpt, const GlobalTrajectoryParameters &oldpar) const
 
int transverseCoord (double cxa, double cya, double ra, double cxb, double cyb, double rb, double &xg1, double &yg1, double &xg2, double &yg2) const
 
double zCoord (const GlobalVector &mom, const GlobalPoint &pos, double r, double xc, double yc, double xg, double yg) const
 

Private Attributes

bool intersection_
 
GlobalTrajectoryParameters paramA
 
GlobalTrajectoryParameters paramB
 
GlobalPoint posA
 
GlobalPoint posB
 
bool status_
 

Detailed Description

Given two trajectory states, computes the two points of tangent approach in the transverse plane for the helices extrapolated from these states. 1) computes the tangent points of the circles in transverse plane. Two cases: - Whether or not the circles intersect the points used are the points of tangent approach of the two circles. 2) computes the corresponding z-coordinates.

Definition at line 15 of file TangentApproachInRPhi.h.

Constructor & Destructor Documentation

TangentApproachInRPhi::TangentApproachInRPhi ( )
inline

Definition at line 19 of file TangentApproachInRPhi.h.

References intersection_, and status_.

Referenced by clone().

Member Function Documentation

bool TangentApproachInRPhi::calculate ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface stb 
)
virtual

Implements ClosestApproachOnHelices.

Definition at line 8 of file TangentApproachInRPhi.cc.

References TrajectoryStateOnSurface::charge(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), TrajectoryStateOnSurface::globalPosition(), GlobalTrajectoryParameters::magneticField(), and FreeTrajectoryState::parameters().

Referenced by ConversionProducer::preselectTrackPair().

10 {
11  TrackCharge chargeA = sta.charge(); TrackCharge chargeB = stb.charge();
12  GlobalVector momentumA = sta.globalMomentum();
13  GlobalVector momentumB = stb.globalMomentum();
14  GlobalPoint positionA = sta.globalPosition();
15  GlobalPoint positionB = stb.globalPosition();
16  paramA = sta.globalParameters();
17  paramB = stb.globalParameters();
18 
19  return calculate(chargeA, momentumA, positionA, chargeB, momentumB, positionB,
21 }
const GlobalTrajectoryParameters & parameters() const
GlobalTrajectoryParameters paramA
GlobalPoint globalPosition() const
int TrackCharge
Definition: TrackCharge.h:4
GlobalTrajectoryParameters paramB
FreeTrajectoryState * freeState(bool withErrors=true) const
const GlobalTrajectoryParameters & globalParameters() const
GlobalVector globalMomentum() const
const MagneticField & magneticField() const
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
bool TangentApproachInRPhi::calculate ( const FreeTrajectoryState sta,
const FreeTrajectoryState stb 
)
virtual

Implements ClosestApproachOnHelices.

Definition at line 24 of file TangentApproachInRPhi.cc.

References FreeTrajectoryState::charge(), GlobalTrajectoryParameters::magneticField(), FreeTrajectoryState::momentum(), FreeTrajectoryState::parameters(), and FreeTrajectoryState::position().

26 {
27  TrackCharge chargeA = sta.charge(); TrackCharge chargeB = stb.charge();
28  GlobalVector momentumA = sta.momentum();
29  GlobalVector momentumB = stb.momentum();
30  GlobalPoint positionA = sta.position();
31  GlobalPoint positionB = stb.position();
32  paramA = sta.parameters();
33  paramB = stb.parameters();
34 
35  return calculate(chargeA, momentumA, positionA, chargeB, momentumB, positionB,
36  sta.parameters().magneticField());
37 }
const GlobalTrajectoryParameters & parameters() const
GlobalTrajectoryParameters paramA
TrackCharge charge() const
int TrackCharge
Definition: TrackCharge.h:4
GlobalTrajectoryParameters paramB
GlobalVector momentum() const
GlobalPoint position() const
const MagneticField & magneticField() const
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
bool TangentApproachInRPhi::calculate ( const TrackCharge chargeA,
const GlobalVector momentumA,
const GlobalPoint positionA,
const TrackCharge chargeB,
const GlobalVector momentumB,
const GlobalPoint positionB,
const MagneticField magField 
)
private

Definition at line 81 of file TangentApproachInRPhi.cc.

88 {
89 
90  // centres and radii of track circles
91  double xca, yca, ra;
92  circleParameters(chargeA, momentumA, positionA, xca, yca, ra, magField);
93  double xcb, ycb, rb;
94  circleParameters(chargeB, momentumB, positionB, xcb, ycb, rb, magField);
95 
96  // points of closest approach in transverse plane
97  double xg1, yg1, xg2, yg2;
98  int flag = transverseCoord(xca, yca, ra, xcb, ycb, rb, xg1, yg1, xg2, yg2);
99  if (flag == 0) {
100  status_ = false;
101  return false;
102  }
103 
104  double xga, yga, zga, xgb, ygb, zgb;
105 
106  if (flag == 1) {
107  intersection_ = true;
108  }
109  else {
110  intersection_ = false;
111  }
112 
113  // one point of closest approach on each track in transverse plane
114  xga = xg1; yga = yg1;
115  zga = zCoord(momentumA, positionA, ra, xca, yca, xga, yga);
116  xgb = xg2; ygb = yg2;
117  zgb = zCoord(momentumB, positionB, rb, xcb, ycb, xgb, ygb);
118 
119 
120  posA = GlobalPoint(xga, yga, zga);
121  posB = GlobalPoint(xgb, ygb, zgb);
122  status_ = true;
123  return true;
124 }
long int flag
Definition: mlp_lapack.h:47
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double zCoord(const GlobalVector &mom, const GlobalPoint &pos, double r, double xc, double yc, double xg, double yg) const
int transverseCoord(double cxa, double cya, double ra, double cxb, double cyb, double rb, double &xg1, double &yg1, double &xg2, double &yg2) const
void circleParameters(const TrackCharge &charge, const GlobalVector &momemtum, const GlobalPoint &position, double &xc, double &yc, double &r, const MagneticField &magField) const
void TangentApproachInRPhi::circleParameters ( const TrackCharge charge,
const GlobalVector momemtum,
const GlobalPoint position,
double &  xc,
double &  yc,
double &  r,
const MagneticField magField 
) const
private

temporary code, to be replaced by call to curvature() when bug is fixed.

end of temporary code

Definition at line 166 of file TangentApproachInRPhi.cc.

References abs, funct::cos(), MagneticField::inTesla(), phi, PV3DBase< T, PVType, FrameType >::phi(), funct::sin(), PV3DBase< T, PVType, FrameType >::transverse(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

172 {
173 
174  // compute radius of circle
178 // double bz = MagneticField::inInverseGeV(position).z();
179  double bz = magField.inTesla(position).z() * 2.99792458e-3;
180 
181  // signed_r directed towards circle center, along F_Lorentz = q*v X B
182  double signed_r = charge*momentum.transverse() / bz;
183  r = abs(signed_r);
187  // compute centre of circle
188  double phi = momentum.phi();
189  xc = signed_r*sin(phi) + position.x();
190  yc = -signed_r*cos(phi) + position.y();
191 
192 }
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:57
#define abs(x)
Definition: mlp_lapack.h:159
double charge(const std::vector< uint8_t > &Ampls)
T z() const
Definition: PV3DBase.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T x() const
Definition: PV3DBase.h:56
Definition: DDAxes.h:10
virtual TangentApproachInRPhi* TangentApproachInRPhi::clone ( void  ) const
inlinevirtual

Clone method

Implements ClosestApproachOnHelices.

Definition at line 51 of file TangentApproachInRPhi.h.

References TangentApproachInRPhi().

51  {
52  return new TangentApproachInRPhi(* this);
53  }
GlobalPoint TangentApproachInRPhi::crossingPoint ( ) const
virtual

arithmetic mean of the two points of closest approach

Implements ClosestApproachOnHelices.

Definition at line 48 of file TangentApproachInRPhi.cc.

References edm::hlt::Exception.

Referenced by ConversionProducer::preselectTrackPair().

49 {
50  if (!status_)
51  throw cms::Exception("TrackingTools/PatternTools","TangentApproachInRPhi::could not compute track crossing. Check status before calling this method!");
52  return GlobalPoint((posA.x() + posB.x())/2.,
53  (posA.y() + posB.y())/2.,
54  (posA.z() + posB.z())/2.);
55 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:57
T z() const
Definition: PV3DBase.h:58
T x() const
Definition: PV3DBase.h:56
float TangentApproachInRPhi::distance ( ) const
virtual

distance between the two points of closest approach in 3D

Implements ClosestApproachOnHelices.

Definition at line 58 of file TangentApproachInRPhi.cc.

References edm::hlt::Exception.

59 {
60  if (!status_)
61  throw cms::Exception("TrackingTools/PatternTools","TangentApproachInRPhi::could not compute track crossing. Check status before calling this method!");
62  return (posB - posA).mag();
63 }
float TangentApproachInRPhi::perpdist ( ) const

signed distance between two points of closest approach in r-phi plane (-ive if circles intersect)

Definition at line 65 of file TangentApproachInRPhi.cc.

References edm::hlt::Exception, and perp().

Referenced by ConversionProducer::preselectTrackPair().

66 {
67  if (!status_)
68  throw cms::Exception("TrackingTools/PatternTools","TangentApproachInRPhi::could not compute track crossing. Check status before calling this method!");
69 
70  float perpdist = (posB - posA).perp();
71 
72  if (intersection_) {
73  perpdist = -perpdist;
74  }
75 
76  return perpdist;
77 
78 }
T perp() const
Magnitude of transverse component.
pair< GlobalPoint, GlobalPoint > TangentApproachInRPhi::points ( ) const
virtual

Returns the two PCA on the trajectories.

Implements ClosestApproachOnHelices.

Definition at line 39 of file TangentApproachInRPhi.cc.

References edm::hlt::Exception.

40 {
41  if (!status_)
42  throw cms::Exception("TrackingTools/PatternTools","TangentApproachInRPhi::could not compute track crossing. Check status before calling this method!");
43  return pair<GlobalPoint, GlobalPoint> (posA, posB);
44 }
virtual bool TangentApproachInRPhi::status ( void  ) const
inlinevirtual

Implements ClosestApproachOnHelices.

Definition at line 27 of file TangentApproachInRPhi.h.

References status_.

Referenced by ConversionProducer::preselectTrackPair().

pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > TangentApproachInRPhi::trajectoryParameters ( ) const

Returns not only the points, but the full GlobalTrajectoryParemeters at the points of closest approach

Definition at line 127 of file TangentApproachInRPhi.cc.

References edm::hlt::Exception, and runTheMatrix::ret.

Referenced by ConversionProducer::preselectTrackPair().

128 {
129  if (!status_)
130  throw cms::Exception("TrackingTools/PatternTools","TangentApproachInRPhi::could not compute track crossing. Check status before calling this method!");
131  pair <GlobalTrajectoryParameters, GlobalTrajectoryParameters>
134  return ret;
135 }
std::pair< GlobalTrajectoryParameters, GlobalTrajectoryParameters > trajectoryParameters() const
GlobalTrajectoryParameters paramA
GlobalTrajectoryParameters paramB
GlobalTrajectoryParameters TangentApproachInRPhi::trajectoryParameters ( const GlobalPoint newpt,
const GlobalTrajectoryParameters oldpar 
) const
private

Definition at line 137 of file TangentApproachInRPhi.cc.

References GlobalTrajectoryParameters::charge(), GlobalTrajectoryParameters::magneticField(), GlobalTrajectoryParameters::momentum(), GlobalTrajectoryParameters::position(), csvReporter::r, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

139 {
140  // First we need the centers of the circles.
141  double xc, yc, r;
142  circleParameters( oldgtp.charge(), oldgtp.momentum(),
143  oldgtp.position(), xc, yc, r, oldgtp.magneticField() );
144 
145  // now we do a translation, move the center of circle to (0,0,0).
146  double dx1 = oldgtp.position().x() - xc;
147  double dy1 = oldgtp.position().y() - yc;
148  double dx2 = newpt.x() - xc;
149  double dy2 = newpt.y() - yc;
150 
151  // now for the angles:
152  double cosphi = ( dx1 * dx2 + dy1 * dy2 ) /
153  ( sqrt ( dx1 * dx1 + dy1 * dy1 ) * sqrt ( dx2 * dx2 + dy2 * dy2 ));
154  double sinphi = - oldgtp.charge() * sqrt ( 1 - cosphi * cosphi );
155 
156  // Finally, the new momenta:
157  double px = cosphi * oldgtp.momentum().x() - sinphi * oldgtp.momentum().y();
158  double py = sinphi * oldgtp.momentum().x() + cosphi * oldgtp.momentum().y();
159 
160  GlobalVector vta ( px, py, oldgtp.momentum().z() );
161  GlobalTrajectoryParameters gta( newpt , vta , oldgtp.charge(), &(oldgtp.magneticField()) );
162  return gta;
163 }
T y() const
Definition: PV3DBase.h:57
T sqrt(T t)
Definition: SSEVec.h:28
void circleParameters(const TrackCharge &charge, const GlobalVector &momemtum, const GlobalPoint &position, double &xc, double &yc, double &r, const MagneticField &magField) const
T x() const
Definition: PV3DBase.h:56
int TangentApproachInRPhi::transverseCoord ( double  cxa,
double  cya,
double  ra,
double  cxb,
double  cyb,
double  rb,
double &  xg1,
double &  yg1,
double &  xg2,
double &  yg2 
) const
private

Definition at line 196 of file TangentApproachInRPhi.cc.

References abs, mathSSE::sqrt(), and v.

200 {
201  int flag = 0;
202  double x1, y1, x2, y2;
203 
204  // new reference frame with origin in (cxa, cya) and x-axis
205  // directed from (cxa, cya) to (cxb, cyb)
206 
207  double d_ab = sqrt((cxb - cxa)*(cxb - cxa) + (cyb - cya)*(cyb - cya));
208  if (d_ab == 0) { // concentric circles
209  return 0;
210  }
211  // elements of rotation matrix
212  double u = (cxb - cxa) / d_ab;
213  double v = (cyb - cya) / d_ab;
214 
215  // conditions for circle intersection
216  if (d_ab <= ra + rb && d_ab >= abs(rb - ra)) {
217 
218  // circles cross each other
219 // flag = 1;
220 //
221 // // triangle (ra, rb, d_ab)
222 // double cosphi = (ra*ra - rb*rb + d_ab*d_ab) / (2*ra*d_ab);
223 // double sinphi2 = 1. - cosphi*cosphi;
224 // if (sinphi2 < 0.) { sinphi2 = 0.; cosphi = 1.; }
225 //
226 // // intersection points in new frame
227 // double sinphi = sqrt(sinphi2);
228 // x1 = ra*cosphi; y1 = ra*sinphi; x2 = x1; y2 = -y1;
229 
230  //circles cross each other, but take tangent points anyway
231  flag = 1;
232 
233  // points of closest approach in new frame
234  // are on line between 2 centers
235  x1 = ra; y1 = 0; x2 = d_ab - rb; y2 = 0;
236 
237 
238  }
239  else if (d_ab > ra + rb) {
240 
241  // circles are external to each other
242  flag = 2;
243 
244  // points of closest approach in new frame
245  // are on line between 2 centers
246  x1 = ra; y1 = 0; x2 = d_ab - rb; y2 = 0;
247  }
248  else if (d_ab < abs(rb - ra)) {
249 
250  // circles are inside each other
251  flag = 2;
252 
253  // points of closest approach in new frame are on line between 2 centers
254  // choose 2 closest points
255  double sign = 1.;
256  if (ra <= rb) sign = -1.;
257  x1 = sign*ra; y1 = 0; x2 = d_ab + sign*rb; y2 = 0;
258  }
259  else {
260  return 0;
261  }
262 
263  // intersection points in global frame, transverse plane
264  xg1 = u*x1 - v*y1 + cxa; yg1 = v*x1 + u*y1 + cya;
265  xg2 = u*x2 - v*y2 + cxa; yg2 = v*x2 + u*y2 + cya;
266 
267  return flag;
268 }
long int flag
Definition: mlp_lapack.h:47
#define abs(x)
Definition: mlp_lapack.h:159
T sqrt(T t)
Definition: SSEVec.h:28
mathSSE::Vec4< T > v
double TangentApproachInRPhi::zCoord ( const GlobalVector mom,
const GlobalPoint pos,
double  r,
double  xc,
double  yc,
double  xg,
double  yg 
) const
private

Definition at line 272 of file TangentApproachInRPhi.cc.

References abs, phi, csvReporter::r, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::transverse(), x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

276 {
277 
278  // starting point
279  double x = pos.x(); double y = pos.y(); double z = pos.z();
280 
281  double px = mom.x(); double py = mom.y(); double pz = mom.z();
282 
283  // rotation angle phi from starting point to crossing point (absolute value)
284  // -- compute sin(phi/2) if phi smaller than pi/4,
285  // -- cos(phi) if phi larger than pi/4
286  double phi = 0.;
287  double sinHalfPhi = sqrt((x-xg)*(x-xg) + (y-yg)*(y-yg))/(2*r);
288  if (sinHalfPhi < 0.383) { // sin(pi/8)
289  phi = 2*asin(sinHalfPhi);
290  }
291  else {
292  double cosPhi = ((x-xc)*(xg-xc) + (y-yc)*(yg-yc))/(r*r);
293  if (std::abs(cosPhi) > 1) cosPhi = (cosPhi > 0 ? 1 : -1);
294  phi = abs(acos(cosPhi));
295  }
296  // -- sign of phi
297  double signPhi = ((x - xc)*(yg - yc) - (xg - xc)*(y - yc) > 0) ? 1. : -1.;
298 
299  // sign of track angular momentum
300  // if rotation is along angular momentum, delta z is along pz
301  double signOmega = ((x - xc)*py - (y - yc)*px > 0) ? 1. : -1.;
302 
303  // delta z
304  // -- |dz| = |cos(theta) * path along helix|
305  // = |cos(theta) * arc length along circle / sin(theta)|
306  double dz = signPhi*signOmega*(pz/mom.transverse())*phi*r;
307 
308  return z + dz;
309 }
T y() const
Definition: PV3DBase.h:57
#define abs(x)
Definition: mlp_lapack.h:159
double double double z
T transverse() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:56
Definition: DDAxes.h:10

Member Data Documentation

bool TangentApproachInRPhi::intersection_
private

Definition at line 100 of file TangentApproachInRPhi.h.

Referenced by TangentApproachInRPhi().

GlobalTrajectoryParameters TangentApproachInRPhi::paramA
private

Definition at line 99 of file TangentApproachInRPhi.h.

GlobalTrajectoryParameters TangentApproachInRPhi::paramB
private

Definition at line 99 of file TangentApproachInRPhi.h.

GlobalPoint TangentApproachInRPhi::posA
private

Definition at line 98 of file TangentApproachInRPhi.h.

GlobalPoint TangentApproachInRPhi::posB
private

Definition at line 98 of file TangentApproachInRPhi.h.

bool TangentApproachInRPhi::status_
private

Definition at line 97 of file TangentApproachInRPhi.h.

Referenced by status(), and TangentApproachInRPhi().