CMS 3D CMS Logo

HitExtractorPIX.cc
Go to the documentation of this file.
1 #include "HitExtractorPIX.h"
3 
6 
8 
9 #include <iostream>
10 using namespace ctfseeding;
11 using namespace std;
12 
14  int idLayer,
15  const std::string& hitProducer,
17  : theHitProducer(iC.consumes<SiPixelRecHitCollection>(hitProducer)),
18  theTtopo(iC.esConsumes()),
19  theSide(side),
20  theIdLayer(idLayer) {}
21 
24 }
25 
27  const edm::Event& ev,
28  const edm::EventSetup& es) const {
30 
31  const TrackerTopology& ttopo = es.getData(theTtopo);
32 
34  ev.getByToken(theHitProducer, pixelHits);
37  } else {
38  range2SeedingHits(*pixelHits, result, ttopo.pxfDetIdDiskComparator(static_cast<unsigned int>(theSide), theIdLayer));
39  }
40 
41  if (skipClusters) {
42  LogDebug("HitExtractorPIX") << "getting : " << result.size() << " pixel hits.";
43  //std::cout<<" skipping"<<std::endl;
44  edm::Handle<SkipClustersCollection> pixelClusterMask;
45  ev.getByToken(theSkipClusters, pixelClusterMask);
46  unsigned int skipped = 0;
47  for (unsigned int iH = 0; iH != result.size(); ++iH) {
48  if (result[iH]->isValid()) { // can be NOT valid???
49  auto const& concrete = (SiPixelRecHit const&)(*result[iH]);
50  assert(pixelClusterMask->refProd().id() == concrete.cluster().id());
51  if (pixelClusterMask->mask(concrete.cluster().key())) {
52  //too much debug LogDebug("HitExtractorPIX")<<"skipping a pixel hit on: "<< result[iH]->hit()->geographicalId().rawId()<<" key: "<<find(f->begin(),f->end(),concrete->cluster())->key();
53  skipped++;
54  result[iH].reset();
55  }
56  }
57  }
58  LogDebug("HitExtractorPIX") << "skipped :" << skipped << " pixel clusters";
59  // std::cout << "HitExtractorPIX " <<"skipped :"<<skipped<<" pixel clusters out of " << result.size() << std::endl;
60  if (skipped > 0) {
61  auto last = std::remove_if(result.begin(), result.end(), [](HitPointer const& p) { return p.empty(); });
62  result.resize(last - result.begin());
63  }
64  }
65  LogDebug("HitExtractorPIX") << "giving :" << result.size() << " rechits out";
66  // std::cout << "HitExtractorPIX "<<"giving :"<<result.size()<<" rechits out" << std::endl;
67  return result;
68 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void range2SeedingHits(DSTV const &dstv, HitExtractor::Hits &v, std::pair< A, B > const &sel)
Definition: HitExtractor.h:54
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::pair< DetId, SameLayerComparator > pxbDetIdLayerComparator(uint32_t layer) const
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
std::vector< HitPointer > Hits
Definition: HitExtractor.h:28
TrackerDetSide
Definition: TrackerDetSide.h:4
void useSkipClusters_(const edm::InputTag &m, edm::ConsumesCollector &iC) override
assert(be >=bs)
edm::EDGetTokenT< SiPixelRecHitCollection > theHitProducer
HitExtractor::Hits hits(const TkTransientTrackingRecHitBuilder &ttrhBuilder, const edm::Event &, const edm::EventSetup &) const override
std::pair< DetId, SameLayerComparator > pxfDetIdDiskComparator(uint32_t side, uint32_t disk) const
bool getData(T &iHolder) const
Definition: EventSetup.h:122
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:124
ProductIndex id() const
Definition: ProductID.h:35
const edm::RefProd< T > & refProd() const
Definition: ContainerMask.h:55
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTtopo
HitExtractorPIX(TrackerDetSide side, int idLayer, const std::string &hitProducer, edm::ConsumesCollector &iC)
edm::EDGetTokenT< SkipClustersCollection > theSkipClusters
bool mask(unsigned int iIndex) const
Definition: ContainerMask.h:43
Our base class.
Definition: SiPixelRecHit.h:23
#define LogDebug(id)