CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
CachingSeedCleanerBySharedInput Class Reference

#include <CachingSeedCleanerBySharedInput.h>

Inheritance diagram for CachingSeedCleanerBySharedInput:
RedundantSeedCleaner

Public Member Functions

virtual void add (const Trajectory *traj)
 
 CachingSeedCleanerBySharedInput (unsigned int numHitsForSeedCleaner=4, bool onlyPixelHits=false)
 
virtual void done ()
 Tells the cleaner that the seeds are finished, and so it can clear any cache it has. More...
 
virtual bool good (const TrajectorySeed *seed)
 Returns true if the seed is not overlapping with another trajectory. More...
 
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 to keep a local collection of trajectories. More...
 
virtual ~CachingSeedCleanerBySharedInput ()
 
- Public Member Functions inherited from RedundantSeedCleaner
void clean (const std::vector< TrajectorySeed > &, std::vector< TrajectorySeed > &)
 clean More...
 
void define (std::vector< TrajectorySeed > &)
 collection definition More...
 
 RedundantSeedCleaner ()
 constructor More...
 
virtual ~RedundantSeedCleaner ()
 
 ~RedundantSeedCleaner ()
 destructor More...
 

Private Attributes

boost::unordered_multimap
< uint32_t, unsigned int > 
theCache
 
int theNumHitsForSeedCleaner
 
bool theOnlyPixelHits
 
std::vector
< Trajectory::RecHitContainer
theVault
 

Detailed Description

Merge of SeedCleanerBySharedInput and CachingSeedCleanerByHitPosition

Definition at line 8 of file CachingSeedCleanerBySharedInput.h.

Constructor & Destructor Documentation

CachingSeedCleanerBySharedInput::CachingSeedCleanerBySharedInput ( unsigned int  numHitsForSeedCleaner = 4,
bool  onlyPixelHits = false 
)
inline

Definition at line 22 of file CachingSeedCleanerBySharedInput.h.

23  :
25  theNumHitsForSeedCleaner(numHitsForSeedCleaner),theOnlyPixelHits(onlyPixelHits){}
RedundantSeedCleaner()
constructor
std::vector< Trajectory::RecHitContainer > theVault
boost::unordered_multimap< uint32_t, unsigned int > theCache
virtual CachingSeedCleanerBySharedInput::~CachingSeedCleanerBySharedInput ( )
inlinevirtual

Definition at line 27 of file CachingSeedCleanerBySharedInput.h.

References theCache, and theVault.

27 { theVault.clear(); theCache.clear(); }
std::vector< Trajectory::RecHitContainer > theVault
boost::unordered_multimap< uint32_t, unsigned int > theCache

Member Function Documentation

void CachingSeedCleanerBySharedInput::add ( const Trajectory traj)
virtual

In this implementation, it does nothing

Implements RedundantSeedCleaner.

Definition at line 29 of file CachingSeedCleanerBySharedInput.cc.

References cond::rpcobgas::detid, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, lumiQTWidget::t, theCache, theOnlyPixelHits, and theVault.

29  {
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 }
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:43
std::vector< Trajectory::RecHitContainer > theVault
boost::unordered_multimap< uint32_t, unsigned int > theCache
void CachingSeedCleanerBySharedInput::done ( )
virtual

Tells the cleaner that the seeds are finished, and so it can clear any cache it has.

Implements RedundantSeedCleaner.

Definition at line 16 of file CachingSeedCleanerBySharedInput.cc.

References theCache, and theVault.

16  {
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 }
std::vector< Trajectory::RecHitContainer > theVault
boost::unordered_multimap< uint32_t, unsigned int > theCache
bool CachingSeedCleanerBySharedInput::good ( const TrajectorySeed seed)
virtual

Returns true if the seed is not overlapping with another trajectory.

Implements RedundantSeedCleaner.

Definition at line 53 of file CachingSeedCleanerBySharedInput.cc.

References TrackingRecHit::all, cond::rpcobgas::detid, first, newFWLiteAna::found, prof2calltree::last, min, TrajectorySeed::nHits(), TrajectorySeed::recHits(), lumiQTWidget::t, theCache, theNumHitsForSeedCleaner, and theVault.

53  {
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 }
#define min(a, b)
Definition: mlp_lapack.h:161
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
std::vector< Trajectory::RecHitContainer > theVault
std::vector< LinkConnSpec >::const_iterator IT
bool first
Definition: L1TdeRCT.cc:94
boost::unordered_multimap< uint32_t, unsigned int > theCache
range recHits() const
unsigned int nHits() const
void CachingSeedCleanerBySharedInput::init ( const std::vector< Trajectory > *  vect)
virtual

Provides the cleaner a pointer to the vector where trajectories are stored, in case it does not want to keep a local collection of trajectories.

Implements RedundantSeedCleaner.

Definition at line 12 of file CachingSeedCleanerBySharedInput.cc.

References theCache, and theVault.

12  {
13  theVault.clear(); theCache.clear();
14 }
std::vector< Trajectory::RecHitContainer > theVault
boost::unordered_multimap< uint32_t, unsigned int > theCache

Member Data Documentation

boost::unordered_multimap<uint32_t, unsigned int> CachingSeedCleanerBySharedInput::theCache
private
int CachingSeedCleanerBySharedInput::theNumHitsForSeedCleaner
private

Definition at line 33 of file CachingSeedCleanerBySharedInput.h.

Referenced by good().

bool CachingSeedCleanerBySharedInput::theOnlyPixelHits
private

Definition at line 34 of file CachingSeedCleanerBySharedInput.h.

Referenced by add().

std::vector<Trajectory::RecHitContainer> CachingSeedCleanerBySharedInput::theVault
private