CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CachingSeedCleanerBySharedInput Class Referencefinal

#include <CachingSeedCleanerBySharedInput.h>

Inheritance diagram for CachingSeedCleanerBySharedInput:
RedundantSeedCleaner

Public Member Functions

void add (const Trajectory *traj) override
 Informs the cleaner that a new trajectory has been made, in case the cleaner keeps a local collection of those tracks (i.e. in a map) More...
 
 CachingSeedCleanerBySharedInput (unsigned int numHitsForSeedCleaner=4, bool onlyPixelHits=false)
 
void done () override
 Tells the cleaner that the seeds are finished, and so it can clear any cache it has. More...
 
bool good (const TrajectorySeed *seed) override
 Returns true if the seed is not overlapping with another trajectory. More...
 
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 to keep a local collection of trajectories. More...
 
- 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

std::unordered_multimap< unsigned int, unsigned int > theCache
 
int theNumHitsForSeedCleaner
 
bool theOnlyPixelHits
 
std::vector< Trajectory::RecHitContainertheVault
 

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  :
numHitsForSeedCleaner
these two parameters are relevant only for the CachingSeedCleanerBySharedInput

Member Function Documentation

void CachingSeedCleanerBySharedInput::add ( const Trajectory traj)
overridevirtual

Informs the cleaner that a new trajectory has been made, in case the cleaner keeps a local collection of those tracks (i.e. in a map)

Implements RedundantSeedCleaner.

Definition at line 24 of file CachingSeedCleanerBySharedInput.cc.

References h, hfClusterShapes_cfi::hits, training_settings::idx, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, theCache, theOnlyPixelHits, and theVault.

Referenced by counter.Counter::register().

24  {
25  unsigned int idx = theVault.size();
26  theVault.resize(idx+1);
27  // a vector of shared pointers....
28  auto & hits = theVault.back();
29  (*trj).validRecHits(hits);
30 
31  for (auto const & h : hits) {
32  auto detid = h->geographicalId().rawId();
33 
34  //For seeds that are made only of pixel hits, it is pointless to store the
35  //information about hits on other sub-detector of the trajectory.
36  if( theOnlyPixelHits &&
37  h->geographicalId().subdetId() != PixelSubdetector::PixelBarrel &&
38  h->geographicalId().subdetId() != PixelSubdetector::PixelEndcap ) continue;
39  if (detid) theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
40  }
41 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::unordered_multimap< unsigned int, unsigned int > theCache
std::vector< Trajectory::RecHitContainer > theVault
void CachingSeedCleanerBySharedInput::done ( )
overridevirtual

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

Implements RedundantSeedCleaner.

Definition at line 15 of file CachingSeedCleanerBySharedInput.cc.

References theCache, and theVault.

15  {
16  //edm::LogInfo("CachingSeedCleanerBySharedInput") << " Calls: " << calls_ << ", Tracks: " << tracks_ <<", Comps: " << comps_ << " Vault: " << theVault.size() << ".";
17  //calls_ = comps_ = tracks_ = 0;
18  theVault.clear(); theCache.clear();
19 
20 }
std::unordered_multimap< unsigned int, unsigned int > theCache
std::vector< Trajectory::RecHitContainer > theVault
bool CachingSeedCleanerBySharedInput::good ( const TrajectorySeed seed)
overridevirtual

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

Implements RedundantSeedCleaner.

Definition at line 43 of file CachingSeedCleanerBySharedInput.cc.

References TrackingRecHit::all, plotBeamSpotDB::first, runEdmFileComparison::found, plotBeamSpotDB::last, min(), TrajectorySeed::nHits(), TrajectorySeed::recHits(), protons_cff::t, theCache, theNumHitsForSeedCleaner, and theVault.

43  {
44  if (seed->nHits()==0){ return true; }
45 
46  auto range = seed->recHits();
47 
48  auto first = range.first;
49  auto last = range.second;
50  auto detid = first->geographicalId().rawId();
51 
52  //calls_++;
53  auto itrange = theCache.equal_range(detid);
54  for (auto it = itrange.first; it != itrange.second; ++it) {
55  assert(it->first == detid);
56  //tracks_++;
57 
58  // seeds are limited to the first "theNumHitsForSeedCleaner" hits in trajectory...
59  int ext = std::min(theNumHitsForSeedCleaner,int(theVault[it->second].size()));
60  auto ts = theVault[it->second].begin();
61  auto te = ts+ext;
62  auto t = ts;
63  auto curr = first;
64  for (; curr != last; ++curr) {
65  bool found = false;
66  for (;t != te; ++t) {
67  //comps_++;
68  if ( curr->sharesInput((**t).hit(),TrackingRecHit::all) ) { found = true; ++t; break; }
69  }
70  if (!found) break;
71  }
72  if (curr == last) return false;
73  }
74  return true;
75 }
std::unordered_multimap< unsigned int, unsigned int > theCache
std::vector< Trajectory::RecHitContainer > theVault
T min(T a, T b)
Definition: MathUtil.h:58
range recHits() const
unsigned int nHits() const
Definition: memstream.h:15
void CachingSeedCleanerBySharedInput::init ( const std::vector< Trajectory > *  vect)
overridevirtual

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 11 of file CachingSeedCleanerBySharedInput.cc.

References theCache, and theVault.

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

Member Data Documentation

std::unordered_multimap<unsigned int, unsigned int> CachingSeedCleanerBySharedInput::theCache
private

Definition at line 28 of file CachingSeedCleanerBySharedInput.h.

Referenced by add(), done(), good(), and init().

int CachingSeedCleanerBySharedInput::theNumHitsForSeedCleaner
private

Definition at line 30 of file CachingSeedCleanerBySharedInput.h.

Referenced by good().

bool CachingSeedCleanerBySharedInput::theOnlyPixelHits
private

Definition at line 31 of file CachingSeedCleanerBySharedInput.h.

Referenced by add().

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

Definition at line 27 of file CachingSeedCleanerBySharedInput.h.

Referenced by add(), done(), good(), and init().