Go to the documentation of this file.00001 #include "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/DetLayers/interface/MeasurementEstimator.h"
00009 #include "TrackingTools/PatternTools/interface/TrajMeasLessEstim.h"
00010
00011
00012 namespace {
00013 const float theRocWidth = 8.1;
00014 const float theRocHeight = 8.1;
00015 }
00016
00017 TkPixelMeasurementDet::TkPixelMeasurementDet( const GeomDet* gdet,
00018 const PixelClusterParameterEstimator* cpe) :
00019 MeasurementDet (gdet),
00020 theCPE(cpe),
00021 skipClusters_(0),
00022 empty(true),
00023 activeThisEvent_(true), activeThisPeriod_(true)
00024 {
00025 if ( dynamic_cast<const PixelGeomDetUnit*>(gdet) == 0) {
00026 throw MeasurementDetException( "TkPixelMeasurementDet constructed with a GeomDet which is not a PixelGeomDetUnit");
00027 }
00028 }
00029
00030 bool TkPixelMeasurementDet::measurements( const TrajectoryStateOnSurface& stateOnThisDet,
00031 const MeasurementEstimator& est,
00032 TempMeasurements & result) const {
00033
00034 if (!isActive()) {
00035 result.add(InvalidTransientRecHit::build(&geomDet(), TrackingRecHit::inactive), 0.F);
00036 return true;
00037 }
00038
00039 auto oldSize = result.size();
00040 MeasurementDet::RecHitContainer && allHits = recHits(stateOnThisDet);
00041 for (auto && hit : allHits) {
00042 std::pair<bool,double> diffEst = est.estimate( stateOnThisDet, *hit);
00043 if ( diffEst.first)
00044 result.add(std::move(hit), diffEst.second);
00045 }
00046
00047 if (result.size()>oldSize) return true;
00048
00049
00050 bool inac = hasBadComponents(stateOnThisDet);
00051 TrackingRecHit::Type type = inac ? TrackingRecHit::inactive : TrackingRecHit::missing;
00052 result.add(InvalidTransientRecHit::build(&fastGeomDet(), type), 0.F);
00053 return inac;
00054
00055 }
00056
00057
00058 TransientTrackingRecHit::RecHitPointer
00059 TkPixelMeasurementDet::buildRecHit( const SiPixelClusterRef & cluster,
00060 const LocalTrajectoryParameters & ltp) const
00061 {
00062 const GeomDetUnit& gdu( specificGeomDet());
00063 LocalValues lv = theCPE->localParameters( * cluster, gdu, ltp );
00064 return TSiPixelRecHit::build( lv.first, lv.second, &fastGeomDet(), cluster, theCPE);
00065 }
00066
00067 TkPixelMeasurementDet::RecHitContainer
00068 TkPixelMeasurementDet::recHits( const TrajectoryStateOnSurface& ts ) const
00069 {
00070 RecHitContainer result;
00071 if (empty == true ) return result;
00072 if (isActive() == false) return result;
00073 const SiPixelCluster* begin=0;
00074 if(0!=handle_->data().size()) {
00075 begin = &(handle_->data().front());
00076 }
00077 result.reserve(detSet_.size());
00078 for ( const_iterator ci = detSet_.begin(); ci != detSet_.end(); ++ ci ) {
00079
00080 if (ci < begin){
00081 edm::LogError("IndexMisMatch")<<"TkPixelMeasurementDet cannot create hit because of index mismatch.";
00082 return result;
00083 }
00084 unsigned int index = ci-begin;
00085 if (skipClusters_!=0 && skipClusters_->size()!=0 && index>=skipClusters_->size()){
00086 edm::LogError("IndexMisMatch")<<"TkPixelMeasurementDet cannot create hit because of index mismatch. i.e "<<index<<" >= "<<skipClusters_->size();
00087 return result;
00088 }
00089 if(0==skipClusters_ or skipClusters_->empty() or (not (*skipClusters_)[index]) ) {
00090 SiPixelClusterRef cluster = edmNew::makeRefTo( handle_, ci );
00091 result.push_back( buildRecHit( cluster, ts.localParameters() ) );
00092 }else{
00093 LogDebug("TkPixelMeasurementDet")<<"skipping this cluster from last iteration on "<<fastGeomDet().geographicalId().rawId()<<" key: "<<index;
00094 }
00095 }
00096 return result;
00097 }
00098
00099 bool
00100 TkPixelMeasurementDet::hasBadComponents( const TrajectoryStateOnSurface &tsos ) const {
00101 if (badRocPositions_.empty()) return false;
00102 LocalPoint lp = tsos.localPosition();
00103 LocalError le = tsos.localError().positionError();
00104 double dx = 3*std::sqrt(le.xx()) + theRocWidth, dy = 3*std::sqrt(le.yy()) + theRocHeight;
00105 for (std::vector<LocalPoint>::const_iterator it = badRocPositions_.begin(), ed = badRocPositions_.end(); it != ed; ++it) {
00106 if ( (std::abs(it->x() - lp.x()) < dx) &&
00107 (std::abs(it->y() - lp.y()) < dy) ) return true;
00108 }
00109 return false;
00110 }