9#include <trg/cdc/modules/houghETF/CDCTriggerHoughETFModule.h>
11#include <framework/logging/Logger.h>
15#include <root/TMatrix.h>
23#define CDC_SUPER_LAYERS 9
24#define CDC_ETF_SECTOR 64
34 unsigned short lcnt = 0;
35 for (
int i = 0; i < CDC_SUPER_LAYERS; ++i) {
36 if (layer[i] ==
true) ++lcnt;
44 unsigned short lcnt = 0;
47 for (
int i = 0; i < CDC_SUPER_LAYERS; i += 2) {
48 if (layer[i] ==
true) ++lcnt;
65 double x1_s,
double x2_s,
66 double y1_s,
double y2_s,
68 unsigned ix_s,
unsigned iy_s)
71 for (
unsigned i = 0; i < iterations; ++i) indent +=
" ";
72 B2DEBUG(150, indent <<
"intercept finder iteration " << iterations
73 <<
" x1 " << x1_s * 180 / M_PI <<
" x2 " << x2_s * 180 / M_PI
74 <<
" y1 " << y1_s <<
" y2 " << y2_s
75 <<
" ix " << ix_s <<
" iy " << iy_s);
84 vector<unsigned> idx_list;
87 double x1_d, x2_d, y1_d, y2_d;
92 unitx = ((x2_s - x1_s) / 2.0);
93 unity = ((y2_s - y1_s) / 2.0);
96 for (i = 0; i < 2 ; ++i) {
98 for (j = 0; j < 2; ++j) {
99 x1_d = x1_s + i * unitx;
100 x2_d = x1_s + (i + 1) * unitx;
101 y1_d = y1_s + j * unity;
102 y2_d = y1_s + (j + 1) * unity;
108 if (x2_d <= -M_PI || x1_d >= M_PI || y2_d <= -maxR + shiftR || y1_d >=
maxR +
shiftR) {
109 B2DEBUG(150, indent <<
"skip Hough cell outside of plane limits");
121 bool layerHit[CDC_SUPER_LAYERS] = {
false};
122 for (
auto it = hits.begin(); it != hits.end(); ++it) {
129 y1 = m * sin(x1_d - 1e-10) - a * cos(x1_d - 1e-10);
130 y2 = m * sin(x2_d + 1e-10) - a * cos(x2_d + 1e-10);
133 if (!((y1 > y2_d && y2 > y2_d) || (y1 < y1_d && y2 < y1_d))) {
135 idx_list.push_back(iHit);
137 layerHit[iSL] =
true;
140 unsigned short nSL =
countSL(layerHit);
141 B2DEBUG(150, indent <<
"i " << i <<
" j " << j
142 <<
" layerHit " <<
int(layerHit[0]) <<
int(layerHit[2])
143 <<
int(layerHit[4]) <<
int(layerHit[6]) <<
int(layerHit[8])
149 ROOT::Math::XYVector v1(x1_d, y1_d);
150 ROOT::Math::XYVector v2(x2_d, y2_d);
160 for (
unsigned min =
m_minHits - 1; min > 0; --min) {
183 vector<vector<CDCTriggerHoughCand>> regions;
184 vector<CDCTriggerHoughCand> cpyCand =
houghCand;
187 B2DEBUG(50,
"houghCand number " << cpyCand.size());
188 for (
unsigned icand = 0; icand <
houghCand.size(); ++icand) {
191 <<
" nSL " <<
houghCand[icand].getSLcount()
192 <<
" x1 " << coord.first.X() <<
" x2 " << coord.second.X()
193 <<
" y1 " << coord.first.Y() <<
" y2 " << coord.second.Y());
197 while (cpyCand.size() > 0) {
198 B2DEBUG(100,
"make new region");
199 vector<CDCTriggerHoughCand> region;
200 vector<CDCTriggerHoughCand> rejected;
202 cpyCand.erase(cpyCand.begin());
203 region.push_back(start);
204 addNeighbors(start, cpyCand, region, rejected, start.getSLcount());
205 regions.push_back(region);
206 for (
auto cand = cpyCand.begin(); cand != cpyCand.end();) {
215 for (
unsigned ir = 0; ir < regions.size(); ++ir) {
216 B2DEBUG(50,
"region " << ir <<
" (" << regions[ir].size() <<
" cells).");
219 B2DEBUG(50,
"Skipping region with " << regions[ir].size() <<
" cells.");
222 double xfirst = regions[ir][0].getCoord().first.X();
226 vector<unsigned> mergedList;
231 vector<ROOT::Math::XYVector> cellIds = {};
232 for (
unsigned ir2 = 0; ir2 < regions[ir].size(); ++ir2) {
234 B2DEBUG(100,
" " << regions[ir][ir2].
getID()
235 <<
" nSL " << regions[ir][ir2].getSLcount()
236 <<
" x1 " << hc.first.X() <<
" x2 " << hc.second.X()
237 <<
" y1 " << hc.first.Y() <<
" y2 " << hc.second.Y());
238 int ix = floor((hc.first.X() + M_PI) / 2. / M_PI *
m_nCellsPhi + 0.5);
240 x += (hc.first.X() + hc.second.X());
241 if (xfirst - hc.first.X() > M_PI) {
244 }
else if (hc.first.X() - xfirst > M_PI) {
248 y += (hc.first.Y() + hc.second.Y());
250 vector<unsigned> idList = regions[ir][ir2].getIdList();
252 xmin = min(xmin, ix);
253 xmax = max(xmax, ix);
254 ymin = min(ymin, iy);
255 ymax = max(ymax, iy);
256 cellIds.push_back(ROOT::Math::XYVector(ix, iy));
264 B2DEBUG(50,
"x " << x <<
" y " << y);
267 vector<unsigned> selectedList = {};
268 vector<unsigned> unselectedList = {};
269 selectHits(mergedList, selectedList, unselectedList);
275 for (
unsigned i = 0; i < selectedList.size(); ++i) {
276 unsigned its = selectedList[i];
280 for (
unsigned i = 0; i < unselectedList.size(); ++i) {
281 unsigned its = unselectedList[i];
286 m_clusters.appendNew(xmin, xmax, ymin, ymax, cellIds);
293 const vector<CDCTriggerHoughCand>& candidates,
294 vector<CDCTriggerHoughCand>& merged,
295 vector<CDCTriggerHoughCand>& rejected,
296 unsigned short nSLmax)
const
298 for (
unsigned icand = 0; icand < candidates.size(); ++icand) {
299 B2DEBUG(120,
"compare center " << center.
getID()
300 <<
" to " << candidates[icand].getID());
301 if (
inList(candidates[icand], merged) ||
inList(candidates[icand], rejected)) {
302 B2DEBUG(120,
" " << candidates[icand].
getID() <<
" already in list");
305 bool reject =
inList(center, rejected);
306 if (
connected(center, candidates[icand])) {
308 B2DEBUG(100,
" lower than highest SLcount, rejected");
309 rejected.push_back(candidates[icand]);
310 }
else if (
m_onlyLocalMax && !reject && candidates[icand].getSLcount() > nSLmax) {
311 B2DEBUG(100,
" new highest SLcount, clearing list");
312 nSLmax = candidates[icand].getSLcount();
313 for (
unsigned imerged = 0; imerged < merged.size(); ++imerged) {
314 rejected.push_back(merged[imerged]);
317 merged.push_back(candidates[icand]);
319 B2DEBUG(100,
" connected to rejected cell, skip");
322 B2DEBUG(100,
" connected to rejected cell, rejected");
323 rejected.push_back(candidates[icand]);
325 B2DEBUG(100,
" connected");
326 merged.push_back(candidates[icand]);
328 vector<CDCTriggerHoughCand> cpyCand = candidates;
329 cpyCand.erase(cpyCand.begin() + icand);
330 addNeighbors(candidates[icand], cpyCand, merged, rejected, nSLmax);
337 const vector<CDCTriggerHoughCand>& list)
const
339 for (
unsigned i = 0; i < list.size(); ++i) {
340 if (a == list[i])
return true;
349 double ax1 = a.getCoord().first.X();
350 double ax2 = a.getCoord().second.X();
351 double ay1 = a.getCoord().first.Y();
352 double ay2 = a.getCoord().second.Y();
353 double bx1 = b.getCoord().first.X();
354 double bx2 = b.getCoord().second.X();
355 double by1 = b.getCoord().first.Y();
356 double by2 = b.getCoord().second.Y();
358 bool direct = ((ax2 == bx1 && ay1 == by1) ||
359 (ax1 == bx2 && ay1 == by1) ||
360 (ax1 == bx1 && ay2 == by1) ||
361 (ax1 == bx1 && ay1 == by2) ||
362 (ax1 + 2. * M_PI == bx2 && ay1 == by1) ||
363 (ax2 == bx1 + 2. * M_PI && ay1 == by1));
365 bool diagRise = ((ax2 == bx1 && ay2 == by1) ||
366 (ax1 == bx2 && ay1 == by2) ||
367 (ax1 + 2. * M_PI == bx2 && ay1 == by2) ||
368 (ax2 == bx1 + 2. * M_PI && ay2 == by1));
369 bool diagFall = ((ax1 == bx2 && ay2 == by1) ||
370 (ax2 == bx1 && ay1 == by2) ||
371 (ax2 == bx1 + 2. * M_PI && ay1 == by2) ||
372 (ax1 + 2. * M_PI == bx2 && ay2 == by1));
374 else if (
m_connect == 6)
return (direct || diagRise);
375 else if (
m_connect == 8)
return (direct || diagRise || diagFall);
376 else B2WARNING(
"Unknown option for connect " <<
m_connect <<
", using default.");
377 return (direct || diagRise);
385 std::vector<unsigned>& a,
386 std::vector<unsigned>& b)
390 for (
auto it = a.begin(); it != a.end(); ++it) {
392 for (
auto it_in = merged.begin(); it_in != merged.end(); ++it_in) {
399 merged.push_back(*it);
403 for (
auto it = b.begin(); it != b.end(); ++it) {
405 for (
auto it_in = merged.begin(); it_in != merged.end(); ++it_in) {
412 merged.push_back(*it);
419 double x1,
double x2,
420 double y1,
double y2,
423 double m, a, y1_h, y2_h;
426 if (iSL % 2)
continue;
428 if (
m_suppressClone && inputMap.find(iHit) == inputMap.end())
continue;
430 vector<double> phi = {0, 0, 0};
432 phi[1] = phi[0] + 0.5;
433 phi[2] = phi[0] - 0.5;
435 for (
unsigned i = 0; i < 3; ++i) {
437 m = cos(phi[i]) / r[i];
438 a = sin(phi[i]) / r[i];
440 y1_h = m * sin(x1 - 1e-10) - a * cos(x1 - 1e-10);
441 y2_h = m * sin(x2 + 1e-10) - a * cos(x2 + 1e-10);
443 if (y1_h > y2_h)
continue;
444 if (!((y1_h > y2 && y2_h > y2) || (y1_h < y1 && y2_h < y1))) {
445 list.push_back(iHit);
457 std::vector<unsigned>& selected,
458 std::vector<unsigned>& unselected)
460 std::vector<int> bestPerSL(5, -1);
461 for (
unsigned i = 0; i < list.size(); ++i) {
463 bool firstPriority = (
m_segmentHits[list[i]]->getPriorityPosition() == 3);
464 if (bestPerSL[iax] < 0) {
467 unsigned itsBest = list[bestPerSL[iax]];
468 bool firstBest = (
m_segmentHits[itsBest]->getPriorityPosition() == 3);
471 if ((firstPriority && !firstBest) ||
472 (firstPriority == firstBest &&
479 for (
unsigned i = 0; i < list.size(); ++i) {
481 if (
int(i) == bestPerSL[iax]) selected.push_back(list[i]);
482 else unselected.push_back(list[i]);
492 bool foundTrack =
false;
493 std::vector<CDCTriggerSegmentHit*> associatedTSHits;
498 for (
unsigned icand = 0; icand <
houghCand.size(); ++icand) {
499 double x = (
houghCand[icand].getCoord().first.X() +
500 houghCand[icand].getCoord().second.X()) / 2.;
501 unsigned ix = floor((x + M_PI) / 2. / M_PI *
m_nCellsPhi);
502 double y = (
houghCand[icand].getCoord().first.Y() +
503 houghCand[icand].getCoord().second.Y()) / 2.;
505 plane2[ix / 2][iy / 2] += 1 << ((ix % 2) + 2 * (iy % 2));
506 planeIcand[ix][iy] = icand;
507 B2DEBUG(100,
"candidate " << icand <<
" at ix " << ix <<
" iy " << iy);
514 for (
unsigned ix = 0; ix < nX; ++ix) {
515 for (
unsigned iy = 0; iy < nY; ++iy) {
516 if (!plane2[ix][iy])
continue;
518 unsigned ileft = (ix - 1 + nX) % nX;
519 B2DEBUG(100,
"ix " << ix <<
" iy " << iy);
520 if (
connectedLR(plane2[ileft][iy], plane2[ix][iy]) ||
521 (iy > 0 &&
connectedUD(plane2[ix][iy - 1], plane2[ix][iy])) ||
522 (iy > 0 &&
connectedDiag(plane2[ileft][iy - 1], plane2[ix][iy]))) {
523 B2DEBUG(100,
"skip connected square");
527 vector<unsigned> pattern(rX * rY, 0);
528 pattern[0] = plane2[ix][iy];
529 vector<ROOT::Math::XYVector> cellIds = {ROOT::Math::XYVector(2 * ix, 2 * iy)};
530 for (
unsigned ix2 = 0; ix2 < rX; ++ix2) {
531 for (
unsigned iy2 = 0; iy2 < rY; ++iy2) {
532 if (iy + iy2 >= nY)
continue;
533 unsigned ip = ix2 + rX * iy2;
534 unsigned iright = (ix + ix2 + nX) % nX;
535 ileft = (iright - 1 + nX) % nX;
536 B2DEBUG(100,
"ix2 " << ix2 <<
" ileft " << ileft <<
" iright " << iright);
539 connectedLR(plane2[ileft][iy + iy2], plane2[iright][iy + iy2])) ||
542 connectedUD(plane2[iright][iy + iy2 - 1], plane2[iright][iy + iy2])) ||
543 (ix2 > 0 && iy2 > 0 &&
544 pattern[ip - rX - 1] &&
545 connectedDiag(plane2[ileft][iy + iy2 - 1], plane2[iright][iy + iy2]))) {
546 pattern[ip] = plane2[iright][iy + iy2];
547 B2DEBUG(100,
"connect cell " << iright <<
" " << iy + iy2);
548 cellIds.push_back(ROOT::Math::XYVector(2 * (ix + ix2), 2 * (iy + iy2)));
552 B2DEBUG(100,
"cluster starting at " << ix <<
" " << iy);
554 bool overflowRight =
false;
555 bool overflowTop =
false;
556 for (
unsigned iy2 = 0; iy2 < rY; ++iy2) {
557 unsigned ip = rX - 1 + rX * iy2;
558 if (!pattern[ip])
continue;
559 unsigned iright = (ix + rX + nX) % nX;
560 ileft = (iright - 1 + nX) % nX;
561 if (
connectedLR(plane2[ileft][iy + iy2], plane2[iright][iy + iy2]) ||
562 ((iy + iy2 + 1 < nY) &&
563 connectedDiag(plane2[ileft][iy + iy2], plane2[iright][iy + iy2 + 1]))) {
565 overflowRight =
true;
569 for (
unsigned ix2 = 0; ix2 < rX; ++ix2) {
570 unsigned ip = ix2 + rX * (rY - 1);
571 if (!pattern[ip])
continue;
572 unsigned iright = (ix + ix2 + 1 + nX) % nX;
573 ileft = (iright - 1 + nX) % nX;
574 if (
connectedUD(plane2[ileft][iy + rY - 1], plane2[ileft][iy + rY]) ||
575 connectedDiag(plane2[ileft][iy + rY - 1], plane2[iright][iy + rY])) {
581 if (overflowRight && !overflowTop) {
582 B2DEBUG(100,
"cluster extends right of " << rX <<
" x " << rY <<
" area");
583 }
else if (overflowTop && !overflowRight) {
584 B2DEBUG(100,
"cluster extends above " << rX <<
" x " << rY <<
" area");
585 }
else if (overflowRight && overflowTop) {
586 B2DEBUG(100,
"cluster extends right and above " << rX <<
" x " << rY <<
" area");
592 B2DEBUG(100,
"topRight2 " << topRight2 <<
" topRight " << topRight <<
" bottomLeft " << bottomLeft);
594 unsigned ixTR = 2 * (topRight2 %
m_clusterSizeX) + (topRight % 2);
595 unsigned ixBL = bottomLeft % 2;
596 unsigned iyTR = 2 * (topRight2 /
m_clusterSizeX) + (topRight / 2);
597 unsigned iyBL = bottomLeft / 2;
598 B2DEBUG(100,
"ixTR " << ixTR <<
" ixBL " << ixBL <<
" iyTR " << iyTR <<
" iyBL " << iyBL);
600 if (
m_minCells > 1 && ixTR == ixBL && iyTR == iyBL) {
601 B2DEBUG(100,
"skipping cluster of size 1");
604 float centerX = 2 * ix + (ixTR + ixBL) / 2.;
606 float centerY = 2 * iy + (iyTR + iyBL) / 2.;
607 B2DEBUG(100,
"center at cell (" << centerX <<
", " << centerY <<
")");
609 double x = -M_PI + (centerX + 0.5) * 2. * M_PI /
m_nCellsPhi;
611 B2DEBUG(100,
"center coordinates (" << x <<
", " << y <<
")");
613 vector <unsigned> idList = {};
615 unsigned icandTR = planeIcand[(ixTR + 2 * ix) %
m_nCellsPhi][iyTR + 2 * iy];
616 unsigned icandBL = planeIcand[ixBL + 2 * ix][iyBL + 2 * iy];
617 vector<unsigned> candIdListTR =
houghCand[icandTR].getIdList();
618 vector<unsigned> candIdListBL =
houghCand[icandBL].getIdList();
620 B2DEBUG(100,
"merge id lists from candidates " << icandTR <<
" and " << icandBL);
624 double x1 = (round(centerX) == centerX) ? x - dx : x - 2 * dx;
625 double x2 = (round(centerX) == centerX) ? x + dx : x + 2 * dx;
626 double y1 = (round(centerY) == centerY) ? y - dy : y - 2 * dy;
627 double y2 = (round(centerY) == centerY) ? y + dy : y + 2 * dy;
630 if (idList.size() == 0) {
632 B2DEBUG(100,
"id list empty");
638 vector<unsigned> selectedList = {};
639 vector<unsigned> unselectedList = {};
640 selectHits(idList, selectedList, unselectedList);
642 associatedTSHits.clear();
644 for (
unsigned i = 0; i < selectedList.size(); ++i)
648 for (
unsigned i = 0; i < idList.size(); ++i)
659 for (
unsigned i = 0; i < selectedList.size(); ++i) {
660 unsigned its = selectedList[i];
664 for (
unsigned i = 0; i < unselectedList.size(); ++i) {
665 unsigned its = unselectedList[i];
669 for (
unsigned i = 0; i < idList.size(); ++i) {
670 unsigned its = idList[i];
679 track->addRelationTo(cluster);
695 bool connectDirect = (((patternL >> 3) & 1) && ((patternR >> 2) & 1)) ||
696 (((patternL >> 1) & 1) && ((patternR >> 0) & 1));
700 bool connectRise = ((patternL >> 1) & 1) && ((patternR >> 2) & 1);
704 bool connectFall = ((patternL >> 3) & 1) && ((patternR >> 0) & 1);
706 if (
m_connect == 4)
return connectDirect;
707 else if (
m_connect == 6)
return (connectDirect || connectRise);
708 else if (
m_connect == 8)
return (connectDirect || connectRise || connectFall);
709 else B2WARNING(
"Unknown option for connect " <<
m_connect <<
", using default.");
710 return (connectDirect || connectRise);
722 bool connectDirect = (((patternU >> 0) & 1) && ((patternD >> 2) & 1)) ||
723 (((patternU >> 1) & 1) && ((patternD >> 3) & 1));
730 bool connectRise = ((patternU >> 1) & 1) && ((patternD >> 2) & 1);
737 bool connectFall = ((patternU >> 0) & 1) && ((patternD >> 3) & 1);
739 if (
m_connect == 4)
return connectDirect;
740 else if (
m_connect == 6)
return (connectDirect || connectRise);
741 else if (
m_connect == 8)
return (connectDirect || connectRise || connectFall);
742 else B2WARNING(
"Unknown option for connect " <<
m_connect <<
", using default.");
743 return (connectDirect || connectRise);
756 return (((patternRU >> 0) & 1) && ((patternLD >> 3) & 1));
763 for (
unsigned index = pattern.size() - 1; index > 0; --index) {
764 if (!pattern[index])
continue;
768 if (ix < m_clusterSizeX - 1 && iy > 0) {
770 for (
unsigned index2 = index - 1; index2 > 0; --index2) {
771 if (!pattern[index2])
continue;
774 if (iy2 < iy && ix2 > ix) {
781 B2DEBUG(100,
"topRightSquare not unique");
795 if ((pattern >> 3) & 1)
return 3;
796 if ((pattern >> 1) & 1) {
797 if ((pattern >> 2) & 1) {
799 B2DEBUG(100,
"topRightCorner not unique");
803 if ((pattern >> 2) & 1)
return 2;
813 if (pattern & 1)
return 0;
814 if ((pattern >> 2) & 1) {
815 if ((pattern >> 1) & 1) {
817 B2DEBUG(100,
"bottomLeftCorner not unique");
821 if ((pattern >> 1) & 1)
return 1;
825CDCTriggerHoughETFModule::highPassTimingList()
827 std::vector<int> ftlists;
833 ftlists.push_back(ft * 2);
840CDCTriggerHoughETFModule::getSector(
int id,
int sl)
842 unsigned int localid =
id -
TSoffset[sl];
843 unsigned int base =
NTS[sl] /
NSEC[sl];
848CDCTriggerHoughETFModule::sectorTimingList()
850 std::vector<int> ftlists;
851 std::array<std::vector<std::pair<int, int>>, CDC_ETF_SECTOR> arr_sector;
861 arr_sector [getSector(
id, sl)].push_back(make_pair(ft, pp));
866 for (
int sec = 0; sec < CDC_ETF_SECTOR; sec++) {
867 if (!arr_sector[sec].size())
continue;
870 for (
auto& ift : arr_sector[sec]) {
871 if ((minft > ift.first) && (pp <= ift.second)) {
876 ftlists.push_back(minft);
883CDCTriggerHoughETFModule::calcEventTiming()
885 std::vector<int> ftlists;
887 ftlists = highPassTimingList();
889 ftlists = sectorTimingList();
893 std::sort(ftlists.begin(), ftlists.end());
896 return median(ftlists);
898 return medianInTimeWindow(ftlists);
903CDCTriggerHoughETFModule::median(std::vector<int> v)
907 copy(v.begin(), v.end(), back_inserter(_v));
908 std::sort(_v.begin(), _v.end());
910 return _v[(size - 1) / 2];
912 return (_v[(size / 2) - 1] + _v[size / 2]) / 2;
917CDCTriggerHoughETFModule::medianInTimeWindow(std::vector<int> v)
923 std::vector<int> _inWindow;
925 for (
auto& t : v)
if (t > tbegin && t < tend) _inWindow.push_back(t);
927 if (_inWindow.size()) {
928 return median(_inWindow);
unsigned getID() const
Get candidate number.
unsigned short getSLcount() const
Get super layer count.
Cluster created by the Hough finder of the CDC trigger.
int NSecOffset[9]
Number of sector offset of each super layer.
std::vector< CDCTriggerHoughCand > houghCand
Hough Candidates.
bool connectedLR(unsigned patternL, unsigned patternR)
Check for left/right connection of patterns in 2 x 2 squares.
unsigned topRightCorner(unsigned pattern)
Find the top right corner within 2 x 2 square.
int fastInterceptFinder(cdcMap &hits, double x1_s, double x2_s, double y1_s, double y2_s, unsigned iterations, unsigned ix_s, unsigned iy_s)
Fast intercept finder Divide Hough plane recursively to find cells with enough crossing lines.
bool m_useHighPassTimingList
Use associated fastest timings track-by-track.
unsigned m_minCells
minimum number of cells in a cluster to form a track
bool connectedUD(unsigned patternD, unsigned patternU)
Check for up/down connection of patterns in 2 x 2 squares.
unsigned maxIterations
number of iterations for the fast peak finder, smallest n such that 2^(n+1) > max(nCellsPhi,...
unsigned m_minHitsShort
short tracks require hits in the first minHitsShort super layers to form a candidate
unsigned m_nCellsR
number of Hough cells in 1/r
StoreArray< CDCTriggerSegmentHit > m_segmentHits
list of track segment hits
unsigned m_nCellsPhi
number of Hough cells in phi
short m_timeWindowEnd
End time of time window relative to median.
unsigned short countSL(bool *superLayers)
count the number of super layers with hits
double maxR
Hough plane limit in 1/r [1/cm].
bool m_hitRelationsFromCorners
switch for creating relations to hits in the pattern clustering algorithm.
std::vector< std::vector< CDCTriggerSegmentHit * > > associatedTSHitsList
list of fastest timing of TS associated with Track
unsigned m_storePlane
switch to save the Hough plane in DataStore (0: don't save, 1: save only peaks, 2: save full plane)
bool inList(const CDCTriggerHoughCand &a, const std::vector< CDCTriggerHoughCand > &list) const
Check if candidate is in list.
unsigned m_connect
number of neighbors to check for connection (4: direct, 6: direct + upper right and lower left corner...
double shiftR
Hough plane shift in 1/r [1/cm].
void findAllCrossingHits(std::vector< unsigned > &list, double x1, double x2, double y1, double y2, const cdcMap &inputMap)
Find all hits in inputMap whose Hough curve crosses the rectangle with corners (x1,...
unsigned nCells
number of cells for the fast peak finder: 2^(maxIterations + 1).
void selectHits(std::vector< unsigned > &list, std::vector< unsigned > &selected, std::vector< unsigned > &unselected)
Select one hit per super layer.
bool m_suppressClone
switch to send only the first found track and suppress the subsequent clones
unsigned m_t0CalcMethod
Switch method to determine the event timing.
double radius[9][2]
Radius of the CDC layers with priority wires (2 per super layer).
StoreArray< CDCTriggerTrack > m_tracks
list of found tracks
unsigned m_arrivalOrder
arrival order of fastest timing used as t0 (effective when t0CalcMEthod == 0)
unsigned m_clusterSizeX
maximum cluster size for pattern algorithm
void mergeIdList(std::vector< unsigned > &merged, std::vector< unsigned > &a, std::vector< unsigned > &b)
Merge lists a and b and put the result in merged.
bool connected(const CDCTriggerHoughCand &a, const CDCTriggerHoughCand &b) const
Check if candidates are connected.
unsigned bottomLeftCorner(unsigned pattern)
Find the bottom left corner within 2 x 2 square.
const int NSEC[9]
Number of sector in each super layer.
bool m_requireSL0
switch to check separately for a hit in the innermost super layer
short m_timeWindowBegin
Start time of time window relative to median.
unsigned m_minHits
minimum number of hits from different super layers in a Hough cell to form a candidate
StoreArray< CDCTriggerHoughCluster > m_clusters
list of clusters in the Hough map
void addNeighbors(const CDCTriggerHoughCand ¢er, const std::vector< CDCTriggerHoughCand > &candidates, std::vector< CDCTriggerHoughCand > &merged, std::vector< CDCTriggerHoughCand > &rejected, unsigned short nSLmax) const
Recursive function to add combine connected cells.
const int NTS[9]
Number of track segments in each super layers.
bool shortTrack(bool *superLayers)
check the short track condition (= hits in the inner super layers rather than any super layers)
bool connectedDiag(unsigned patternLD, unsigned patternRU)
Check for diagonal connected of patterns in 2 x 2 squares.
unsigned topRightSquare(std::vector< unsigned > &pattern)
Find the top right square within a cluster of 2 x 2 squares In case of ambiguity, top is favored over...
unsigned TSoffset[10]
Number of track segments up to super layer.
bool m_storeTracks
Switch to save the 2D Hough track reconstructed in this module.
bool patternClustering(const cdcMap &inputMap)
Combine Hough candidates to tracks by a fixed pattern algorithm.
bool m_onlyLocalMax
switch to ignore candidates connected to cells with higher super layer count
bool m_usePriorityTiming
Switch to use priority timing instead of fastest timing.
unsigned m_clusterSizeY
maximum cluster size for pattern algorithm
void connectedRegions()
Combine Hough candidates to tracks by merging connected cells.
Track created by the CDC trigger.
void setReturnValue(int value)
Sets the return value for this module as integer.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
std::map< int, cdcPair > cdcMap
Map of <counter, cdcPair>, for hits with indices.
std::pair< ROOT::Math::XYVector, ROOT::Math::XYVector > coord2dPair
Hough Tuples.
std::pair< unsigned short, ROOT::Math::XYVector > cdcPair
Pair of <iSuperLayer, (x, y)>, for hits in conformal space.
Abstract base class for different kinds of events.