ATLAS Offline Software
Public Member Functions | Private Member Functions | List of all members
FPGATrackSimClusteringTool Class Reference

#include <FPGATrackSimClusteringTool.h>

Inheritance diagram for FPGATrackSimClusteringTool:
Collaboration diagram for FPGATrackSimClusteringTool:

Public Member Functions

 FPGATrackSimClusteringTool (const std::string &, const std::string &, const IInterface *)
 
virtual ~FPGATrackSimClusteringTool ()=default
 
virtual StatusCode DoClustering (FPGATrackSimLogicalEventInputHeader &, std::vector< FPGATrackSimCluster > &) const override
 

Private Member Functions

void SortedClustering (const std::vector< std::vector< FPGATrackSimHit > > &sorted_hits, std::vector< FPGATrackSimCluster > &) const
 
void Clustering (std::vector< FPGATrackSimHit >, std::vector< FPGATrackSimCluster > &) const
 
void splitAndSortHits (std::vector< FPGATrackSimHit > &hits, std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule, int &eta_phi) const
 
void splitAndSortHits (std::vector< FPGATrackSimHit > &hits, std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule) const
 
void splitHitsToModules (std::vector< FPGATrackSimHit > &hits, std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule) const
 
void normaliseClusters (std::vector< FPGATrackSimCluster > &clusters) const
 
void sortHitsOnModules (std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule, int &eta_phi) const
 
void sortHitsOnModules (std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule) const
 
bool etaOrPhi (const FPGATrackSimHit &hit) const
 
bool sortIBLInput (const std::unique_ptr< FPGATrackSimHit > &i, const std::unique_ptr< FPGATrackSimHit > &j) const
 
bool sortPixelInput (const std::unique_ptr< FPGATrackSimHit > &i, const std::unique_ptr< FPGATrackSimHit > &j) const
 

Detailed Description

Definition at line 32 of file FPGATrackSimClusteringTool.h.

Constructor & Destructor Documentation

◆ FPGATrackSimClusteringTool()

FPGATrackSimClusteringTool::FPGATrackSimClusteringTool ( const std::string &  algname,
const std::string &  name,
const IInterface *  ifc 
)

Definition at line 18 of file FPGATrackSimClusteringTool.cxx.

18  :
19  base_class(algname, name, ifc)
20 {
21 }

◆ ~FPGATrackSimClusteringTool()

virtual FPGATrackSimClusteringTool::~FPGATrackSimClusteringTool ( )
virtualdefault

Member Function Documentation

◆ Clustering()

void FPGATrackSimClusteringTool::Clustering ( std::vector< FPGATrackSimHit moduleHits,
std::vector< FPGATrackSimCluster > &  moduleClusters 
) const
private

Definition at line 74 of file FPGATrackSimClusteringTool.cxx.

74  {
75  //To hold the current cluster vars for comparison
76  //loop over the hits that we have been passed for this module
77  for( auto& hit: moduleHits){
78  int is_clustered_hit =0;
79  // int nclustered =0;
80  //Loop over the clusters we have already made, check if this hit should be added to them?
81  for( auto& cluster: moduleClusters){
82  if(hit.isPixel()){
83  is_clustered_hit = FPGATrackSimCLUSTERING::updatePixelCluster(cluster, hit, false);
84  }
85  if(hit.isStrip()){
86  is_clustered_hit = FPGATrackSimCLUSTERING::updateStripCluster(cluster, hit, false);
87  }
88  }
89  //If it is the first hit or a not clustered hit, then start a new cluster and add it to the output vector
90  if((is_clustered_hit==0) or (moduleClusters.size()==0)){
91  FPGATrackSimCluster cluster;
92  if(hit.isPixel()){
93  is_clustered_hit = FPGATrackSimCLUSTERING::updatePixelCluster(cluster, hit, true);
94  } else if(hit.isStrip()){
95  is_clustered_hit = FPGATrackSimCLUSTERING::updateStripCluster(cluster, hit, true);
96  }
97  //Put this cluster into the output hits. Will update it in place.
98  moduleClusters.push_back(cluster);
99  }
100  }
101 }

