16 constexpr unsigned int ETA = 1;
17 constexpr unsigned int PHI = 0;
21 base_class(algname, name, ifc)
27 return StatusCode::SUCCESS;
33 for (
int i = 0; i<
header.nTowers(); i++)
38 hits.reserve(tower.
hits().size());
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);
91 clusters.push_back(cluster);
96 return StatusCode::SUCCESS;
102 int maxPhiIdx{-std::numeric_limits<int>::max()}, maxEtaIdx{-std::numeric_limits<int>::max()};
103 int minPhiIdx{std::numeric_limits<int>::max()}, minEtaIdx{std::numeric_limits<int>::max()};
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;
140 std::vector<FPGATrackSimCluster>::iterator it_added_clus;
143 for(std::vector<FPGATrackSimCluster>::iterator it = moduleClusters.begin(); it != moduleClusters.end(); ++it) {
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();
217 int tot = clusterEquiv.
getToT();
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));
225 clusterEquiv.
setPhiCoord((xPhiOld*n + xPhiNew) / (n+1));
226 clusterEquiv.
setEtaCoord((xEtaOld*n + xEtaNew) / (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));
233 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
234 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
238 clusterEquiv.
setToT(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){
319 if(
etaOrPhi(*module.at(0)) ==
true){
322 if (module.size() > 1) {
323 if (module.at(0)->isStrip())
326 if (module.size() > 1) {
327 if (module.at(0)->isStrip())
333 if (module.size() > 1) {
334 if (module.at(0)->isStrip())
337 if (module.size() > 1) {
338 if (module.at(0)->isStrip())
347 for (
auto& module:hitsPerModule){
348 if (module.size() > 1) {
349 if (module.at(0)->isStrip())
352 if (module.size() > 1) {
353 if (module.at(0)->isStrip())
363 for(
auto &cluster:clusters){
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()) {
608 auto hitEta = hit.getEtaIndex();
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();
657 int tot = clusterEquiv.
getToT();
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));
668 clusterEquiv.
setPhiCoord((xPhiOld*n + xPhiNew) / (n+1));
669 clusterEquiv.
setEtaCoord((xEtaOld*n + xEtaNew) / (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));
676 clusterEquiv.
setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
677 clusterEquiv.
setEtaCoord((xEtaOld*tot + xEtaNew*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));
692 clusterEquiv.
setToT(tot + totNew);
707 if (hitA->getIdentifierHash() != hitB->getIdentifierHash())
708 return hitA->getIdentifierHash() < hitB->getIdentifierHash();
709 return hitA->getEtaIndex() < hitB->getEtaIndex();
716 if (hitA->getIdentifierHash() != hitB->getIdentifierHash())
717 return hitA->getIdentifierHash() < hitB->getIdentifierHash();
718 return hitA->getPhiIndex() < hitB->getPhiIndex();
724 float pos[3] = { clusterEquiv.
getR(), clusterEquiv.
getGPhi(), clusterEquiv.
getZ() };
730 clusterEquiv.
setX(pos[0] * std::cos(pos[1]));
731 clusterEquiv.
setY(pos[0] * std::sin(pos[1]));
732 clusterEquiv.
setZ(pos[2]);
744 hit.
setX(pos[0] * std::cos(pos[1]));
745 hit.
setY(pos[0] * std::sin(pos[1]));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
void setClusterEquiv(const FPGATrackSimHit &input)
hitVector const & getHitList() const
FPGATrackSimHit const & getClusterEquiv() const
void push_backHitList(const FPGATrackSimHit &input)
unsigned getPhiIndex() const
void setMinEtaIndex(int v)
void setCluster1ID(int v)
void setEtaIndex(unsigned v)
void setPhiIndex(unsigned v)
void setMinPhiIndex(int v)
float getPhiCoord() const
float getCentroidPhiIndex() const
void setHitType(HitType type)
int getEtaModule(bool old=false) const
void setPhiCoord(float v)
unsigned getPhysLayer(bool old=false) const
void setCentroidPhiIndex(float v)
void setParentageMask(unsigned long v)
SiliconTech getDetType() const
void setMaxEtaIndex(int v)
unsigned getEtaWidth() const
float getEtaCoord() const
DetectorZone getDetectorZone() const
void setEtaCoord(float v)
void setMaxPhiIndex(int v)
void setEtaWidth(unsigned v)
void setPhiWidth(unsigned v)
float getCentroidEtaIndex() const
unsigned getEtaIndex() const
void setCentroidEtaIndex(float v)
unsigned getPhiWidth() const
void add(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
std::pair< unsigned long, unsigned long > Barcode
bool sortITkInputEta(const std::unique_ptr< FPGATrackSimHit > &hitA, const std::unique_ptr< FPGATrackSimHit > &hitB)
bool sortITkInputPhi(const std::unique_ptr< FPGATrackSimHit > &hitA, const std::unique_ptr< FPGATrackSimHit > &HitB)
bool updatePixelCluster(FPGATrackSimCluster ¤tCluster, FPGATrackSimHit &incomingHit, bool newCluster, bool digitalClustering)
bool updateStripCluster(FPGATrackSimCluster ¤tCluster, FPGATrackSimHit &incomingHit, bool newCluster, bool digitalClustering)
bool updateClusterContents(FPGATrackSimCluster ¤tCluster, int &clusterRow, int &clusterRowWidth, int &clusterCol, int &clusterColWidth, FPGATrackSimHit &incomingHit, bool digitalClustering)
void attachTruth(std::vector< FPGATrackSimHit > &)
constexpr float scaleHitFactor
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
Tell the compiler to optimize assuming that FP may trap.
#define CXXUTILS_TRAPPING_FP