CMS 3D CMS Logo

JacobianCurvilinearToLocal.cc
Go to the documentation of this file.
5 
7 
10  const LocalTrajectoryParameters& localParameters,
11  const MagneticField& magField) : theJacobian(ROOT::Math::SMatrixNoInit()) {
12 
13  GlobalPoint x = surface.toGlobal(localParameters.position());
14  GlobalVector h = magField.inInverseGeV(x);
15  GlobalVector qh = h*localParameters.signedInverseMomentum(); // changed sign
16 
17 
18  // GlobalVector hdir = h.unit();
19  //double q = -h.mag() * localParameters.signedInverseMomentum();
20 
21  LocalVector tnl = localParameters.direction();
22  GlobalVector tn = surface.toGlobal(tnl);
23  double t1r = 1./tnl.z();
24 
25  // GlobalVector dj = surface.toGlobal(LocalVector(1., 0., 0.));
26  // GlobalVector dk = surface.toGlobal(LocalVector(0., 1., 0.));
27  // GlobalVector di = surface.toGlobal(LocalVector(0., 0., 1.));
28  Surface::RotationType const & rot = surface.rotation();
29 
30  compute(rot, tn, qh, t1r);
31 }
32 
35  const LocalTrajectoryParameters& localParameters,
36  const GlobalTrajectoryParameters& globalParameters,
37  const MagneticField& magField) : theJacobian(ROOT::Math::SMatrixNoInit()) {
38 
39  // GlobalPoint x = globalParameters.position();
40  // GlobalVector h = magField.inInverseGeV(x);
41  GlobalVector h = globalParameters.magneticFieldInInverseGeV();
42  GlobalVector qh = h*localParameters.signedInverseMomentum(); // changed sign
43 
44  //GlobalVector hdir = h.unit();
45  //double q = -h.mag() * localParameters.signedInverseMomentum();
46 
47 
48  // GlobalVector tn = globalParameters.momentum().unit();
49  // LocalVector tnl = localParameters.momentum().unit();
50 
51  LocalVector tnl = localParameters.direction();
52  // GlobalVector tn = surface.toGlobal(tnl); // faster?
53  GlobalVector tn = globalParameters.momentum()*std::abs(localParameters.signedInverseMomentum());
54  double t1r = 1./tnl.z();
55 
56 
57  Surface::RotationType const & rot = surface.rotation();
58 
59  compute(rot, tn, qh, t1r);
60 }
61 
62 
63 void JacobianCurvilinearToLocal::compute(Surface::RotationType const & rot, GlobalVector const & tn, GlobalVector const & qh, double t1r) {
64  // Origin: TRSCSD
65 
66  double cosl = tn.perp(); if (cosl < 1.e-30) cosl = 1.e-30;
67  double cosl1 = 1./cosl;
68  GlobalVector un(-tn.y()*cosl1, tn.x()*cosl1, 0.);
69  GlobalVector vn(-tn.z()*un.y(), tn.z()*un.x(), cosl);
70 
71  auto u = rot.rotate(un.basicVector());
72  auto v = rot.rotate(vn.basicVector());
73 
74  int j=0, k=1, i=2;
75 
76  // double t1r = 1./tvw.x();
77  double t2r = t1r*t1r;
78  double t3r = t1r*t2r;
79 
80  theJacobian(0,0) = 1.;
81  for (auto i=1;i<5; ++i) theJacobian(0,i)=0.;
82  theJacobian(1,0) = 0.;
83  theJacobian(2,0) = 0.;
84 
85  theJacobian(1,1) = -u[k]*t2r;
86  theJacobian(1,2) = v[k]*(cosl*t2r);
87  theJacobian(2,1) = u[j]*t2r;
88  theJacobian(2,2) = -v[j]*(cosl*t2r);
89 
90  for (auto i=0;i<3; ++i) { theJacobian(3,i)=0.; theJacobian(4,i)=0.; }
91 
92  theJacobian(3,3) = v[k]*t1r;
93  theJacobian(3,4) = -u[k]*t1r;
94  theJacobian(4,3) = -v[j]*t1r;
95  theJacobian(4,4) = u[j]*t1r;
96 
97 
98  double sinz = un.dot(qh);
99  double cosz =-vn.dot(qh);
100  double ui = u[i]*(t3r);
101  double vi = v[i]*(t3r);
102  theJacobian(1,3) =-ui*(v[k]*cosz-u[k]*sinz);
103  theJacobian(1,4) =-vi*(v[k]*cosz-u[k]*sinz);
104  theJacobian(2,3) = ui*(v[j]*cosz-u[j]*sinz);
105  theJacobian(2,4) = vi*(v[j]*cosz-u[j]*sinz);
106  // end of TRSCSD
107  //dbg::dbg_trace(1,"Cu2L", localParameters.vector(),di,dj,dk,theJacobian);
108 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
LocalVector direction() const
Momentum vector unit in the local frame.
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
LocalPoint position() const
Local x and y position coordinates.
T y() const
Definition: PV3DBase.h:63
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
JacobianCurvilinearToLocal(const Surface &surface, const LocalTrajectoryParameters &localParameters, const MagneticField &magField)
GlobalVector magneticFieldInInverseGeV(const GlobalPoint &x) const
float signedInverseMomentum() const
Signed inverse momentum q/p (zero for neutrals).
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:39
Basic3DVector< T > rotate(const Basic3DVector< T > &v) const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
const RotationType & rotation() const
void compute(Surface::RotationType const &rot, GlobalVector const &tn, GlobalVector const &qh, double lz)
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56