15 constexpr
unsigned int ETA = 1;
16 constexpr
unsigned int PHI = 0;
31 std::vector<FPGATrackSimHit>
hits = tower.
hits();
33 std::vector<std::vector<FPGATrackSimHit>> hitsPerModule;
34 std::vector<FPGATrackSimCluster> towerClusters;
37 for (
auto &hit :
hits)
49 clusters.reserve(towerClusters.size());
51 ATH_MSG_WARNING(
"more than one tower, m_clusters is only going to contain those from the last one");
53 unsigned cluster_count = 0;
54 unsigned int pixelCounter = 0;
55 unsigned int stripCounter = 0;
56 for (
auto &cluster: towerClusters){
74 tower.
addHit(cluster_as_FPGATrackSimhit);
82 return StatusCode::SUCCESS;
87 std::vector<FPGATrackSimCluster> moduleClusters;
89 for(
auto& moduleHits:sorted_hits){
93 clusters.insert(
clusters.end(), moduleClusters.begin(), moduleClusters.end());
95 moduleClusters.clear();
100 std::vector<FPGATrackSimCluster> tempClusters;
102 bool newCluster, newHit;
106 for(
auto& hit: moduleHits){
107 bool is_clustered_hit =
false;
110 for(
auto& cluster: tempClusters){
113 is_clustered_hit =
true;
117 is_clustered_hit =
true;
122 if((is_clustered_hit==0) or (tempClusters.size()==0)){
127 }
else if(hit.isStrip()){
131 tempClusters.push_back(cluster);
136 for (
auto& cluster : tempClusters) {
139 for (
auto& finalCluster : moduleClusters) {
140 int cPhi = cluster.getClusterEquiv().getPhiIndex();
141 int cPhiWidth = cluster.getClusterEquiv().getPhiWidth();
142 int cEta = cluster.getClusterEquiv().getEtaIndex();
143 int cEtaWidth = cluster.getClusterEquiv().getEtaWidth();
144 int fCPhi = finalCluster.getClusterEquiv().getPhiIndex();
145 int fCPhiWidth = finalCluster.getClusterEquiv().getPhiWidth();
146 int fCEta = finalCluster.getClusterEquiv().getEtaIndex();
147 int fCEtaWidth = finalCluster.getClusterEquiv().getEtaWidth();
150 if ((fCPhi > cPhi + cPhiWidth - 1) ||
151 (cPhi > fCPhi + fCPhiWidth - 1))
155 if ((fCEta > cEta + cEtaWidth - 1) ||
156 (cEta > fCEta + fCEtaWidth - 1))
160 unsigned int sharedhits = 0;
161 for (
auto & hit : cluster.getHitList()) {
163 for (
auto & finalHit : finalCluster.getHitList()) {
164 if (hit.getEtaIndex() == finalHit.getEtaIndex() &&
165 hit.getPhiIndex() == finalHit.getPhiIndex())
179 clusterEquiv = finalCluster.getClusterEquiv();
184 if (cPhi + cPhiWidth < fCPhi + fCPhiWidth)
185 clusterEquiv.
setPhiWidth(fCPhiWidth + (fCPhi - cPhi));
190 if (!(cPhi + cPhiWidth < fCPhi + fCPhiWidth))
191 clusterEquiv.
setPhiWidth(cPhiWidth + (cPhi - fCPhi));
199 if (cEta + cEtaWidth < fCEta + fCEtaWidth)
200 clusterEquiv.
setEtaWidth(fCEtaWidth + (fCEta - cEta));
205 if (!(cEta + cEtaWidth < fCEta + fCEtaWidth))
206 clusterEquiv.
setEtaWidth(cEtaWidth + (cEta - fCEta));
211 finalCluster.setClusterEquiv(clusterEquiv);
213 for (
auto & hit : cluster.getHitList()) {
215 for (
auto & finalHit : finalCluster.getHitList()) {
216 if (hit.getEtaIndex() == finalHit.getEtaIndex() &&
217 hit.getPhiIndex() == finalHit.getPhiIndex())
222 clusterEquiv = finalCluster.getClusterEquiv();
223 float xOld = clusterEquiv.
getX();
224 float yOld = clusterEquiv.
getY();
225 float zOld = clusterEquiv.
getZ();
230 float xNew = hit.getX();
231 float yNew = hit.getY();
232 float zNew = hit.getZ();
233 float xPhiNew = hit.getPhiCoord();
234 float xEtaNew = hit.getEtaCoord();
235 float cPhiNew = hit.getPhiIndex() + 0.5;
236 float cEtaNew = hit.getEtaIndex() + 0.5;
237 int tot = clusterEquiv.
getToT();
238 int totNew = hit.getToT();
241 int n = finalCluster.getHitList().size();
242 clusterEquiv.
setX((xOld*
n + xNew) / (
n+1));
243 clusterEquiv.
setY((yOld*
n + yNew) / (
n+1));
244 clusterEquiv.
setZ((zOld*
n + zNew) / (
n+1));
250 clusterEquiv.
setX((xOld*tot + xNew*totNew) / (tot+totNew));
251 clusterEquiv.
setY((yOld*tot + yNew*totNew) / (tot+totNew));
252 clusterEquiv.
setZ((zOld*tot + zNew*totNew) / (tot+totNew));
253 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
254 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
258 clusterEquiv.
setToT(tot + totNew);
259 finalCluster.setClusterEquiv(clusterEquiv);
260 finalCluster.push_backHitList(hit);
266 moduleClusters.push_back(cluster);
284 std::vector<FPGATrackSimHit> currentModule;
287 for (
auto& hit:
hits){
289 currentModule.push_back(hit);
290 hashing = hit.getIdentifierHash();
291 }
else if (hit.getIdentifierHash() == hashing) {
292 currentModule.push_back(hit);
294 hitsPerModule.push_back(currentModule);
295 currentModule.clear();
296 hashing = hit.getIdentifierHash();
297 currentModule.push_back(hit);
302 if (currentModule.size() > 0) hitsPerModule.push_back(currentModule);
307 for (
auto&
module:hitsPerModule){
313 if (
module.at(0).isStrip())
317 if (
module.at(0).isStrip())
324 if (
module.at(0).isStrip())
328 if (
module.at(0).isStrip())
337 for (
auto&
module:hitsPerModule){
339 if (
module.at(0).isStrip())
343 if (
module.at(0).isStrip())
366 cluster.setClusterEquiv(clusterEquiv);
440 for(
auto& hit :
hits) {
443 if(!hit.getTruth().isEmpty()) {
444 mt.
add(hit.getTruth());
448 mt.
maximize(uniquecode, hit.getBarcodePt());
486 if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
491 }
else if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
497 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
501 }
else if ((hitCol == clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
505 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
510 }
else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow - 1)) {
517 }
else if ((hitCol == clusterCol - 1) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
522 }
else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow + clusterRowWidth)) {
528 }
else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
577 clusterCol = clusterCol - clusterColWidth;
579 clusterColWidth = clusterColWidth+tempWidth+1;
581 clusterCol = clusterCol + clusterColWidth;
592 bool isConnected =
false;
596 for (
auto & hit : currentCluster.
getHitList()) {
598 auto hitPhi = hit.getPhiIndex();
602 if (((inHitEta == hitEta - 1) && (inHitPhi == hitPhi - 1)) ||
603 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi - 1)) ||
604 ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi + 1)) ||
605 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi + 1)) ||
606 ((inHitEta == hitEta) && (inHitPhi == hitPhi - 1)) ||
607 ((inHitEta == hitEta) && (inHitPhi == hitPhi + 1)) ||
608 ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi)) ||
609 ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi))) {
625 float xOld = clusterEquiv.
getX();
626 float yOld = clusterEquiv.
getY();
627 float zOld = clusterEquiv.
getZ();
632 float xNew = incomingHit.
getX();
633 float yNew = incomingHit.
getY();
634 float zNew = incomingHit.
getZ();
639 int tot = clusterEquiv.
getToT();
640 int totNew = incomingHit.
getToT();
644 if (digitalClustering) {
647 clusterEquiv.
setX((xOld*
n + xNew) / (
n+1));
648 clusterEquiv.
setY((yOld*
n + yNew) / (
n+1));
649 clusterEquiv.
setZ((zOld*
n + zNew) / (
n+1));
655 clusterEquiv.
setX((xOld*tot + xNew*totNew) / (tot+totNew));
656 clusterEquiv.
setY((yOld*tot + yNew*totNew) / (tot+totNew));
657 clusterEquiv.
setZ((zOld*tot + zNew*totNew) / (tot+totNew));
658 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
659 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
669 clusterEquiv.
setX((xOld*
N + xNew*newN) / (
N+newN));
670 clusterEquiv.
setY((yOld*
N + yNew*newN) / (
N+newN));
671 clusterEquiv.
setZ((zOld*
N + zNew*newN) / (
N+newN));
673 clusterEquiv.
setToT(tot + totNew);
715 cluster.setClusterEquiv(clusterEquiv);