ATLAS Offline Software
Functions
FPGATrackSimCLUSTERING Namespace Reference

Functions

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

399  {
400  for( auto& hit : hits) {
402  // record highest pt contribution to the combination (cluster
403  if(!hit.getTruth().isEmpty()) {
404  mt.add(hit.getTruth());
405  hit.setTruth(mt);
406  } else {
407  FPGATrackSimMultiTruth::Barcode uniquecode(hit.getEventIndex(), hit.getBarcode());
408  mt.maximize(uniquecode, hit.getBarcodePt());
409  hit.setTruth(mt);
410  }
411  }
412 } //record truth for each raw channel in the cluster

◆ sortITkInputEta()

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

Definition at line 613 of file FPGATrackSimClusteringTool.cxx.

614 {
615  return hitA.getEtaIndex() < hitB.getEtaIndex();
616 }

◆ sortITkInputPhi()

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

Definition at line 620 of file FPGATrackSimClusteringTool.cxx.

621 {
622  return hitA.getPhiIndex() < hitB.getPhiIndex();
623 }

◆ updateClusterContents()

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

Definition at line 543 of file FPGATrackSimClusteringTool.cxx.

543  {
544  //Grab the cluster equiv
545  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
546  bool isConnected = false;
547 
548  //Check if connected to another hit in the cluster
549  if(incomingHit.isPixel()){
550  for (auto & hit : currentCluster.getHitList()) {
551  auto hitEta = hit.getEtaIndex();
552  auto hitPhi = hit.getPhiIndex();
553  auto inHitEta = incomingHit.getEtaIndex();
554  auto inHitPhi = incomingHit.getPhiIndex();
555 
556  if (((inHitEta == hitEta - 1) && (inHitPhi == hitPhi - 1)) ||
557  ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi - 1)) ||
558  ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi + 1)) ||
559  ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi + 1)) ||
560  ((inHitEta == hitEta) && (inHitPhi == hitPhi - 1)) ||
561  ((inHitEta == hitEta) && (inHitPhi == hitPhi + 1)) ||
562  ((inHitEta == hitEta - 1) && (inHitPhi == hitPhi)) ||
563  ((inHitEta == hitEta + 1) && (inHitPhi == hitPhi))) {
564  isConnected = true;
565  break;
566  }
567  }
568  if (!isConnected)
569  return false;
570  }
571 
572  //Update the clusterEquiv's position and width
573  clusterEquiv.setEtaIndex(clusterRow);
574  clusterEquiv.setEtaWidth(clusterRowWidth);
575  clusterEquiv.setPhiIndex(clusterCol);
576  clusterEquiv.setPhiWidth(clusterColWidth);
577 
578 
579  float xOld = clusterEquiv.getX();
580  float yOld = clusterEquiv.getY();
581  float zOld = clusterEquiv.getZ();
582  float xNew = incomingHit.getX();
583  float yNew = incomingHit.getY();
584  float zNew = incomingHit.getZ();
585  //As strips arrive pre-clustered, this is different for pixels/strips
586  if(incomingHit.isPixel()){
587  int n = currentCluster.getHitList().size();
588  // n+1 because that is old + new now
589  clusterEquiv.setX((xOld*n + xNew) / (n+1));
590  clusterEquiv.setY((yOld*n + yNew) / (n+1));
591  clusterEquiv.setZ((zOld*n + zNew) / (n+1));
592  } else {
593  //Phi width + 1 for the seed is the width of the current cluster
594  int N = currentCluster.getClusterEquiv().getPhiWidth()+1;
595  //Phi width of an incoming strip is the width of the cluster
596  int newN = incomingHit.getPhiWidth();
597  //Now as above, N+newN
598  clusterEquiv.setX((xOld*N + xNew*newN) / (N+newN));
599  clusterEquiv.setY((yOld*N + yNew*newN) / (N+newN));
600  clusterEquiv.setZ((zOld*N + zNew*newN) / (N+newN));
601  }
602  //Put it back
603  currentCluster.setClusterEquiv(clusterEquiv);
604 
605  //Pushback the hit into the hitlist
606  currentCluster.push_backHitList(incomingHit);
607 
608  return true;
609 }

◆ updatePixelCluster()

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

Definition at line 418 of file FPGATrackSimClusteringTool.cxx.

418  {
419 
420  if(newCluster){
421  FPGATrackSimHit newHit = incomingHit;
422  newHit.setEtaIndex(incomingHit.getEtaIndex());
423  newHit.setPhiIndex(incomingHit.getPhiIndex());
424  newHit.setEtaWidth(1);
425  newHit.setPhiWidth(1);
426  //Set the initial clusterEquiv to be the incoming hit with double precision
427  currentCluster.setClusterEquiv(newHit);
428  //Add the current hit to the list of hits
429  currentCluster.push_backHitList(incomingHit);
430  //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
431  return true;
432  } else {
433  int hitRow = incomingHit.getEtaIndex();
434  int hitCol = incomingHit.getPhiIndex();
435 
436  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
437  int clusterRow = clusterEquiv.getEtaIndex();
438  int clusterRowWidth = clusterEquiv.getEtaWidth();
439  int clusterCol = clusterEquiv.getPhiIndex();
440  int clusterColWidth = clusterEquiv.getPhiWidth();
441 
442  if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
443  clusterColWidth++;
444  clusterRowWidth++;
445 
446  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
447  } else if ((hitCol == clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
448  clusterColWidth++;
449  clusterRow--;
450  clusterRowWidth++;
451 
452  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
453  } else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow + clusterRowWidth)) {
454  clusterRowWidth++;
455 
456  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
457  } else if ((hitCol == clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
458  clusterColWidth++;
459 
460  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
461  } else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow == clusterRow - 1)) {
462  clusterRow--;
463  clusterRowWidth++;
464 
465  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
466  } else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow - 1)) {
467  clusterCol--;
468  clusterColWidth++;
469  clusterRow--;
470  clusterRowWidth++;
471 
472  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
473  } else if ((hitCol == clusterCol - 1) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
474  clusterCol--;
475  clusterColWidth++;
476 
477  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
478  } else if ((hitCol == clusterCol - 1) && (hitRow == clusterRow + clusterRowWidth)) {
479  clusterCol--;
480  clusterColWidth++;
481  clusterRowWidth++;
482 
483  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
484  } else if ((hitCol >= clusterCol) && (hitCol < clusterCol + clusterColWidth) && (hitRow >= clusterRow) && (hitRow < clusterRow + clusterRowWidth)) {
485  return FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
486  } else {
487  return false;
488  }
489  }
490 }

