CMS 3D CMS Logo

TransverseImpactPointExtrapolator.cc

Go to the documentation of this file.
00001 #include "TrackingTools/PatternTools/interface/TransverseImpactPointExtrapolator.h"
00002 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00003 #include "DataFormats/GeometrySurface/interface/Surface.h" 
00004 #include "boost/intrusive_ptr.hpp" 
00005 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00006 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00007 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00008 #include "DataFormats/GeometryVector/interface/Point2DBase.h"
00009 #include "DataFormats/GeometryVector/interface/Vector2DBase.h"
00010 #include "DataFormats/GeometrySurface/interface/PlaneBuilder.h"
00011 
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 
00014 
00015 TransverseImpactPointExtrapolator::TransverseImpactPointExtrapolator () :
00016   thePropagator(0) {}
00017 
00018 
00019 TransverseImpactPointExtrapolator::TransverseImpactPointExtrapolator (const MagneticField* field) :
00020   thePropagator(new AnalyticalPropagator(field, anyDirection)) {}
00021 
00022 TransverseImpactPointExtrapolator::TransverseImpactPointExtrapolator (const Propagator& u) :
00023   thePropagator(u.clone()) 
00024 {
00025   thePropagator->setPropagationDirection(anyDirection);
00026 }
00027 
00028 TrajectoryStateOnSurface 
00029 TransverseImpactPointExtrapolator::extrapolate (const FreeTrajectoryState& fts, 
00030                                                 const GlobalPoint& vtx) const
00031 {
00032   return doExtrapolation(fts, vtx, *thePropagator);
00033 }
00034 
00035 TrajectoryStateOnSurface 
00036 TransverseImpactPointExtrapolator::extrapolate (const TrajectoryStateOnSurface tsos, 
00037                                                 const GlobalPoint& vtx) const
00038 {
00039   if ( !tsos.isValid() )  return tsos;
00040   return doExtrapolation(tsos, vtx, *thePropagator);
00041 }
00042 
00043 TrajectoryStateOnSurface 
00044 TransverseImpactPointExtrapolator::extrapolate (const FreeTrajectoryState& fts, 
00045                                                 const GlobalPoint& vtx, 
00046                                                 const Propagator& u) const
00047 {
00048   //
00049   // use clone of propagator for bidirectional propagation
00050   //
00051   DeepCopyPointerByClone<Propagator> p(u.clone());
00052   p->setPropagationDirection(anyDirection);
00053 
00054   return doExtrapolation(fts,vtx,*p);
00055 } 
00056 
00057 TrajectoryStateOnSurface 
00058 TransverseImpactPointExtrapolator::extrapolate (const TrajectoryStateOnSurface tsos, 
00059                                                 const GlobalPoint& vtx, 
00060                                                 const Propagator& u) const
00061 {
00062   if ( !tsos.isValid() )  return tsos;
00063   //
00064   // use clone of propagator for bidirectional propagation
00065   //
00066   DeepCopyPointerByClone<Propagator> p(u.clone());
00067   p->setPropagationDirection(anyDirection);
00068 
00069   return doExtrapolation(tsos,vtx,*p);
00070 } 
00071 
00072 TrajectoryStateOnSurface 
00073 TransverseImpactPointExtrapolator::doExtrapolation (const TrajectoryStateOnSurface tsos, 
00074                                                     const GlobalPoint& vtx, 
00075                                                     const Propagator& p) const
00076 {
00077   //
00078   // Compute tip surface
00079   //
00080   if (fabs(tsos.freeState()->transverseCurvature())<1.E-6){
00081     LogDebug("TransverseImpactPointExtrapolator")<< "negligeable curvature: using a trick to extrapolate:\n"<<tsos;
00082 
00083     //0T field probably
00084     //x is perpendicular to the momentum
00085     GlobalVector xLocal = GlobalVector(-tsos.globalMomentum().y(),tsos.globalMomentum().x(),0).unit();
00086     //y along global Z
00087     GlobalVector yLocal(0.,0.,1.);
00088     //z accordingly
00089     GlobalVector zLocal(xLocal.cross(yLocal));
00090 
00091     Surface::PositionType origin(vtx);
00092     Surface::RotationType rotation(xLocal,yLocal,zLocal);
00093     ReferenceCountingPointer<BoundPlane> surface =  PlaneBuilder().plane(origin,rotation);
00094     
00095     return p.propagate(*tsos.freeState(),*surface);
00096   }else{
00097   ReferenceCountingPointer<BoundPlane> surface = 
00098     tipSurface(tsos.globalPosition(),tsos.globalMomentum(),
00099                1./tsos.transverseCurvature(),vtx);
00100   //
00101   // propagate
00102   //
00103   return p.propagate(tsos,*surface);
00104   }
00105 }
00106 
00107 TrajectoryStateOnSurface 
00108 TransverseImpactPointExtrapolator::doExtrapolation (const FreeTrajectoryState& fts, 
00109                                                     const GlobalPoint& vtx, 
00110                                                     const Propagator& p) const
00111 {
00112   //
00113   // Compute tip surface
00114   //
00115   if (fabs(fts.transverseCurvature())<1.E-6){
00116     LogDebug("TransverseImpactPointExtrapolator")<< "negligeable curvature: using a trick to extrapolate:\n"<<fts;
00117 
00118     //0T field probably
00119     //x is perpendicular to the momentum
00120     GlobalVector xLocal = GlobalVector(-fts.momentum().y(),fts.momentum().x(),0).unit();
00121     //y along global Z
00122     GlobalVector yLocal(0.,0.,1.);
00123     //z accordingly
00124     GlobalVector zLocal(xLocal.cross(yLocal));
00125 
00126     Surface::PositionType origin(vtx);
00127     Surface::RotationType rotation(xLocal,yLocal,zLocal);
00128     ReferenceCountingPointer<BoundPlane> surface =  PlaneBuilder().plane(origin,rotation);
00129     
00130     return p.propagate(fts,*surface);
00131   }else{
00132   ReferenceCountingPointer<BoundPlane> surface = 
00133     tipSurface(fts.position(),fts.momentum(),
00134                1./fts.transverseCurvature(),vtx);
00135   //
00136   // propagate
00137   //
00138   return p.propagate(fts,*surface);
00139   }
00140 }
00141 
00142 ReferenceCountingPointer<BoundPlane>
00143 TransverseImpactPointExtrapolator::tipSurface (const GlobalPoint& position,
00144                                                const GlobalVector& momentum,
00145                                                const double& signedTransverseRadius,
00146                                                const GlobalPoint& vertex) const
00147 {
00148 
00149   LogDebug("TransverseImpactPointExtrapolator")<< position<<"\n"
00150                                                     <<momentum<<"\n"
00151                                                     <<"signedTransverseRadius : "<<signedTransverseRadius<<"\n"
00152                                                     <<vertex;
00153 
00154   typedef Point2DBase<double,GlobalTag> PositionType2D;
00155   typedef Vector2DBase<double,GlobalTag> DirectionType2D;
00156   
00157   PositionType2D x0(position.x(),position.y());
00158   DirectionType2D t0(-momentum.y(),momentum.x());
00159   t0 = t0/t0.mag();
00160 
00161   PositionType2D xc(x0+signedTransverseRadius*t0);
00162 
00163   DirectionType2D vtxDirection(xc.x()-vertex.x(),xc.y()-vertex.y());
00164   double vtxDistance = vtxDirection.mag();
00165 
00166   Surface::PositionType origin(vertex);
00167   GlobalVector xLocal(vtxDirection.x()/vtxDistance,
00168                       vtxDirection.y()/vtxDistance,
00169                       0.);
00170   if ( vtxDistance<fabs(signedTransverseRadius) )  xLocal = -xLocal;
00171   GlobalVector yLocal(0.,0.,1.);
00172   GlobalVector zLocal(xLocal.cross(yLocal));
00173   if ( zLocal.dot(momentum)<0. ) {
00174     yLocal = -yLocal;
00175     zLocal = -zLocal;
00176   }
00177   Surface::RotationType rotation(xLocal,yLocal,zLocal);
00178   return PlaneBuilder().plane(origin,rotation);
00179 }

Generated on Tue Jun 9 17:48:26 2009 for CMSSW by  doxygen 1.5.4