CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoTracker/TkDetLayers/src/TkDetUtil.cc

Go to the documentation of this file.
00001 #include "TkDetUtil.h"
00002 #include "TrackingTools/DetLayers/interface/PhiLess.h"
00003 
00004 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00005 #include "TrackingTools/PatternTools/interface/MeasurementEstimator.h"
00006 #include "DataFormats/GeometrySurface/interface/BoundPlane.h"
00007 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00008 #include "TrackingTools/DetLayers/interface/rangesIntersect.h"
00009 
00010 
00011 namespace tkDetUtil {
00012 
00013   namespace {
00014     struct PhiLess {
00015       bool operator()(float a, float b) const {
00016         return Geom::phiLess(a,b);
00017       }
00018     };
00019   }
00020 
00021   bool overlapInPhi( const GlobalPoint& crossPoint,const GeomDet & det, float phiWindow) 
00022   {
00023     float phi = crossPoint.barePhi();
00024     std::pair<float,float> phiRange(phi-phiWindow, phi+phiWindow);
00025     std::pair<float,float> detPhiRange = det.surface().phiSpan(); 
00026     //   return rangesIntersect( phiRange, detPhiRange, boost::function<bool(float,float)>(&Geom::phiLess));
00027     return rangesIntersect( phiRange, detPhiRange, PhiLess());
00028   }
00029  
00030 
00031   float computeWindowSize( const GeomDet* det, 
00032                            const TrajectoryStateOnSurface& tsos, 
00033                            const MeasurementEstimator& est)
00034   {
00035     const BoundPlane& startPlane = det->surface();  
00036     MeasurementEstimator::Local2DVector maxDistance = 
00037       est.maximalLocalDisplacement( tsos, startPlane);
00038     return calculatePhiWindow( maxDistance, tsos, startPlane);
00039   }
00040 
00041 
00042 
00043   float 
00044   calculatePhiWindow( const MeasurementEstimator::Local2DVector& maxDistance, 
00045                       const TrajectoryStateOnSurface& ts, 
00046                       const BoundPlane& plane)
00047   {
00048     
00049     LocalPoint start = ts.localPosition();
00050     float corners[]  =  { plane.toGlobal(LocalPoint( start.x()+maxDistance.x(), start.y()+maxDistance.y() )).barePhi(),
00051                           plane.toGlobal(LocalPoint( start.x()-maxDistance.x(), start.y()+maxDistance.y() )).barePhi(),
00052                           plane.toGlobal(LocalPoint( start.x()-maxDistance.x(), start.y()-maxDistance.y() )).barePhi(),
00053                           plane.toGlobal(LocalPoint( start.x()+maxDistance.x(), start.y()-maxDistance.y() )).barePhi() 
00054     };
00055     
00056     float phimin = corners[0];
00057     float phimax = phimin;
00058     for ( int i = 1; i<4; i++) {
00059       float cPhi = corners[i];
00060       if ( Geom::phiLess(cPhi, phimin) ) { phimin = cPhi; }
00061       if ( Geom::phiLess( phimax, cPhi) ) { phimax = cPhi; }
00062     }
00063     float phiWindow = phimax - phimin;
00064     if ( phiWindow < 0.) { phiWindow +=  2.*Geom::pi();}
00065     
00066     return phiWindow;
00067   }
00068 
00069 
00070 
00071 
00072 }