ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimCLUSTERING Namespace Reference

Functions

void attachTruth (std::vector< FPGATrackSimHit > &)
bool updatePixelCluster (FPGATrackSimCluster &currentCluster, FPGATrackSimHit &incomingHit, bool newCluster, bool digitalClustering)
bool updateStripCluster (FPGATrackSimCluster &currentCluster, FPGATrackSimHit &incomingHit, bool newCluster, bool digitalClustering)
bool updateClusterContents (FPGATrackSimCluster &currentCluster, int &clusterRow, int &clusterRowWidth, int &clusterCol, int &clusterColWidth, FPGATrackSimHit &incomingHit, bool digitalClustering)
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)

Function Documentation

◆ attachTruth()

void FPGATrackSimCLUSTERING::attachTruth ( std::vector< FPGATrackSimHit > & hits)

Definition at line 449 of file FPGATrackSimClusteringTool.cxx.

449 {
450 for( auto& hit : hits) {
452 // record highest pt contribution to the combination (cluster
453 if(!hit.getTruth().isEmpty()) {
454 mt.add(hit.getTruth());
455 hit.setTruth(mt);
456 } else {
457 FPGATrackSimMultiTruth::Barcode uniquecode(hit.getEventIndex(), hit.getBarcode());
458 mt.maximize(uniquecode, hit.getBarcodePt());
459 hit.setTruth(mt);
460 }
461 }
462} //record truth for each raw channel in the cluster
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

◆ sortITkInputEta()

bool FPGATrackSimCLUSTERING::sortITkInputEta ( const std::unique_ptr< FPGATrackSimHit > & hitA,
const std::unique_ptr< FPGATrackSimHit > & hitB )

Definition at line 705 of file FPGATrackSimClusteringTool.cxx.

706{
707 if (hitA->getIdentifierHash() != hitB->getIdentifierHash())
708 return hitA->getIdentifierHash() < hitB->getIdentifierHash();
709 return hitA->getEtaIndex() < hitB->getEtaIndex();
710}

◆ sortITkInputPhi()

bool FPGATrackSimCLUSTERING::sortITkInputPhi ( const std::unique_ptr< FPGATrackSimHit > & hitA,
const std::unique_ptr< FPGATrackSimHit > & HitB )

Definition at line 714 of file FPGATrackSimClusteringTool.cxx.

715{
716 if (hitA->getIdentifierHash() != hitB->getIdentifierHash())
717 return hitA->getIdentifierHash() < hitB->getIdentifierHash();
718 return hitA->getPhiIndex() < hitB->getPhiIndex();
719}

◆ updateClusterContents()

bool FPGATrackSimCLUSTERING::updateClusterContents ( FPGATrackSimCluster & currentCluster,
int & clusterRow,
int & clusterRowWidth,
int & clusterCol,
int & clusterColWidth,
FPGATrackSimHit & incomingHit,
bool digitalClustering )

Definition at line 600 of file FPGATrackSimClusteringTool.cxx.

