File indexing completed on 2023-03-17 11:22:06
0001 #include "RecoTracker/CkfPattern/interface/CachingSeedCleanerBySharedInput.h"
0002
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
0006
0007 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0008
0009 #include <algorithm>
0010
0011 void CachingSeedCleanerBySharedInput::init(const std::vector<Trajectory> *vect) {
0012 theVault.clear();
0013 theCache.clear();
0014 }
0015
0016 void CachingSeedCleanerBySharedInput::done() {
0017
0018
0019 theVault.clear();
0020 theCache.clear();
0021 }
0022
0023 void CachingSeedCleanerBySharedInput::add(const Trajectory *trj) {
0024 unsigned int idx = theVault.size();
0025 theVault.resize(idx + 1);
0026
0027 auto &hits = theVault.back();
0028 (*trj).validRecHits(hits);
0029
0030 for (auto const &h : hits) {
0031 auto detid = h->geographicalId().rawId();
0032
0033
0034
0035 if (theOnlyPixelHits && h->geographicalId().subdetId() != PixelSubdetector::PixelBarrel &&
0036 h->geographicalId().subdetId() != PixelSubdetector::PixelEndcap)
0037 continue;
0038 if (detid)
0039 theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
0040 }
0041 }
0042
0043 bool CachingSeedCleanerBySharedInput::good(const TrajectorySeed *seed) {
0044 if (seed->nHits() == 0) {
0045 return true;
0046 }
0047
0048 auto const &range = seed->recHits();
0049
0050 auto first = range.begin();
0051 auto last = range.end();
0052 auto detid = first->geographicalId().rawId();
0053
0054
0055 auto itrange = theCache.equal_range(detid);
0056 for (auto it = itrange.first; it != itrange.second; ++it) {
0057 assert(it->first == detid);
0058
0059
0060
0061 int ext = std::min(theNumHitsForSeedCleaner, int(theVault[it->second].size()));
0062 auto ts = theVault[it->second].begin();
0063 auto te = ts + ext;
0064 auto t = ts;
0065 auto curr = first;
0066 for (; curr != last; ++curr) {
0067 bool found = false;
0068 for (; t != te; ++t) {
0069
0070 if (curr->sharesInput((**t).hit(), TrackingRecHit::all)) {
0071 found = true;
0072 ++t;
0073 break;
0074 }
0075 }
0076 if (!found)
0077 break;
0078 }
0079 if (curr == last)
0080 return false;
0081 }
0082 return true;
0083 }