CMS 3D CMS Logo

TrackKinematicStatePropagator.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFitPrimitives/interface/TrackKinematicStatePropagator.h"
00002 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCartesianToCurvilinear.h"
00003 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCurvilinearToCartesian.h"
00004 #include "TrackingTools/AnalyticalJacobians/interface/AnalyticalCurvilinearJacobian.h"
00005 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00006 
00007 using namespace std;
00008 
00009 KinematicState
00010 TrackKinematicStatePropagator::propagateToTheTransversePCA
00011         (const KinematicState& state, const GlobalPoint& referencePoint) const
00012 {
00013  if( state.particleCharge() == 0. ) {
00014     return propagateToTheTransversePCANeutral(state, referencePoint);
00015   } else {
00016     return propagateToTheTransversePCACharged(state, referencePoint);
00017   }
00018 }
00019 
00020 pair<HelixBarrelPlaneCrossingByCircle,BoundPlane *>
00021 TrackKinematicStatePropagator::planeCrossing(const FreeTrajectoryState& state,
00022         const GlobalPoint& point) const
00023 {
00024  GlobalPoint inPos = state.position();
00025  GlobalVector inMom = state.momentum();
00026  double kappa = state.transverseCurvature();
00027  double fac = 1./state.charge()/state.parameters().magneticField().inInverseGeV(point).z();
00028  
00029  GlobalVectorDouble xOrig2Centre = GlobalVectorDouble(fac * inMom.y(), -fac * inMom.x(), 0.);
00030  GlobalVectorDouble xOrigProj = GlobalVectorDouble(inPos.x(), inPos.y(), 0.);
00031  GlobalVectorDouble xRefProj = GlobalVectorDouble(point.x(), point.y(), 0.);
00032  GlobalVectorDouble deltax = xRefProj-xOrigProj-xOrig2Centre;
00033  GlobalVectorDouble ndeltax = deltax.unit();
00034   
00035  PropagationDirection direction = anyDirection;
00036  Surface::PositionType pos(point);
00037   
00038 // Need to define plane with orientation as the ImpactPointSurface
00039  GlobalVector X(ndeltax.x(), ndeltax.y(), ndeltax.z());
00040  GlobalVector Y(0.,0.,1.);
00041  Surface::RotationType rot(X,Y);
00042  BoundPlane* plane = new BoundPlane(pos,rot);
00043  HelixBarrelPlaneCrossingByCircle 
00044    planeCrossing(HelixPlaneCrossing::PositionType(inPos.x(), inPos.y(), inPos.z()),
00045                  HelixPlaneCrossing::DirectionType(inMom.x(), inMom.y(), inMom.z()), 
00046                  kappa, direction);
00047  pair<bool,double> propResult = planeCrossing.pathLength(*plane);
00048  if ( !propResult.first ) throw VertexException("KinematicStatePropagator without material::propagation failed!");
00049  return pair<HelixBarrelPlaneCrossingByCircle,BoundPlane *>(planeCrossing,plane);
00050 }
00051 
00052 
00053 KinematicState
00054 TrackKinematicStatePropagator::propagateToTheTransversePCACharged
00055         (const KinematicState& state, const GlobalPoint& referencePoint) const
00056 {
00057 //first use the existing FTS propagator to obtain parameters at PCA
00058 //in transverse plane to the given point
00059 
00060 //final parameters and covariance
00061   AlgebraicVector7 par;
00062   AlgebraicSymMatrix77 cov;
00063     
00064 //initial parameters as class and vectors:  
00065   GlobalTrajectoryParameters inPar(state.globalPosition(),state.globalMomentum(), 
00066                 state.particleCharge(), state.magneticField());
00067   ParticleMass mass = state.mass();                                                       
00068   GlobalVector inMom = state.globalMomentum();                                                    
00069   
00070 //making a free trajectory state and looking 
00071 //for helix barrel plane crossing  
00072   FreeTrajectoryState fState = state.freeTrajectoryState();             
00073   GlobalPoint iP = referencePoint;                                        
00074   pair<HelixBarrelPlaneCrossingByCircle, BoundPlane *> cros = planeCrossing(fState,iP);    
00075   
00076   HelixBarrelPlaneCrossingByCircle planeCrossing = cros.first; 
00077   BoundPlane * plane = cros.second;
00078   pair<bool,double> propResult = planeCrossing.pathLength(*plane);
00079   double s = propResult.second;
00080   
00081   HelixPlaneCrossing::PositionType xGen = planeCrossing.position(s);
00082   GlobalPoint nPosition(xGen.x(),xGen.y(),xGen.z());
00083   HelixPlaneCrossing::DirectionType pGen = planeCrossing.direction(s);
00084   pGen *= inMom.mag()/pGen.mag();
00085   GlobalVector nMomentum(pGen.x(),pGen.y(),pGen.z()); 
00086   par(0) = nPosition.x();
00087   par(1) = nPosition.y();
00088   par(2) = nPosition.z();
00089   par(3) = nMomentum.x();
00090   par(4) = nMomentum.y();
00091   par(5) = nMomentum.z();
00092   par(6) = mass;
00093   
00094 //covariance matrix business  
00095 //elements of 7x7 covariance matrix responcible for the mass and
00096 //mass - momentum projections corellations do change under such a transformation:
00097 //special Jacobian needed  
00098   GlobalTrajectoryParameters fPar(nPosition, nMomentum, state.particleCharge(),
00099                                 state.magneticField());
00100                                                                                                   
00101   JacobianCartesianToCurvilinear cart2curv(inPar);
00102   JacobianCurvilinearToCartesian curv2cart(fPar);
00103   
00104   AlgebraicMatrix67 ca2cu;
00105   AlgebraicMatrix76 cu2ca;
00106   ca2cu.Place_at(cart2curv.jacobian(),0,0);
00107   cu2ca.Place_at(curv2cart.jacobian(),0,0);
00108   ca2cu(5,6) = 1;  
00109   cu2ca(6,5) = 1;
00110 
00111 //now both transformation jacobians: cartesian to curvilinear and back are done
00112 //We transform matrix to curv frame, then propagate it and translate it back to
00113 //cartesian frame.  
00114   AlgebraicSymMatrix66 cov1 = ROOT::Math::Similarity(ca2cu, state.kinematicParametersError().matrix());
00115 
00116 //propagation jacobian
00117   AnalyticalCurvilinearJacobian prop(inPar,nPosition,nMomentum,s);
00118   AlgebraicMatrix66 pr;
00119   pr(5,5) = 1;
00120   pr.Place_at(prop.jacobian(),0,0);
00121 
00122 //transportation
00123   AlgebraicSymMatrix66 cov2 = ROOT::Math::Similarity(pr, cov1);
00124   
00125 //now geting back to 7-parametrization from curvilinear
00126   cov = ROOT::Math::Similarity(cu2ca, cov2);
00127   
00128 //return parameters as a kiematic state  
00129   KinematicParameters resPar(par);
00130   KinematicParametersError resEr(cov);
00131   return  KinematicState(resPar,resEr,state.particleCharge(), state.magneticField()); 
00132  }
00133   
00134 KinematicState TrackKinematicStatePropagator::propagateToTheTransversePCANeutral
00135         (const KinematicState& state, const GlobalPoint& referencePoint) const
00136 {
00137 //new parameters vector and covariance:
00138  AlgebraicVector7 par;
00139  AlgebraicSymMatrix77 cov;
00140  
00141  AlgebraicVector7 inStatePar = state.kinematicParameters().vector();
00142  GlobalTrajectoryParameters inPar(state.globalPosition(),state.globalMomentum(), 
00143                 state.particleCharge(), state.magneticField());
00144  
00145 //first making a free trajectory state and propagating it according
00146 //to the algorithm provided by Thomas Speer and Wolfgang Adam 
00147  FreeTrajectoryState fState = state.freeTrajectoryState();
00148   
00149  GlobalPoint xvecOrig = fState.position();
00150  double phi = fState.momentum().phi();
00151  double theta = fState.momentum().theta();
00152  double xOrig = xvecOrig.x();
00153  double yOrig = xvecOrig.y();
00154  double zOrig = xvecOrig.z();
00155  double xR = referencePoint.x();
00156  double yR = referencePoint.y();
00157 
00158  double s2D = (xR - xOrig)  * cos(phi) + (yR - yOrig)  * sin(phi);
00159  double s = s2D / sin(theta);
00160  double xGen = xOrig + s2D*cos(phi);
00161  double yGen = yOrig + s2D*sin(phi);
00162  double zGen = zOrig + s2D/tan(theta);
00163  GlobalPoint xPerigee = GlobalPoint(xGen, yGen, zGen);
00164 
00165 //new parameters
00166  GlobalVector pPerigee = fState.momentum();
00167  par(0) = xPerigee.x();
00168  par(1) = xPerigee.y(); 
00169  par(2) = xPerigee.z(); 
00170  par(3) = pPerigee.x(); 
00171  par(4) = pPerigee.y(); 
00172  par(5) = pPerigee.z(); 
00173  par(6) = inStatePar(7);
00174 
00175 //covariance matrix business:
00176 //everything lake it was before: jacobains are smart enouhg to 
00177 //distinguish between neutral and charged states themselves
00178 
00179  GlobalTrajectoryParameters fPar(xPerigee, pPerigee, state.particleCharge(),
00180                                 state.magneticField());
00181 
00182  JacobianCartesianToCurvilinear cart2curv(inPar);
00183  JacobianCurvilinearToCartesian curv2cart(fPar);
00184   
00185   AlgebraicMatrix67 ca2cu;
00186   AlgebraicMatrix76 cu2ca;
00187   ca2cu.Place_at(cart2curv.jacobian(),0,0);
00188   cu2ca.Place_at(curv2cart.jacobian(),0,0);
00189   ca2cu(5,6) = 1;  
00190   cu2ca(6,5) = 1;
00191 
00192 //now both transformation jacobians: cartesian to curvilinear and back are done
00193 //We transform matrix to curv frame, then propagate it and translate it back to
00194 //cartesian frame.  
00195   AlgebraicSymMatrix66 cov1 = ROOT::Math::Similarity(ca2cu, state.kinematicParametersError().matrix());
00196 
00197 //propagation jacobian
00198   AnalyticalCurvilinearJacobian prop(inPar,xPerigee,pPerigee,s);
00199   AlgebraicMatrix66 pr;
00200   pr(5,5) = 1;
00201   pr.Place_at(prop.jacobian(),0,0);
00202   
00203 //transportation
00204   AlgebraicSymMatrix66 cov2 = ROOT::Math::Similarity(pr, cov1);
00205   
00206 //now geting back to 7-parametrization from curvilinear
00207   cov = ROOT::Math::Similarity(cu2ca, cov2);
00208  
00209 //return parameters as a kiematic state  
00210  KinematicParameters resPar(par);
00211  KinematicParametersError resEr(cov);
00212  return  KinematicState(resPar,resEr,state.particleCharge(), state.magneticField());    
00213 }
00214 
00215 

Generated on Tue Jun 9 17:46:11 2009 for CMSSW by  doxygen 1.5.4