13 DupFitTrkKiller::DupFitTrkKiller(
const Settings* settings)
14 : settings_(settings), dupTrkAlg_(static_cast<
DupAlgoName>(settings->dupTrkAlgFit())) {}
21 list<const L1fittedTrack*> copyTracks;
23 copyTracks.push_back(&trk);
38 throw cms::Exception(
"BadConfig") <<
"KillDupTrks: Cfg option DupFitTrkAlg has invalid value.";
51 constexpr
bool debug =
false;
52 constexpr
bool doRecoveryStep =
true;
53 constexpr
bool reduceDups =
true;
54 constexpr
bool memorizeAllHTcells =
56 constexpr
bool doSectorCheck =
false;
57 constexpr
bool usePtAndZ0Cuts =
false;
58 constexpr
bool goOutsideArray =
true;
59 constexpr
bool limitDiff =
true;
61 if (debug && not tracks.empty())
62 PrintL1trk() <<
"Start DupFitTrkKiller" << tracks.size();
64 list<const L1fittedTrack*> tracksFiltered;
69 set<pair<unsigned int, unsigned int>> htCellUsed;
70 list<const L1fittedTrack*> tracksRejected;
73 map<unsigned int, pair<unsigned int, unsigned int>> tpFound;
74 map<unsigned int, unsigned int> tpFoundAtPass;
78 if ((!doSectorCheck) || trk.consistentSector()) {
79 if ((!usePtAndZ0Cuts) ||
82 const TP*
tp = trk.matchedTP();
85 bool consistentCell = trk.consistentHTcell();
88 tracksFiltered.push_back(&trk);
90 if (!memorizeAllHTcells) {
91 pair<unsigned int, unsigned int> htCell = trk.cellLocationHT();
92 htCellUsed.insert(htCell);
93 if (trk.l1track3D()->mergedHTcell()) {
96 pair<unsigned int, unsigned int> htCell10(htCell.first + 1, htCell.second);
97 pair<unsigned int, unsigned int> htCell01(htCell.first, htCell.second + 1);
98 pair<unsigned int, unsigned int> htCell11(htCell.first + 1, htCell.second + 1);
99 htCellUsed.insert(htCell10);
100 htCellUsed.insert(htCell01);
101 htCellUsed.insert(htCell11);
105 if (debug && tp !=
nullptr) {
106 PrintL1trk() <<
"FIRST PASS: m=" << trk.cellLocationHT().first <<
"/" << trk.cellLocationFit().first
107 <<
" c=" << trk.cellLocationHT().second <<
"/" << trk.cellLocationFit().second
108 <<
" Delta(m,c)=(" << int(trk.cellLocationHT().first) -
int(trk.cellLocationFit().first)
109 <<
"," <<
int(trk.cellLocationHT().second) -
int(trk.cellLocationFit().second)
110 <<
") pure=" << trk.purity() <<
" merged=" << trk.l1track3D()->mergedHTcell()
111 <<
" #layers=" << trk.l1track3D()->numLayers() <<
" tp=" << tp->
index() <<
" dupCell=("
112 << tpFound[tp->
index()].first <<
"," << tpFound[tp->
index()].second
113 <<
") dup=" << tpFoundAtPass[tp->
index()];
116 if (tpFound.find(tp->
index()) != tpFound.end())
117 tpFound[tp->
index()] = trk.cellLocationFit();
118 tpFoundAtPass[tp->
index()] = 1;
123 const unsigned int maxDiff = 1;
124 if (
abs(
int(trk.cellLocationHT().first) -
int(trk.cellLocationFit().first)) <= int(maxDiff) &&
125 abs(
int(trk.cellLocationHT().second) -
int(trk.cellLocationFit().second)) <= int(maxDiff))
126 tracksRejected.push_back(&trk);
128 tracksRejected.push_back(&trk);
131 if (debug && tp !=
nullptr) {
132 PrintL1trk() <<
"FIRST REJECT: m=" << trk.cellLocationHT().first <<
"/" << trk.cellLocationFit().first
133 <<
" c=" << trk.cellLocationHT().second <<
"/" << trk.cellLocationFit().second
134 <<
" Delta(m,c)=(" << int(trk.cellLocationHT().first) -
int(trk.cellLocationFit().first)
135 <<
"," <<
int(trk.cellLocationHT().second) -
int(trk.cellLocationFit().second)
136 <<
") pure=" << trk.purity() <<
" merged=" << trk.l1track3D()->mergedHTcell()
137 <<
" #layers=" << trk.l1track3D()->numLayers() <<
" tp=" << tp->
index() <<
" dupCell=("
138 << tpFound[tp->
index()].first <<
"," << tpFound[tp->
index()].second
139 <<
") dup=" << tpFoundAtPass[tp->
index()];
143 if (memorizeAllHTcells) {
144 pair<unsigned int, unsigned int> htCell =
145 trk.cellLocationFit();
146 htCellUsed.insert(htCell);
147 if (trk.l1track3D()->mergedHTcell()) {
151 pair<unsigned int, unsigned int> htCell10(htCell.first + 1, htCell.second);
152 pair<unsigned int, unsigned int> htCell01(htCell.first, htCell.second + 1);
153 pair<unsigned int, unsigned int> htCell11(htCell.first + 1, htCell.second + 1);
154 htCellUsed.insert(htCell10);
155 htCellUsed.insert(htCell01);
156 htCellUsed.insert(htCell11);
163 if (doRecoveryStep) {
167 pair<unsigned int, unsigned int> htCell = trk->cellLocationFit();
170 if (
std::count(htCellUsed.begin(), htCellUsed.end(), htCell) == 0) {
171 tracksFiltered.push_back(trk);
174 if (reduceDups && outsideCheck)
175 htCellUsed.insert(htCell);
178 const TP*
tp = trk->matchedTP();
180 if (debug && tp !=
nullptr) {
181 PrintL1trk() <<
"SECOND PASS: m=" << trk->cellLocationHT().first <<
"/" << trk->cellLocationFit().first
182 <<
" c=" << trk->cellLocationHT().second <<
"/" << trk->cellLocationFit().second
183 <<
" Delta(m,c)=(" << int(trk->cellLocationHT().first) -
int(trk->cellLocationFit().first)
184 <<
"," <<
int(trk->cellLocationHT().second) -
int(trk->cellLocationFit().second)
185 <<
") pure=" << trk->purity() <<
" merged=" << trk->l1track3D()->mergedHTcell()
186 <<
" #layers=" << trk->l1track3D()->numLayers() <<
" tp=" << tp->
index() <<
" dupCell=("
187 << tpFound[tp->
index()].first <<
"," << tpFound[tp->
index()].second
188 <<
") dup=" << tpFoundAtPass[tp->
index()];
189 if (tpFound.find(tp->
index()) != tpFound.end())
190 tpFound[tp->
index()] = htCell;
191 tpFoundAtPass[tp->
index()] = 2;
201 return tracksFiltered;
212 const bool debug =
false;
214 if (debug && not tracks.empty())
217 list<const L1fittedTrack*> tracksFiltered;
218 set<pair<unsigned int, unsigned int>> htCellUsed;
222 pair<unsigned int, unsigned int> htCell = trk.cellLocationFit();
225 if (
std::count(htCellUsed.begin(), htCellUsed.end(), htCell) == 0) {
226 tracksFiltered.push_back(&trk);
228 htCellUsed.insert(htCell);
230 const TP*
tp = trk.matchedTP();
231 int tpIndex = (tp !=
nullptr) ? tp->
index() : -999;
232 PrintL1trk() <<
"ALG51: m=" << trk.cellLocationHT().first <<
"/" << trk.cellLocationFit().first
233 <<
" c=" << trk.cellLocationHT().second <<
"/" << trk.cellLocationFit().second
234 <<
" tp=" << tpIndex <<
" pure=" << trk.purity();
243 return tracksFiltered;
248 map<const TP*, list<const L1fittedTrack*>> tpMap;
250 const TP*
tp = trk->matchedTP();
252 tpMap[
tp].push_back(trk);
255 for (
const auto&
p : tpMap) {
256 const TP*
tp =
p.first;
257 const list<const L1fittedTrack*> vecTrk =
p.second;
258 if (vecTrk.size() > 1) {
260 PrintL1trk() <<
" MESS UP : m=" << trk->cellLocationHT().first <<
"/" << trk->cellLocationFit().first
261 <<
" c=" << trk->cellLocationHT().second <<
"/" << trk->cellLocationFit().second
262 <<
" tp=" << tp->
index() <<
" tp_pt=" << tp->
pt() <<
" fit_pt=" << trk->pt()
263 <<
" pure=" << trk->purity();
265 for (
const Stub*
s : trk->stubs())
271 if (not tracks.empty())
double houghMinPt() const
unsigned int index() const
std::list< const L1fittedTrack * > filter(const std::list< L1fittedTrack > &vecTracks) const
auto const & tracks
cannot be loose
double beamWindowZ() const
void printDuplicateTracks(const std::list< const L1fittedTrack * > &tracks) const
Abs< T >::type abs(const T &t)
std::list< const L1fittedTrack * > filterAlg1(const std::list< L1fittedTrack > &tracks) const
float maxDiff(float one, float two, float three, float four)
std::list< const L1fittedTrack * > filterAlg2(const std::list< L1fittedTrack > &tracks) const
const Settings * settings_