CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/TrackingTools/AnalyticalJacobians/src/JacobianCurvilinearToLocal.cc

Go to the documentation of this file.
00001 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCurvilinearToLocal.h"
00002 #include "DataFormats/GeometrySurface/interface/Surface.h"
00003 #include "TrackingTools/TrajectoryParametrization/interface/LocalTrajectoryParameters.h"
00004 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00005 
00006 #include "MagneticField/Engine/interface/MagneticField.h"
00007 
00008 JacobianCurvilinearToLocal::
00009 JacobianCurvilinearToLocal(const Surface& surface, 
00010                            const LocalTrajectoryParameters& localParameters,
00011                            const MagneticField& magField) : theJacobian() {
00012  
00013   GlobalPoint  x = surface.toGlobal(localParameters.position());
00014   GlobalVector h  = magField.inInverseGeV(x);
00015   GlobalVector qh = h*localParameters.signedInverseMomentum();  // changed sign
00016 
00017 
00018   //  GlobalVector  hdir =  h.unit();
00019   //double q = -h.mag() * localParameters.signedInverseMomentum();
00020   
00021   LocalVector tnl = localParameters.direction();
00022   GlobalVector tn = surface.toGlobal(tnl);
00023   double t1r = 1./tnl.z();
00024 
00025   // GlobalVector dj = surface.toGlobal(LocalVector(1., 0., 0.));
00026   // GlobalVector dk = surface.toGlobal(LocalVector(0., 1., 0.));
00027   //  GlobalVector di = surface.toGlobal(LocalVector(0., 0., 1.));
00028   Surface::RotationType const & rot = surface.rotation();
00029 
00030   compute(rot, tn, qh, t1r);
00031 }
00032 
00033 JacobianCurvilinearToLocal::
00034 JacobianCurvilinearToLocal(const Surface& surface, 
00035                            const LocalTrajectoryParameters& localParameters,
00036                            const GlobalTrajectoryParameters& globalParameters,
00037                            const MagneticField& magField) : theJacobian() {
00038  
00039   GlobalPoint  x =  globalParameters.position();
00040   GlobalVector h  = magField.inInverseGeV(x);
00041   GlobalVector qh = h*globalParameters.signedInverseMomentum();  // changed sign
00042 
00043   //GlobalVector  hdir =  h.unit();
00044   //double q = -h.mag() * localParameters.signedInverseMomentum();
00045 
00046  
00047   //  GlobalVector tn = globalParameters.momentum().unit();
00048   //  LocalVector tnl = localParameters.momentum().unit();
00049 
00050   LocalVector tnl = localParameters.direction();
00051   GlobalVector tn = surface.toGlobal(tnl);
00052   double t1r = 1./tnl.z();
00053  
00054  
00055   Surface::RotationType const & rot = surface.rotation();
00056 
00057   compute(rot, tn, qh, t1r);
00058 }
00059 
00060 
00061 void JacobianCurvilinearToLocal::compute(Surface::RotationType const & rot, GlobalVector  const & tn, GlobalVector const & qh, double t1r) {
00062   // Origin: TRSCSD
00063 
00064   GlobalVector dj(rot.x());
00065   GlobalVector dk(rot.y());
00066   GlobalVector di(rot.z());
00067 
00068   double cosl = tn.perp(); if (cosl < 1.e-30) cosl = 1.e-30;
00069   double cosl1 = 1./cosl;
00070   GlobalVector un(-tn.y()*cosl1, tn.x()*cosl1, 0.);
00071   GlobalVector vn(-tn.z()*un.y(), tn.z()*un.x(), cosl);
00072 
00073   double uj = un.dot(dj);
00074   double uk = un.dot(dk);
00075   double vj = vn.dot(dj);
00076   double vk = vn.dot(dk);
00077 
00078   //  double t1r = 1./tvw.x();
00079   double t2r = t1r*t1r;
00080   double t3r = t1r*t2r;
00081 
00082   theJacobian(0,0) = 1.;
00083   theJacobian(1,1) = -uk*t2r;
00084   theJacobian(1,2) = vk*(cosl*t2r);
00085   theJacobian(2,1) = uj*t2r;
00086   theJacobian(2,2) = -vj*(cosl*t2r);
00087   theJacobian(3,3) = vk*t1r;
00088   theJacobian(3,4) = -uk*t1r;
00089   theJacobian(4,3) = -vj*t1r;
00090   theJacobian(4,4) = uj*t1r;
00091 
00092 
00093   double sinz = un.dot(qh);
00094   double cosz =-vn.dot(qh);
00095   double ui = un.dot(di)*(t3r);
00096   double vi = vn.dot(di)*(t3r);
00097   theJacobian(1,3) =-ui*(vk*cosz-uk*sinz);
00098   theJacobian(1,4) =-vi*(vk*cosz-uk*sinz);
00099   theJacobian(2,3) = ui*(vj*cosz-uj*sinz);
00100   theJacobian(2,4) = vi*(vj*cosz-uj*sinz);
00101   // end of TRSCSD
00102   //dbg::dbg_trace(1,"Cu2L", localParameters.vector(),di,dj,dk,theJacobian);
00103 }