600 {
601 //Grab the cluster equiv
602 FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
603 bool isConnected = false;
604
605 //Check if connected to another hit in the cluster
606 if(incomingHit.isPixel()){
607 for (auto & hit : currentCluster.getHitList()) {
608 auto hitEta = hit.getEtaIndex();
609 auto hitPhi = hit.getPhiIndex();
610 auto inHitEta = incomingHit.getEtaIndex();
611 auto inHitPhi = incomingHit.getPhiIndex();
612
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))) {
621 isConnected = true;
622 break;
623 }
624 }
625 if (!isConnected)
626 return false;
627 }
628
629 //Update the clusterEquiv's position and width
630 if (incomingHit.isPixel()) {
631 clusterEquiv.setEtaIndex(clusterCol);
632 clusterEquiv.setEtaWidth(clusterColWidth);
633 clusterEquiv.setPhiIndex(clusterRow);
634 clusterEquiv.setPhiWidth(clusterRowWidth);
635 } else {
636 clusterEquiv.setEtaIndex(clusterRow);
637 clusterEquiv.setEtaWidth(clusterRowWidth);
638 clusterEquiv.setCentroidPhiIndex(clusterCol);
639 clusterEquiv.setPhiWidth(clusterColWidth);
640 }
641
642
643 float xOld = clusterEquiv.getX();
644 float yOld = clusterEquiv.getY();
645 float zOld = clusterEquiv.getZ();
646 float xPhiOld = clusterEquiv.getPhiCoord();
647 float xEtaOld = clusterEquiv.getEtaCoord();
648 float cPhiOld = clusterEquiv.getCentroidPhiIndex();
649 float cEtaOld = clusterEquiv.getCentroidEtaIndex();
650 float xNew = incomingHit.getX();
651 float yNew = incomingHit.getY();
652 float zNew = incomingHit.getZ();
653 float xPhiNew = incomingHit.getPhiCoord();
654 float xEtaNew = incomingHit.getEtaCoord();
655 float cPhiNew = incomingHit.getPhiIndex();
656 float cEtaNew = incomingHit.getEtaIndex();
657 int tot = clusterEquiv.getToT();
658 int totNew = incomingHit.getToT();
659 //As strips arrive pre-clustered, this is different for pixels/strips
660 if(incomingHit.isPixel()){
662 if (digitalClustering) {
663 // n+1 because that is old + new now
664 int n = currentCluster.getHitList().size();
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));
670 clusterEquiv.setCentroidPhiIndex((cPhiOld*n + cPhiNew) / (n+1));
671 clusterEquiv.setCentroidEtaIndex((cEtaOld*n + cEtaNew) / (n+1));
672 } else {
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));
678 clusterEquiv.setCentroidPhiIndex((cPhiOld*tot + cPhiNew*totNew) / (tot+totNew));
679 clusterEquiv.setCentroidEtaIndex((cEtaOld*tot + cEtaNew*totNew) / (tot+totNew));
680 }
681 } else {
682 //Phi width + 1 for the seed is the width of the current cluster
683 int N = currentCluster.getClusterEquiv().getPhiWidth()+1;
684 //Phi width of an incoming strip is the width of the cluster
685 int newN = incomingHit.getPhiWidth();
686 //Now as above, N+newN
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));
691 }
692 clusterEquiv.setToT(tot + totNew);
693
694 //Put it back
695 currentCluster.setClusterEquiv(clusterEquiv);
696
697 //Pushback the hit into the hitlist
698 currentCluster.push_backHitList(incomingHit);
699
700 return true;
701}
void setClusterEquiv(const FPGATrackSimHit &input)
hitVector const & getHitList() const
FPGATrackSimHit const & getClusterEquiv() const
void push_backHitList(const FPGATrackSimHit &input)
float getY() const
unsigned getToT() const
unsigned getPhiIndex() const
void setEtaIndex(unsigned v)
void setPhiIndex(unsigned v)
float getPhiCoord() const
float getX() const
float getCentroidPhiIndex() const
float getZ() const
void setPhiCoord(float v)
void setZ(float v)
void setX(float v)
void setCentroidPhiIndex(float v)
void setToT(unsigned v)
bool isPixel() const
void setY(float v)
float getEtaCoord() const
void setEtaCoord(float v)
void setEtaWidth(unsigned v)
void setPhiWidth(unsigned v)
float getCentroidEtaIndex() const
unsigned getEtaIndex() const
void setCentroidEtaIndex(float v)
unsigned getPhiWidth() const
#define CXXUTILS_TRAPPING_FP
Definition trapping_fp.h:24

◆ updatePixelCluster()

bool FPGATrackSimCLUSTERING::updatePixelCluster ( FPGATrackSimCluster & currentCluster,
FPGATrackSimHit & incomingHit,
bool newCluster,
bool digitalClustering )

Definition at line 468 of file FPGATrackSimClusteringTool.cxx.

