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){
88 tower.
addHit(cluster_as_FPGATrackSimhit);
89 cluster.setClusterEquiv(cluster_as_FPGATrackSimhit);
96 return StatusCode::SUCCESS;
105 maxPhiIdx =
std::max(maxPhiIdx,
static_cast<int>(hit.getPhiIndex()));
106 minPhiIdx =
std::min(minPhiIdx,
static_cast<int>(hit.getPhiIndex()));
107 maxEtaIdx =
std::max(maxEtaIdx,
static_cast<int>(hit.getEtaIndex()));
108 minEtaIdx =
std::min(minEtaIdx,
static_cast<int>(hit.getEtaIndex()));
119 std::vector<FPGATrackSimCluster> moduleClusters;
123 Clustering(std::move(moduleHits), moduleClusters);
125 clusters.insert(
clusters.end(), moduleClusters.begin(), moduleClusters.end());
127 moduleClusters.clear();
138 for(
auto& hit: moduleHits){
139 bool is_clustered_hit =
false;
146 if (!is_clustered_hit) {
147 is_clustered_hit =
true;
150 int cPhi =
it->getClusterEquiv().getPhiIndex();
151 int cPhiWidth =
it->getClusterEquiv().getPhiWidth();
152 int cEta =
it->getClusterEquiv().getEtaIndex();
153 int cEtaWidth =
it->getClusterEquiv().getEtaWidth();
154 int fCPhi = it_added_clus->getClusterEquiv().getPhiIndex();
155 int fCPhiWidth = it_added_clus->getClusterEquiv().getPhiWidth();
156 int fCEta = it_added_clus->getClusterEquiv().getEtaIndex();
157 int fCEtaWidth = it_added_clus->getClusterEquiv().getEtaWidth();
159 clusterEquiv = it_added_clus->getClusterEquiv();
164 if (cPhi + cPhiWidth < fCPhi + fCPhiWidth)
165 clusterEquiv.
setPhiWidth(fCPhiWidth + (fCPhi - cPhi));
170 if (!(cPhi + cPhiWidth < fCPhi + fCPhiWidth))
171 clusterEquiv.
setPhiWidth(cPhiWidth + (cPhi - fCPhi));
179 if (cEta + cEtaWidth < fCEta + fCEtaWidth)
180 clusterEquiv.
setEtaWidth(fCEtaWidth + (fCEta - cEta));
185 if (!(cEta + cEtaWidth < fCEta + fCEtaWidth))
186 clusterEquiv.
setEtaWidth(cEtaWidth + (cEta - fCEta));
191 it_added_clus->setClusterEquiv(clusterEquiv);
193 for (
auto& hit :
it->getHitList()) {
195 for (
auto& finalHit : it_added_clus->getHitList()) {
196 if (hit.getEtaIndex() == finalHit.getEtaIndex() &&
197 hit.getPhiIndex() == finalHit.getPhiIndex())
202 clusterEquiv = it_added_clus->getClusterEquiv();
203 float xOld = clusterEquiv.
getX();
204 float yOld = clusterEquiv.
getY();
205 float zOld = clusterEquiv.
getZ();
210 float xNew = hit.getX();
211 float yNew = hit.getY();
212 float zNew = hit.getZ();
213 float xPhiNew = hit.getPhiCoord();
214 float xEtaNew = hit.getEtaCoord();
215 float cPhiNew = hit.getPhiIndex();
216 float cEtaNew = hit.getEtaIndex();
218 int totNew = hit.getToT();
221 int n = it_added_clus->getHitList().size();
222 clusterEquiv.
setX((xOld*
n + xNew) / (
n+1));
223 clusterEquiv.
setY((yOld*
n + yNew) / (
n+1));
224 clusterEquiv.
setZ((zOld*
n + zNew) / (
n+1));
230 clusterEquiv.
setX((xOld*
tot + xNew*totNew) / (
tot+totNew));
231 clusterEquiv.
setY((yOld*
tot + yNew*totNew) / (
tot+totNew));
232 clusterEquiv.
setZ((zOld*
tot + zNew*totNew) / (
tot+totNew));
239 it_added_clus->setClusterEquiv(clusterEquiv);
240 it_added_clus->push_backHitList(hit);
247 if (
it != moduleClusters.end() - 1) {
248 *
it = moduleClusters.back();
249 moduleClusters.pop_back();
252 moduleClusters.pop_back();
260 is_clustered_hit =
true;
265 if((!is_clustered_hit) || (moduleClusters.size() == 0)){
270 }
else if(hit->isStrip()){
274 moduleClusters.push_back(cluster);
298 for (
auto& hit:
hits){
300 hashing = hit->getIdentifierHash();
301 currentModule.push_back(std::move(hit));
302 }
else if (hit->getIdentifierHash() == hashing) {
303 currentModule.push_back(std::move(hit));
306 hashing = hit->getIdentifierHash();
307 currentModule.push_back(std::move(hit));
312 if (currentModule.size() > 0) hitsPerModule.push_back(std::move(currentModule));
317 for (
auto&
module:hitsPerModule){
323 if (
module.at(0)->isStrip())
327 if (
module.at(0)->isStrip())
334 if (
module.at(0)->isStrip())
338 if (
module.at(0)->isStrip())
347 for (
auto&
module:hitsPerModule){
349 if (
module.at(0)->isStrip())
353 if (
module.at(0)->isStrip())
376 cluster.setClusterEquiv(clusterEquiv);
450 for(
auto& hit :
hits) {
453 if(!hit.getTruth().isEmpty()) {
454 mt.
add(hit.getTruth());
458 mt.
maximize(uniquecode, hit.getBarcodePt());
496 if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
501 }
else if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
507 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
511 }
else if ((hitCol == clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
515 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
520 }
else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow - 1)) {
527 }
else if ((hitCol == clusterCol - 1) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
532 }
else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow + clusterRowWidth)) {
538 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
588 clusterCol = clusterCol - clusterColWidth;
590 clusterColWidth = clusterColWidth+tempWidth+1;
592 clusterCol = clusterCol + clusterColWidth;
603 bool isConnected =
false;
607 for (
auto & hit : currentCluster.
getHitList()) {
609 auto hitPhi = hit.getPhiIndex();
613 if (((inHitEta == hitEta - 1) && (inHitPhi == hitPhi - 1)) ||
614 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi - 1)) ||
615 ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi + 1)) ||
616 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi + 1)) ||
617 ((inHitEta == hitEta) && (inHitPhi == hitPhi - 1)) ||
618 ((inHitEta == hitEta) && (inHitPhi == hitPhi + 1)) ||
619 ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi)) ||
620 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi))) {
643 float xOld = clusterEquiv.
getX();
644 float yOld = clusterEquiv.
getY();
645 float zOld = clusterEquiv.
getZ();
650 float xNew = incomingHit.
getX();
651 float yNew = incomingHit.
getY();
652 float zNew = incomingHit.
getZ();
658 int totNew = incomingHit.
getToT();
662 if (digitalClustering) {
665 clusterEquiv.
setX((xOld*
n + xNew) / (
n+1));
666 clusterEquiv.
setY((yOld*
n + yNew) / (
n+1));
667 clusterEquiv.
setZ((zOld*
n + zNew) / (
n+1));
673 clusterEquiv.
setX((xOld*
tot + xNew*totNew) / (
tot+totNew));
674 clusterEquiv.
setY((yOld*
tot + yNew*totNew) / (
tot+totNew));
675 clusterEquiv.
setZ((zOld*
tot + zNew*totNew) / (
tot+totNew));
687 clusterEquiv.
setPhiCoord((xPhiOld*
N + xPhiNew*newN) / (
N+newN));
688 clusterEquiv.
setX((xOld*
N + xNew*newN) / (
N+newN));
689 clusterEquiv.
setY((yOld*
N + yNew*newN) / (
N+newN));
690 clusterEquiv.
setZ((zOld*
N + zNew*newN) / (
N+newN));