167 typedef map<const TrackingRecHit*,vector<unsigned int>,
HitComparator>
170 vector<bool>
keep(tracks.size(),
true);
175 <<
" [TrackCleaner] initial tracks : " << tracks.size();
177 for(
unsigned int i = 0;
i < tracks.size();
i++)
193 for(
unsigned int i = 0;
i < tracks.size();
i++)
196 for(vector<const TrackingRecHit *>::const_iterator
197 recHit = tracks[i].
second.begin();
198 recHit!= tracks[
i].second.end(); recHit++)
199 recHitMap[*recHit].push_back(i);
203 typedef map<unsigned int,int,less<unsigned int> > TrackMap;
205 for(
unsigned int i = 0; i < tracks.size(); i++)
208 if(!
keep[i])
continue;
219 for(vector<const TrackingRecHit *>::const_iterator
220 recHit = tracks[i].
second.begin();
221 recHit!= tracks[
i].second.end(); recHit++)
224 vector<unsigned int> sharing = recHitMap[*recHit];
226 for(vector<unsigned int>::iterator
j = sharing.begin();
227 j!= sharing.end();
j++)
233 for(TrackMap::iterator sharing = trackMap.begin();
234 sharing!= trackMap.end(); sharing++)
236 unsigned int j = (*sharing).first;
239 if(tracks[i].
second.size() >=3)
241 if((*sharing).second >
min(
int(tracks[i].
second.size()),
242 int(tracks[j].
second.size()))/2)
247 for(vector<const TrackingRecHit *>::const_iterator
248 recHit = tracks[j].second.begin();
249 recHit!= tracks[
j].second.end(); recHit++)
252 for(vector<const TrackingRecHit *>::const_iterator
253 recHitA = tracks[i].second.begin();
254 recHitA!= tracks[
i].second.end(); recHitA++)
255 if(
areSame(*recHit,*recHitA)) ok =
false;
259 tracks[
i].second.push_back(*recHit);
260 recHitMap[*recHit].push_back(i);
262 sort(tracks[i].second.begin(),
263 tracks[
i].second.end(),
271 <<
" Merge #" << i <<
" #" << j
272 <<
", first now has " << tracks[
i].second.size();
281 if(fabs(tracks[i].
first->d0())
282 < fabs(tracks[j].
first->d0()))
288 <<
" Clash #" << i <<
" #" << j
289 <<
" keep lower d0 " << tracks[
i].first->d0()
290 <<
" " << tracks[
j].first->d0()
291 <<
", keep #" << (
keep[
i] ? i : (
keep[
j] ? j : 9999 ) );
298 if((*sharing).second > 1)
300 if(tracks[i].second.size() != tracks[
j].second.size())
302 if(tracks[i].second.size() > tracks[
j].second.size())
307 <<
" Sharing " << (*sharing).second <<
" remove by size";
311 if(fabs(tracks[i].
first->d0())
312 < fabs(tracks[j].
first->d0()))
317 <<
" Sharing " << (*sharing).second <<
" remove by d0";
324 if((*sharing).second > 0)
344 for(
unsigned int i = 0; i < tracks.size(); i++)
346 cleaned.push_back(tracks[i]);
350 <<
" [TrackCleaner] cleaned tracks : " << cleaned.size();
352 for(
unsigned int i = 0; i < cleaned.size(); i++)
const std::vector< reco::PFCandidatePtr > & tracks_
bool areSame(const TrackingRecHit *a, const TrackingRecHit *b)
bool canBeMerged(const std::vector< const TrackingRecHit * > &recHitsA, const std::vector< const TrackingRecHit * > &recHitsB, const TrackerTopology *tTopo)
U second(std::pair< T, U > const &p)
std::vector< TrackWithRecHits > TracksWithRecHits
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)