CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/TrackingTools/KalmanUpdators/interface/TrackingRecHitPropagator.h

Go to the documentation of this file.
00001 #ifndef TrackingTools_TrackingRecHitPropagator_h
00002 #define TrackingTools_TrackingRecHitPropagator_h
00003 
00004 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00005 #include "TrackingTools/KalmanUpdators/interface/TrackingRecHitPropagator.h"
00006 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00007 #include "MagneticField/Engine/interface/MagneticField.h"
00008 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00009 #include "TrackingTools/TransientTrackingRecHit/interface/InvalidTransientRecHit.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 
00012 
00013 /* propagates the RecHit position from the original reference frame
00014    to the reference frame of another detector.
00015    Useful for algorithms like the DAF or the MTF        
00016 */
00017 
00018 class TrackingRecHitPropagator {
00019         public: 
00020         TrackingRecHitPropagator(const MagneticField* magf){
00021                 thePropagator = new AnalyticalPropagator(magf, anyDirection, 1.6);
00022         };
00023 
00024         ~TrackingRecHitPropagator() {delete thePropagator;}
00025 
00026         template <class ResultingHit> TransientTrackingRecHit::RecHitPointer project(const TransientTrackingRecHit::ConstRecHitPointer hit,
00027                                                                                      const GeomDet& det,
00028                                                                                      const TrajectoryStateOnSurface ts) const{
00029         //1) propagate the best possible track parameters to the surface of the hit you want to "move" using a AnalyticalPropagator ;
00030         //2) create LocalTrajectoryParameters with the local x,y of the hit and direction + momentum from the propagated track parameters;
00031         //3) create a LocalTrajectoryError matrix which is 0 except for the local x,y submatrix, which is filled with the hit errors;
00032         //4) create a TSOS from the result of 2) and 3) and propagate it to the reference surface;
00033         //5) create a new hit with the local x,y subspace of the result of 4)
00034           if (!ts.isValid()) return InvalidTransientRecHit::build(hit->det());
00035           //      LogTrace("SiTrackerMultiRecHitUpdator") << "the tsos is valid";         
00036                 //check if the ts lays or not on the destination surface and in case propagate it
00037                 TrajectoryStateOnSurface propagated =ts;
00038                 if (hit->surface() != &(ts.surface())) propagated = thePropagator->propagate(ts, *(hit->surface()));
00039                 if (!propagated.isValid()) return InvalidTransientRecHit::build(hit->det());    
00040                 //        LogTrace("SiTrackerMultiRecHitUpdator") << "the propagate tsos is valid";       
00041                 //              LogTrace("SiTrackerMultiRecHitUpdator") << "Original: position: "<<hit->parameters()<<" error: "<<hit->parametersError()<<std::endl;
00042                 //clone the original hit with this state
00043                 TransientTrackingRecHit::RecHitPointer updatedOriginal = hit->clone(propagated);
00044                 //              LogTrace("SiTrackerMultiRecHitUpdator") << "New: position: "<<updatedOriginal->parameters()<<" error: "<<updatedOriginal->parametersError()<<std::endl;
00045                 
00046                 //        LogTrace("SiTrackerMultiRecHitUpdator") << "rechit cloned";     
00047                 LocalTrajectoryParameters ltp(updatedOriginal->localPosition(), propagated.localMomentum(), propagated.charge());
00048                 AlgebraicSymMatrix55 ltem;
00049                 ltem(3,3) = (updatedOriginal->parametersError())(1,1);
00050                 ltem(4,4) = (updatedOriginal->parametersError())(2,2);
00051                 ltem(3,4) = (updatedOriginal->parametersError())(1,2);
00052                 //              LogTrace("SiTrackerMultiRecHitUpdator") <<"The cov matrix: "<<ltem<<std::endl;
00053                 LocalTrajectoryError lte(ltem);
00054                 //              LogTrace("SiTrackerMultiRecHitUpdator") <<"Original cov matrix: "<<lte.matrix()<<std::endl;
00055                 TrajectoryStateOnSurface hit_state(ltp, lte, propagated.surface(), propagated.magneticField());
00056                 TrajectoryStateOnSurface projected_hit_state = thePropagator->propagate(hit_state, det.surface());
00057                 if (!projected_hit_state.isValid()) return InvalidTransientRecHit::build(hit->det());   
00058                 LocalPoint p = projected_hit_state.localPosition();
00059                 LocalError e = projected_hit_state.localError().positionError();
00060                 //              LogTrace("SiTrackerMultiRecHitUpdator") << "position: "<<p<<" error: "<<e<<std::endl;
00061                 //AlgebraicSymMatrix55 projm=projected_hit_state.localError().matrix();   
00062                 //              for(int i=0;i<5;i++){
00063                 //              LogTrace("SiTrackerMultiRecHitUpdator") <<"cov matrix: "<<projm<<std::endl;
00064                 //              }
00065                 return ResultingHit::build(p, e, &det, updatedOriginal->det(), updatedOriginal, this);
00066         }
00067         
00068         private:
00069         const AnalyticalPropagator* thePropagator;
00070 };
00071 
00072 #endif