CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HitExtractorPIX.cc
Go to the documentation of this file.
1 #include "HitExtractorPIX.h"
4 
7 
10 
11 #include <iostream>
12 using namespace ctfseeding;
13 using namespace std;
14 
16  SeedingLayer::Side & side, int idLayer, const std::string & hitProducer, edm::ConsumesCollector& iC)
17  : theHitProducer(iC.consumes<SiPixelRecHitCollection>(hitProducer)), theSide(side), theIdLayer(idLayer)
18 { }
19 
22 }
23 
24 HitExtractor::Hits HitExtractorPIX::hits(const TkTransientTrackingRecHitBuilder &ttrhBuilder, const edm::Event& ev, const edm::EventSetup& es) const
25 {
27  TrackerLayerIdAccessor accessor;
29  ev.getByToken( theHitProducer, pixelHits);
31  range2SeedingHits( *pixelHits, result, accessor.pixelBarrelLayer(theIdLayer));
32  } else {
33  range2SeedingHits( *pixelHits, result, accessor.pixelForwardDisk(theSide,theIdLayer));
34  }
35 
36 
37  if (skipClusters){
38  LogDebug("HitExtractorPIX")<<"getting : "<<result.size()<<" pixel hits.";
39  //std::cout<<" skipping"<<std::endl;
40  edm::Handle<SkipClustersCollection> pixelClusterMask;
41  ev.getByToken(theSkipClusters,pixelClusterMask);
42  unsigned int skipped=0;
43  for (unsigned int iH=0;iH!=result.size();++iH){
44  if (result[iH]->isValid()){ // can be NOT valid???
45  auto const & concrete = (SiPixelRecHit const&)(*result[iH]);
46  assert(pixelClusterMask->refProd().id() == concrete.cluster().id());
47  if(pixelClusterMask->mask(concrete.cluster().key())) {
48  //too much debug LogDebug("HitExtractorPIX")<<"skipping a pixel hit on: "<< result[iH]->hit()->geographicalId().rawId()<<" key: "<<find(f->begin(),f->end(),concrete->cluster())->key();
49  skipped++;
50  result[iH].reset();
51  }
52  }
53  }
54  LogDebug("HitExtractorPIX")<<"skipped :"<<skipped<<" pixel clusters";
55  // std::cout << "HitExtractorPIX " <<"skipped :"<<skipped<<" pixel clusters out of " << result.size() << std::endl;
56  if (skipped>0) {
57  auto last = std::remove_if(result.begin(),result.end(),[]( HitPointer const & p) {return p.empty();});
58  result.resize(last-result.begin());
59  }
60  }
61  LogDebug("HitExtractorPIX")<<"giving :"<<result.size()<<" rechits out";
62  // std::cout << "HitExtractorPIX "<<"giving :"<<result.size()<<" rechits out" << std::endl;
63  return result;
64 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void range2SeedingHits(DSTV const &dstv, HitExtractor::Hits &v, std::pair< A, B > const &sel)
Definition: HitExtractor.h:45
std::vector< HitPointer > Hits
Definition: HitExtractor.h:25
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void useSkipClusters_(const edm::InputTag &m, edm::ConsumesCollector &iC) override
std::pair< DetId, DetIdPXFSameDiskComparator > pixelForwardDisk(int side, int disk)
edm::EDGetTokenT< SiPixelRecHitCollection > theHitProducer
SeedingLayer::Side theSide
virtual HitExtractor::Hits hits(const TkTransientTrackingRecHitBuilder &ttrhBuilder, const edm::Event &, const edm::EventSetup &) const override
tuple result
Definition: query.py:137
std::pair< DetId, DetIdPXBSameLayerComparator > pixelBarrelLayer(int layer)
edm::EDGetTokenT< SkipClustersCollection > theSkipClusters
HitExtractorPIX(SeedingLayer::Side &side, int idLayer, const std::string &hitProducer, edm::ConsumesCollector &iC)
Pixel Reconstructed Hit.