Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions
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 FPGATrackSimHit &hitA, const FPGATrackSimHit &hitB)
 
bool sortITkInputPhi (const FPGATrackSimHit &hitA, const FPGATrackSimHit &HitB)
 

Function Documentation

◆ attachTruth()

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

Definition at line 439 of file FPGATrackSimClusteringTool.cxx.

439  {
440  for( auto& hit : hits) {
442  // record highest pt contribution to the combination (cluster
443  if(!hit.getTruth().isEmpty()) {
444  mt.add(hit.getTruth());
445  hit.setTruth(mt);
446  } else {
447  FPGATrackSimMultiTruth::Barcode uniquecode(hit.getEventIndex(), hit.getBarcode());
448  mt.maximize(uniquecode, hit.getBarcodePt());
449  hit.setTruth(mt);
450  }
451  }
452 } //record truth for each raw channel in the cluster

◆ sortITkInputEta()

bool FPGATrackSimCLUSTERING::sortITkInputEta ( const FPGATrackSimHit hitA,
const FPGATrackSimHit hitB 
)

Definition at line 694 of file FPGATrackSimClusteringTool.cxx.

695 {
696  if (hitA.getIdentifierHash() != hitB.getIdentifierHash())
697  return hitA.getIdentifierHash() < hitB.getIdentifierHash();
698  return hitA.getEtaIndex() < hitB.getEtaIndex();
699 }

◆ sortITkInputPhi()

bool FPGATrackSimCLUSTERING::sortITkInputPhi ( const FPGATrackSimHit hitA,
const FPGATrackSimHit HitB 
)

Definition at line 703 of file FPGATrackSimClusteringTool.cxx.

704 {
705  if (hitA.getIdentifierHash() != hitB.getIdentifierHash())
706  return hitA.getIdentifierHash() < hitB.getIdentifierHash();
707  return hitA.getPhiIndex() < hitB.getPhiIndex();
708 }

◆ updateClusterContents()

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

Definition at line 590 of file FPGATrackSimClusteringTool.cxx.