◆ DoClustering()

StatusCode FPGATrackSimClusteringTool::DoClustering ( FPGATrackSimLogicalEventInputHeader header,
std::vector< FPGATrackSimCluster > &  clusters 
) const
overridevirtual

Definition at line 24 of file FPGATrackSimClusteringTool.cxx.

25 {
26  for (int i = 0; i<header.nTowers(); i++)
27  {
28  // Retreive the hits from the tower
29  FPGATrackSimTowerInputHeader& tower = *header.getTower(i);
30  std::vector<FPGATrackSimHit> hits = tower.hits();
31 
32  std::vector<std::vector<FPGATrackSimHit>> hitsPerModule;
33  std::vector<FPGATrackSimCluster> towerClusters;
34  splitAndSortHits(hits, hitsPerModule);
35  SortedClustering(hitsPerModule, towerClusters);
36  normaliseClusters(towerClusters);
37 
38  //remove the old hits from the tower...
39  tower.clearHits();
40  tower.reserveHits(towerClusters.size());
41  clusters.clear();
42  clusters.reserve(towerClusters.size());
43  if(i > 1)
44  ATH_MSG_WARNING("more than one tower, m_clusters is only going to contain those from the last one");
45  unsigned cluster_count = 0;
46  for ( auto &cluster: towerClusters){
47  FPGATrackSimHit cluster_as_FPGATrackSimhit = cluster.getClusterEquiv();
48  cluster_as_FPGATrackSimhit.setHitType(HitType::clustered);
49  cluster_as_FPGATrackSimhit.setParentageMask(cluster_count); // making use of unused m_parentageMask to keep track of cluster index
50  tower.addHit(cluster_as_FPGATrackSimhit);
51  //send back a copy for monitoring and to check when writing out hits in each road
52  clusters.push_back(cluster);
53  cluster_count++;
54  }
55  }
56  ATH_MSG_DEBUG("Produced "<< clusters.size()<< " clusters");
57  return StatusCode::SUCCESS;
58 }

◆ etaOrPhi()

bool FPGATrackSimClusteringTool::etaOrPhi ( const FPGATrackSimHit hit) const
private

Definition at line 192 of file FPGATrackSimClusteringTool.cxx.

192  {
193 
194  /*This currently might get complicated as eta/phi ordering varies depending on the position in the detector.
195  * For ITK-20-00-00 Step 2.2 inclined duals layout, worked out by Naoki.
196  * Detector position | Module Type (# chip) | Column | Row |
197  * =============================================================================
198  * Barrel Layer 0 Eta module 1-6 | 2 (double) | eta | phi |
199  * Barrel Layer 0 Eta module 7-22 | 1 (single) | phi | eta |
200  * Barrel Layer 1 Eta module 1-6 | 3 (quad) | eta | phi |
201  * Barrel Layer 1 Eta module 7-19 | 3 | phi | eta |
202  * Barrel Layer 2 Eta module 1-11 | 3 | eta | phi |
203  * Barrel Layer 2 Eta module 12-22 | 2 | phi | eta |
204  * Barrel Layer 3 Eta module 1-12 | 3 | eta | phi |
205  * Barrel Layer 3 Eta module 13-25 | 2 | phi | eta |
206  * Barrel Layer 4 Eta module 1-13 | 3 | eta | phi |
207  * Barrel Layer 4 Eta module 14-26 | 2 | phi | eta |
208  * All Endcap modules | 3 | eta | phi |
209  * =============================================================================
210  * Module Type 1 = Single, 2, Dual, 3 Quad
211  * 328x400 blocks
212  * Hit type is essentially isPixel
213  * DetectorZone 0 = Barrel, -ive/+ive = endcaps
214  */
215 
216  //Check if the two hits are from the same module
217  //If it is not a barrel module then sort eta as column
219  return ETA;
220  }
221  //Otherwise it is a barrel module and now things get more complicated
222  else {
223  //Start by looking at what layer it is in
224  if (hit.getPhysLayer() == 0 || hit.getPhysLayer() == 1) {
225  if (hit.getEtaModule() <=6) {
226  return ETA;
227  } else {
228  return PHI;
229  }
230  } else if (hit.getPhysLayer() == 2) {
231  if (hit.getEtaModule() <=11) {
232  return ETA;
233  } else {
234  return PHI;
235  }
236  } else if (hit.getPhysLayer() == 3) {
237  if (hit.getEtaModule() <=12) {
238  return ETA;
239  } else {
240  return PHI;
241  }
242  } else if (hit.getPhysLayer() == 4) {
243  if (hit.getEtaModule() <=13) {
244  return ETA;
245  } else {
246  return PHI;
247  }
248  }
249  }
250  //Default to ETA, but shouldn't reach here
251  return ETA;
252 }

