CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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 #include "DataFormats/Common/interface/ContainerMask.h"
00012 
00013 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00014 
00015 using namespace ctfseeding;
00016 using namespace std;
00017 
00018 HitExtractorPIX::HitExtractorPIX(
00019     SeedingLayer::Side & side, int idLayer, const std::string & hitProducer)
00020   : theSide(side), theIdLayer(idLayer), theHitProducer(hitProducer)
00021 { }
00022 
00023 HitExtractor::Hits HitExtractorPIX::hits(const SeedingLayer & sl,const edm::Event& ev, const edm::EventSetup& es) const
00024 {
00025   HitExtractor::Hits result;
00026   TrackerLayerIdAccessor accessor;
00027   edm::Handle<SiPixelRecHitCollection> pixelHits;
00028   ev.getByLabel( theHitProducer, pixelHits);
00029   if (theSide==SeedingLayer::Barrel) {
00030     range2SeedingHits( *pixelHits, result, accessor.pixelBarrelLayer(theIdLayer), sl, es );
00031   } else {
00032     range2SeedingHits( *pixelHits, result, accessor.pixelForwardDisk(theSide,theIdLayer), sl, es );
00033   }
00034 
00035 
00036   if (skipClusters){
00037     LogDebug("HitExtractorPIX")<<"getting : "<<result.size()<<" pixel hits.";
00038     //std::cout<<" skipping"<<std::endl;
00039     edm::Handle<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > > pixelClusterMask;
00040     ev.getByLabel(theSkipClusters,pixelClusterMask);
00041     std::vector<bool> keep(result.size(),true);
00042     HitExtractor::Hits newHits;
00043     unsigned int skipped=0;
00044     if (result.empty()) return result;
00045     newHits.reserve(result.size());
00046     for (unsigned int iH=0;iH!=result.size();++iH){
00047       if (result[iH]->hit()->isValid()){
00048         SiPixelRecHit * concrete = (SiPixelRecHit *) result[iH]->hit();
00049         assert(pixelClusterMask->refProd().id() == concrete->cluster().id());
00050         if(pixelClusterMask->mask(concrete->cluster().key())) {
00051           //too much debug LogDebug("HitExtractorPIX")<<"skipping a pixel hit on: "<< result[iH]->hit()->geographicalId().rawId()<<" key: "<<find(f->begin(),f->end(),concrete->cluster())->key();
00052           skipped++;
00053           continue;
00054         }
00055       }
00056       newHits.push_back(result[iH]);
00057     }
00058     result.swap(newHits);
00059     LogDebug("HitExtractorPIX")<<"skipped :"<<skipped<<" pixel clusters";
00060   }
00061   LogDebug("HitExtractorPIX")<<"giving :"<<result.size()<<" rechits out";
00062   return result;
00063 }