CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/TrackingTools/GsfTools/src/MultiTrajectoryStateTransform.cc

Go to the documentation of this file.
00001 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateTransform.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 
00004 #include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
00005 #include "DataFormats/GsfTrackReco/interface/GsfTrackExtraFwd.h"
00006 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00007 #include "TrackingTools/GsfTools/interface/BasicMultiTrajectoryState.h"
00008 #include "TrackingTools/TrajectoryParametrization/interface/LocalTrajectoryParameters.h"
00009 #include "TrackingTools/TrajectoryParametrization/interface/LocalTrajectoryError.h"
00010 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00011 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00012 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00013 #include "TrackingTools/GsfTools/interface/GsfPropagatorAdapter.h"
00014 #include "TrackingTools/PatternTools/interface/TransverseImpactPointExtrapolator.h"
00015 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateMode.h"
00016 
00017 MultiTrajectoryStateTransform::~MultiTrajectoryStateTransform () {delete extrapolator_;}
00018 
00019 TrajectoryStateOnSurface 
00020 MultiTrajectoryStateTransform::outerStateOnSurface(const reco::GsfTrack& tk) const
00021 {
00022   return checkGeometry() ? outerStateOnSurface(tk,*geometry_,field_) : TrajectoryStateOnSurface();
00023 }
00024 
00025 TrajectoryStateOnSurface 
00026 MultiTrajectoryStateTransform::innerStateOnSurface(const reco::GsfTrack& tk) const
00027 {
00028   return checkGeometry() ? innerStateOnSurface(tk,*geometry_,field_) : TrajectoryStateOnSurface();
00029 }
00030 
00031 bool
00032 MultiTrajectoryStateTransform::outerMomentumFromMode (const reco::GsfTrack& tk,
00033                                                       GlobalVector& momentum) const
00034 {
00035   return MultiTrajectoryStateMode().momentumFromModeCartesian(outerStateOnSurface(tk),momentum);
00036 }
00037 
00038 bool
00039 MultiTrajectoryStateTransform::innerMomentumFromMode (const reco::GsfTrack& tk,
00040                                                       GlobalVector& momentum) const
00041 {
00042   return MultiTrajectoryStateMode().momentumFromModeCartesian(outerStateOnSurface(tk),momentum);
00043 }
00044 
00045 TrajectoryStateOnSurface 
00046 MultiTrajectoryStateTransform::outerStateOnSurface( const reco::GsfTrack& tk, 
00047                                                     const TrackingGeometry& geom,
00048                                                     const MagneticField* field) const
00049 {
00050   const Surface& surface = geom.idToDet( DetId( tk.extra()->outerDetId()))->surface();
00051 
00052   const reco::GsfTrackExtraRef& extra(tk.gsfExtra());
00053   return stateOnSurface(extra->outerStateWeights(),
00054                         extra->outerStateLocalParameters(),
00055                         extra->outerStateCovariances(),
00056                         extra->outerStateLocalPzSign(),
00057                         surface,field);
00058 }
00059 
00060 TrajectoryStateOnSurface 
00061 MultiTrajectoryStateTransform::innerStateOnSurface( const reco::GsfTrack& tk, 
00062                                                     const TrackingGeometry& geom,
00063                                                     const MagneticField* field) const
00064 {
00065   const Surface& surface = geom.idToDet( DetId( tk.extra()->innerDetId()))->surface();
00066 
00067   const reco::GsfTrackExtraRef& extra(tk.gsfExtra());
00068   return stateOnSurface(extra->innerStateWeights(),
00069                         extra->innerStateLocalParameters(),
00070                         extra->innerStateCovariances(),
00071                         extra->innerStateLocalPzSign(),
00072                         surface,field);
00073 }
00074 
00075 TrajectoryStateOnSurface 
00076 MultiTrajectoryStateTransform::stateOnSurface (const std::vector<double>& weights,
00077                                                const std::vector<ParameterVector>& parameters,
00078                                                const std::vector<CovarianceMatrix>& covariances,
00079                                                const double& pzSign,
00080                                                const Surface& surface,
00081                                                const MagneticField* field) const
00082 {
00083   if ( weights.empty() )  return TrajectoryStateOnSurface();
00084   
00085   unsigned int nc(weights.size());
00086   AlgebraicVector5 pars;
00087   AlgebraicSymMatrix55 cov;
00088   
00089   std::vector<TrajectoryStateOnSurface> components;
00090   components.reserve(nc);
00091   
00092   // create components TSOSs
00093   for ( unsigned int i=0; i<nc; i++ ) {
00094     // convert parameter vector and covariance matrix
00095     for ( unsigned int j1=0; j1<dimension; j1++ ) {
00096       pars[j1] = parameters[i](j1);
00097       for ( unsigned int j2=0; j2<=j1; j2++ ) 
00098         cov(j1,j2) = covariances[i](j1,j2);          //FIXME: SMatrix copy constructor should handle this!!
00099     }
00100     // create local parameters & errors
00101     LocalTrajectoryParameters lp(pars,pzSign);
00102     LocalTrajectoryError le(cov);
00103     // create component
00104     components.push_back(TrajectoryStateOnSurface(lp,le,surface,field,weights[i]));
00105   }
00106   return 
00107     TrajectoryStateOnSurface(new BasicMultiTrajectoryState(components));
00108 }
00109 
00110 bool
00111 MultiTrajectoryStateTransform::checkGeometry () const
00112 {
00113   if ( geometry_ && field_ )  return true;
00114 
00115   edm::LogError("MultiTrajectoryStateTransform") << "Missing ES components";
00116   return false;
00117 }
00118 
00119 TrajectoryStateOnSurface 
00120 MultiTrajectoryStateTransform::extrapolatedState (const TrajectoryStateOnSurface tsos,
00121                                                   const GlobalPoint& point) const
00122 {
00123   return checkExtrapolator() ? extrapolator_->extrapolate(tsos,point) : TrajectoryStateOnSurface();
00124 }
00125 
00126 bool
00127 MultiTrajectoryStateTransform::checkExtrapolator () const
00128 {
00129   if ( extrapolator_ )  return true;
00130 
00131   if ( field_==0 ) {
00132     edm::LogError("MultiTrajectoryStateTransform") << "Missing magnetic field";
00133     return false;
00134   }
00135 
00136   GsfPropagatorAdapter gsfPropagator(AnalyticalPropagator(field_,anyDirection));
00137   extrapolator_ = new TransverseImpactPointExtrapolator(gsfPropagator);
00138   return true;
00139 }