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)
 
void 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 256 of file FPGATrackSimClusteringTool.cxx.

256  {
257  for( auto& hit : hits) {
259  // record highest pt contribution to the combination (cluster
260  if(!hit.getTruth().isEmpty()) {
261  mt.add(hit.getTruth());
262  hit.setTruth(mt);
263  } else {
264  FPGATrackSimMultiTruth::Barcode uniquecode(hit.getEventIndex(), hit.getBarcode());
265  mt.maximize(uniquecode, hit.getBarcodePt());
266  hit.setTruth(mt);
267  }
268  }
269 } //record truth for each raw channel in the cluster

◆ sortITkInputEta()

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

Definition at line 446 of file FPGATrackSimClusteringTool.cxx.

447 {
448  return hitA.getEtaIndex() < hitB.getEtaIndex();
449 }

◆ sortITkInputPhi()

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

Definition at line 453 of file FPGATrackSimClusteringTool.cxx.

454 {
455  return hitA.getPhiIndex() < hitB.getPhiIndex();
456 }

◆ updateClusterContents()

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

Definition at line 403 of file FPGATrackSimClusteringTool.cxx.

403  {
404  //Grab the cluster equiv
405  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
406 
407  //Update the clusterEquiv's position and width
408  clusterEquiv.setEtaIndex(clusterRow);
409  clusterEquiv.setEtaWidth(clusterRowWidth);
410  clusterEquiv.setPhiIndex(clusterCol);
411  clusterEquiv.setPhiWidth(clusterColWidth);
412 
413 
414  float xOld = clusterEquiv.getX();
415  float yOld = clusterEquiv.getY();
416  float zOld = clusterEquiv.getZ();
417  float xNew = incomingHit.getX();
418  float yNew = incomingHit.getY();
419  float zNew = incomingHit.getZ();
420  //As strips arrive pre-clustered, this is different for pixels/strips
421  if(incomingHit.isPixel()){
422  int n = currentCluster.getHitList().size();
423  // n+1 because that is old + new now
424  clusterEquiv.setX((xOld*n + xNew) / (n+1));
425  clusterEquiv.setY((yOld*n + yNew) / (n+1));
426  clusterEquiv.setZ((zOld*n + zNew) / (n+1));
427  } else {
428  //Phi width + 1 for the seed is the width of the current cluster
429  int N = currentCluster.getClusterEquiv().getPhiWidth()+1;
430  //Phi width of an incoming strip is the width of the cluster
431  int newN = incomingHit.getPhiWidth();
432  //Now as above, N+newN
433  clusterEquiv.setX((xOld*N + xNew*newN) / (N+newN));
434  clusterEquiv.setY((yOld*N + yNew*newN) / (N+newN));
435  clusterEquiv.setZ((zOld*N + zNew*newN) / (N+newN));
436  }
437  //Put it back
438  currentCluster.setClusterEquiv(clusterEquiv);
439 
440  //Pushback the hit into the hitlist
441  currentCluster.push_backHitList(incomingHit);
442 }

◆ updatePixelCluster()

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

Definition at line 275 of file FPGATrackSimClusteringTool.cxx.

