CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CachingSeedCleanerBySharedInput.cc
Go to the documentation of this file.
2 
4 
6 
8 
9 #include <algorithm>
10 
11 void CachingSeedCleanerBySharedInput::init(const std::vector<Trajectory> *vect) {
12  theVault.clear();
13  theCache.clear();
14 }
15 
17  //edm::LogInfo("CachingSeedCleanerBySharedInput") << " Calls: " << calls_ << ", Tracks: " << tracks_ <<", Comps: " << comps_ << " Vault: " << theVault.size() << ".";
18  //calls_ = comps_ = tracks_ = 0;
19  theVault.clear();
20  theCache.clear();
21 }
22 
24  unsigned int idx = theVault.size();
25  theVault.resize(idx + 1);
26  // a vector of shared pointers....
27  auto &hits = theVault.back();
28  (*trj).validRecHits(hits);
29 
30  for (auto const &h : hits) {
31  auto detid = h->geographicalId().rawId();
32 
33  //For seeds that are made only of pixel hits, it is pointless to store the
34  //information about hits on other sub-detector of the trajectory.
35  if (theOnlyPixelHits && h->geographicalId().subdetId() != PixelSubdetector::PixelBarrel &&
36  h->geographicalId().subdetId() != PixelSubdetector::PixelEndcap)
37  continue;
38  if (detid)
39  theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
40  }
41 }
42 
44  if (seed->nHits() == 0) {
45  return true;
46  }
47 
48  auto const &range = seed->recHits();
49 
50  auto first = range.begin();
51  auto last = range.end();
52  auto detid = first->geographicalId().rawId();
53 
54  //calls_++;
55  auto itrange = theCache.equal_range(detid);
56  for (auto it = itrange.first; it != itrange.second; ++it) {
57  assert(it->first == detid);
58  //tracks_++;
59 
60  // seeds are limited to the first "theNumHitsForSeedCleaner" hits in trajectory...
61  int ext = std::min(theNumHitsForSeedCleaner, int(theVault[it->second].size()));
62  auto ts = theVault[it->second].begin();
63  auto te = ts + ext;
64  auto t = ts;
65  auto curr = first;
66  for (; curr != last; ++curr) {
67  bool found = false;
68  for (; t != te; ++t) {
69  //comps_++;
70  if (curr->sharesInput((**t).hit(), TrackingRecHit::all)) {
71  found = true;
72  ++t;
73  break;
74  }
75  }
76  if (!found)
77  break;
78  }
79  if (curr == last)
80  return false;
81  }
82  return true;
83 }
void done() override
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.
bool good(const TrajectorySeed *seed) override
Returns true if the seed is not overlapping with another trajectory.
void add(const Trajectory *traj) override
Informs the cleaner that a new trajectory has been made, in case the cleaner keeps a local collection...
assert(be >=bs)
const uint16_t range(const Frame &aFrame)
std::unordered_multimap< unsigned int, unsigned int > theCache
std::vector< Trajectory::RecHitContainer > theVault
RecHitRange recHits() const
unsigned int nHits() const
tuple last
Definition: dqmdumpme.py:56
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void init(const std::vector< Trajectory > *vect) override
Provides the cleaner a pointer to the vector where trajectories are stored, in case it does not want ...