CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/TrackingTools/TransientTrackingRecHit/interface/TrackingRecHitProjector.h

Go to the documentation of this file.
00001 #ifndef TrackingRecHitProjector_H
00002 #define TrackingRecHitProjector_H
00003 
00004 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00005 //#include <iostream>
00006 
00007 template <class ResultingHit>
00008 class TrackingRecHitProjector {
00009  public:
00010 
00011   typedef  TransientTrackingRecHit::RecHitPointer      RecHitPointer;
00012 
00013 
00014   RecHitPointer project( const TransientTrackingRecHit& hit,
00015                          const GeomDet& det, 
00016                          const TrajectoryStateOnSurface& ts) const {
00017 
00018     GlobalVector gdir = ts.globalParameters().momentum();
00019     return project(hit, det, gdir);
00020   }
00021   RecHitPointer project( const TransientTrackingRecHit& hit,
00022                          const GeomDet& det) const {
00023     GlobalVector gdir = hit.globalPosition() - GlobalPoint(0,0,0);
00024     return project(hit, det, gdir);
00025   }
00026 
00027   RecHitPointer project( const TransientTrackingRecHit& hit,
00028                          const GeomDet& det,
00029                          const GlobalVector & gdir) const {
00030     const BoundPlane& gluedPlane = det.surface();
00031     const BoundPlane& hitPlane = hit.det()->surface();
00032 
00033     // check if the planes are parallel
00034     //const float epsilon = 1.e-7; // corresponds to about 0.3 miliradian but cannot be reduced
00035                                  // because of float precision
00036 
00037     //if (fabs(gluedPlane.normalVector().dot( hitPlane.normalVector())) < 1-epsilon) {
00038     //       std::cout << "TkGluedMeasurementDet plane not parallel to DetUnit plane: dot product is " 
00039     //     << gluedPlane.normalVector().dot( hitPlane.normalVector()) << endl;
00040     // FIXME: throw the appropriate exception here...
00041     //throw MeasurementDetException("TkGluedMeasurementDet plane not parallel to DetUnit plane");
00042     //}
00043 
00044     double delta = gluedPlane.localZ( hitPlane.position());
00045     LocalVector ldir = gluedPlane.toLocal(gdir);
00046     LocalPoint lhitPos = gluedPlane.toLocal( hit.globalPosition());
00047     LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
00048 
00049     LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1,0,0)));
00050     LocalError hitErr = hit.localPositionError();
00051     if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
00052       // the two planes are inverted, and the correlation element must change sign
00053       hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
00054     }
00055     LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
00056     
00057     return ResultingHit::build( projectedHitPos, rotatedError, &det, hit.det(), hit);
00058   }
00059 
00060 };
00061 
00062 #endif