11 #include <tracking/modules/DATCON/DATCONTrackingModule.h>
20 DATCONTrackingModule::layerFilter(
bool* layer)
22 unsigned int layercount = 0;
25 for (
int i = 0; i < 4; ++i) {
26 if (layer[i] ==
true) {
31 if (layercount >= m_minimumLines) {
49 DATCONTrackingModule::fastInterceptFinder2d(
houghMap& hits,
bool uSide, TVector2 v1_s,
52 unsigned int iterations,
unsigned int maxIterations)
55 unsigned int countLayer;
61 vector<unsigned int> candidateIDList;
65 int maxSectorX, maxSectorY;
68 TVector2 v1, v2, v3, v4;
70 unitX = ((v2_s.X() - v1_s.X()) / 2.0);
71 unitY = ((v1_s.Y() - v4_s.Y()) / 2.0);
76 maxSectorX = (int)pow(2, m_maxIterationsU + 1) - 1;
77 maxSectorY = (int)pow(2, m_maxIterationsU + 1) - 1;
81 maxSectorX = (int)pow(2, m_maxIterationsV + 1) - 1;
82 maxSectorY = (int)pow(2, m_maxIterationsV + 1) - 1;
86 for (
int i = 0; i < 2 ; ++i) {
87 for (
int j = 0; j < 2; ++j) {
88 v1.Set((v4_s.X() + (double) i * unitX), (v4_s.Y() + (double) j * unitY + unitY));
89 v2.Set((v4_s.X() + (double) i * unitX + unitX), (v4_s.Y() + (double) j * unitY + unitY));
90 v3.Set((v4_s.X() + (double) i * unitX + unitX), (v4_s.Y() + (double) j * unitY));
91 v4.Set((v4_s.X() + (double) i * unitX), (v4_s.Y() + (double) j * unitY));
93 candidateIDList.clear();
94 bool layerHit[4] = {
false};
95 for (
const auto& hit : hits) {
103 y1 = m * cos(v1.X()) + a * sin(v1.X());
104 y2 = m * cos(v2.X()) + a * sin(v2.X());
108 y1 = 2. * (m * cos(v1.X()) + a * sin(v1.X()));
109 y2 = 2. * (m * cos(v2.X()) + a * sin(v2.X()));
110 if (m_usePhase2Simulation) {
113 y1 = m * cos(v1.X()) + a * sin(v1.X());
114 y2 = m * cos(v2.X()) + a * sin(v2.X());
119 if (y1 <= v1.Y() && y2 >= v3.Y() && y2 >= y1) {
120 if (iterations == maxIterations) {
121 candidateIDList.push_back(hitID);
124 layerHit[sensor.getLayerNumber() - 3] =
true;
126 containedHits.insert(hit);
130 if (countLayer >= m_minimumLines) {
131 if (layerFilter(layerHit)) {
134 if (iterations != maxIterations) {
135 fastInterceptFinder2d(containedHits, uSide, v1, v2, v4,
136 iterations + 1, maxIterations);
139 vHoughCand.push_back(
DATCONHoughCand(candidateIDList, make_pair(v1, v3)));
140 if (m_useHoughSpaceClustering) {
141 xdiff = v4.X() - baseX;
142 ydiff = v4.Y() - baseY;
143 sectorX = round(xdiff / unitX);
144 sectorY = maxSectorY - round(ydiff / unitY);
145 if (sectorX > maxSectorX) {
146 sectorX = maxSectorX;
147 }
else if (sectorX < 0) {
150 if (sectorY > maxSectorY) {
151 sectorY = maxSectorY;
152 }
else if (sectorY < 0) {
155 ArrayOfActiveSectorsThetaHS[sectorY][sectorX] = -1;
158 activeSectorVectorTheta.push_back(
true);
162 uHoughCand.push_back(
DATCONHoughCand(candidateIDList, make_pair(v1, v3)));
163 if (m_useHoughSpaceClustering) {
165 baseY = -m_rectSizeU;
166 xdiff = v4.X() - baseX;
167 ydiff = v4.Y() - baseY;
168 maxSectorX = (int)pow(2, m_maxIterationsU + 1) - 1;
169 maxSectorY = (int)pow(2, m_maxIterationsU + 1) - 1;
170 sectorX = round(xdiff / unitX);
171 sectorY = maxSectorY - round(ydiff / unitY);
172 if (sectorX > maxSectorX) {
173 sectorX = maxSectorX;
174 }
else if (sectorX < 0) {
177 if (sectorY > maxSectorY) {
178 sectorY = maxSectorY;
179 }
else if (sectorY < 0) {
182 ArrayOfActiveSectorsPhiHS[sectorY][sectorX] = -1;
185 activeSectorVectorPhi.push_back(
true);
191 if (m_useHoughSpaceClustering) {
193 activeSectorVectorPhi.push_back(
false);
195 activeSectorVectorTheta.push_back(
false);
219 DATCONTrackingModule::slowInterceptFinder2d(
houghMap& hits,
bool uSide)
222 unsigned int countLayer;
228 vector<unsigned int> candidateIDList;
229 unsigned short angleSectors, vertSectors;
230 double angleRange, vertRange;
231 double left, right, up, down;
233 TVector2 v1, v2, v3, v4;
234 if (m_usePhase2Simulation) {
237 B2WARNING(
"This mode is not yet implemented, nothing will happen! Return...");
241 angleSectors = m_nAngleSectorsU;
242 vertSectors = m_nVertSectorsU;
248 angleSectors = m_nAngleSectorsV;
249 vertSectors = m_nVertSectorsV;
257 angleRange = (right - left);
258 vertRange = (up - down);
259 unitX = angleRange / (double)(angleSectors);
260 unitY = vertRange / (double)(vertSectors);
263 for (
int i = vertSectors - 1; i >= 0; i--) {
264 for (
int j = 0; j < angleSectors; j++) {
265 v1.Set((left + (
double) j * unitX), (up - (
double) i * unitY));
266 v2.Set((left + (
double) j * unitX + unitX), (up - (
double) i * unitY));
267 v3.Set((left + (
double) j * unitX + unitX), (up - (
double) i * unitY - unitY));
268 v4.Set((left + (
double) j * unitX), (up - (
double) i * unitY - unitY));
271 candidateIDList.clear();
272 bool layerHit[4] = {
false};
273 for (
const auto& hit : hits) {
281 y1 = m * cos(v1.X()) + a * sin(v1.X());
282 y2 = m * cos(v2.X()) + a * sin(v2.X());
286 y1 = 2 * (m * cos(v1.X()) + a * sin(v1.X()));
287 y2 = 2 * (m * cos(v2.X()) + a * sin(v2.X()));
290 if (y1 <= v1.Y() && y2 >= v3.Y() && y2 > y1) {
291 candidateIDList.push_back(hitID);
292 layerHit[sensor.getLayerNumber() - 3] =
true;
296 if (countLayer >= m_minimumLines) {
297 if (layerFilter(layerHit)) {
299 vHoughCand.push_back(
DATCONHoughCand(candidateIDList, make_pair(v1, v3)));
300 ArrayOfActiveSectorsThetaHS[i][j] = -1;
302 activeSectorVectorTheta.push_back(
true);
304 uHoughCand.push_back(
DATCONHoughCand(candidateIDList, make_pair(v1, v3)));
305 ArrayOfActiveSectorsPhiHS[i][j] = -1;
307 activeSectorVectorPhi.push_back(
true);
312 activeSectorVectorPhi.push_back(
false);
314 activeSectorVectorTheta.push_back(
false);