14 using namespace pixeltrackfitting;
116 static int max[3] = {20, 32, 44};
117 if(dphi > max[p1.
layer()-1] / 2) dphi = max[p1.
layer()-1] - dphi;
121 if(dphi == 1 && dz <= 1)
return true;
129 p1.
disk() != p2.
disk())
return true;
133 if(dphi > max / 2) dphi = max - dphi;
138 if(dphi <= 1 && dr <= 1 && !(dphi == 0 && dr == 0))
return true;
146 (vector<const TrackingRecHit *> recHitsA,
147 vector<const TrackingRecHit *> recHitsB)
151 for(vector<const TrackingRecHit *>::const_iterator
152 recHitA = recHitsA.begin(); recHitA!= recHitsA.end(); recHitA++)
153 for(vector<const TrackingRecHit *>::const_iterator
154 recHitB = recHitsB.begin(); recHitB!= recHitsB.end(); recHitB++)
155 if(!areSame(*recHitA,*recHitB))
156 if(!isCompatible((*recHitA)->geographicalId(),
157 (*recHitB)->geographicalId()))
170 typedef map<const TrackingRecHit*,vector<unsigned int>,
HitComparator>
173 vector<bool>
keep(tracks.size(),
true);
178 <<
" [TrackCleaner] initial tracks : " << tracks.size();
180 for(
unsigned int i = 0;
i < tracks.size();
i++)
196 for(
unsigned int i = 0;
i < tracks.size();
i++)
199 for(vector<const TrackingRecHit *>::const_iterator
200 recHit = tracks[i].second.begin();
201 recHit!= tracks[
i].second.end(); recHit++)
202 recHitMap[*recHit].push_back(i);
206 typedef map<unsigned int,int,less<unsigned int> > TrackMap;
208 for(
unsigned int i = 0; i < tracks.size(); i++)
211 if(!
keep[i])
continue;
222 for(vector<const TrackingRecHit *>::const_iterator
223 recHit = tracks[i].second.begin();
224 recHit!= tracks[
i].second.end(); recHit++)
227 vector<unsigned int> sharing = recHitMap[*recHit];
229 for(vector<unsigned int>::iterator
j = sharing.begin();
230 j!= sharing.end();
j++)
236 for(TrackMap::iterator sharing = trackMap.begin();
237 sharing!= trackMap.end(); sharing++)
239 unsigned int j = (*sharing).first;
242 if(tracks[i].second.size() >=3)
244 if((*sharing).second >
min(
int(tracks[i].second.size()),
245 int(tracks[j].second.size()))/2)
247 if(canBeMerged(tracks[i].second,tracks[j].second))
250 for(vector<const TrackingRecHit *>::const_iterator
251 recHit = tracks[j].second.begin();
252 recHit!= tracks[
j].second.end(); recHit++)
255 for(vector<const TrackingRecHit *>::const_iterator
256 recHitA = tracks[i].second.begin();
257 recHitA!= tracks[
i].second.end(); recHitA++)
258 if(areSame(*recHit,*recHitA)) ok =
false;
262 tracks[
i].second.push_back(*recHit);
263 recHitMap[*recHit].push_back(i);
265 sort(tracks[i].second.begin(),
266 tracks[
i].second.end(),
274 <<
" Merge #" << i <<
" #" << j
275 <<
", first now has " << tracks[
i].second.size();
284 if(fabs(tracks[i].
first->d0())
285 < fabs(tracks[j].
first->d0()))
291 <<
" Clash #" << i <<
" #" << j
292 <<
" keep lower d0 " << tracks[
i].first->d0()
293 <<
" " << tracks[
j].first->d0()
294 <<
", keep #" << (
keep[
i] ? i : (
keep[
j] ? j : 9999 ) );
301 if((*sharing).second > 1)
303 if(tracks[i].second.size() != tracks[
j].second.size())
305 if(tracks[i].second.size() > tracks[
j].second.size())
310 <<
" Sharing " << (*sharing).second <<
" remove by size";
314 if(fabs(tracks[i].
first->d0())
315 < fabs(tracks[j].
first->d0()))
320 <<
" Sharing " << (*sharing).second <<
" remove by d0";
327 if((*sharing).second > 0)
347 for(
unsigned int i = 0;
i < tracks.size();
i++)
349 cleaned.push_back(tracks[i]);
350 else delete tracks_[
i].first;
353 <<
" [TrackCleaner] cleaned tracks : " << cleaned.size();
355 for(
unsigned int i = 0; i < cleaned.size(); i++)
static std::string getInfo(const DetId &id)
TrackCleaner(const edm::ParameterSet &ps)
unsigned int panel() const
panel id
bool areSame(const TrackingRecHit *a, const TrackingRecHit *b)
unsigned int ladder() const
ladder id
unsigned int layer() const
layer id
unsigned int blade() const
blade id
U second(std::pair< T, U > const &p)
bool isCompatible(const DetId &i1, const DetId &i2)
const T & max(const T &a, const T &b)
bool canBeMerged(std::vector< const TrackingRecHit * > recHitsA, std::vector< const TrackingRecHit * > recHitsB)
unsigned int module() const
det id
unsigned int module() const
det id
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int disk() const
disk id
virtual TracksWithRecHits cleanTracks(const TracksWithRecHits &tracksWithRecHits)
std::vector< TrackWithRecHits > TracksWithRecHits
unsigned int side() const
positive or negative id
const reco::PFCandidateRefVector & tracks_
DetId geographicalId() const
virtual LocalPoint localPosition() const =0
pixeltrackfitting::TracksWithRecHits TracksWithRecHits