CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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*localParameters.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); // faster?
00052   GlobalVector tn =  globalParameters.momentum()*std::abs(localParameters.signedInverseMomentum());
00053   double t1r = 1./tnl.z();
00054  
00055  
00056   Surface::RotationType const & rot = surface.rotation();
00057 
00058   compute(rot, tn, qh, t1r);
00059 }
00060 
00061 
00062 void JacobianCurvilinearToLocal::compute(Surface::RotationType const & rot, GlobalVector  const & tn, GlobalVector const & qh, double t1r) {
00063   // Origin: TRSCSD
00064 
00065   double cosl = tn.perp(); if (cosl < 1.e-30) cosl = 1.e-30;
00066   double cosl1 = 1./cosl;
00067   GlobalVector un(-tn.y()*cosl1, tn.x()*cosl1, 0.);
00068   GlobalVector vn(-tn.z()*un.y(), tn.z()*un.x(), cosl);
00069 
00070   auto u = rot.rotate(un.basicVector());
00071   auto v = rot.rotate(vn.basicVector());
00072 
00073   int j=0, k=1, i=2;
00074 
00075   //  double t1r = 1./tvw.x();
00076   double t2r = t1r*t1r;
00077   double t3r = t1r*t2r;
00078 
00079   theJacobian(0,0) = 1.;
00080   theJacobian(1,1) = -u[k]*t2r;
00081   theJacobian(1,2) = v[k]*(cosl*t2r);
00082   theJacobian(2,1) = u[j]*t2r;
00083   theJacobian(2,2) = -v[j]*(cosl*t2r);
00084   theJacobian(3,3) = v[k]*t1r;
00085   theJacobian(3,4) = -u[k]*t1r;
00086   theJacobian(4,3) = -v[j]*t1r;
00087   theJacobian(4,4) = u[j]*t1r;
00088 
00089 
00090   double sinz = un.dot(qh);
00091   double cosz =-vn.dot(qh);
00092   double ui = u[i]*(t3r);
00093   double vi = v[i]*(t3r);
00094   theJacobian(1,3) =-ui*(v[k]*cosz-u[k]*sinz);
00095   theJacobian(1,4) =-vi*(v[k]*cosz-u[k]*sinz);
00096   theJacobian(2,3) = ui*(v[j]*cosz-u[j]*sinz);
00097   theJacobian(2,4) = vi*(v[j]*cosz-u[j]*sinz);
00098   // end of TRSCSD
00099   //dbg::dbg_trace(1,"Cu2L", localParameters.vector(),di,dj,dk,theJacobian);
00100 }