◆ normaliseClusters()

void FPGATrackSimClusteringTool::normaliseClusters ( std::vector< FPGATrackSimCluster > &  clusters) const
private

Definition at line 167 of file FPGATrackSimClusteringTool.cxx.

167  {
168  for( auto &cluster:clusters){
169  //Grab the cluster equiv
170  FPGATrackSimHit clusterEquiv = cluster.getClusterEquiv();
171  //Update the clusterEquiv's position and width
172  if(clusterEquiv.isStrip()){
173  //Clear the groupsize, set this to be one as we are only clustering one row.
174  clusterEquiv.setEtaWidth(1);
175  clusterEquiv.setPhiCoord(clusterEquiv.getPhiCoord()/fpgatracksim::scaleHitFactor);
176  clusterEquiv.setPhiWidth(clusterEquiv.getPhiWidth()+1);
177  } else {
178  clusterEquiv.setEtaCoord(clusterEquiv.getEtaCoord()/fpgatracksim::scaleHitFactor);
179  clusterEquiv.setEtaWidth(clusterEquiv.getEtaWidth()+1);
180  clusterEquiv.setPhiCoord(clusterEquiv.getPhiCoord()/fpgatracksim::scaleHitFactor);
181  clusterEquiv.setPhiWidth(clusterEquiv.getPhiWidth()+1);
182  }
183  cluster.setClusterEquiv(clusterEquiv);
184  }
185 }

◆ SortedClustering()

void FPGATrackSimClusteringTool::SortedClustering ( const std::vector< std::vector< FPGATrackSimHit > > &  sorted_hits,
std::vector< FPGATrackSimCluster > &  clusters 
) const
private

Definition at line 61 of file FPGATrackSimClusteringTool.cxx.

61  {
62  std::vector<FPGATrackSimCluster> moduleClusters;
63  //Loop over the sorted modules that we have
64  for( auto& moduleHits:sorted_hits){
65  //Make the clusters for this module
66  Clustering(moduleHits, moduleClusters);
67  //Put these clusters into the output list
68  clusters.insert(clusters.end(), moduleClusters.begin(), moduleClusters.end());
69  //Clear the vector or this will get messy
70  moduleClusters.clear();
71  }
72 }

◆ sortHitsOnModules() [1/2]

void FPGATrackSimClusteringTool::sortHitsOnModules ( std::vector< std::vector< FPGATrackSimHit > > &  hitsPerModule) const
private

Definition at line 156 of file FPGATrackSimClusteringTool.cxx.

156  {
157  //Loop over the module separated hits
158  for ( auto& module:hitsPerModule){
161  }
162 }

◆ sortHitsOnModules() [2/2]

void FPGATrackSimClusteringTool::sortHitsOnModules ( std::vector< std::vector< FPGATrackSimHit > > &  hitsPerModule,
int &  eta_phi 
) const
private

Definition at line 138 of file FPGATrackSimClusteringTool.cxx.

138  {
139  //Loop over the module separated hits
140  for ( auto& module:hitsPerModule){
141  //Work out if columns are ETA (1) || PHI (0)
142  if(etaOrPhi(module.at(0)) == true){
143  //Sort by ETA first
144  eta_phi = ETA;
147  } else {
148  //Sort by PHI first
149  eta_phi = PHI;
152  }
153  }
154 }

