Go to the documentation of this file.00001 #include "RecoTracker/CkfPattern/interface/CachingSeedCleanerBySharedInput.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004
00005 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00006
00007 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00008
00009 #include<boost/bind.hpp>
00010 #include<algorithm>
00011
00012 void CachingSeedCleanerBySharedInput::init(const std::vector<Trajectory> *vect) {
00013 theVault.clear(); theCache.clear();
00014 }
00015
00016 void CachingSeedCleanerBySharedInput::done() {
00017
00018
00019 theVault.clear(); theCache.clear();
00020
00021
00022
00023
00024
00025 }
00026
00027
00028
00029 void CachingSeedCleanerBySharedInput::add(const Trajectory *trj) {
00030 typedef Trajectory::RecHitContainer::const_iterator TI;
00031 unsigned int idx = theVault.size();
00032 theVault.resize(idx+1);
00033
00034 Trajectory::ConstRecHitContainer & hits = theVault.back();
00035 (*trj).validRecHits(hits);
00036
00037
00038
00039 uint32_t detid;
00040 for (TI t = hits.begin(), te = hits.end(); t != te; ++t) {
00041
00042 detid = (*t)->geographicalId().rawId();
00043
00044
00045
00046 if( theOnlyPixelHits &&
00047 (*t)->geographicalId().subdetId() != PixelSubdetector::PixelBarrel &&
00048 (*t)->geographicalId().subdetId() != PixelSubdetector::PixelEndcap ) continue;
00049 if (detid) theCache.insert(std::pair<uint32_t, unsigned int>(detid, idx));
00050 }
00051 }
00052
00053 bool CachingSeedCleanerBySharedInput::good(const TrajectorySeed *seed) {
00054 if (seed->nHits()==0){ return true; }
00055
00056 typedef TrajectorySeed::const_iterator SI;
00057 typedef Trajectory::RecHitContainer::const_iterator TI;
00058 TrajectorySeed::range range = seed->recHits();
00059
00060 SI first = range.first, last = range.second, curr;
00061 uint32_t detid = first->geographicalId().rawId();
00062
00063
00064 typedef boost::unordered_multimap<uint32_t, unsigned int>::const_iterator IT;
00065 IT it; std::pair<IT,IT> itrange;
00066
00067
00068
00069
00070 for (itrange = theCache.equal_range(detid), it = itrange.first; it != itrange.second; ++it) {
00071 assert(it->first == detid);
00072
00073
00074
00075 int ext = std::min(theNumHitsForSeedCleaner,int(theVault[it->second].size()));
00076 TI te = theVault[it->second].begin()+ext;
00077
00078
00079 TI ts = theVault[it->second].begin();
00080 TI t = ts;
00081 for (curr = first; curr != last; ++curr) {
00082 bool found = false;
00083
00084 for (;t != te; ++t) {
00085
00086 if ( curr->sharesInput((**t).hit(),TrackingRecHit::all) ) { found = true; ++t; break; }
00087 }
00088 if (!found) break;
00089 }
00090 if (curr == last) return false;
00091 }
00092 return true;
00093 }