CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/MeasurementDet/src/TkPixelMeasurementDet.cc

Go to the documentation of this file.
00001 #include "RecoTracker/MeasurementDet/interface/TkPixelMeasurementDet.h"
00002 #include "TrackingTools/TransientTrackingRecHit/interface/InvalidTransientRecHit.h"
00003 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00004 #include "TrackingTools/MeasurementDet/interface/MeasurementDetException.h"
00005 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
00006 #include "RecoTracker/TransientTrackingRecHit/interface/TSiPixelRecHit.h"
00007 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00008 #include "TrackingTools/PatternTools/interface/MeasurementEstimator.h"
00009 #include "TrackingTools/PatternTools/interface/TrajMeasLessEstim.h"
00010 
00011 const float TkPixelMeasurementDet::theRocWidth  = 8.1;
00012 const float TkPixelMeasurementDet::theRocHeight = 8.1;
00013 
00014 TkPixelMeasurementDet::TkPixelMeasurementDet( const GeomDet* gdet,
00015                                               const PixelClusterParameterEstimator* cpe) : 
00016     MeasurementDet (gdet),
00017     theCPE(cpe),
00018     empty(true),
00019     activeThisEvent_(true), activeThisPeriod_(true)
00020   {
00021     thePixelGDU = dynamic_cast<const PixelGeomDetUnit*>(gdet);
00022     if (thePixelGDU == 0) {
00023       throw MeasurementDetException( "TkPixelMeasurementDet constructed with a GeomDet which is not a PixelGeomDetUnit");
00024     }
00025   }
00026 
00027 std::vector<TrajectoryMeasurement> 
00028 TkPixelMeasurementDet::fastMeasurements( const TrajectoryStateOnSurface& stateOnThisDet, 
00029                                          const TrajectoryStateOnSurface& startingState, 
00030                                          const Propagator&, 
00031                                          const MeasurementEstimator& est) const
00032 {
00033   std::vector<TrajectoryMeasurement> result;
00034 
00035   if (isActive() == false) {
00036     result.push_back( TrajectoryMeasurement( stateOnThisDet, 
00037                 InvalidTransientRecHit::build(&geomDet(), TrackingRecHit::inactive), 
00038                 0.F));
00039     return result;
00040   }
00041  
00042   MeasurementDet::RecHitContainer allHits = recHits( stateOnThisDet);
00043   for (RecHitContainer::const_iterator ihit=allHits.begin();
00044        ihit != allHits.end(); ihit++) {
00045     std::pair<bool,double> diffEst = est.estimate( stateOnThisDet, **ihit);
00046     if ( diffEst.first) {
00047       result.push_back( TrajectoryMeasurement( stateOnThisDet, *ihit, 
00048                                                diffEst.second));
00049     }
00050     //RC else delete *ihit; // we own allHits and have to delete the ones we don't return
00051   }
00052   if ( result.empty()) {
00053     // create a TrajectoryMeasurement with an invalid RecHit and zero estimate
00054     TrackingRecHit::Type type = (hasBadComponents(stateOnThisDet) ? TrackingRecHit::inactive : TrackingRecHit::missing);
00055     result.push_back( TrajectoryMeasurement( stateOnThisDet, 
00056                                              InvalidTransientRecHit::build(&geomDet(), type), 0.F)); 
00057   }
00058   else {
00059     // sort results according to estimator value
00060     if ( result.size() > 1) {
00061       sort( result.begin(), result.end(), TrajMeasLessEstim());
00062     }
00063   }
00064   return result;
00065 }
00066 
00067 TransientTrackingRecHit::RecHitPointer
00068 TkPixelMeasurementDet::buildRecHit( const SiPixelClusterRef & cluster,
00069                                     const LocalTrajectoryParameters & ltp) const
00070 {
00071   const GeomDetUnit& gdu( specificGeomDet());
00072   LocalValues lv = theCPE->localParameters( * cluster, gdu, ltp );
00073   return TSiPixelRecHit::build( lv.first, lv.second, &geomDet(), cluster, theCPE);
00074 }
00075 
00076 TkPixelMeasurementDet::RecHitContainer 
00077 TkPixelMeasurementDet::recHits( const TrajectoryStateOnSurface& ts ) const
00078 {
00079   RecHitContainer result;
00080   if (empty == true ) return result;
00081   if (isActive() == false) return result; 
00082   for ( const_iterator ci = detSet_.begin(); ci != detSet_.end(); ++ ci ) {
00083     SiPixelClusterRef cluster = edmNew::makeRefTo( handle_, ci ); 
00084     if (skipClusters_.find(cluster)==skipClusters_.end())
00085       result.push_back( buildRecHit( cluster, ts.localParameters() ) );
00086     else LogDebug("TkPixelMeasurementDet")<<"skipping this cluster from last iteration on "<<geomDet().geographicalId().rawId()<<" key: "<<cluster.key();
00087   }
00088   return result;
00089 }
00090 
00091 bool
00092 TkPixelMeasurementDet::hasBadComponents( const TrajectoryStateOnSurface &tsos ) const {
00093     if (badRocPositions_.empty()) return false;
00094     LocalPoint lp = tsos.localPosition();
00095     LocalError le = tsos.localError().positionError();
00096     double dx = 3*std::sqrt(le.xx()) + theRocWidth, dy = 3*std::sqrt(le.yy()) + theRocHeight;
00097     for (std::vector<LocalPoint>::const_iterator it = badRocPositions_.begin(), ed = badRocPositions_.end(); it != ed; ++it) {
00098         if ( (std::abs(it->x() - lp.x()) < dx) &&
00099              (std::abs(it->y() - lp.y()) < dy) ) return true;
00100     } 
00101     return false;
00102 }