◆ sortIBLInput()

bool FPGATrackSimClusteringTool::sortIBLInput ( const std::unique_ptr< FPGATrackSimHit > &  i,
const std::unique_ptr< FPGATrackSimHit > &  j 
) const
private

◆ sortPixelInput()

bool FPGATrackSimClusteringTool::sortPixelInput ( const std::unique_ptr< FPGATrackSimHit > &  i,
const std::unique_ptr< FPGATrackSimHit > &  j 
) const
private

◆ splitAndSortHits() [1/2]

void FPGATrackSimClusteringTool::splitAndSortHits ( std::vector< FPGATrackSimHit > &  hits,
std::vector< std::vector< FPGATrackSimHit > > &  hitsPerModule 
) const
private

Definition at line 108 of file FPGATrackSimClusteringTool.cxx.

108  {
109  splitHitsToModules(hits, hitsPerModule);
110  sortHitsOnModules(hitsPerModule);
111 }

◆ splitAndSortHits() [2/2]

void FPGATrackSimClusteringTool::splitAndSortHits ( std::vector< FPGATrackSimHit > &  hits,
std::vector< std::vector< FPGATrackSimHit > > &  hitsPerModule,
int &  eta_phi 
) const
private

Definition at line 103 of file FPGATrackSimClusteringTool.cxx.

103  {
104  splitHitsToModules(hits, hitsPerModule);
105  sortHitsOnModules(hitsPerModule, eta_phi);
106 }

◆ splitHitsToModules()

void FPGATrackSimClusteringTool::splitHitsToModules ( std::vector< FPGATrackSimHit > &  hits,
std::vector< std::vector< FPGATrackSimHit > > &  hitsPerModule 
) const
private

Definition at line 115 of file FPGATrackSimClusteringTool.cxx.

115  {
116  //To hold the current module
117  std::vector<FPGATrackSimHit> currentModule;
118  uint hashing = 0;
119  //Split the incoming hits into hits by module
120  for ( auto& hit:hits){
121  if(hashing == 0){
122  currentModule.push_back(hit);
123  hashing = hit.getIdentifierHash();
124  } else if (hit.getIdentifierHash() == hashing) {
125  currentModule.push_back(hit);
126  } else {
127  hitsPerModule.push_back(currentModule);
128  currentModule.clear();
129  hashing = hit.getIdentifierHash();
130  currentModule.push_back(hit);
131  }
132  }
133 
134  // Now push that last one
135  if (currentModule.size() > 0) hitsPerModule.push_back(currentModule);
136 }

