CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CachingSeedCleanerBySharedInput.cc
Go to the documentation of this file.
2 
4 
6 
8 
9 #include<boost/bind.hpp>
10 #include<algorithm>
11 
12 void CachingSeedCleanerBySharedInput::init(const std::vector<Trajectory> *vect) {
13  theVault.clear(); 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(); theCache.clear();
20 
21  //don't, at least we'll not copy vector by value!
22 
23  // std::vector<Trajectory::RecHitContainer> swapper;
24  //swapper.swap(theVault); // this should clean the vault even more
25 }
26 
27 
28 
30  typedef Trajectory::RecHitContainer::const_iterator TI;
31  unsigned int idx = theVault.size();
32  theVault.resize(idx+1);
33  // a vector of shared pointers....
35  (*trj).validRecHits(hits);
36  // std::sort(hits.begin(),hits.end(),
37  // boost::bind(&TrackingRecHit::geographicalId(),_1));
38 
39  uint32_t detid;
40  for (TI t = hits.begin(), te = hits.end(); t != te; ++t) {
41  // if ((*t)->isValid()) { // they are valid!
42  detid = (*t)->geographicalId().rawId();
43 
44  //For seeds that are made only of pixel hits, it is pointless to store the
45  //information about hits on other sub-detector of the trajectory.
46  if( theOnlyPixelHits &&
47  (*t)->geographicalId().subdetId() != PixelSubdetector::PixelBarrel &&
48  (*t)->geographicalId().subdetId() != PixelSubdetector::PixelEndcap ) continue;
49  if (detid) theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
50  }
51 }
52 
54  if (seed->nHits()==0){ return true; }
55 
57  typedef Trajectory::RecHitContainer::const_iterator TI;
58  TrajectorySeed::range range = seed->recHits();
59 
60  SI first = range.first, last = range.second, curr;
61  uint32_t detid = first->geographicalId().rawId();
62 
63  //std::multimap<uint32_t, unsigned int>::const_iterator it, end = theCache.end();
64  typedef boost::unordered_multimap<uint32_t, unsigned int>::const_iterator IT;
65  IT it; std::pair<IT,IT> itrange;
66 
67 
68  //calls_++;
69  //for (it = theCache.find(detid); (it != end) && (it->first == detid); ++it) {
70  for (itrange = theCache.equal_range(detid), it = itrange.first; it != itrange.second; ++it) {
71  assert(it->first == detid);
72  //tracks_++;
73 
74  // seeds are limited to the first "theNumHitsForSeedCleaner" hits in trajectory...
75  int ext = std::min(theNumHitsForSeedCleaner,int(theVault[it->second].size()));
76  TI te = theVault[it->second].begin()+ext;
77  // TI te = theVault[it->second].end();
78 
79  TI ts = theVault[it->second].begin();
80  TI t = ts;
81  for (curr = first; curr != last; ++curr) {
82  bool found = false;
83  // for (TI t = ts; t != te; ++t) {
84  for (;t != te; ++t) {
85  //comps_++;
86  if ( curr->sharesInput((**t).hit(),TrackingRecHit::all) ) { found = true; ++t; break; }
87  }
88  if (!found) break;
89  }
90  if (curr == last) return false;
91  }
92  return true;
93 }
assert(m_qm.get())
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
virtual void add(const Trajectory *traj)
std::vector< Trajectory::RecHitContainer > theVault
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< LinkConnSpec >::const_iterator IT
boost::unordered_multimap< uint32_t, unsigned int > theCache
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
range recHits() const
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:45
unsigned int nHits() const
virtual bool good(const TrajectorySeed *seed)
Returns true if the seed is not overlapping with another trajectory.
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 void done()
Tells the cleaner that the seeds are finished, and so it can clear any cache it has.