CMS 3D CMS Logo

CachingSeedCleanerByHitPosition.cc

Go to the documentation of this file.
00001 #include "RecoTracker/CkfPattern/interface/CachingSeedCleanerByHitPosition.h"
00002 #include "TrackingTools/TransientTrackingRecHit/interface/RecHitComparatorByPosition.h"
00003 
00004 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 void CachingSeedCleanerByHitPosition::init(const std::vector<Trajectory> *vect) { 
00008     theVault.clear(); theCache.clear();
00009 }
00010 
00011 void CachingSeedCleanerByHitPosition::done() { 
00012     //edm::LogInfo("CachingSeedCleanerByHitPosition") << " Calls: " << calls_ << ", Tracks: " << tracks_ <<", Comps: " << comps_ << " Vault: " << theVault.size() << ".";
00013     //calls_ = comps_ = tracks_ = 0;
00014 
00015     theVault.clear(); theCache.clear();
00016 
00017     std::vector<Trajectory::RecHitContainer> swapper;
00018     swapper.swap(theVault); // this should clean the vault even more
00019 }
00020 
00021 
00022 
00023 void CachingSeedCleanerByHitPosition::add(const Trajectory *trj) {
00024     typedef Trajectory::RecHitContainer::const_iterator TI;
00025     unsigned short idx = theVault.size();
00026     Trajectory::RecHitContainer hits = trj->recHits();
00027     theVault.push_back(hits);
00028 
00029     uint32_t detid;
00030     for (TI t = hits.begin(), te = hits.end(); t != te; ++t) {
00031         if ((*t)->isValid()) {
00032             detid = (*t)->geographicalId().rawId();
00033             if (detid) theCache.insert(std::pair<uint32_t, unsigned short>(detid, idx));
00034         }
00035     }
00036 }
00037 
00038 bool CachingSeedCleanerByHitPosition::good(const TrajectorySeed *seed) {
00039     static RecHitComparatorByPosition comp;
00040     typedef TrajectorySeed::const_iterator SI;
00041     typedef Trajectory::RecHitContainer::const_iterator TI;
00042     TrajectorySeed::range range = seed->recHits();
00043 
00044     SI first = range.first, last = range.second, curr;
00045     uint32_t detid = first->geographicalId().rawId();
00046     
00047     std::multimap<uint32_t, unsigned short>::const_iterator it, end = theCache.end();
00048 
00049     //calls_++;
00050     for (it = theCache.find(detid); (it != end) && (it->first == detid); ++it) {
00051         //tracks_++;
00052         TI ts = theVault[it->second].begin(), te = theVault[it->second].end();
00053         for (curr = first; curr != last; ++curr) {
00054             bool found = false;
00055             for (TI t = ts; t != te; ++t) {
00056                 //comps_++;
00057                 if (comp.equals(&(*curr), &(**t))) { found = true; break; }
00058             }
00059             if (!found) break;
00060         }
00061         if (curr == last) return false;
00062     }
00063     return true;
00064 }

Generated on Tue Jun 9 17:45:19 2009 for CMSSW by  doxygen 1.5.4