14 using namespace pixeltrackfitting;
39 int r1 = (tTopo_->pxbLayer(i1) - 1)*2 + (tTopo_->pxbLadder(i1) - 1)%2;
40 int r2 = (tTopo_->pxbLayer(i2) - 1)*2 + (tTopo_->pxbLadder(i2) - 1)%2;
46 int r1 = (tTopo_->pxfDisk(i1) - 1)*2 + (tTopo_->pxfPanel(i1) - 1)%2;
47 int r2 = (tTopo_->pxfDisk(i2) - 1)*2 + (tTopo_->pxfPanel(i2) - 1)%2;
113 static int max[3] = {20, 32, 44};
114 if(dphi > max[tTopo->
pxbLayer(i1)-1] / 2) dphi = max[tTopo->
pxbLayer(i1)-1] - dphi;
118 if(dphi == 1 && dz <= 1)
return true;
128 if(dphi > max / 2) dphi = max - dphi;
133 if(dphi <= 1 && dr <= 1 && !(dphi == 0 && dr == 0))
return true;
141 (
const vector<const TrackingRecHit *>& recHitsA,
142 const vector<const TrackingRecHit *>& recHitsB,
147 for(vector<const TrackingRecHit *>::const_iterator
148 recHitA = recHitsA.begin(); recHitA!= recHitsA.end(); recHitA++)
149 for(vector<const TrackingRecHit *>::const_iterator
150 recHitB = recHitsB.begin(); recHitB!= recHitsB.end(); recHitB++)
151 if(!areSame(*recHitA,*recHitB))
152 if(!isCompatible((*recHitA)->geographicalId(),
153 (*recHitB)->geographicalId(),
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)
244 if(canBeMerged(tracks[i].second,tracks[j].second,tTopo))
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]);
347 else delete tracks_[
i].first;
350 <<
" [TrackCleaner] cleaned tracks : " << cleaned.size();
352 for(
unsigned int i = 0; i < cleaned.size(); i++)
TrackCleaner(const edm::ParameterSet &ps)
const std::vector< reco::PFCandidatePtr > & tracks_
unsigned int pxfDisk(const DetId &id) const
bool isBarrel(GeomDetEnumerators::SubDetector m)
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)
unsigned int pxbLadder(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
virtual TracksWithRecHits cleanTracks(const TracksWithRecHits &tracksWithRecHits, const TrackerTopology *tTopo)
U second(std::pair< T, U > const &p)
HitComparatorByRadius(const TrackerTopology *tTopo)
Abs< T >::type abs(const T &t)
bool isCompatible(const DetId &i1, const DetId &i2, const TrackerTopology *tTopo)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int pxfModule(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
std::vector< TrackWithRecHits > TracksWithRecHits
unsigned int pxfSide(const DetId &id) const
DetId geographicalId() const
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
virtual LocalPoint localPosition() const =0
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
pixeltrackfitting::TracksWithRecHits TracksWithRecHits
const TrackerTopology * tTopo_