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 686 of file FPGATrackSimClusteringTool.cxx.

687 {
688  if (hitA.getIdentifierHash() != hitB.getIdentifierHash())
689  return hitA.getIdentifierHash() < hitB.getIdentifierHash();
690  return hitA.getEtaIndex() < hitB.getEtaIndex();
691 }

◆ sortITkInputPhi()

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

Definition at line 695 of file FPGATrackSimClusteringTool.cxx.

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

◆ updateClusterContents()

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

Definition at line 589 of file FPGATrackSimClusteringTool.cxx.

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

◆ 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() + 0.5);
467  newHit.setCentroidEtaIndex(incomingHit.getEtaIndex() + 0.5);
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 hitRow = incomingHit.getEtaIndex();
478  int hitCol = incomingHit.getPhiIndex();
479 
480  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
481  int clusterRow = clusterEquiv.getEtaIndex();
482  int clusterRowWidth = clusterEquiv.getEtaWidth();
483  int clusterCol = clusterEquiv.getPhiIndex();
484  int clusterColWidth = 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(tempCentroid+tempWidth);
555  newHit.setPhiWidth(tempWidth);
556  //Set the initial clusterEquiv to be the incoming hit with double precision
557  currentCluster.setClusterEquiv(newHit);
558  //Add the current hit to the list of hits
559  currentCluster.push_backHitList(incomingHit);
560  //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
561  return true;
562  } else {
563  //Now get the --START-- of the new strip cluster
564  int hitRow = incomingHit.getEtaIndex();
565  int hitCol = incomingHit.getPhiIndex()*fpgatracksim::scaleHitFactor;
566 
567  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
568  int clusterRow = clusterEquiv.getEtaIndex();
569  int clusterRowWidth = clusterEquiv.getEtaWidth();
570  int clusterCol = clusterEquiv.getPhiIndex();
571  int clusterColWidth = clusterEquiv.getPhiWidth();
572 
573  //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.
574  if(hitCol == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor && hitRow == clusterRow) {
575  //The new centroid will be the original column position, minus its width, plus the new width
576  //So subtract the original width...
577  clusterCol = clusterCol - clusterColWidth;
578  //The new width will be the combination of the current widths, ++
579  clusterColWidth = clusterColWidth+tempWidth+1;
580  //And add on the new width
581  clusterCol = clusterCol + clusterColWidth;
582  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit, digitalClustering);
583  return true;
584  } else return false;
585  }
586 }
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:589
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