CMS 3D CMS Logo

TrajectoryToResiduals.cc

Go to the documentation of this file.
00001 #include "TrajectoryToResiduals.h"
00002 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00003 #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
00004 #include "TrackingTools/TransientTrackingRecHit/interface/HelpertRecHit2DLocalPos.h"
00005 
00006 reco::TrackResiduals trajectoryToResiduals (const Trajectory &trajectory,
00007                                             enum reco::TrackResiduals::ResidualType type) 
00008 {
00009      reco::TrackResiduals residuals(type);
00010      int i_residual = 0;
00011      Trajectory::DataContainer::const_iterator i_fwd = 
00012           trajectory.measurements().begin(); 
00013      Trajectory::DataContainer::const_reverse_iterator i_bwd = 
00014           trajectory.measurements().rbegin(); 
00015      Trajectory::DataContainer::const_iterator i_end = 
00016           trajectory.measurements().end(); 
00017      Trajectory::DataContainer::const_reverse_iterator i_rend = 
00018           trajectory.measurements().rend(); 
00019      bool forward = trajectory.direction() == alongMomentum;
00020      for (; forward ? i_fwd != i_end : i_bwd != i_rend; 
00021           ++i_fwd, ++i_bwd, ++i_residual) {
00022           const TrajectoryMeasurement *i = forward ? &*i_fwd : &*i_bwd;
00023           if (!i->recHit()->isValid()) 
00024                continue;
00025           TrajectoryStateCombiner combine;
00026           TrajectoryStateOnSurface combo = combine(i->forwardPredictedState(),
00027                                                    i->backwardPredictedState());
00028           LocalPoint combo_localpos = combo.localPosition();
00029           LocalError combo_localerr = combo.localError().positionError();
00030           LocalPoint dethit_localpos = i->recHit()->localPosition();     
00031           LocalError dethit_localerr = i->recHit()->localPositionError();
00032           HelpertRecHit2DLocalPos helper;
00033           AlgebraicSymMatrix error_including_alignment = 
00034                helper.parError(dethit_localerr, *i->recHit()->det());
00035           switch (type) {
00036           case reco::TrackResiduals::X_Y_RESIDUALS: 
00037           {
00038                double x = (dethit_localpos.x() - combo_localpos.x()) / 
00039                     sqrt(error_including_alignment[0][0]);
00040                double y = (dethit_localpos.y() - combo_localpos.y()) / 
00041                     sqrt(error_including_alignment[1][1]);
00042                residuals.setResidualXY(i_residual, x, y);
00043                break;
00044           }
00045           case reco::TrackResiduals::X_Y_PULLS:
00046           {
00047                double x = (dethit_localpos.x() - combo_localpos.x()) / 
00048                     sqrt(error_including_alignment[0][0] + combo_localerr.xx());
00049                double y = (dethit_localpos.y() - combo_localpos.y()) / 
00050                     sqrt(error_including_alignment[1][1] + combo_localerr.yy());
00051                residuals.setPullXY(i_residual, x, y);
00052                break;
00053           }
00054           default:
00055                assert(0);
00056           }
00057      }
00058      return residuals;
00059 }

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