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<boost/bind.hpp>
00008 #include<algorithm>
00009
00010 void CachingSeedCleanerBySharedInput::init(const std::vector<Trajectory> *vect) {
00011 theVault.clear(); theCache.clear();
00012 }
00013
00014 void CachingSeedCleanerBySharedInput::done() {
00015
00016
00017 theVault.clear(); theCache.clear();
00018
00019
00020
00021
00022
00023 }
00024
00025
00026
00027 void CachingSeedCleanerBySharedInput::add(const Trajectory *trj) {
00028 typedef Trajectory::RecHitContainer::const_iterator TI;
00029 unsigned short idx = theVault.size();
00030 theVault.resize(idx+1);
00031
00032 Trajectory::ConstRecHitContainer & hits = theVault.back();
00033 (*trj).validRecHits(hits);
00034
00035
00036
00037 uint32_t detid;
00038 for (TI t = hits.begin(), te = hits.end(); t != te; ++t) {
00039
00040 detid = (*t)->geographicalId().rawId();
00041 if (detid) theCache.insert(std::pair<uint32_t, unsigned short>(detid, idx));
00042 }
00043 }
00044
00045 bool CachingSeedCleanerBySharedInput::good(const TrajectorySeed *seed) {
00046 if (seed->nHits()==0){ return true; }
00047
00048 typedef TrajectorySeed::const_iterator SI;
00049 typedef Trajectory::RecHitContainer::const_iterator TI;
00050 TrajectorySeed::range range = seed->recHits();
00051
00052 SI first = range.first, last = range.second, curr;
00053 uint32_t detid = first->geographicalId().rawId();
00054
00055
00056 typedef boost::unordered_multimap<uint32_t, unsigned short>::const_iterator IT;
00057 IT it; std::pair<IT,IT> itrange;
00058
00059
00060
00061
00062 for (itrange = theCache.equal_range(detid), it = itrange.first; it != itrange.second; ++it) {
00063 assert(it->first == detid);
00064
00065
00066
00067 int ext = std::min(4,int(theVault[it->second].size()));
00068 TI te = theVault[it->second].begin()+ext;
00069
00070
00071 TI ts = theVault[it->second].begin();
00072 TI t = ts;
00073 for (curr = first; curr != last; ++curr) {
00074 bool found = false;
00075
00076 for (;t != te; ++t) {
00077
00078 if ( curr->sharesInput((**t).hit(),TrackingRecHit::all) ) { found = true; ++t; break; }
00079 }
00080 if (!found) break;
00081 }
00082 if (curr == last) return false;
00083 }
00084 return true;
00085 }