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 ()
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 short > 
theCache
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 ( ) [inline]

Definition at line 22 of file CachingSeedCleanerBySharedInput.h.

                                     : RedundantSeedCleaner(), theVault(), theCache()
                                             /*,comps_(0), tracks_(0), calls_(0)*/ {}
virtual CachingSeedCleanerBySharedInput::~CachingSeedCleanerBySharedInput ( ) [inline, virtual]

Definition at line 24 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 27 of file CachingSeedCleanerBySharedInput.cc.

References cond::rpcobgas::detid, matplotRender::t, theCache, and theVault.

                                                               {
    typedef Trajectory::RecHitContainer::const_iterator TI;
    unsigned short 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();
      if (detid) theCache.insert(std::pair<uint32_t, unsigned short>(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 14 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 45 of file CachingSeedCleanerBySharedInput.cc.

References cond::ecalcond::all, cond::rpcobgas::detid, first, newFWLiteAna::found, prof2calltree::last, min, TrajectorySeed::nHits(), TrajectorySeed::recHits(), matplotRender::t, theCache, 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 short>::const_iterator it, end = theCache.end();
    typedef boost::unordered_multimap<uint32_t, unsigned short>::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 4 hits in trajectory...
      int ext = std::min(4,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 10 of file CachingSeedCleanerBySharedInput.cc.

References theCache, and theVault.

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

Member Data Documentation

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