11 #include <tracking/modules/DATCON/DATCONTrackingModule.h>
21 DATCONTrackingModule::purifyTrackCandsList()
23 vector<unsigned int> merged_idList;
24 unsigned int cand_cnt = 0;
26 double x_tolerance = 0.2;
27 vector<DATCONHoughCand> cpyCand;
28 bool useMerger =
false;
33 sort(cpyCand.begin(), cpyCand.end());
34 for (
auto it = cpyCand.begin(); it != cpyCand.end(); ++it) {
35 vector<unsigned int> idList = it->getIdList();
37 if (it == cpyCand.begin()) {
38 x = hc.first.X() + hc.second.X();
39 y = hc.first.Y() + hc.second.Y();
40 merged_idList = idList;
42 }
else if (compareList(idList, merged_idList) && fabs(x / (2.0 * cand_cnt) - hc.first.X()) < x_tolerance
43 && it != cpyCand.end()) {
44 x += hc.first.X() + hc.second.X();
45 y += hc.first.Y() + hc.second.Y();
48 mergeIdList(merged_idList, idList);
50 merged_idList = idList;
53 if (it != cpyCand.begin()) {
54 x /= (2.0 * ((double) cand_cnt));
55 y /= (2.0 * ((double) cand_cnt));
58 x = hc.first.X() + hc.second.X();
59 y = hc.first.Y() + hc.second.Y();
61 merged_idList = idList;
65 if (cpyCand.size() > 0) {
66 x /= (2.0 * ((double) cand_cnt));
67 y /= (2.0 * ((double) cand_cnt));
76 sort(cpyCand.begin(), cpyCand.end());
77 for (
auto it = cpyCand.begin(); it != cpyCand.end(); ++it) {
78 vector<unsigned int> idList = it->getIdList();
80 if (it == cpyCand.begin()) {
81 x = hc.first.X() + hc.second.X();
82 y = hc.first.Y() + hc.second.Y();
84 merged_idList = idList;
85 }
else if (compareList(idList, merged_idList) && fabs(x / (2.0 * cand_cnt) - hc.first.X()) < x_tolerance
86 && it != cpyCand.end()) {
87 x += hc.first.X() + hc.second.X();
88 y += hc.first.Y() + hc.second.Y();
91 mergeIdList(merged_idList, idList);
93 merged_idList = idList;
96 if (it != cpyCand.begin()) {
97 x /= (2.0 * ((double) cand_cnt));
98 y /= (2.0 * ((double) cand_cnt));
101 x = hc.first.X() + hc.second.X();
102 y = hc.first.Y() + hc.second.Y();
104 merged_idList = idList;
108 if (cpyCand.size() > 0) {
109 x /= (2.0 * ((double) cand_cnt));
110 y /= (2.0 * ((double) cand_cnt));
123 DATCONTrackingModule::compareList(std::vector<unsigned int>& aList, std::vector<unsigned int>& bList)
125 unsigned int countLayer = 0;
126 bool foundLayer[4] = {
false};
128 for (
auto ita = aList.begin(); ita != aList.end(); ++ita) {
129 for (
auto itb = bList.begin(); itb != bList.end(); ++itb) {
130 int hitIDa = (int)(*ita) - (((int)(*ita) / 10000) * 10000);
131 int hitIDb = (int)(*itb) - (((int)(*itb) / 10000) * 10000);
132 int layera = (int)(*ita) / 10000000;
133 if (hitIDa == hitIDb && !foundLayer[layera - 3]) {
134 foundLayer[layera - 3] =
true;
140 if (countLayer >= m_minimumLines) {
153 DATCONTrackingModule::mergeIdList(std::vector<unsigned int>& mergedList, std::vector<unsigned int>& mergeme)
155 for (
auto& mergemeit : mergeme) {
157 for (
auto& mergedit : mergedList) {
158 if (mergedit == mergemeit) {
164 mergedList.push_back(mergemeit);