CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/TkSeedingLayers/src/HitExtractorPIX.cc

Go to the documentation of this file.
00001 #include "HitExtractorPIX.h"
00002 #include "Geometry/TrackerGeometryBuilder/interface/TrackerLayerIdAccessor.h"
00003 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00004 
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 
00011 
00012 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00013 
00014 using namespace ctfseeding;
00015 using namespace std;
00016 
00017 HitExtractorPIX::HitExtractorPIX(
00018     SeedingLayer::Side & side, int idLayer, const std::string & hitProducer)
00019   : theSide(side), theIdLayer(idLayer), theHitProducer(hitProducer)
00020 { }
00021 
00022 HitExtractor::Hits HitExtractorPIX::hits(const SeedingLayer & sl,const edm::Event& ev, const edm::EventSetup& es) const
00023 {
00024   HitExtractor::Hits result;
00025   TrackerLayerIdAccessor accessor;
00026   edm::Handle<SiPixelRecHitCollection> pixelHits;
00027   ev.getByLabel( theHitProducer, pixelHits);
00028   if (theSide==SeedingLayer::Barrel) {
00029     range2SeedingHits( *pixelHits, result, accessor.pixelBarrelLayer(theIdLayer), sl, es );
00030   } else {
00031     range2SeedingHits( *pixelHits, result, accessor.pixelForwardDisk(theSide,theIdLayer), sl, es );
00032   }
00033 
00034 
00035   if (skipClusters){
00036     LogDebug("HitExtractorPIX")<<"getting : "<<result.size()<<" pixel hits.";
00037     //std::cout<<" skipping"<<std::endl;
00038     edm::Handle<edmNew::DetSetVector<SiPixelClusterRefNew> > pixelClusterRefs;
00039     ev.getByLabel(theSkipClusters,pixelClusterRefs);
00040     std::vector<bool> keep(result.size(),true);
00041     HitExtractor::Hits newHits;
00042     uint skipped=0;
00043     if (result.empty()) return result;
00044     DetId lookup=result.front()->hit()->geographicalId();
00045     edmNew::DetSetVector<SiPixelClusterRefNew>::const_iterator f=pixelClusterRefs->find(lookup);
00046     newHits.reserve(result.size());
00047     for (unsigned int iH=0;iH!=result.size();++iH){
00048       if (result[iH]->hit()->geographicalId()!=lookup)
00049         {
00050           lookup=result[iH]->hit()->geographicalId();
00051           f=pixelClusterRefs->find(lookup);
00052         }
00053       if (result[iH]->hit()->isValid()){
00054         SiPixelRecHit * concrete = (SiPixelRecHit *) result[iH]->hit();
00055         if (f!=pixelClusterRefs->end() && find(f->begin(),f->end(),concrete->cluster())!=f->end()){
00056           //too much debug LogDebug("HitExtractorPIX")<<"skipping a pixel hit on: "<< result[iH]->hit()->geographicalId().rawId()<<" key: "<<find(f->begin(),f->end(),concrete->cluster())->key();
00057           skipped++;
00058           continue;
00059         }
00060       }
00061       newHits.push_back(result[iH]);
00062     }
00063     result.swap(newHits);
00064     LogDebug("HitExtractorPIX")<<"skipped :"<<skipped<<" pixel clusters";
00065   }
00066   LogDebug("HitExtractorPIX")<<"giving :"<<result.size()<<" rechits out";
00067   return result;
00068 }