590  {
591  //Grab the cluster equiv
592  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
593  bool isConnected = false;
594 
595  //Check if connected to another hit in the cluster
596  if(incomingHit.isPixel()){
597  for (auto & hit : currentCluster.getHitList()) {
598  auto hitEta = hit.getEtaIndex();
599  auto hitPhi = hit.getPhiIndex();
600  auto inHitEta = incomingHit.getEtaIndex();
601  auto inHitPhi = incomingHit.getPhiIndex();
602 
603  if (((inHitEta == hitEta - 1) && (inHitPhi == hitPhi - 1)) ||
604  ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi - 1)) ||
605  ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi + 1)) ||
606  ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi + 1)) ||
607  ((inHitEta == hitEta) && (inHitPhi == hitPhi - 1)) ||
608  ((inHitEta == hitEta) && (inHitPhi == hitPhi + 1)) ||
609  ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi)) ||
610  ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi))) {
611  isConnected = true;
612  break;
613  }
614  }
615  if (!isConnected)
616  return false;
617  }
618 
619  //Update the clusterEquiv's position and width
620  if (incomingHit.isPixel()) {
621  clusterEquiv.setEtaIndex(clusterCol);
622  clusterEquiv.setEtaWidth(clusterColWidth);
623  clusterEquiv.setPhiIndex(clusterRow);
624  clusterEquiv.setPhiWidth(clusterRowWidth);
625  } else {
626  clusterEquiv.setEtaIndex(clusterRow);
627  clusterEquiv.setEtaWidth(clusterRowWidth);
628  clusterEquiv.setCentroidPhiIndex(clusterCol);
629  clusterEquiv.setPhiWidth(clusterColWidth);
630  }
631 
632 
633  float xOld = clusterEquiv.getX();
634  float yOld = clusterEquiv.getY();
635  float zOld = clusterEquiv.getZ();
636  float xPhiOld = clusterEquiv.getPhiCoord();
637  float xEtaOld = clusterEquiv.getEtaCoord();
638  float cPhiOld = clusterEquiv.getCentroidPhiIndex();
639  float cEtaOld = clusterEquiv.getCentroidEtaIndex();
640  float xNew = incomingHit.getX();
641  float yNew = incomingHit.getY();
642  float zNew = incomingHit.getZ();
643  float xPhiNew = incomingHit.getPhiCoord();
644  float xEtaNew = incomingHit.getEtaCoord();
645  float cPhiNew = incomingHit.getPhiIndex();
646  float cEtaNew = incomingHit.getEtaIndex();
647  int tot = clusterEquiv.getToT();
648  int totNew = incomingHit.getToT();
649  //As strips arrive pre-clustered, this is different for pixels/strips
650  if(incomingHit.isPixel()){
652  if (digitalClustering) {
653  // n+1 because that is old + new now
654  int n = currentCluster.getHitList().size();
655  clusterEquiv.setX((xOld*n + xNew) / (n+1));
656  clusterEquiv.setY((yOld*n + yNew) / (n+1));
657  clusterEquiv.setZ((zOld*n + zNew) / (n+1));
658  clusterEquiv.setPhiCoord((xPhiOld*n + xPhiNew) / (n+1));
659  clusterEquiv.setEtaCoord((xEtaOld*n + xEtaNew) / (n+1));
660  clusterEquiv.setCentroidPhiIndex((cPhiOld*n + cPhiNew) / (n+1));
661  clusterEquiv.setCentroidEtaIndex((cEtaOld*n + cEtaNew) / (n+1));
662  } else {
663  clusterEquiv.setX((xOld*tot + xNew*totNew) / (tot+totNew));
664  clusterEquiv.setY((yOld*tot + yNew*totNew) / (tot+totNew));
665  clusterEquiv.setZ((zOld*tot + zNew*totNew) / (tot+totNew));
666  clusterEquiv.setPhiCoord((xPhiOld*tot + xPhiNew*totNew) / (tot+totNew));
667  clusterEquiv.setEtaCoord((xEtaOld*tot + xEtaNew*totNew) / (tot+totNew));
668  clusterEquiv.setCentroidPhiIndex((cPhiOld*tot + cPhiNew*totNew) / (tot+totNew));
669  clusterEquiv.setCentroidEtaIndex((cEtaOld*tot + cEtaNew*totNew) / (tot+totNew));
670  }
671  } else {
672  //Phi width + 1 for the seed is the width of the current cluster
673  int N = currentCluster.getClusterEquiv().getPhiWidth()+1;
674  //Phi width of an incoming strip is the width of the cluster
675  int newN = incomingHit.getPhiWidth();
676  //Now as above, N+newN
677  clusterEquiv.setX((xOld*N + xNew*newN) / (N+newN));
678  clusterEquiv.setY((yOld*N + yNew*newN) / (N+newN));
679  clusterEquiv.setZ((zOld*N + zNew*newN) / (N+newN));
680  }
681  clusterEquiv.setToT(tot + totNew);
682 
683  //Put it back
684  currentCluster.setClusterEquiv(clusterEquiv);
685 
686  //Pushback the hit into the hitlist
687  currentCluster.push_backHitList(incomingHit);
688 
689  return true;
690 }

◆ updatePixelCluster()

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

Definition at line 458 of file FPGATrackSimClusteringTool.cxx.

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

◆ updateStripCluster()

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

Definition at line 540 of file FPGATrackSimClusteringTool.cxx.

