CMS 3D CMS Logo

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   RecHitPointer project( const TransientTrackingRecHit& hit,
00014                          const GeomDet& det, 
00015                          const TrajectoryStateOnSurface& ts) const {
00016 
00017     GlobalVector gdir = ts.globalParameters().momentum();
00018     const BoundPlane& gluedPlane = det.surface();
00019     const BoundPlane& hitPlane = hit.det()->surface();
00020 
00021     // check if the planes are parallel
00022     //const float epsilon = 1.e-7; // corresponds to about 0.3 miliradian but cannot be reduced
00023                                  // because of float precision
00024 
00025     //if (fabs(gluedPlane.normalVector().dot( hitPlane.normalVector())) < 1-epsilon) {
00026     //       std::cout << "TkGluedMeasurementDet plane not parallel to DetUnit plane: dot product is " 
00027     //     << gluedPlane.normalVector().dot( hitPlane.normalVector()) << endl;
00028     // FIXME: throw the appropriate exception here...
00029     //throw MeasurementDetException("TkGluedMeasurementDet plane not parallel to DetUnit plane");
00030     //}
00031 
00032     double delta = gluedPlane.localZ( hitPlane.position());
00033     LocalVector ldir = gluedPlane.toLocal(gdir);
00034     LocalPoint lhitPos = gluedPlane.toLocal( hit.globalPosition());
00035     LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.z();
00036 
00037     LocalVector hitXAxis = gluedPlane.toLocal( hitPlane.toGlobal( LocalVector(1,0,0)));
00038     LocalError hitErr = hit.localPositionError();
00039     if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
00040       // the two planes are inverted, and the correlation element must change sign
00041       hitErr = LocalError( hitErr.xx(), -hitErr.xy(), hitErr.yy());
00042     }
00043     LocalError rotatedError = hitErr.rotate( hitXAxis.x(), hitXAxis.y());
00044     
00045     return ResultingHit::build( projectedHitPos, rotatedError, &det, hit.det(), hit);
00046   }
00047 
00048 };
00049 
00050 #endif

Generated on Tue Jun 9 17:48:40 2009 for CMSSW by  doxygen 1.5.4