◆ updateStripCluster()

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

Definition at line 496 of file FPGATrackSimClusteringTool.cxx.

496  {
497 
498  // Shift initial widths 1->0, 2->2, 3->4, 4->6 etc...
499  //The groupSize is stored in the EtaWidth
501  // Now shift to pixel width equivalents, 0->0, 2->1, 4->2, 6->3 etc...
502  if(tempWidth > 0) tempWidth = tempWidth/fpgatracksim::scaleHitFactor;
503  if(newCluster){
504  FPGATrackSimHit newHit = incomingHit;
505  //Double the precision of the strip positions.
506  int tempCentroid = incomingHit.getPhiCoord()*fpgatracksim::scaleHitFactor;
507  // Now shift the centroid phi+phiWidth, and store the width (put it back in the PhiWidth)
508  newHit.setPhiCoord(tempCentroid+tempWidth);
509  newHit.setPhiWidth(tempWidth);
510  //Set the initial clusterEquiv to be the incoming hit with double precision
511  currentCluster.setClusterEquiv(newHit);
512  //Add the current hit to the list of hits
513  currentCluster.push_backHitList(incomingHit);
514  //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
515  return true;
516  } else {
517  //Now get the --START-- of the new strip cluster
518  int hitRow = incomingHit.getEtaCoord();
519  int hitCol = incomingHit.getPhiCoord()*fpgatracksim::scaleHitFactor;
520 
521  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
522  int clusterRow = clusterEquiv.getEtaCoord();
523  int clusterRowWidth = clusterEquiv.getEtaWidth();
524  int clusterCol = clusterEquiv.getPhiCoord();
525  int clusterColWidth = clusterEquiv.getPhiWidth();
526 
527  //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.
528  if(hitCol == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor && hitRow == clusterRow) {
529  //The new centroid will be the original column position, minus its width, plus the new width
530  //So subtract the original width...
531  clusterCol = clusterCol - clusterColWidth;
532  //The new width will be the combination of the current widths, ++
533  clusterColWidth = clusterColWidth+tempWidth+1;
534  //And add on the new width
535  clusterCol = clusterCol + clusterColWidth;
536  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
537  return true;
538  } else return false;
539  }
540 }
FPGATrackSimCluster::getHitList
hitVector const & getHitList() const
Definition: FPGATrackSimCluster.h:30
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSimHit::setEtaIndex
void setEtaIndex(unsigned v)
Definition: FPGATrackSimHit.h:103
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:104
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:137
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:135
FPGATrackSimCluster::setClusterEquiv
void setClusterEquiv(const FPGATrackSimHit &input)
Definition: FPGATrackSimCluster.h:35
FPGATrackSimCLUSTERING::updateClusterContents
bool updateClusterContents(FPGATrackSimCluster &currentCluster, int &clusterRow, int &clusterRowWidth, int &clusterCol, int &clusterColWidth, FPGATrackSimHit &incomingHit)
Definition: FPGATrackSimClusteringTool.cxx:543
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:108
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:134
FPGATrackSimHit::setPhiIndex
void setPhiIndex(unsigned v)
Definition: FPGATrackSimHit.h:102
FPGATrackSimHit::getPhiIndex
unsigned getPhiIndex() const
Definition: FPGATrackSimHit.h:106
beamspotman.n
n
Definition: beamspotman.py:731
FPGATrackSimMultiTruth::add
void add(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
Definition: FPGATrackSimMultiTruth.cxx:22
FPGATrackSimMultiTruth::Barcode
std::pair< unsigned long, unsigned long > Barcode
Definition: FPGATrackSimMultiTruth.h:49
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:138
FPGATrackSimHit::getEtaIndex
unsigned getEtaIndex() const
Definition: FPGATrackSimHit.h:107
FPGATrackSimHit::isPixel
bool isPixel() const
Definition: FPGATrackSimHit.h:64
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:139
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::setPhiWidth
void setPhiWidth(unsigned v)
Definition: FPGATrackSimHit.h:79
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:109
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:136
fpgatracksim::scaleHitFactor
constexpr float scaleHitFactor
Definition: FPGATrackSimConstants.h:18
FPGATrackSimHit::getEtaWidth
unsigned getEtaWidth() const
Definition: FPGATrackSimHit.h:85
FPGATrackSimHit::getPhiWidth
unsigned getPhiWidth() const
Definition: FPGATrackSimHit.h:86
FPGATrackSimCluster::push_backHitList
void push_backHitList(const FPGATrackSimHit &input)
Definition: FPGATrackSimCluster.h:38