19 #include <unordered_set>
33 unordered_set<string>
outputs = {
"trackout",
46 auto*
tmp = dynamic_cast<CleanTrackMemory*>(
memory);
51 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output: " <<
output;
59 unordered_set<string>
inputs = {
"trackin",
73 auto*
tmp = dynamic_cast<TrackFitMemory*>(
memory);
78 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input: " <<
input;
91 if (inputtrackfit->nTracks() == 0)
93 for (
unsigned int j = 0;
j < inputtrackfit->nTracks();
j++) {
94 Track* aTrack = inputtrackfit->getTrack(
j)->getTrack();
111 std::vector<std::pair<int, bool>> trackInfo;
113 std::vector<int> seedRank;
124 throw "Number of stublists and tracks don't match up!";
133 std::vector<std::pair<int, int>> stubidslist =
inputtrackfits_[
i]->getStubidslist(
j);
141 unsigned int curSeed = aTrack->
seedIndex();
143 seedRank.push_back(1);
144 }
else if (curSeed == 2) {
145 seedRank.push_back(2);
146 }
else if (curSeed == 5) {
147 seedRank.push_back(3);
148 }
else if (curSeed == 4) {
149 seedRank.push_back(4);
150 }
else if (curSeed == 1) {
151 seedRank.push_back(5);
152 }
else if (curSeed == 7) {
153 seedRank.push_back(6);
154 }
else if (curSeed == 3) {
155 seedRank.push_back(7);
156 }
else if (curSeed == 6) {
157 seedRank.push_back(8);
159 seedRank.push_back(9);
161 throw cms::Exception(
"LogError") << __FILE__ <<
" " << __LINE__ <<
" Seed " << curSeed
162 <<
" not found in list, and settings->extended() not set.";
165 if (stublist.size() != stubidslist.size())
166 throw "Number of stubs and stubids don't match up!";
168 trackInfo.emplace_back(
i,
false);
177 bool dupMap[numStublists][numStublists];
178 for (
unsigned int itrk = 0; itrk < numStublists; itrk++) {
179 for (
unsigned int jtrk = 0; jtrk < numStublists; jtrk++) {
180 dupMap[itrk][jtrk] =
false;
186 for (
unsigned int itrk = 0; itrk < numStublists - 1; itrk++) {
187 for (
unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) {
195 unsigned int nShareUR = 0;
196 unsigned int nURStubTrk1 = 0;
197 unsigned int nURStubTrk2 = 0;
200 for (
auto&
i : URArray) {
203 for (
const auto& st1 : stubsTrk1) {
204 for (
const auto& st2 : stubsTrk2) {
205 if (st1.first == st2.first && st1.second == st2.second) {
208 int reg = (
i > 0 &&
i < 10) * (
i - 1) + (
i > 10) * (
i - 5) - (
i < 0) *
i;
221 int URStubidsTrk1[16];
222 int URStubidsTrk2[16];
223 for (
int i = 0;
i < 16;
i++) {
224 URStubidsTrk1[
i] = -1;
225 URStubidsTrk2[
i] = -1;
228 for (
unsigned int stcount = 0; stcount < stubsTrk1.size(); stcount++) {
229 int i = stubsTrk1[stcount].first;
230 int reg = (
i > 0 &&
i < 10) * (
i - 1) + (
i > 10) * (
i - 5) - (
i < 0) *
i;
233 if (URStubidsTrk1[reg] != -1)
235 if (URStubidsTrk1[reg] == -1 || nres < ores) {
236 URStubidsTrk1[reg] = stcount;
240 for (
unsigned int stcount = 0; stcount < stubsTrk2.size(); stcount++) {
241 int i = stubsTrk2[stcount].first;
242 int reg = (
i > 0 &&
i < 10) * (
i - 1) + (
i > 10) * (
i - 5) - (
i < 0) *
i;
245 if (URStubidsTrk2[reg] != -1)
247 if (URStubidsTrk2[reg] == -1 || nres < ores) {
248 URStubidsTrk2[reg] = stcount;
252 for (
int i = 0;
i < 16;
i++) {
253 int t1i = URStubidsTrk1[
i];
254 int t2i = URStubidsTrk2[
i];
255 if (t1i != -1 && t2i != -1 && stubsTrk1[t1i].
first == stubsTrk2[t2i].
first &&
261 for (
int i = 0;
i < 16;
i++) {
262 if (URStubidsTrk1[
i] != -1)
264 if (URStubidsTrk2[
i] != -1)
271 dupMap[itrk][jtrk] =
true;
272 dupMap[jtrk][itrk] =
true;
278 for (
unsigned int itrk = 0; itrk < numStublists - 1; itrk++) {
279 for (
unsigned int jtrk = itrk + 1; jtrk < numStublists; jtrk++) {
281 if (dupMap[itrk][jtrk]) {
285 if (seedRank[itrk] < seedRank[jtrk]) {
294 std::vector<const Stub*> newStubList;
297 newStubList = stubsTrk1;
298 for (
unsigned int stub2it = 0; stub2it < stubsTrk2.size(); stub2it++) {
299 if (
find(stubsTrk1.begin(), stubsTrk1.end(), stubsTrk2[stub2it]) == stubsTrk1.end()) {
300 newStubList.push_back(stubsTrk2[stub2it]);
306 std::vector<std::pair<int, int>> newStubidsList;
309 newStubidsList = stubidsTrk1;
310 for (
unsigned int stub2it = 0; stub2it < stubidsTrk2.size(); stub2it++) {
311 if (
find(stubidsTrk1.begin(), stubidsTrk1.end(), stubidsTrk2[stub2it]) == stubidsTrk1.end()) {
312 newStubidsList.push_back(stubidsTrk2[stub2it]);
319 trackInfo[rejetrk].second =
true;
325 for (
unsigned int itrk = 0; itrk < numStublists; itrk++) {
330 hybridFitter.
Fit(tracklet, trackstublist);
333 if (tracklet->
fit()) {
337 if (trackInfo[itrk].
second ==
true)
345 outputtracks_.push_back(outtrack);
357 return lhs->
ichisq() / lhs->
stubID().size() < rhs->ichisq() / rhs->stubID().size();
359 bool grid[35][40] = {{
false}};
361 for (
unsigned int itrk = 0; itrk < numTrk; itrk++) {
363 edm::LogPrint(
"Tracklet") <<
"WARNING: Track already tagged as duplicate!!";
378 if (phiTest < -2 *
M_PI / 27)
380 if (phiTest > 2 * 2 *
M_PI / 27)
389 for (
unsigned int itrk = 0; itrk < numTrk - 1; itrk++) {
395 unsigned int nStubP = 0;
396 vector<unsigned int> nStubS(numTrk);
397 vector<unsigned int> nShare(numTrk);
399 std::map<int, int> stubsTrk1 =
inputtracks_[itrk]->stubID();
400 nStubP = stubsTrk1.size();
402 for (
unsigned int jtrk = itrk + 1; jtrk < numTrk; jtrk++) {
408 std::map<int, int> stubsTrk2 =
inputtracks_[jtrk]->stubID();
409 nStubS[jtrk] = stubsTrk2.size();
412 for (
auto& st : stubsTrk1) {
413 if (stubsTrk2.find(st.first) != stubsTrk2.end()) {
414 if (st.second == stubsTrk2[st.first])
421 for (
unsigned int jtrk = itrk + 1; jtrk < numTrk; jtrk++) {
437 edm::LogVerbatim(
"Tracklet") <<
"Error: Didn't tag either track in duplicate pair.";
446 }
else if ((nStubS[jtrk] - nShare[jtrk] <
settings_.
minIndStubs()) && (nStubS[jtrk] <= nStubP)) {
449 edm::LogVerbatim(
"Tracklet") <<
"Error: Didn't tag either track in duplicate pair.";
465 ofstream
fout(
"seeds.txt", ofstream::app);
489 int seedindex = curTracklet->
seedIndex();
491 if ((seedindex == 0 && (
Layer == 1 ||
Layer == 2)) || (seedindex == 1 && (
Layer == 2 ||
abs(
Disk) == 0)) ||
492 (seedindex == 2 && (
Layer == 3 ||
Layer == 4)) || (seedindex == 3 && (
Layer == 5 ||
Layer == 6)) ||
502 }
else if (
Layer != 0) {
504 }
else if (
Disk != 0) {
507 throw cms::Exception(
"LogicError") << __FILE__ <<
" " << __LINE__ <<
" Layer: " <<
Layer <<
" -- Disk: " <<
Disk
508 <<
" Stub is not layer or disk in getPhiRes";
511 phires =
std::abs(stubphi - phiproj);