468 {
469
470 if(newCluster){
471 FPGATrackSimHit newHit = incomingHit;
472 newHit.setEtaIndex(incomingHit.getEtaIndex());
473 newHit.setPhiIndex(incomingHit.getPhiIndex());
474 newHit.setEtaCoord(incomingHit.getEtaCoord());
475 newHit.setPhiCoord(incomingHit.getPhiCoord());
476 newHit.setCentroidPhiIndex(incomingHit.getPhiIndex());
477 newHit.setCentroidEtaIndex(incomingHit.getEtaIndex());
478 newHit.setEtaWidth(1);
479 newHit.setPhiWidth(1);
480 //Set the initial clusterEquiv to be the incoming hit with double precision
481 currentCluster.setClusterEquiv(newHit);
482 //Add the current hit to the list of hits
483 currentCluster.push_backHitList(incomingHit);
484 //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
485 return true;
486 } else {
487 int hitCol = incomingHit.getEtaIndex();
488 int hitRow = incomingHit.getPhiIndex();
489
490 FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
491 int clusterCol = clusterEquiv.getEtaIndex();
492 int clusterColWidth = clusterEquiv.getEtaWidth();
493 int clusterRow = clusterEquiv.getPhiIndex();
494 int clusterRowWidth = clusterEquiv.getPhiWidth();
495
496 if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
497 clusterColWidth++;
498 clusterRowWidth++;
499
500 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
501 } else if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
502 clusterColWidth++;
503 clusterRow--;
504 clusterRowWidth++;
505
506 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
507 } else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
508 clusterRowWidth++;
509
510 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
511 } else if ((hitCol == clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
512 clusterColWidth++;
513
514 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
515 } else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
516 clusterRow--;
517 clusterRowWidth++;
518
519 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
520 } else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow - 1)) {
521 clusterCol--;
522 clusterColWidth++;
523 clusterRow--;
524 clusterRowWidth++;
525
526 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
527 } else if ((hitCol == clusterCol - 1) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
528 clusterCol--;
529 clusterColWidth++;
530
531 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
532 } else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow + clusterRowWidth)) {
533 clusterCol--;
534 clusterColWidth++;
535 clusterRowWidth++;
536
537 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
538 } else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
539 return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
540 } else {
541 return false;
542 }
543 }
544}
unsigned getEtaWidth() const
bool updateClusterContents(FPGATrackSimCluster &currentCluster, int &clusterRow, int &clusterRowWidth, int &clusterCol, int &clusterColWidth, FPGATrackSimHit &incomingHit, bool digitalClustering)

◆ updateStripCluster()

bool FPGATrackSimCLUSTERING::updateStripCluster ( FPGATrackSimCluster & currentCluster,
FPGATrackSimHit & incomingHit,
bool newCluster,
bool digitalClustering )

Definition at line 550 of file FPGATrackSimClusteringTool.cxx.

550 {
551
553
554 // Shift initial widths 1->0, 2->2, 3->4, 4->6 etc...
555 //The groupSize is stored in the EtaWidth
557 // Now shift to pixel width equivalents, 0->0, 2->1, 4->2, 6->3 etc...
558 if(tempWidth > 0) tempWidth = tempWidth/fpgatracksim::scaleHitFactor;
559 if(newCluster){
560 FPGATrackSimHit newHit = incomingHit;
561 //Double the precision of the strip positions.
562 int tempCentroid = incomingHit.getPhiIndex()*fpgatracksim::scaleHitFactor;
563 // Now shift the centroid phi+phiWidth, and store the width (put it back in the PhiWidth)
564 newHit.setPhiIndex(incomingHit.getPhiIndex());
565 newHit.setCentroidPhiIndex(tempCentroid+tempWidth);
566 newHit.setPhiWidth(tempWidth);
567 //Set the initial clusterEquiv to be the incoming hit with double precision
568 currentCluster.setClusterEquiv(newHit);
569 //Add the current hit to the list of hits
570 currentCluster.push_backHitList(incomingHit);
571 //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
572 return true;
573 } else {
574 //Now get the --START-- of the new strip cluster
575 int hitRow = incomingHit.getEtaIndex();
576 int hitCol = incomingHit.getPhiIndex()*fpgatracksim::scaleHitFactor;
577
578 FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
579 int clusterRow = clusterEquiv.getEtaIndex();
580 int clusterRowWidth = clusterEquiv.getEtaWidth();
581 int clusterCol = clusterEquiv.getCentroidPhiIndex();
582 int clusterColWidth = clusterEquiv.getPhiWidth();
583
584 //Looking for a neighbour to the right. i.e. find the end of the current cluster (Col+width) and look in the next cell (+2). Compare this to the start of the new cluster. This is unlikely/impossible(?) to happen due to preclustering.
585 if(hitCol == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor && hitRow == clusterRow) {
586 //The new centroid will be the original column position, minus its width, plus the new width
587 //So subtract the original width...
588 clusterCol = clusterCol - clusterColWidth;
589 //The new width will be the combination of the current widths, ++
590 clusterColWidth = clusterColWidth+tempWidth+1;
591 //And add on the new width
592 clusterCol = clusterCol + clusterColWidth;
593 FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
594 return true;
595 } else return false;
596 }
597}
constexpr float scaleHitFactor