540  {
541 
543 
544  // Shift initial widths 1->0, 2->2, 3->4, 4->6 etc...
545  //The groupSize is stored in the EtaWidth
547  // Now shift to pixel width equivalents, 0->0, 2->1, 4->2, 6->3 etc...
548  if(tempWidth > 0) tempWidth = tempWidth/fpgatracksim::scaleHitFactor;
549  if(newCluster){
550  FPGATrackSimHit newHit = incomingHit;
551  //Double the precision of the strip positions.
552  int tempCentroid = incomingHit.getPhiIndex()*fpgatracksim::scaleHitFactor;
553  // Now shift the centroid phi+phiWidth, and store the width (put it back in the PhiWidth)
554  newHit.setPhiIndex(incomingHit.getPhiIndex());
555  newHit.setCentroidPhiIndex(tempCentroid+tempWidth);
556  newHit.setPhiWidth(tempWidth);
557  //Set the initial clusterEquiv to be the incoming hit with double precision
558  currentCluster.setClusterEquiv(newHit);
559  //Add the current hit to the list of hits
560  currentCluster.push_backHitList(incomingHit);
561  //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
562  return true;
563  } else {
564  //Now get the --START-- of the new strip cluster
565  int hitRow = incomingHit.getEtaIndex();
566  int hitCol = incomingHit.getPhiIndex()*fpgatracksim::scaleHitFactor;
567 
568  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
569  int clusterRow = clusterEquiv.getEtaIndex();
570  int clusterRowWidth = clusterEquiv.getEtaWidth();
571  int clusterCol = clusterEquiv.getCentroidPhiIndex();
572  int clusterColWidth = clusterEquiv.getPhiWidth();
573 
574  //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.
575  if(hitCol == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor && hitRow == clusterRow) {
576  //The new centroid will be the original column position, minus its width, plus the new width
577  //So subtract the original width...
578  clusterCol = clusterCol - clusterColWidth;
579  //The new width will be the combination of the current widths, ++
580  clusterColWidth = clusterColWidth+tempWidth+1;
581  //And add on the new width
582  clusterCol = clusterCol + clusterColWidth;
583  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
584  return true;
585  } else return false;
586  }
587 }
CXXUTILS_TRAPPING_FP
#define CXXUTILS_TRAPPING_FP
Definition: trapping_fp.h:24
FPGATrackSimCluster::getHitList
hitVector const & getHitList() const
Definition: FPGATrackSimCluster.h:30
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSimHit::getToT
unsigned getToT() const
Definition: FPGATrackSimHit.h:155
FPGATrackSimHit::setEtaIndex
void setEtaIndex(unsigned v)
Definition: FPGATrackSimHit.h:102
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:105
FPGATrackSimHit::setCentroidPhiIndex
void setCentroidPhiIndex(float v)
Definition: FPGATrackSimHit.h:103
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:140
FPGATrackSimCLUSTERING::updateClusterContents
bool updateClusterContents(FPGATrackSimCluster &currentCluster, int &clusterRow, int &clusterRowWidth, int &clusterCol, int &clusterColWidth, FPGATrackSimHit &incomingHit, bool digitalClustering)
Definition: FPGATrackSimClusteringTool.cxx:590
FPGATrackSimHit::setEtaWidth
void setEtaWidth(unsigned v)
Definition: FPGATrackSimHit.h:78
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:138
FPGATrackSimCluster::setClusterEquiv
void setClusterEquiv(const FPGATrackSimHit &input)
Definition: FPGATrackSimCluster.h:35
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:111
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:137
FPGATrackSimHit::setToT
void setToT(unsigned v)
Definition: FPGATrackSimHit.h:148
FPGATrackSimHit::setPhiIndex
void setPhiIndex(unsigned v)
Definition: FPGATrackSimHit.h:101
FPGATrackSimHit::getPhiIndex
unsigned getPhiIndex() const
Definition: FPGATrackSimHit.h:107
beamspotman.n
n
Definition: beamspotman.py:731
FPGATrackSimMultiTruth::add
void add(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
Definition: FPGATrackSimMultiTruth.cxx:22
FPGATrackSimHit::setEtaCoord
void setEtaCoord(float v)
Definition: FPGATrackSimHit.h:106
FPGATrackSimMultiTruth::Barcode
std::pair< unsigned long, unsigned long > Barcode
Definition: FPGATrackSimMultiTruth.h:49
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:141
FPGATrackSimHit::getEtaIndex
unsigned getEtaIndex() const
Definition: FPGATrackSimHit.h:108
FPGATrackSimHit::getIdentifierHash
unsigned getIdentifierHash() const
Definition: FPGATrackSimHit.h:81
FPGATrackSimHit::isPixel
bool isPixel() const
Definition: FPGATrackSimHit.h:64
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:142
FPGATrackSimMultiTruth::maximize
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
Definition: FPGATrackSimMultiTruth.cxx:36
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimCluster::getClusterEquiv
FPGATrackSimHit const & getClusterEquiv() const
Definition: FPGATrackSimCluster.h:31
FPGATrackSimHit::getCentroidPhiIndex
float getCentroidPhiIndex() const
Definition: FPGATrackSimHit.h:109
FPGATrackSimHit::setPhiWidth
void setPhiWidth(unsigned v)
Definition: FPGATrackSimHit.h:79
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:112
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:139
FPGATrackSimHit::getCentroidEtaIndex
float getCentroidEtaIndex() const
Definition: FPGATrackSimHit.h:110
fpgatracksim::scaleHitFactor
constexpr float scaleHitFactor
Definition: FPGATrackSimConstants.h:18
FPGATrackSimHit::getEtaWidth
unsigned getEtaWidth() const
Definition: FPGATrackSimHit.h:85
FPGATrackSimHit::setCentroidEtaIndex
void setCentroidEtaIndex(float v)
Definition: FPGATrackSimHit.h:104
FPGATrackSimHit::getPhiWidth
unsigned getPhiWidth() const
Definition: FPGATrackSimHit.h:86
FPGATrackSimCluster::push_backHitList
void push_backHitList(const FPGATrackSimHit &input)
Definition: FPGATrackSimCluster.h:38