The documentation for this class was generated from the following files:
FPGATrackSimTowerInputHeader::clearHits
void clearHits()
Definition: FPGATrackSimTowerInputHeader.h:47
FPGATrackSimClusteringTool::sortHitsOnModules
void sortHitsOnModules(std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule, int &eta_phi) const
Definition: FPGATrackSimClusteringTool.cxx:138
getMenu.algname
algname
Definition: getMenu.py:53
FPGATrackSimHit::isStrip
bool isStrip() const
Definition: FPGATrackSimHit.h:62
header
Definition: hcg.cxx:526
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer() const
Definition: FPGATrackSimHit.cxx:67
FPGATrackSimCLUSTERING::sortITkInputPhi
bool sortITkInputPhi(const FPGATrackSimHit &hitA, const FPGATrackSimHit &HitB)
Definition: FPGATrackSimClusteringTool.cxx:453
FPGATrackSimCluster
Definition: FPGATrackSimCluster.h:25
FPGATrackSimCLUSTERING::updateStripCluster
bool updateStripCluster(FPGATrackSimCluster &currentCluster, FPGATrackSimHit &incomingHit, bool newCluster)
Definition: FPGATrackSimClusteringTool.cxx:356
FPGATrackSimTowerInputHeader::addHit
void addHit(FPGATrackSimHit s)
Definition: FPGATrackSimTowerInputHeader.h:46
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:99
FPGATrackSimHit::setEtaWidth
void setEtaWidth(unsigned v)
Definition: FPGATrackSimHit.h:74
RoiUtil::PHI
@ PHI
Definition: RoiSerialise.cxx:31
FPGATrackSimHit::getEtaModule
unsigned getEtaModule() const
Definition: FPGATrackSimHit.h:82
std::stable_sort
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
Definition: DVL_algorithms.h:711
FPGATrackSimHit
Definition: FPGATrackSimHit.h:38
FPGATrackSimClusteringTool::etaOrPhi
bool etaOrPhi(const FPGATrackSimHit &hit) const
Definition: FPGATrackSimClusteringTool.cxx:192
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:103
python.PyAthena.module
module
Definition: PyAthena.py:134
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
lumiFormat.i
int i
Definition: lumiFormat.py:92
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
FPGATrackSimHit::setEtaCoord
void setEtaCoord(float v)
Definition: FPGATrackSimHit.h:100
FPGATrackSimClusteringTool::normaliseClusters
void normaliseClusters(std::vector< FPGATrackSimCluster > &clusters) const
Definition: FPGATrackSimClusteringTool.cxx:167
FPGATrackSimCLUSTERING::sortITkInputEta
bool sortITkInputEta(const FPGATrackSimHit &hitA, const FPGATrackSimHit &hitB)
Definition: FPGATrackSimClusteringTool.cxx:446
FPGATrackSimCLUSTERING::updatePixelCluster
bool updatePixelCluster(FPGATrackSimCluster &currentCluster, FPGATrackSimHit &incomingHit, bool newCluster)
Definition: FPGATrackSimClusteringTool.cxx:275
FPGATrackSimHit::getDetectorZone
DetectorZone getDetectorZone() const
Definition: FPGATrackSimHit.h:56
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
FPGATrackSimClusteringTool::SortedClustering
void SortedClustering(const std::vector< std::vector< FPGATrackSimHit > > &sorted_hits, std::vector< FPGATrackSimCluster > &) const
Definition: FPGATrackSimClusteringTool.cxx:61
HitType::clustered
@ clustered
FPGATrackSimHit::setPhiWidth
void setPhiWidth(unsigned v)
Definition: FPGATrackSimHit.h:75
RoiUtil::ETA
@ ETA
Definition: RoiSerialise.cxx:30
FPGATrackSimClusteringTool::splitAndSortHits
void splitAndSortHits(std::vector< FPGATrackSimHit > &hits, std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule, int &eta_phi) const
Definition: FPGATrackSimClusteringTool.cxx:103
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:104
fpgatracksim::scaleHitFactor
constexpr float scaleHitFactor
Definition: FPGATrackSimConstants.h:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FPGATrackSimClusteringTool::splitHitsToModules
void splitHitsToModules(std::vector< FPGATrackSimHit > &hits, std::vector< std::vector< FPGATrackSimHit > > &hitsPerModule) const
Definition: FPGATrackSimClusteringTool.cxx:115
FPGATrackSimTowerInputHeader::reserveHits
void reserveHits(size_t size)
Definition: FPGATrackSimTowerInputHeader.h:48
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
DetectorZone::barrel
@ barrel
FPGATrackSimHit::getEtaWidth
unsigned getEtaWidth() const
Definition: FPGATrackSimHit.h:80
FPGATrackSimTowerInputHeader::hits
const std::vector< FPGATrackSimHit > & hits() const
Definition: FPGATrackSimTowerInputHeader.h:44
FPGATrackSimHit::setParentageMask
void setParentageMask(unsigned long v)
Definition: FPGATrackSimHit.h:137
FPGATrackSimTowerInputHeader
Definition: FPGATrackSimTowerInputHeader.h:18
FPGATrackSimHit::getPhiWidth
unsigned getPhiWidth() const
Definition: FPGATrackSimHit.h:81
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:51
FPGATrackSimClusteringTool::Clustering
void Clustering(std::vector< FPGATrackSimHit >, std::vector< FPGATrackSimCluster > &) const
Definition: FPGATrackSimClusteringTool.cxx:74