CMS 3D CMS Logo

Public Member Functions | Private Attributes

CachingSeedCleanerBySharedInput Class Reference

#include <CachingSeedCleanerBySharedInput.h>

Inheritance diagram for CachingSeedCleanerBySharedInput:
RedundantSeedCleaner

List of all members.

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.
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 to keep a local collection of trajectories.
virtual ~CachingSeedCleanerBySharedInput ()

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.

                                                           : 
   RedundantSeedCleaner(), theVault(), theCache(),
   theNumHitsForSeedCleaner(numHitsForSeedCleaner),theOnlyPixelHits(onlyPixelHits){}
virtual CachingSeedCleanerBySharedInput::~CachingSeedCleanerBySharedInput ( ) [inline, virtual]

Definition at line 27 of file CachingSeedCleanerBySharedInput.h.

References theCache, and theVault.

{ theVault.clear(); theCache.clear(); }

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, UserOptions_cff::idx, PixelSubdetector::PixelBarrel, GeomDetEnumerators::PixelEndcap, lumiQTWidget::t, theCache, theOnlyPixelHits, and theVault.

                                                               {
    typedef Trajectory::RecHitContainer::const_iterator TI;
    unsigned int idx = theVault.size();
    theVault.resize(idx+1);
    // a vector of shared pointers....
    Trajectory::ConstRecHitContainer & hits = theVault.back();
    (*trj).validRecHits(hits);
    //    std::sort(hits.begin(),hits.end(),
    //        boost::bind(&TrackingRecHit::geographicalId(),_1));
    
    uint32_t detid;
    for (TI t = hits.begin(), te = hits.end(); t != te; ++t) {
      //    if ((*t)->isValid()) {   // they are valid!
      detid = (*t)->geographicalId().rawId();

      //For seeds that are made only of pixel hits, it is pointless to store the 
      //information about hits on other sub-detector of the trajectory.
      if( theOnlyPixelHits && 
          (*t)->geographicalId().subdetId() != PixelSubdetector::PixelBarrel && 
          (*t)->geographicalId().subdetId() != PixelSubdetector::PixelEndcap    ) continue;
      if (detid) theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
    }
}
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.

                                           { 
    //edm::LogInfo("CachingSeedCleanerBySharedInput") << " Calls: " << calls_ << ", Tracks: " << tracks_ <<", Comps: " << comps_ << " Vault: " << theVault.size() << ".";
    //calls_ = comps_ = tracks_ = 0;
    theVault.clear(); theCache.clear();

    //don't, at least we'll not copy vector by value!

    //    std::vector<Trajectory::RecHitContainer> swapper;
    //swapper.swap(theVault); // this should clean the vault even more
}
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 cond::ecalcond::all, cond::rpcobgas::detid, first, newFWLiteAna::found, prof2calltree::last, min, TrajectorySeed::nHits(), TrajectorySeed::recHits(), lumiQTWidget::t, theCache, theNumHitsForSeedCleaner, and theVault.

                                                                     {
  if (seed->nHits()==0){    return true; }

    typedef TrajectorySeed::const_iterator SI;
    typedef Trajectory::RecHitContainer::const_iterator TI;
    TrajectorySeed::range range = seed->recHits();

    SI first = range.first, last = range.second, curr;
    uint32_t detid = first->geographicalId().rawId();
    
    //std::multimap<uint32_t, unsigned int>::const_iterator it, end = theCache.end();
    typedef boost::unordered_multimap<uint32_t, unsigned int>::const_iterator IT;
    IT it; std::pair<IT,IT> itrange;
    

    //calls_++;
    //for (it = theCache.find(detid); (it != end) && (it->first == detid); ++it) {
    for (itrange = theCache.equal_range(detid), it = itrange.first; it != itrange.second; ++it) {
      assert(it->first == detid);
      //tracks_++;
      
      // seeds are limited to the first "theNumHitsForSeedCleaner" hits in trajectory...
      int ext = std::min(theNumHitsForSeedCleaner,int(theVault[it->second].size()));
      TI te =  theVault[it->second].begin()+ext;
      //    TI  te = theVault[it->second].end();
      
      TI ts = theVault[it->second].begin();
      TI t = ts;
      for (curr = first; curr != last; ++curr) {
        bool found = false;
        // for (TI t = ts; t != te; ++t) {
        for (;t != te; ++t) {
          //comps_++;
          if ( curr->sharesInput((**t).hit(),TrackingRecHit::all) ) { found = true; ++t; break; }
        }
        if (!found) break;
      }
      if (curr == last) return false;
    }
    return true;
}
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.

                                                                            { 
    theVault.clear(); theCache.clear();
}

Member Data Documentation

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

Definition at line 33 of file CachingSeedCleanerBySharedInput.h.

Referenced by good().

Definition at line 34 of file CachingSeedCleanerBySharedInput.h.

Referenced by add().