16 constexpr
unsigned int ETA = 1;
17 constexpr
unsigned int PHI = 0;
27 return StatusCode::SUCCESS;
39 for (
auto& hit : tower.
hits()) {
40 hits.push_back(std::make_unique<FPGATrackSimHit>(hit));
44 std::vector<FPGATrackSimCluster> towerClusters;
47 for (
auto &hit :
hits)
59 clusters.reserve(towerClusters.size());
61 ATH_MSG_WARNING(
"more than one tower, m_clusters is only going to contain those from the last one");
63 unsigned cluster_count = 0;
64 unsigned int pixelCounter = 0;
65 unsigned int stripCounter = 0;
66 for (
auto &cluster: towerClusters){
85 tower.
addHit(cluster_as_FPGATrackSimhit);
90 cluster.setClusterEquiv(cluster_as_FPGATrackSimhit);
97 return StatusCode::SUCCESS;
106 maxPhiIdx =
std::max(maxPhiIdx,
static_cast<int>(hit.getPhiIndex()));
107 minPhiIdx =
std::min(minPhiIdx,
static_cast<int>(hit.getPhiIndex()));
108 maxEtaIdx =
std::max(maxEtaIdx,
static_cast<int>(hit.getEtaIndex()));
109 minEtaIdx =
std::min(minEtaIdx,
static_cast<int>(hit.getEtaIndex()));
120 std::vector<FPGATrackSimCluster> moduleClusters;
124 Clustering(std::move(moduleHits), moduleClusters);
126 clusters.insert(
clusters.end(), moduleClusters.begin(), moduleClusters.end());
128 moduleClusters.clear();
139 for(
auto& hit: moduleHits){
140 bool is_clustered_hit =
false;
147 if (!is_clustered_hit) {
148 is_clustered_hit =
true;
151 int cPhi =
it->getClusterEquiv().getPhiIndex();
152 int cPhiWidth =
it->getClusterEquiv().getPhiWidth();
153 int cEta =
it->getClusterEquiv().getEtaIndex();
154 int cEtaWidth =
it->getClusterEquiv().getEtaWidth();
155 int fCPhi = it_added_clus->getClusterEquiv().getPhiIndex();
156 int fCPhiWidth = it_added_clus->getClusterEquiv().getPhiWidth();
157 int fCEta = it_added_clus->getClusterEquiv().getEtaIndex();
158 int fCEtaWidth = it_added_clus->getClusterEquiv().getEtaWidth();
160 clusterEquiv = it_added_clus->getClusterEquiv();
165 if (cPhi + cPhiWidth < fCPhi + fCPhiWidth)
166 clusterEquiv.
setPhiWidth(fCPhiWidth + (fCPhi - cPhi));
171 if (!(cPhi + cPhiWidth < fCPhi + fCPhiWidth))
172 clusterEquiv.
setPhiWidth(cPhiWidth + (cPhi - fCPhi));
180 if (cEta + cEtaWidth < fCEta + fCEtaWidth)
181 clusterEquiv.
setEtaWidth(fCEtaWidth + (fCEta - cEta));
186 if (!(cEta + cEtaWidth < fCEta + fCEtaWidth))
187 clusterEquiv.
setEtaWidth(cEtaWidth + (cEta - fCEta));
192 it_added_clus->setClusterEquiv(clusterEquiv);
194 for (
auto& hit :
it->getHitList()) {
196 for (
auto& finalHit : it_added_clus->getHitList()) {
197 if (hit.getEtaIndex() == finalHit.getEtaIndex() &&
198 hit.getPhiIndex() == finalHit.getPhiIndex())
203 clusterEquiv = it_added_clus->getClusterEquiv();
204 float xOld = clusterEquiv.
getX();
205 float yOld = clusterEquiv.
getY();
206 float zOld = clusterEquiv.
getZ();
211 float xNew = hit.getX();
212 float yNew = hit.getY();
213 float zNew = hit.getZ();
214 float xPhiNew = hit.getPhiCoord();
215 float xEtaNew = hit.getEtaCoord();
216 float cPhiNew = hit.getPhiIndex();
217 float cEtaNew = hit.getEtaIndex();
218 int tot = clusterEquiv.
getToT();
219 int totNew = hit.getToT();
222 int n = it_added_clus->getHitList().size();
223 clusterEquiv.
setX((xOld*
n + xNew) / (
n+1));
224 clusterEquiv.
setY((yOld*
n + yNew) / (
n+1));
225 clusterEquiv.
setZ((zOld*
n + zNew) / (
n+1));
231 clusterEquiv.
setX((xOld*tot + xNew*totNew) / (tot+totNew));
232 clusterEquiv.
setY((yOld*tot + yNew*totNew) / (tot+totNew));
233 clusterEquiv.
setZ((zOld*tot + zNew*totNew) / (tot+totNew));
234 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
235 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
239 clusterEquiv.
setToT(tot + totNew);
240 it_added_clus->setClusterEquiv(clusterEquiv);
241 it_added_clus->push_backHitList(hit);
248 if (
it != moduleClusters.end() - 1) {
249 *
it = moduleClusters.back();
250 moduleClusters.pop_back();
253 moduleClusters.pop_back();
261 is_clustered_hit =
true;
266 if((!is_clustered_hit) || (moduleClusters.size() == 0)){
271 }
else if(hit->isStrip()){
275 moduleClusters.push_back(cluster);
299 for (
auto& hit:
hits){
301 hashing = hit->getIdentifierHash();
302 currentModule.push_back(std::move(hit));
303 }
else if (hit->getIdentifierHash() == hashing) {
304 currentModule.push_back(std::move(hit));
307 hashing = hit->getIdentifierHash();
308 currentModule.push_back(std::move(hit));
313 if (currentModule.size() > 0) hitsPerModule.push_back(std::move(currentModule));
318 for (
auto&
module:hitsPerModule){
324 if (
module.at(0)->isStrip())
328 if (
module.at(0)->isStrip())
335 if (
module.at(0)->isStrip())
339 if (
module.at(0)->isStrip())
348 for (
auto&
module:hitsPerModule){
350 if (
module.at(0)->isStrip())
354 if (
module.at(0)->isStrip())
377 cluster.setClusterEquiv(clusterEquiv);
451 for(
auto& hit :
hits) {
454 if(!hit.getTruth().isEmpty()) {
455 mt.
add(hit.getTruth());
459 mt.
maximize(uniquecode, hit.getBarcodePt());
497 if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
502 }
else if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
508 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
512 }
else if ((hitCol == clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
516 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
521 }
else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow - 1)) {
528 }
else if ((hitCol == clusterCol - 1) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
533 }
else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow + clusterRowWidth)) {
539 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
589 clusterCol = clusterCol - clusterColWidth;
591 clusterColWidth = clusterColWidth+tempWidth+1;
593 clusterCol = clusterCol + clusterColWidth;
604 bool isConnected =
false;
608 for (
auto & hit : currentCluster.
getHitList()) {
610 auto hitPhi = hit.getPhiIndex();
614 if (((inHitEta == hitEta - 1) && (inHitPhi == hitPhi - 1)) ||
615 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi - 1)) ||
616 ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi + 1)) ||
617 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi + 1)) ||
618 ((inHitEta == hitEta) && (inHitPhi == hitPhi - 1)) ||
619 ((inHitEta == hitEta) && (inHitPhi == hitPhi + 1)) ||
620 ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi)) ||
621 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi))) {
644 float xOld = clusterEquiv.
getX();
645 float yOld = clusterEquiv.
getY();
646 float zOld = clusterEquiv.
getZ();
651 float xNew = incomingHit.
getX();
652 float yNew = incomingHit.
getY();
653 float zNew = incomingHit.
getZ();
658 int tot = clusterEquiv.
getToT();
659 int totNew = incomingHit.
getToT();
663 if (digitalClustering) {
666 clusterEquiv.
setX((xOld*
n + xNew) / (
n+1));
667 clusterEquiv.
setY((yOld*
n + yNew) / (
n+1));
668 clusterEquiv.
setZ((zOld*
n + zNew) / (
n+1));
674 clusterEquiv.
setX((xOld*tot + xNew*totNew) / (tot+totNew));
675 clusterEquiv.
setY((yOld*tot + yNew*totNew) / (tot+totNew));
676 clusterEquiv.
setZ((zOld*tot + zNew*totNew) / (tot+totNew));
677 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
678 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
688 clusterEquiv.
setPhiCoord((xPhiOld*
N + xPhiNew*newN) / (
N+newN));
689 clusterEquiv.
setX((xOld*
N + xNew*newN) / (
N+newN));
690 clusterEquiv.
setY((yOld*
N + yNew*newN) / (
N+newN));
691 clusterEquiv.
setZ((zOld*
N + zNew*newN) / (
N+newN));
693 clusterEquiv.
setToT(tot + totNew);