CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CachingSeedCleanerByHitPosition.cc
Go to the documentation of this file.
3 
6 
7 void CachingSeedCleanerByHitPosition::init(const std::vector<Trajectory> *vect) {
8  theVault.clear(); theCache.clear();
9 }
10 
12  //edm::LogInfo("CachingSeedCleanerByHitPosition") << " Calls: " << calls_ << ", Tracks: " << tracks_ <<", Comps: " << comps_ << " Vault: " << theVault.size() << ".";
13  //calls_ = comps_ = tracks_ = 0;
14 
15  theVault.clear(); theCache.clear();
16 
17  std::vector<Trajectory::RecHitContainer> swapper;
18  swapper.swap(theVault); // this should clean the vault even more
19 }
20 
21 
22 
24  typedef Trajectory::RecHitContainer::const_iterator TI;
25  unsigned int idx = theVault.size();
27  theVault.push_back(hits);
28 
29  uint32_t detid;
30  for (TI t = hits.begin(), te = hits.end(); t != te; ++t) {
31  if ((*t)->isValid()) {
32  detid = (*t)->geographicalId().rawId();
33  if (detid) theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
34  }
35  }
36 }
37 
39  static RecHitComparatorByPosition comp;
41  typedef Trajectory::RecHitContainer::const_iterator TI;
42  TrajectorySeed::range range = seed->recHits();
43 
44  SI first = range.first, last = range.second, curr;
45  uint32_t detid = first->geographicalId().rawId();
46 
47  std::multimap<uint32_t, unsigned int>::const_iterator it, end = theCache.end();
48 
49  //calls_++;
50  for (it = theCache.find(detid); (it != end) && (it->first == detid); ++it) {
51  //tracks_++;
52  TI ts = theVault[it->second].begin(), te = theVault[it->second].end();
53  for (curr = first; curr != last; ++curr) {
54  bool found = false;
55  for (TI t = ts; t != te; ++t) {
56  //comps_++;
57  if (comp.equals(&(*curr), &(**t))) { found = true; break; }
58  }
59  if (!found) break;
60  }
61  if (curr == last) return false;
62  }
63  return true;
64 }
bool equals(const TrackingRecHit *a, const TrackingRecHit *b) const
std::multimap< uint32_t, unsigned int > theCache
virtual void init(const std::vector< Trajectory > *vect)
Provides the cleaner a pointer to the vector where trajectories are stored, in case it does not want ...
virtual bool good(const TrajectorySeed *seed)
Returns true if the seed is not overlapping with another trajectory.
virtual void done()
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.
virtual void add(const Trajectory *traj)
ConstRecHitContainer recHits(bool splitting=false) const
Definition: Trajectory.cc:67
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
#define end
Definition: vmac.h:38
bool first
Definition: L1TdeRCT.cc:94
ConstRecHitContainer RecHitContainer
Definition: Trajectory.h:44
range recHits() const
std::vector< Trajectory::RecHitContainer > theVault