275  {
276 
277  if(newCluster){
278  FPGATrackSimHit newHit = incomingHit;
279  //Double the precision on the positions
280  //By doing this the hardware is able to handle clusters where the centre of the cluster is on a boundary between two clusters without needing a float
283  //Set the initial clusterEquiv to be the incoming hit with double precision
284  currentCluster.setClusterEquiv(newHit);
285  //Add the current hit to the list of hits
286  currentCluster.push_backHitList(incomingHit);
287  //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
288  return true;
289  } else {
290  int hitRow = incomingHit.getEtaIndex();
291  int hitCol = incomingHit.getPhiIndex();
292 
293  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
294  int clusterRow = clusterEquiv.getEtaIndex();
295  int clusterRowWidth = clusterEquiv.getEtaWidth();
296  int clusterCol = clusterEquiv.getPhiIndex();
297  int clusterColWidth = clusterEquiv.getPhiWidth();
298 
299  //Looking for a neighbour in up/right position to the currentCluster
300  if((hitRow*fpgatracksim::scaleHitFactor == clusterRow+clusterRowWidth+fpgatracksim::scaleHitFactor) &&
301  (hitCol*fpgatracksim::scaleHitFactor == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor) ){
302  clusterRow++;
303  clusterRowWidth++;
304  clusterCol++;
305  clusterColWidth++;
306  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
307  return true;
308  }
309 
310  //Looking for a neighbour in down right
311  else if((hitRow*fpgatracksim::scaleHitFactor == clusterRow-clusterRowWidth-fpgatracksim::scaleHitFactor) && //because row then col sorted data, i.e. col sorted.
312  (hitCol*fpgatracksim::scaleHitFactor == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor) ){
313  clusterRow--; // important
314  clusterRowWidth++;
315  clusterCol++;
316  clusterColWidth++;
317  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
318  return true;
319  }
320 
321  //Looking for a neighbour above
322  else if((hitRow*fpgatracksim::scaleHitFactor == clusterRow+clusterRowWidth+fpgatracksim::scaleHitFactor) &&
323  (hitCol*fpgatracksim::scaleHitFactor == clusterCol+clusterColWidth) ){
324  clusterRow++;
325  clusterRowWidth++;
326  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
327  return true;
328  }
329 
330  //Looking for a neighbour to the right
331  else if(((hitRow*fpgatracksim::scaleHitFactor > clusterRow-clusterRowWidth-fpgatracksim::scaleHitFactor) && (hitRow*fpgatracksim::scaleHitFactor < clusterRow+clusterRowWidth+fpgatracksim::scaleHitFactor)) &&
332  (hitCol*fpgatracksim::scaleHitFactor == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor) ){
333  clusterCol++;
334  clusterColWidth++;
335  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
336  return true;
337  }
338 
339  //Checking for hits inside the box
340  else if((hitRow*fpgatracksim::scaleHitFactor > clusterRow-clusterRowWidth-fpgatracksim::scaleHitFactor) &&
341  (hitRow*fpgatracksim::scaleHitFactor < clusterRow+clusterRowWidth+fpgatracksim::scaleHitFactor) &&
342  (hitCol*fpgatracksim::scaleHitFactor < clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor) ){
343  //We still want to do this as we are not changing the position of the cluster, but we are adding to its hitlist
344  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
345  return true;
346  }
347  //if we made it here then this cluster then start again
348  else return false;
349  }
350 }

◆ updateStripCluster()

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

Definition at line 356 of file FPGATrackSimClusteringTool.cxx.

