File indexing completed on 2024-04-06 12:28:55
0001 #include "HitExtractorPIX.h"
0002 #include "TrackingTools/DetLayers/interface/DetLayer.h"
0003
0004 #include "DataFormats/Common/interface/Handle.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008
0009 #include <iostream>
0010 using namespace ctfseeding;
0011 using namespace std;
0012
0013 HitExtractorPIX::HitExtractorPIX(TrackerDetSide side,
0014 int idLayer,
0015 const std::string& hitProducer,
0016 edm::ConsumesCollector& iC)
0017 : theHitProducer(iC.consumes<SiPixelRecHitCollection>(hitProducer)),
0018 theTtopo(iC.esConsumes()),
0019 theSide(side),
0020 theIdLayer(idLayer) {}
0021
0022 void HitExtractorPIX::useSkipClusters_(const edm::InputTag& m, edm::ConsumesCollector& iC) {
0023 theSkipClusters = iC.consumes<SkipClustersCollection>(m);
0024 }
0025
0026 HitExtractor::Hits HitExtractorPIX::hits(const TkTransientTrackingRecHitBuilder& ttrhBuilder,
0027 const edm::Event& ev,
0028 const edm::EventSetup& es) const {
0029 HitExtractor::Hits result;
0030
0031 const TrackerTopology& ttopo = es.getData(theTtopo);
0032
0033 edm::Handle<SiPixelRecHitCollection> pixelHits;
0034 ev.getByToken(theHitProducer, pixelHits);
0035 if (theSide == TrackerDetSide::Barrel) {
0036 range2SeedingHits(*pixelHits, result, ttopo.pxbDetIdLayerComparator(theIdLayer));
0037 } else {
0038 range2SeedingHits(*pixelHits, result, ttopo.pxfDetIdDiskComparator(static_cast<unsigned int>(theSide), theIdLayer));
0039 }
0040
0041 if (skipClusters) {
0042 LogDebug("HitExtractorPIX") << "getting : " << result.size() << " pixel hits.";
0043
0044 edm::Handle<SkipClustersCollection> pixelClusterMask;
0045 ev.getByToken(theSkipClusters, pixelClusterMask);
0046 unsigned int skipped = 0;
0047 for (unsigned int iH = 0; iH != result.size(); ++iH) {
0048 if (result[iH]->isValid()) {
0049 auto const& concrete = (SiPixelRecHit const&)(*result[iH]);
0050 assert(pixelClusterMask->refProd().id() == concrete.cluster().id());
0051 if (pixelClusterMask->mask(concrete.cluster().key())) {
0052
0053 skipped++;
0054 result[iH].reset();
0055 }
0056 }
0057 }
0058 LogDebug("HitExtractorPIX") << "skipped :" << skipped << " pixel clusters";
0059
0060 if (skipped > 0) {
0061 auto last = std::remove_if(result.begin(), result.end(), [](HitPointer const& p) { return p.empty(); });
0062 result.resize(last - result.begin());
0063 }
0064 }
0065 LogDebug("HitExtractorPIX") << "giving :" << result.size() << " rechits out";
0066
0067 return result;
0068 }