CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/TrackingTools/PatternTools/src/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& p) const
00047 {
00048   //
00049   // set propagator for bidirectional propagation
00050   //
00051   SetPropagationDirection setter(p,anyDirection);
00052   return doExtrapolation(fts,vtx,p);
00053 } 
00054 
00055 TrajectoryStateOnSurface 
00056 TransverseImpactPointExtrapolator::extrapolate (const TrajectoryStateOnSurface tsos, 
00057                                                 const GlobalPoint& vtx, 
00058                                                 const Propagator& p) const
00059 {
00060   if ( !tsos.isValid() )  return tsos;
00061   //
00062   // set propagator for bidirectional propagation
00063   //
00064   SetPropagationDirection setter(p,anyDirection);
00065   return doExtrapolation(tsos,vtx,p);
00066 } 
00067 
00068 TrajectoryStateOnSurface 
00069 TransverseImpactPointExtrapolator::doExtrapolation (const TrajectoryStateOnSurface tsos, 
00070                                                     const GlobalPoint& vtx, 
00071                                                     const Propagator& p) const
00072 {
00073   //
00074   // Compute tip surface
00075   //
00076   if (fabs(tsos.freeState()->transverseCurvature())<1.E-6){
00077     LogDebug("TransverseImpactPointExtrapolator")<< "negligeable curvature: using a trick to extrapolate:\n"<<tsos;
00078 
00079     //0T field probably
00080     //x is perpendicular to the momentum
00081     GlobalVector xLocal = GlobalVector(-tsos.globalMomentum().y(),tsos.globalMomentum().x(),0).unit();
00082     //y along global Z
00083     GlobalVector yLocal(0.,0.,1.);
00084     //z accordingly
00085     GlobalVector zLocal(xLocal.cross(yLocal));
00086 
00087     Surface::PositionType origin(vtx);
00088     Surface::RotationType rotation(xLocal,yLocal,zLocal);
00089     ReferenceCountingPointer<BoundPlane> surface =  PlaneBuilder().plane(origin,rotation);
00090     
00091     return p.propagate(*tsos.freeState(),*surface);
00092   }else{
00093   ReferenceCountingPointer<BoundPlane> surface = 
00094     tipSurface(tsos.globalPosition(),tsos.globalMomentum(),
00095                1./tsos.transverseCurvature(),vtx);
00096   //
00097   // propagate
00098   //
00099   return p.propagate(tsos,*surface);
00100   }
00101 }
00102 
00103 TrajectoryStateOnSurface 
00104 TransverseImpactPointExtrapolator::doExtrapolation (const FreeTrajectoryState& fts, 
00105                                                     const GlobalPoint& vtx, 
00106                                                     const Propagator& p) const
00107 {
00108   //
00109   // Compute tip surface
00110   //
00111   if (fabs(fts.transverseCurvature())<1.E-6){
00112     LogDebug("TransverseImpactPointExtrapolator")<< "negligeable curvature: using a trick to extrapolate:\n"<<fts;
00113 
00114     //0T field probably
00115     //x is perpendicular to the momentum
00116     GlobalVector xLocal = GlobalVector(-fts.momentum().y(),fts.momentum().x(),0).unit();
00117     //y along global Z
00118     GlobalVector yLocal(0.,0.,1.);
00119     //z accordingly
00120     GlobalVector zLocal(xLocal.cross(yLocal));
00121 
00122     Surface::PositionType origin(vtx);
00123     Surface::RotationType rotation(xLocal,yLocal,zLocal);
00124     ReferenceCountingPointer<BoundPlane> surface =  PlaneBuilder().plane(origin,rotation);
00125     
00126     return p.propagate(fts,*surface);
00127   }else{
00128   ReferenceCountingPointer<BoundPlane> surface = 
00129     tipSurface(fts.position(),fts.momentum(),
00130                1./fts.transverseCurvature(),vtx);
00131   //
00132   // propagate
00133   //
00134   return p.propagate(fts,*surface);
00135   }
00136 }
00137 
00138 ReferenceCountingPointer<BoundPlane>
00139 TransverseImpactPointExtrapolator::tipSurface (const GlobalPoint& position,
00140                                                const GlobalVector& momentum,
00141                                                const double& signedTransverseRadius,
00142                                                const GlobalPoint& vertex) const
00143 {
00144 
00145   LogDebug("TransverseImpactPointExtrapolator")<< position<<"\n"
00146                                                     <<momentum<<"\n"
00147                                                     <<"signedTransverseRadius : "<<signedTransverseRadius<<"\n"
00148                                                     <<vertex;
00149 
00150   typedef Point2DBase<double,GlobalTag> PositionType2D;
00151   typedef Vector2DBase<double,GlobalTag> DirectionType2D;
00152   
00153   PositionType2D x0(position.x(),position.y());
00154   DirectionType2D t0(-momentum.y(),momentum.x());
00155   t0 = t0/t0.mag();
00156 
00157   PositionType2D xc(x0+signedTransverseRadius*t0);
00158 
00159   DirectionType2D vtxDirection(xc.x()-vertex.x(),xc.y()-vertex.y());
00160   double vtxDistance = vtxDirection.mag();
00161 
00162   Surface::PositionType origin(vertex);
00163   GlobalVector xLocal(vtxDirection.x()/vtxDistance,
00164                       vtxDirection.y()/vtxDistance,
00165                       0.);
00166   if ( vtxDistance<fabs(signedTransverseRadius) ) {
00167     LogDebug("TransverseImpactPointExtrapolator")<<"Inverting the x axis.";
00168     xLocal = -xLocal;
00169   }
00170   GlobalVector yLocal(0.,0.,1.);
00171   GlobalVector zLocal(xLocal.cross(yLocal));
00172   if ( zLocal.dot(momentum)<0. ) {
00173     LogDebug("TransverseImpactPointExtrapolator")<<"Inverting the y,z frame.";
00174     yLocal = -yLocal;
00175     zLocal = -zLocal;
00176   }
00177   Surface::RotationType rotation(xLocal,yLocal,zLocal);
00178   
00179   LogDebug("TransverseImpactPointExtrapolator")<<"plane center: "<<origin<<"\n"
00180                                                <<"plane rotation axis:\n"
00181                                                <<xLocal<<"\n"
00182                                                <<yLocal<<"\n"
00183                                                <<zLocal<<"\n"
00184                                                <<"x0: "<<x0<<"\n"
00185                                                <<"t0: "<<t0<<"\n"
00186                                                <<"xc: "<<xc<<"\n"
00187                                                <<"vtxDirection: "<<vtxDirection;
00188 
00189   return PlaneBuilder().plane(origin,rotation);
00190 }