356  {
357 
358  // Shift initial widths 1->0, 2->2, 3->4, 4->6 etc...
359  //The groupSize is stored in the EtaWidth
361  // Now shift to pixel width equivalents, 0->0, 2->1, 4->2, 6->3 etc...
362  if(tempWidth > 0) tempWidth = tempWidth/fpgatracksim::scaleHitFactor;
363  if(newCluster){
364  FPGATrackSimHit newHit = incomingHit;
365  //Double the precision of the strip positions.
366  int tempCentroid = incomingHit.getPhiCoord()*fpgatracksim::scaleHitFactor;
367  // Now shift the centroid phi+phiWidth, and store the width (put it back in the PhiWidth)
368  newHit.setPhiCoord(tempCentroid+tempWidth);
369  newHit.setPhiWidth(tempWidth);
370  //Set the initial clusterEquiv to be the incoming hit with double precision
371  currentCluster.setClusterEquiv(newHit);
372  //Add the current hit to the list of hits
373  currentCluster.push_backHitList(incomingHit);
374  //It doesn't really matter, as we will be at the end of the hit loop, but we did technically "cluster" this hit
375  return true;
376  } else {
377  //Now get the --START-- of the new strip cluster
378  int hitRow = incomingHit.getEtaCoord();
379  int hitCol = incomingHit.getPhiCoord()*fpgatracksim::scaleHitFactor;
380 
381  FPGATrackSimHit clusterEquiv = currentCluster.getClusterEquiv();
382  int clusterRow = clusterEquiv.getEtaCoord();
383  int clusterRowWidth = clusterEquiv.getEtaWidth();
384  int clusterCol = clusterEquiv.getPhiCoord();
385  int clusterColWidth = clusterEquiv.getPhiWidth();
386 
387  //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.
388  if(hitCol == clusterCol+clusterColWidth+fpgatracksim::scaleHitFactor && hitRow == clusterRow) {
389  //The new centroid will be the original column position, minus its width, plus the new width
390  //So subtract the original width...
391  clusterCol = clusterCol - clusterColWidth;
392  //The new width will be the combination of the current widths, ++
393  clusterColWidth = clusterColWidth+tempWidth+1;
394  //And add on the new width
395  clusterCol = clusterCol + clusterColWidth;
396  FPGATrackSimCLUSTERING::updateClusterContents(currentCluster, clusterRow, clusterRowWidth, clusterCol, clusterColWidth, incomingHit);
397  return true;
398  } else return false;
399  }
400 }
FPGATrackSimCluster::getHitList
hitVector const & getHitList() const
Definition: FPGATrackSimCluster.h:30
FPGATrackSimHit::setEtaIndex
void setEtaIndex(unsigned v)
Definition: FPGATrackSimHit.h:98
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:99
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:125
FPGATrackSimHit::setEtaWidth
void setEtaWidth(unsigned v)
Definition: FPGATrackSimHit.h:74
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:123
FPGATrackSimCluster::setClusterEquiv
void setClusterEquiv(const FPGATrackSimHit &input)
Definition: FPGATrackSimCluster.h:35
FPGATrackSimCLUSTERING::updateClusterContents
void updateClusterContents(FPGATrackSimCluster &currentCluster, int &clusterRow, int &clusterRowWidth, int &clusterCol, int &clusterColWidth, FPGATrackSimHit &incomingHit)
Definition: FPGATrackSimClusteringTool.cxx:403
FPGATrackSimHit
Definition: FPGATrackSimHit.h:38
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:103
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:122
FPGATrackSimHit::setPhiIndex
void setPhiIndex(unsigned v)
Definition: FPGATrackSimHit.h:97
FPGATrackSimHit::getPhiIndex
unsigned getPhiIndex() const
Definition: FPGATrackSimHit.h:101
beamspotman.n
n
Definition: beamspotman.py:731
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
FPGATrackSimMultiTruth::add
void add(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
FPGATrackSimMultiTruth::Barcode
std::pair< unsigned long, unsigned long > Barcode
Definition: FPGATrackSimMultiTruth.h:49
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:126
FPGATrackSimHit::getEtaIndex
unsigned getEtaIndex() const
Definition: FPGATrackSimHit.h:102
FPGATrackSimHit::isPixel
bool isPixel() const
Definition: FPGATrackSimHit.h:61
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:127
FPGATrackSimMultiTruth::maximize
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
Definition: FPGATrackSimMultiTruth.cxx:37
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimCluster::getClusterEquiv
FPGATrackSimHit const & getClusterEquiv() const
Definition: FPGATrackSimCluster.h:31
FPGATrackSimHit::setPhiWidth
void setPhiWidth(unsigned v)
Definition: FPGATrackSimHit.h:75
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:104
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:124
fpgatracksim::scaleHitFactor
constexpr float scaleHitFactor
Definition: FPGATrackSimConstants.h:18
FPGATrackSimHit::getEtaWidth
unsigned getEtaWidth() const
Definition: FPGATrackSimHit.h:80
FPGATrackSimHit::getPhiWidth
unsigned getPhiWidth() const
Definition: FPGATrackSimHit.h:81
FPGATrackSimCluster::push_backHitList
void push_backHitList(const FPGATrackSimHit &input)
Definition: FPGATrackSimCluster.h:38