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
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 unsigned int 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
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 }