CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
TrackingJacobians.h File Reference
#include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"

Go to the source code of this file.

Functions

AlgebraicMatrix56 jacobianCartesianToCurvilinear (const GlobalVector &momentum, int charge)
 
AlgebraicMatrix65 jacobianCurvilinearToCartesian (const GlobalVector &momentum, int charge)
 

Function Documentation

AlgebraicMatrix56 jacobianCartesianToCurvilinear ( const GlobalVector momentum,
int  charge 
)

Definition at line 57 of file TrackingJacobians.cc.

References Vector3DBase< T, FrameTag >::cross(), PV3DBase< T, PVType, FrameType >::mag(), AlCaHLTBitMon_ParallelJobs::p, p2, p3, PV3DBase< T, PVType, FrameType >::perp(), EnergyCorrector::pt, dttmaxenums::R, Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

57  {
58  AlgebraicMatrix56 theJacobian;
59  GlobalVector xt=momentum;
60  GlobalVector yt(-xt.y(), xt.x(), 0.);
61  GlobalVector zt = xt.cross(yt);
62  GlobalVector pvec=momentum;
63  double pt = pvec.perp(), p = pvec.mag();
64  double px = pvec.x(), py = pvec.y(), pz = pvec.z();
65  double pt2 = pt*pt, p2 = p*p, p3 = p*p*p;
66  // for neutrals: qbp is 1/p instead of q/p -
67  // equivalent to charge 1
68  if ( q==0 ) q = 1;
69  xt = xt.unit();
70  if(fabs(pt) > 0){
71  yt = yt.unit();
72  zt = zt.unit();
73  }
74 
76  R(0,0) = xt.x(); R(0,1) = xt.y(); R(0,2) = xt.z();
77  R(1,0) = yt.x(); R(1,1) = yt.y(); R(1,2) = yt.z();
78  R(2,0) = zt.x(); R(2,1) = zt.y(); R(2,2) = zt.z();
79  R(3,3) = 1.;
80  R(4,4) = 1.;
81  R(5,5) = 1.;
82 
83  theJacobian(0,3) = -q*px/p3; theJacobian(0,4) = -q*py/p3; theJacobian(0,5) = -q*pz/p3;
84  if(fabs(pt) > 0){
85  //theJacobian(1,3) = (px*pz)/(pt*p2); theJacobian(1,4) = (py*pz)/(pt*p2); theJacobian(1,5) = -pt/p2; //wrong sign
86  theJacobian(1,3) = -(px*pz)/(pt*p2); theJacobian(1,4) = -(py*pz)/(pt*p2); theJacobian(1,5) = pt/p2;
87  theJacobian(2,3) = -py/pt2; theJacobian(2,4) = px/pt2; theJacobian(2,5) = 0.;
88  }
89  theJacobian(3,1) = 1.;
90  theJacobian(4,2) = 1.;
91  theJacobian = theJacobian * R;
92  //dbg::dbg_trace(1,"Ca2Cu", globalParameters.vector(),theJacobian);
93  return theJacobian;
94 }
T perp() const
Definition: PV3DBase.h:72
ROOT::Math::SMatrix< double, 5, 6, ROOT::Math::MatRepStd< double, 5, 6 > > AlgebraicMatrix56
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
T y() const
Definition: PV3DBase.h:63
T mag() const
Definition: PV3DBase.h:67
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
Vector3DBase unit() const
Definition: Vector3DBase.h:57
T x() const
Definition: PV3DBase.h:62
double p3[4]
Definition: TauolaWrapper.h:91
AlgebraicMatrix65 jacobianCurvilinearToCartesian ( const GlobalVector momentum,
int  charge 
)

Definition at line 6 of file TrackingJacobians.cc.

References funct::cos(), Vector3DBase< T, FrameTag >::cross(), M_PI, PV3DBase< T, PVType, FrameType >::mag(), AlCaHLTBitMon_ParallelJobs::p, p2, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), phi(), EnergyCorrector::pt, dttmaxenums::R, funct::sin(), PV3DBase< T, PVType, FrameType >::theta(), Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

6  {
7  AlgebraicMatrix65 theJacobian;
8  GlobalVector xt=momentum;
9  GlobalVector yt(-xt.y(), xt.x(), 0.);
10  GlobalVector zt = xt.cross(yt);
11 
12  GlobalVector pvec=momentum;
13  double pt = pvec.perp();
14  // for neutrals: qbp is 1/p instead of q/p -
15  // equivalent to charge 1
16  if ( q==0 ) q = 1;
17 
18  xt = xt.unit();
19  if(fabs(pt) > 0){
20  yt = yt.unit();
21  zt = zt.unit();
22  }
23 
25  R(0,0) = xt.x(); R(0,1) = yt.x(); R(0,2) = zt.x();
26  R(1,0) = xt.y(); R(1,1) = yt.y(); R(1,2) = zt.y();
27  R(2,0) = xt.z(); R(2,1) = yt.z(); R(2,2) = zt.z();
28  R(3,3) = 1.;
29  R(4,4) = 1.;
30  R(5,5) = 1.;
31 
32  double p = pvec.mag(), p2 = p*p;
33  double lambda = 0.5 * M_PI - pvec.theta();
34  double phi = pvec.phi();
35  double sinlambda = sin(lambda), coslambda = cos(lambda);
36  double sinphi = sin(phi), cosphi = cos(phi);
37 
38  theJacobian(1,3) = 1.;
39  theJacobian(2,4) = 1.;
40  theJacobian(3,0) = -q * p2 * coslambda * cosphi;
41  theJacobian(3,1) = -p * sinlambda * cosphi;
42  theJacobian(3,2) = -p * coslambda * sinphi;
43  theJacobian(4,0) = -q * p2 * coslambda * sinphi;
44  theJacobian(4,1) = -p * sinlambda * sinphi;
45  theJacobian(4,2) = p * coslambda * cosphi;
46  theJacobian(5,0) = -q * p2 * sinlambda;
47  theJacobian(5,1) = p * coslambda;
48  theJacobian(5,2) = 0.;
49 
50  //ErrorPropagation:
51  // C(Cart) = R(6*6) * J(6*5) * C(Curvi) * J(5*6)_T * R(6*6)_T
52  theJacobian = R*theJacobian;
53  //dbg::dbg_trace(1,"Cu2Ca", globalParameters.vector(),theJacobian);
54  return theJacobian;
55 }
T perp() const
Definition: PV3DBase.h:72
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double p2[4]
Definition: TauolaWrapper.h:90
#define M_PI
Vector3DBase unit() const
Definition: Vector3DBase.h:57
Geom::Phi< T > phi() const
ROOT::Math::SMatrix< double, 6, 5, ROOT::Math::MatRepStd< double, 6, 5 > > AlgebraicMatrix65
T x() const
Definition: PV3DBase.h:62