ATLAS Offline Software
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
FPGATrackSimNNPathfinderExtensionTool Class Reference

#include <FPGATrackSimNNPathfinderExtensionTool.h>

Inheritance diagram for FPGATrackSimNNPathfinderExtensionTool:
Collaboration diagram for FPGATrackSimNNPathfinderExtensionTool:

Public Member Functions

virtual StatusCode initialize () override
 
virtual StatusCode extendTracks (const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits, const std::vector< std::shared_ptr< const FPGATrackSimTrack >> &tracks, std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads) override
 
virtual StatusCode setupSlices (FPGATrackSimLogicalEventInputHeader *slicedHitHeader) override
 

Private Member Functions

StatusCode fillInputTensorForNN (miniRoad &thisRoad, std::vector< float > &inputTensorValues)
 
StatusCode getPredictedHit (std::vector< float > &inputTensorValues, std::vector< float > &outputTensorValues, long &fineID)
 
StatusCode addHitToRoad (miniRoad &newroad, miniRoad &currentRoad, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
 
StatusCode getFakeHit (miniRoad &currentRoad, std::vector< float > &predhit, const long &fineID, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
 
StatusCode getLastLayer (miniRoad &currentRoad, unsigned &lastHitLayer, std::shared_ptr< const FPGATrackSimHit > &lastHit)
 
StatusCode findHitinNextStripLayer (std::shared_ptr< const FPGATrackSimHit > hit, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hitList, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
 
void printRoad (miniRoad &currentRoad)
 

Static Private Member Functions

static float getXScale ()
 
static float getYScale ()
 
static float getZScale ()
 
static float getRScale ()
 
static float getPhiScale ()
 

Private Attributes

ServiceHandle< IFPGATrackSimMappingSvcm_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc", "FPGATrackSimMappingSvc"}
 
ServiceHandle< ITHistSvc > m_tHistSvc {this, "THistSvc", "THistSvc"}
 
Gaudi::Property< unsigned > m_maxMiss { this, "threshold", 2, "Maximum number of missing hits to reject a road"}
 
Gaudi::Property< std::string > m_region { this, "OutputRegion", "", "region ID"}
 
Gaudi::Property< std::vector< float > > m_windowR { this, "windowR", {20.0}, "Window Size to search in for r, either pass one value for all layers or use the number of layers"}
 
Gaudi::Property< std::vector< float > > m_windowZ { this, "windowZ", {20.0}, "Window Size to search in for z, either pass one value for all layers or use the number of layers"}
 
Gaudi::Property< std::vector< float > > m_windowPhi { this, "windowPhi", {0.4}, "Window Size to search in for phi, either pass one value for all layers or use the number of layers"}
 
Gaudi::Property< std::vector< int > > m_windowFineID { this, "windowFineID", {0}, "Fine ID indexing for windows"}
 
Gaudi::Property< float > m_lowPtValueForWindowRScaling { this, "lowPtValueWindowR", -1, "Value in MeV below which we scale the r window size"}
 
Gaudi::Property< float > m_lowPtWindowRScaling {this, "lowPtRScaling", 1.0, "Scaling factor for low pt in R"}
 
Gaudi::Property< float > m_lowPtValueForWindowZScaling { this, "lowPtValueWindowZ", -1, "Value in MeV below which we scale the r window size"}
 
Gaudi::Property< float > m_lowPtWindowZScaling {this, "lowPtZScaling", 1.0, "Scaling factor for low pt in Z"}
 
Gaudi::Property< float > m_lowPtValueForWindowPhiScaling { this, "lowPtValueWindowPhi", -1, "Value in MeV below which we scale the phi window size"}
 
Gaudi::Property< float > m_lowPtWindowPhiScaling {this, "lowPtPhiScaling", 1.0, "Scaling factor for low pt in Phi"}
 
Gaudi::Property< float > m_missedHitRScaling {this, "missedHitRScaling", -1, "Amount to scale R window if previous hit was missed. Negative means this is disabled"}
 
Gaudi::Property< float > m_missedHitZScaling {this, "missedHitZScaling", -1, "Amount to scale Z window if previous hit was missed. Negative means this is disabled"}
 
Gaudi::Property< float > m_missedHitPhiScaling {this, "missedHitPhiScaling", -1, "Amount to scale Phi window if previous hit was missed. Negative means this is disabled"}
 
Gaudi::Property< int > m_maxBranches { this, "maxBranches", -1, "Max number of branches before we stop, if negative this is disabled"}
 
Gaudi::Property< bool > m_doOutsideIn { this, "doOutsideIn", true, "Setup the tool so it's doing outside in extrap"}
 
Gaudi::Property< int > m_predictionWindowLength { this, "predictionWindowLength", 3, "Length of hits needed for prediction"}
 
Gaudi::Property< bool > m_useCartesian { this, "useCartesian", true, "If true, NNs use Cartestian coordinates. If false,they use cylindrical coordiantes"}
 
std::vector< FPGATrackSimRoadm_roads
 
unsigned m_nLayers_1stStage = 0
 
unsigned m_nLayers_2ndStage = 0
 
bool m_debugEvent = false
 
FPGATrackSimLogicalEventInputHeaderm_slicedHitHeader = nullptr
 
OnnxRuntimeBase m_extensionVolNN
 
OnnxRuntimeBase m_extensionHitNN
 

Detailed Description

Definition at line 125 of file FPGATrackSimNNPathfinderExtensionTool.h.

Member Function Documentation

◆ addHitToRoad()

StatusCode FPGATrackSimNNPathfinderExtensionTool::addHitToRoad ( miniRoad newroad,
miniRoad currentRoad,
const std::vector< std::shared_ptr< const FPGATrackSimHit >> &  hits 
)
private

Definition at line 583 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

584 {
585  newroad.setHits(currentRoad.getHits());
586  newroad.addHits(hits);
587  return StatusCode::SUCCESS;
588 }

◆ extendTracks()

StatusCode FPGATrackSimNNPathfinderExtensionTool::extendTracks ( const std::vector< std::shared_ptr< const FPGATrackSimHit >> &  hits,
const std::vector< std::shared_ptr< const FPGATrackSimTrack >> &  tracks,
std::vector< std::shared_ptr< const FPGATrackSimRoad >> &  roads 
)
overridevirtual

Definition at line 64 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

66  {
67 
68  // Reset the internal second stage roads storage.
69  roads.clear();
70  m_roads.clear();
71  const FPGATrackSimRegionMap* rmap_2nd = m_FPGATrackSimMapping->SubRegionMap_2nd();
72 
73  // Create one "tower" per slice for this event.
74  // Note that there now might be only one "slice", at least for the time being.
75  if (m_slicedHitHeader) {
76  for (int ireg = 0; ireg < rmap_2nd->getNRegions(); ireg++) {
79  }
80  }
81  if(m_debugEvent) ATH_MSG_DEBUG("Got: "<<tracks.size()<<" tracks to extrapolate");
82  // Now, loop over the tracks.
83  for (std::shared_ptr<const FPGATrackSimTrack> track : tracks) {
84  if(m_debugEvent) ATH_MSG_DEBUG("\033[1;31m-------------------------- extraploating Track ------------------ \033[0m");
85  if (track->passedOR() == 0) {
86  continue;
87  }
88  const std::vector<FPGATrackSimHit> hitsOnTrack = track->getFPGATrackSimHits();
89  miniRoad road;
90  float pt = track->getPt();
91 
92  for (const auto &thit : hitsOnTrack) {
93  road.addHit(std::make_shared<const FPGATrackSimHit>(thit)); // add all hits, we check if WC later
94  }
95 
96  if(m_debugEvent) {
97  ATH_MSG_DEBUG("-----------------Hits in event");
98  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hits) {
99  ATH_MSG_DEBUG("Hit " << " X: " << hit->getX() << " Y: " << hit->getY() << " Z: " << hit->getZ() << " R: " << hit->getR() << "phi = " << hit->getGPhi() << " hitType: " << hit->getHitType() << " getDetType: " << hit->getDetType());
100  }
101  }
102  std::vector<miniRoad> roadsToExtrapolate;
103  roadsToExtrapolate.push_back(road);
104 
105  std::vector<miniRoad> completedRoads;
106 
107  int count = 0;
108  // FIXED: Add maximum iteration limit to prevent infinite loops
109  const int MAX_ROADS = 10000;
110  while(roadsToExtrapolate.size() > 0 && count < MAX_ROADS ) {
111  miniRoad currentRoad = *roadsToExtrapolate.begin();
112 
113  // Erase this road from the vector
114  roadsToExtrapolate.erase(roadsToExtrapolate.begin());
115  count ++;
116  if(m_debugEvent) {
117  ATH_MSG_DEBUG("\033[1;31m-------------------------- extraploating road "<< count << "------------------ \033[0m");
118  printRoad(currentRoad);
119  }
120  // Check exit condition
121  if (currentRoad.getNHits() >= (m_nLayers_1stStage+m_nLayers_2ndStage))
122  {
123  completedRoads.push_back(currentRoad);
124  continue; // this one is done
125  }
126  // Other try to find the next hit in this road
127  std::vector<float> inputTensorValues;
128  if (!fillInputTensorForNN(currentRoad, inputTensorValues)) {
129  ATH_MSG_WARNING("Failed to create input tensor for this road");
130  continue;
131  }
132  std::vector<float> predhit;
133  long fineID;
134  if (!getPredictedHit(inputTensorValues, predhit, fineID)) {
135  ATH_MSG_WARNING("Failed to predict hit for this road");
136  continue;
137  }
138  // Check if exist conditions are there
139  if (m_doOutsideIn) {
140  // Make sure we are not predicting inside the inner most layer (x and y < 25, or r < 25)
141  // If we are, road is done
142  if ((m_useCartesian && (abs(predhit[0]) < 25 && abs(predhit[1]) < 25)) ||
143  (!m_useCartesian && abs(predhit[0]) < 25))
144  {
145  completedRoads.push_back(currentRoad);
146  continue;
147  }
148  }
149  else {
150  // Make sure we are not predicting outside the outer most layer
151  // if we are, road is done
152  double radius = std::sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
153  if ((m_useCartesian && (abs(predhit[0]) > 1024 || abs(predhit[1]) > 1024 || radius > 1024 || abs(predhit[2]) > 3000)) ||
154  (!m_useCartesian && (abs(predhit[0]) > 1024 || abs(predhit[2]) > 3000))) {
155  completedRoads.push_back(currentRoad);
156  continue;
157  }
158  }
159  if(m_debugEvent) {
160  ATH_MSG_DEBUG("Predicted hit at: " << predhit[0] << " " << predhit[1] << " " << predhit[2]);
161  }
162 
163  // Now search for the hits
164  bool foundhitForRoad = false;
165  if(fineID == 215){
166  ATH_MSG_DEBUG("Stopping condition reached");
167  completedRoads.push_back(currentRoad);
168  continue;
169  }
170  // Get the last layer and hit in the road
171  unsigned lastLayerInRoad = 0;
172  std::shared_ptr<const FPGATrackSimHit> lastHit;
173  if(!getLastLayer(currentRoad, lastLayerInRoad, lastHit) or !lastHit) {
174  ATH_MSG_WARNING("Failed to find last layer this road");
175  continue;
176  }
177  unsigned layer = lastLayerInRoad+1; // the layer we're looking to find
178  bool lastHitWasReal = lastHit->isReal();
179  float lastHitR = lastHit->getR();
181  completedRoads.push_back(currentRoad);
182  continue;
183  }
184  unsigned int hitsInWindow = 0;
185 
186  // List of all the hits, with their distances to the predicted point
187  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> listofHitsFound;
188 
189  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hits) {
190  if (m_doOutsideIn && (hit->getR() > lastHitR)) continue;
191  if (!m_doOutsideIn && (hit->getR() < lastHitR)) continue;
192  if ((hit->getHitType() == HitType::spacepoint) && ((hit->getPhysLayer(true)) %2 == 1)) continue; // ignore outer parts of SP, they get added separately
193  if(m_debugEvent) {
194  ATH_MSG_DEBUG("In the hit loop hit at x: " << hit->getX() << " y " << hit->getY() << " z " << hit->getZ() << " phi " << hit->getGPhi());
195  }
196  // loop over hits in that layer
197  if (getFineID(*hit) == fineID && hit->isReal()) {
198  // a hit is in the right fine ID == layer
199  double hitz = hit->getZ();
200  double hitr = hit->getR();
201  double hitphi = hit->getGPhi();
202  double predr = (m_useCartesian ? sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]) : predhit[0]);
203  double predphi = predhit[1]; // only for non cartesian, ie cylinndrical
204  double predz = predhit[2];
205  double windowR = m_windowR[0]; // default for all layers
206  double windowPhi = m_windowPhi[0]; // default for all layers
207  double windowZ = m_windowZ[0]; // default for all layers
208  int fineID_index = 0;
209  // But if available pick up per-window values
210  if (m_windowZ.size() > 1 || m_windowR.size() > 1 || m_windowPhi.size() > 1) {
211 
212  auto fineID_it = std::find(m_windowFineID.begin(), m_windowFineID.end(), fineID);
213  if (fineID_it == m_windowFineID.end()){
214  ATH_MSG_DEBUG("No windows for predicted fineID " << fineID << ", using maximum in provided list instead!");
215  fineID_index = -1;
216  }
217  else {
218  fineID_index = fineID_it - m_windowFineID.begin();
219  }
220  }
221  if (m_windowR.size() > 1) {
222  if (fineID_index == -1) {
223  windowR = *std::max_element(m_windowR.begin(), m_windowR.end());
224  }
225  else {
226  windowR = m_windowR[fineID_index];
227  }
228  }
229  if (m_windowZ.size() > 1) {
230  if (fineID_index == -1) {
231  windowZ = *std::max_element(m_windowZ.begin(), m_windowZ.end());
232  }
233  else {
234  windowZ = m_windowZ[fineID_index];
235  }
236  }
237  if (m_windowPhi.size() > 1) {
238  if (fineID_index == -1) {
239  windowPhi = *std::max_element(m_windowPhi.begin(), m_windowPhi.end());
240  }
241  else {
242  windowPhi = m_windowPhi[fineID_index];
243  }
244  }
245 
246  // If last hit was not real and we want to, scale the window
247  if (m_missedHitRScaling > 0 && !lastHitWasReal) windowR *= m_missedHitRScaling;
248  if (m_missedHitZScaling > 0 && !lastHitWasReal) windowZ *= m_missedHitZScaling;
249  if (m_missedHitPhiScaling > 0 && !lastHitWasReal) windowPhi *= m_missedHitPhiScaling;
250  // now scale windows for low pt, if desired
251  if (pt < m_lowPtValueForWindowRScaling.value()) windowR *= m_lowPtWindowRScaling.value();
252  if (pt < m_lowPtValueForWindowZScaling.value()) windowZ *= m_lowPtWindowZScaling.value();
253  if (pt < m_lowPtValueForWindowPhiScaling.value()) windowPhi *= m_lowPtWindowPhiScaling.value();
254 
255  double dr = abs(hitr - predr);
256  double dz = abs(hitz - predz);
257  double dphi = abs(hitphi - predphi);
258  while (dphi > pi) dphi -= pi;
259  if ((m_useCartesian && dr < windowR && dz < windowZ) ||
260  (!m_useCartesian && dphi < windowPhi && dz < windowZ && dr < windowR))
261  {
262  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits {hit};
263  hitsInWindow = hitsInWindow + 1;
264  // If the hit is a space point, skip the next layer, as it will be a duplicated space point and we have already taken care of that in the adding of the hits
265  if(hit->isStrip()) {
266  if (hit->getHitType() == HitType::spacepoint) {
267  // find the hit in the next layer
268  if(!findHitinNextStripLayer(hit, hits, theseHits)) {
269  ATH_MSG_WARNING("For a SP in layer " << layer << " Couldn't find a matching strip SP");
270  }
271  }
272  else {
273  std::shared_ptr<FPGATrackSimHit> guessedSecondHitPtr = std::make_shared<FPGATrackSimHit>();
274  guessedSecondHitPtr->setX(0);
275  guessedSecondHitPtr->setY(0);
276  guessedSecondHitPtr->setZ(0);
277  guessedSecondHitPtr->setPhysLayer(lastHit->getPhysLayer(true)+1);
278  guessedSecondHitPtr->setHitType(HitType::undefined);
279  if(isFineIDInStrip(fineID)) guessedSecondHitPtr->setDetType(SiliconTech::strip);
280  else guessedSecondHitPtr->setDetType(SiliconTech::pixel);
281 
282  theseHits.push_back(guessedSecondHitPtr);
283  }
284  }
285  // Store the hits for now
286  listofHitsFound.push_back(theseHits);
287  }
288  }
289  }
290  // Sort the hit by the distance
291  if (m_useCartesian) {
292  std::sort(listofHitsFound.begin(), listofHitsFound.end(), [&predhit](auto& a, auto& b){
293  double predr = sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
294  double predz = predhit[2];
295 
296  // HitA
297  double hitz = a[0]->getZ();
298  double hitr = a[0]->getR();
299  float distance_a = (hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz);
300 
301  // HitB
302  hitz = b[0]->getZ();
303  hitr = b[0]->getR();
304  float distance_b = (hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz);
305 
306  return distance_a < distance_b;
307  });
308  }
309  else {
310  std::sort(listofHitsFound.begin(), listofHitsFound.end(), [&predhit](auto& a, auto& b){
311 
312  double predr = predhit[0];
313  double predphi = predhit[1];
314  double predz = predhit[2];
315  // HitA
316  double hitr = a[0]->getR();
317  double hitphi = a[0]->getGPhi();
318  double hitz = a[0]->getZ();
319  double dz = abs(hitz - predz);
320  double dr = abs(hitr - predr);
321  double dphi = abs(hitphi - predphi);
322  while (dphi > pi) dphi -= pi;
323 
324  // scaled distance because z and phi and r are not in same units
325  float distance_a = dz*dz/(getZScale()*getZScale()) + dphi*dphi/(getPhiScale()*getPhiScale()) + dr*dr/(getRScale()*getRScale());
326 
327  // HitB
328  hitr = b[0]->getR();
329  hitphi = b[0]->getGPhi();
330  hitz = b[0]->getZ();
331  dz = abs(hitz - predz);
332  dr = abs(hitr - predr);
333  dphi = abs(hitphi - predphi);
334  while (dphi > pi) dphi -= pi;
335 
336  // scaled distance because z and phi and r are not in same units
337  float distance_b = dz*dz/(getZScale()*getZScale()) + dphi*dphi/(getPhiScale()*getPhiScale()) + dr*dr/(getRScale()*getRScale());
338 
339  return distance_a < distance_b;
340  });
341  }
342  // Select the top N hits
343  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> cleanHitsToGrow;
344 
345  // If max branches are limited, pick only the top N from the list of hits found at each level
346  if (m_maxBranches.value() >= 0) {
347  int nHitsToChoose = std::min(int(m_maxBranches.value()), int(listofHitsFound.size()));
348  cleanHitsToGrow.reserve(nHitsToChoose);
349  std::copy(listofHitsFound.begin(), listofHitsFound.begin() + nHitsToChoose, std::back_inserter(cleanHitsToGrow));
350  }
351  else {
352  cleanHitsToGrow = std::move(listofHitsFound);
353  }
354 
355  for (auto& hitsFound: cleanHitsToGrow) {
356 
357  // We got a hit, lets make a road
358  miniRoad newRoad;
359  if(!addHitToRoad(newRoad, currentRoad, std::move(hitsFound))) {
360  ATH_MSG_WARNING("Failed to make a new road");
361  continue;
362  }
363  roadsToExtrapolate.push_back(newRoad);
364  foundhitForRoad = true;
365  if(m_debugEvent) {
366  ATH_MSG_DEBUG("------ road grown with hit from layer "<<layer<<" to");
367  printRoad(newRoad);
368  }
369  }
370  // If the hit wasn't found, push a fake hit
371  if (!foundhitForRoad) {
372  // did not find a hit to extrapolate to, check if we need to delete this road. if not, add a guessed hit if still useful
373  if (currentRoad.getNWCLayers() >= m_maxMiss) {
374  // we don't want this road, so we continue
375  continue;
376  }
377  else {
378  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits;
379  // first make the fake hit that we will add
380  if (!getFakeHit(currentRoad, predhit, fineID, theseHits)) {
381  ATH_MSG_WARNING("Failed adding a guessed hit in extrapolation");
382  continue;
383  }
384 
385  if((isFineIDInPixel(fineID) && theseHits.size() != 1) || (isFineIDInStrip(fineID) && theseHits.size() != 2)) {
386  continue;
387  }
388  // add the hit to the road
389  miniRoad newroad;
390  if (!addHitToRoad(newroad, currentRoad, std::move(theseHits))) {
391  ATH_MSG_WARNING("Failed making a new road with fake hit");
392  continue;
393  }
394  roadsToExtrapolate.push_back(newroad);
395  }
396  }
397  }
398  // This track has been extrapolated, copy the completed tracks to the full list with full road objects
399  for (const auto &miniroad : completedRoads) {
400  FPGATrackSimRoad road;
401  road.setWCLayers(miniroad.getWCLayers());
402  road.setHitLayers(miniroad.getHitLayers());
403  road.setRoadID(m_roads.size() - 1);
404  // Set the "Hough x" and "Hough y" using the track parameters.
405  road.setX(track->getPhi());
406  road.setY(track->getQOverPt());
407  road.setXBin(track->getHoughXBin());
408  road.setYBin(track->getHoughYBin());
409  road.setSubRegion(track->getSubRegion());
410 
411  // just force the right number of layers now, in case we find fewer than expected (needed downstream)
412  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> roadhits = miniroad.getVecHits();
413  unsigned nexpected = m_nLayers_1stStage+m_nLayers_2ndStage;
414  if (roadhits.size() > nexpected) { // cut off the last ones
415  roadhits.resize(nexpected);
416  }
417  else if (roadhits.size() < nexpected) { // fill with missing hits
418  for (unsigned layer = roadhits.size(); layer < nexpected; layer++) {
419  std::shared_ptr<FPGATrackSimHit> emptyHitPtr = std::make_shared<FPGATrackSimHit>();
420  emptyHitPtr->setX(0);
421  emptyHitPtr->setY(0);
422  emptyHitPtr->setZ(0);
423  emptyHitPtr->setLayer(layer);
424  emptyHitPtr->setHitType(HitType::wildcard);
425  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitVec;
426  hitVec.push_back(emptyHitPtr);
427  roadhits.push_back(hitVec);
428  layer_bitmask_t wclayers = road.getWCLayers();
429  wclayers |= (1 << layer);
430  road.setWCLayers(wclayers);
431  }
432  }
433  road.setHits(std::move(roadhits));
434 
435  m_roads.push_back(road);
436  }
437  }
438  // Copy the roads we found into the output argument and return success.
439  roads.reserve(m_roads.size());
440  for (FPGATrackSimRoad & r : m_roads)
441  {
442  if (r.getNWCLayers() >= m_maxMiss) continue; // extra check on this
443  roads.emplace_back(std::make_shared<const FPGATrackSimRoad>(r));
444  }
445  ATH_MSG_DEBUG("Found " << roads.size() << " new roads in second stage.");
446 
447  return StatusCode::SUCCESS;
448 }

◆ fillInputTensorForNN()

StatusCode FPGATrackSimNNPathfinderExtensionTool::fillInputTensorForNN ( miniRoad thisRoad,
std::vector< float > &  inputTensorValues 
)
private

Definition at line 450 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

451 {
452  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsR;
453 
454  std::vector<std::shared_ptr<const FPGATrackSimHit>> hits = thisroad.getHits();
455 
456 
457  for (unsigned ihit = 0; ihit < hits.size(); ihit++) {
458  if (ihit < m_nLayers_1stStage && !(hits[ihit]->isReal())) continue; // skip guessed hits for the 1st stage
459  hitsR.push_back(hits[ihit]);
460  }
461  // Sort in increasing 3D distance.
462  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
463  double dist_a = std::hypot(a->getX(), a->getY(), a->getZ());
464  double dist_b = std::hypot(b->getX(), b->getY(), b->getZ());
465  return dist_a < dist_b;
466  });
467 
468  if(m_debugEvent) ATH_MSG_DEBUG("hitsR");
469  for (auto thit : hitsR)
470  {
471  if(m_debugEvent) ATH_MSG_DEBUG(thit->getX()<<" "<<thit->getY()<<" "<<thit->getZ() << " and phi = " << thit->getGPhi());
472  }
473 
474  // Remove all the duplicate space points
475  std::vector<std::shared_ptr<const FPGATrackSimHit>> cleanHits;
476  bool skipHit = false;
477  for (auto thit : hitsR)
478  {
479  if(skipHit)
480  {
481  skipHit = false;
482  continue;
483  }
484  if (thit->isPixel())
485  {
486  cleanHits.push_back(thit);
487  }
488  else if (thit->isStrip() && (thit->getHitType() == HitType::spacepoint))
489  {
490  // This is a proper strips SP, push the first hit back and skip the next one since its a duplicate
491  cleanHits.push_back(thit);
492  skipHit = true;
493  }
494  else if (thit->isStrip() && (thit->getHitType() == HitType::guessed))
495  {
496  // this is a guessed strip SP, push the first hit back and skip the next one since its a duplicate
497  cleanHits.push_back(thit);
498  skipHit = true;
499  }
500  else if (thit->isStrip() && (thit->getHitType() == HitType::undefined))
501  {
502  // this is a fake hit, inserted for a unpaired SP, continue
503  continue;
504  }
505  else if (thit->isStrip() && thit->isReal())
506  {
507  // What is left here is a unpaired hit, push it back
508  cleanHits.push_back(thit);
509  }
510  else
511  {
512  ATH_MSG_WARNING("No clue how to deal with this hit in the NN predicition ");
513  continue;
514  }
515  }
516 
517  // Reverse the hits as we changed the ordering before
518  if(!m_doOutsideIn)
519  {
520  std::reverse(cleanHits.begin(), cleanHits.end());
521  }
522 
523  // Select the top N hits
524  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsToEncode;
525  std::copy(cleanHits.begin(), cleanHits.begin() + m_predictionWindowLength, std::back_inserter(hitsToEncode));
526 
527  if(m_debugEvent) ATH_MSG_DEBUG("Clean hits");
528  for (auto thit : cleanHits)
529  {
530  if(m_debugEvent) ATH_MSG_DEBUG(thit->getX()<<" "<<thit->getY()<<" "<<thit->getZ()<<" "<<thit->isStrip() << " and gphi = " << thit->getGPhi());
531  }
532 
533  // Reverse this vector so we can encode it the format as expected from the NN
534  std::reverse(hitsToEncode.begin(), hitsToEncode.end());
535 
536  if(m_debugEvent) ATH_MSG_DEBUG("Input for NN prediction");
537  for (auto thit : hitsToEncode)
538  {
539  if (m_useCartesian) {
540  inputTensorValues.push_back(thit->getX()/ getXScale());
541  inputTensorValues.push_back(thit->getY()/ getYScale());
542  inputTensorValues.push_back(thit->getZ()/ getZScale());
543  }
544  else {
545  inputTensorValues.push_back(thit->getR()/ getRScale());
546  inputTensorValues.push_back(thit->getGPhi()/ getPhiScale());
547  inputTensorValues.push_back(thit->getZ()/ getZScale());
548  }
549 
550  if(m_debugEvent) ATH_MSG_DEBUG(thit->getX()<<" "<<thit->getY()<<" "<<thit->getZ() << " and gphi = " << thit->getGPhi());
551  }
552 
553  return StatusCode::SUCCESS;
554 
555 }

◆ findHitinNextStripLayer()

StatusCode FPGATrackSimNNPathfinderExtensionTool::findHitinNextStripLayer ( std::shared_ptr< const FPGATrackSimHit hit,
const std::vector< std::shared_ptr< const FPGATrackSimHit >> &  hitList,
std::vector< std::shared_ptr< const FPGATrackSimHit >> &  hits 
)
private

Definition at line 656 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

657 {
658  float EPSILON = 0.00001;
659  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hitList)
660  {
661  if (abs(hit->getX() - hitToSearch->getX()) < EPSILON && abs(hit->getY() - hitToSearch->getY()) < EPSILON && abs(hit->getZ() - hitToSearch->getZ()) < EPSILON && hit->getIdentifierHash() != hitToSearch->getIdentifierHash())
662  {
663  hits.push_back(hit);
664  return StatusCode::SUCCESS;
665  }
666 
667  }
668 
669  ATH_MSG_WARNING("Didn't find a matching space point");
670 
671  return StatusCode::FAILURE;
672 }

◆ getFakeHit()

StatusCode FPGATrackSimNNPathfinderExtensionTool::getFakeHit ( miniRoad currentRoad,
std::vector< float > &  predhit,
const long &  fineID,
std::vector< std::shared_ptr< const FPGATrackSimHit >> &  hits 
)
private

Definition at line 590 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

590  {
591 
592  unsigned guessedLayer(0);
593 
594  std::shared_ptr<FPGATrackSimHit> guessedHitPtr = std::make_shared<FPGATrackSimHit>();
595  if (m_useCartesian) {
596  guessedHitPtr->setX(predhit[0]);
597  guessedHitPtr->setY(predhit[1]);
598  guessedHitPtr->setZ(predhit[2]);
599  }
600  else {
601  double r = predhit[0];
602  double phi = predhit[1];
603  guessedHitPtr->setX(r*cos(phi));
604  guessedHitPtr->setY(r*sin(phi));
605  guessedHitPtr->setZ(predhit[2]);
606  }
607 
608 
609  if (m_doOutsideIn) { // outside in
610  // TODO
611  }
612  else { // nope, inside out
613  guessedLayer = currentRoad.getNHits();
614  }
615 
616  guessedHitPtr->setLayer(guessedLayer);
617  guessedHitPtr->setHitType(HitType::guessed);
618 
619  if(isFineIDInStrip(fineID)) {
620  guessedHitPtr->setDetType(SiliconTech::strip);
621  guessedHitPtr->setPhysLayer(0); // it is just to set the side, it's not actually 0
622  }
623  else guessedHitPtr->setDetType(SiliconTech::pixel);
624 
625 
626  // Make sure that the hit is inside the boundaries of the layers
627  if(guessedLayer < (m_nLayers_1stStage + m_nLayers_2ndStage ))
628  {
629  hits.push_back(guessedHitPtr);
630  }
631  // if in strips, add the second hit into the list
632  if(isFineIDInStrip(fineID))
633  {
634  std::shared_ptr<FPGATrackSimHit> guessedSecondHitPtr = std::make_shared<FPGATrackSimHit>();
635  guessedSecondHitPtr->setX(0);
636  guessedSecondHitPtr->setY(0);
637  guessedSecondHitPtr->setZ(0);
638  guessedSecondHitPtr->setLayer( guessedLayer + 1 );
639  guessedSecondHitPtr->setHitType(HitType::guessed);
640 
641  guessedSecondHitPtr->setDetType(SiliconTech::strip);
642  guessedHitPtr->setPhysLayer(1); // it is just to set the side, it's not actually 1
643  // Make sure that the hit is inside the boundaries of the layers
644  if((guessedLayer + 1) < (m_nLayers_1stStage + m_nLayers_2ndStage ))
645  {
646  hits.push_back(guessedSecondHitPtr);
647  }
648  }
649 
650 
651 
652  return StatusCode::SUCCESS;
653 
654 }

◆ getLastLayer()

StatusCode FPGATrackSimNNPathfinderExtensionTool::getLastLayer ( miniRoad currentRoad,
unsigned &  lastHitLayer,
std::shared_ptr< const FPGATrackSimHit > &  lastHit 
)
private

Definition at line 709 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

710 {
711  lastHitLayer = currentRoad.getNHits()-1;
712  lastHit = currentRoad.getHit(lastHitLayer);
713  return StatusCode::SUCCESS;
714 
715 }

◆ getPhiScale()

static float FPGATrackSimNNPathfinderExtensionTool::getPhiScale ( )
inlinestaticprivate

Definition at line 183 of file FPGATrackSimNNPathfinderExtensionTool.h.

183 {return 3.15;};

◆ getPredictedHit()

StatusCode FPGATrackSimNNPathfinderExtensionTool::getPredictedHit ( std::vector< float > &  inputTensorValues,
std::vector< float > &  outputTensorValues,
long &  fineID 
)
private

Definition at line 558 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

559 {
560  std::vector<float> NNVoloutput = m_extensionVolNN.runONNXInference(inputTensorValues);
561  fineID = std::distance(NNVoloutput.begin(),std::max_element(NNVoloutput.begin(), NNVoloutput.end()));
562  // Insert the output for the second stage NN
563  inputTensorValues.insert(inputTensorValues.end(), NNVoloutput.begin(), NNVoloutput.end()); //now we append the first NN to the list of coordinates
564 
565  // use the above to predict the next hit position
566  outputTensorValues = m_extensionHitNN.runONNXInference(inputTensorValues);
567 
568  // now scale back
569  if (m_useCartesian) {
570  outputTensorValues[0] *= getXScale();
571  outputTensorValues[1] *= getYScale();
572  outputTensorValues[2] *= getZScale();
573  }
574  else {
575  outputTensorValues[0] *= getRScale();
576  outputTensorValues[1] *= getPhiScale();
577  outputTensorValues[2] *= getZScale();
578  }
579 
580  return StatusCode::SUCCESS;
581 }

◆ getRScale()

static float FPGATrackSimNNPathfinderExtensionTool::getRScale ( )
inlinestaticprivate

Definition at line 182 of file FPGATrackSimNNPathfinderExtensionTool.h.

182 {return 1015.;};

◆ getXScale()

static float FPGATrackSimNNPathfinderExtensionTool::getXScale ( )
inlinestaticprivate

Definition at line 179 of file FPGATrackSimNNPathfinderExtensionTool.h.

179 { return 1015.;};

◆ getYScale()

static float FPGATrackSimNNPathfinderExtensionTool::getYScale ( )
inlinestaticprivate

Definition at line 180 of file FPGATrackSimNNPathfinderExtensionTool.h.

180 { return 1015.;};

◆ getZScale()

static float FPGATrackSimNNPathfinderExtensionTool::getZScale ( )
inlinestaticprivate

Definition at line 181 of file FPGATrackSimNNPathfinderExtensionTool.h.

181 { return 3000.;};

◆ initialize()

StatusCode FPGATrackSimNNPathfinderExtensionTool::initialize ( )
overridevirtual

Definition at line 23 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

23  {
24 
25  // Retrieve the mapping service.
26  ATH_CHECK(m_FPGATrackSimMapping.retrieve());
27 
28  // hard code this for now but we may chance in the future
31 
32  if (m_windowR.size() != 1 && m_windowR.size() != m_windowFineID.size()) {
33  ATH_MSG_ERROR("Window r size = " << m_windowR << " is not equal to 1 (for all layers) and not equal to " << m_windowFineID.size());
34  return StatusCode::FAILURE;
35  }
36 
37  if (m_windowPhi.size() != 1 && m_windowPhi.size() != m_windowFineID.size()) {
38  ATH_MSG_ERROR("Window phi size = " << m_windowPhi << " is not equal to 1 (for all layers) and not equal to " << m_windowFineID.size());
39  return StatusCode::FAILURE;
40  }
41 
42  if (m_windowZ.size() != 1 && m_windowZ.size() != m_windowFineID.size()) {
43  ATH_MSG_ERROR("Window z size = " << m_windowZ << " is not equal to 1 (for all layers) and not equal to " << m_windowFineID.size());
44  return StatusCode::FAILURE;
45  }
46 
47  if (m_FPGATrackSimMapping->getExtensionNNVolMapString() != "" && m_FPGATrackSimMapping->getExtensionNNHitMapString() != "") {
48  ATH_MSG_INFO("Initializing extension hit NN with string = " << m_FPGATrackSimMapping->getExtensionNNHitMapString());
49  m_extensionHitNN.initialize(m_FPGATrackSimMapping->getExtensionNNHitMapString());
50  ATH_MSG_INFO("Initializing volume NN with string = " << m_FPGATrackSimMapping->getExtensionNNVolMapString());
51  m_extensionVolNN.initialize(m_FPGATrackSimMapping->getExtensionNNVolMapString());
52  }
53  else {
54  ATH_MSG_ERROR("Path to NN-based track extension ONNX file is empty! If you want to run this pipeline, you need to provide an input file.");
55  return StatusCode::FAILURE;
56  }
57 
58  ATH_CHECK(m_tHistSvc.retrieve());
59 
60  return StatusCode::SUCCESS;
61 }

◆ printRoad()

void FPGATrackSimNNPathfinderExtensionTool::printRoad ( miniRoad currentRoad)
private

Definition at line 674 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

675 {
676  if(!m_debugEvent) return;
677 
678  // print this road
679  if(m_debugEvent)
680  {
681  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsR;
682  for (auto &hit : currentRoad.getHits()) {
683  hitsR.push_back(hit);
684  }
685 
686  // If outside in, sort in increasing R, otherwise, decreasing R
687  if(m_doOutsideIn)
688  {
689  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
690  if(a->getR() == b->getR()) return a->getLayer() < b->getLayer();
691  return a->getR() < b->getR();
692  });
693  }
694  else
695  {
696  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
697  return a->getR() > b->getR();
698  });
699  }
700 
701  for (unsigned long i = 0; i < hitsR.size(); i++)
702  {
703  ATH_MSG_DEBUG("Hit i "<<i<<" X: "<<hitsR[i]->getX()<<" Y: "<<hitsR[i]->getY()<<" Z: "<<hitsR[i]->getZ()<<" R: "<<hitsR[i]->getR()<< " hitType: "<<hitsR[i]->getHitType()<<" getDetType: "<<hitsR[i]->getDetType() << "phi = " << hitsR[i]->getGPhi());
704  }
705  }
706 
707 }

◆ setupSlices()

virtual StatusCode FPGATrackSimNNPathfinderExtensionTool::setupSlices ( FPGATrackSimLogicalEventInputHeader slicedHitHeader)
inlineoverridevirtual

Definition at line 138 of file FPGATrackSimNNPathfinderExtensionTool.h.

138  {
139  m_slicedHitHeader = slicedHitHeader;
140  return StatusCode::SUCCESS;
141  };

Member Data Documentation

◆ m_debugEvent

bool FPGATrackSimNNPathfinderExtensionTool::m_debugEvent = false
private

Definition at line 185 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_doOutsideIn

Gaudi::Property<bool> FPGATrackSimNNPathfinderExtensionTool::m_doOutsideIn { this, "doOutsideIn", true, "Setup the tool so it's doing outside in extrap"}
private

Definition at line 170 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_extensionHitNN

OnnxRuntimeBase FPGATrackSimNNPathfinderExtensionTool::m_extensionHitNN
private

Definition at line 192 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_extensionVolNN

OnnxRuntimeBase FPGATrackSimNNPathfinderExtensionTool::m_extensionVolNN
private

Definition at line 191 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_FPGATrackSimMapping

ServiceHandle<IFPGATrackSimMappingSvc> FPGATrackSimNNPathfinderExtensionTool::m_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc", "FPGATrackSimMappingSvc"}
private

Definition at line 145 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_lowPtValueForWindowPhiScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowPhiScaling { this, "lowPtValueWindowPhi", -1, "Value in MeV below which we scale the phi window size"}
private

Definition at line 163 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_lowPtValueForWindowRScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowRScaling { this, "lowPtValueWindowR", -1, "Value in MeV below which we scale the r window size"}
private

Definition at line 159 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_lowPtValueForWindowZScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowZScaling { this, "lowPtValueWindowZ", -1, "Value in MeV below which we scale the r window size"}
private

Definition at line 161 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_lowPtWindowPhiScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowPhiScaling {this, "lowPtPhiScaling", 1.0, "Scaling factor for low pt in Phi"}
private

Definition at line 164 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_lowPtWindowRScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowRScaling {this, "lowPtRScaling", 1.0, "Scaling factor for low pt in R"}
private

Definition at line 160 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_lowPtWindowZScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowZScaling {this, "lowPtZScaling", 1.0, "Scaling factor for low pt in Z"}
private

Definition at line 162 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_maxBranches

Gaudi::Property<int> FPGATrackSimNNPathfinderExtensionTool::m_maxBranches { this, "maxBranches", -1, "Max number of branches before we stop, if negative this is disabled"}
private

Definition at line 169 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_maxMiss

Gaudi::Property<unsigned> FPGATrackSimNNPathfinderExtensionTool::m_maxMiss { this, "threshold", 2, "Maximum number of missing hits to reject a road"}
private

Definition at line 148 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_missedHitPhiScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_missedHitPhiScaling {this, "missedHitPhiScaling", -1, "Amount to scale Phi window if previous hit was missed. Negative means this is disabled"}
private

Definition at line 168 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_missedHitRScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_missedHitRScaling {this, "missedHitRScaling", -1, "Amount to scale R window if previous hit was missed. Negative means this is disabled"}
private

Definition at line 166 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_missedHitZScaling

Gaudi::Property<float> FPGATrackSimNNPathfinderExtensionTool::m_missedHitZScaling {this, "missedHitZScaling", -1, "Amount to scale Z window if previous hit was missed. Negative means this is disabled"}
private

Definition at line 167 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_nLayers_1stStage

unsigned FPGATrackSimNNPathfinderExtensionTool::m_nLayers_1stStage = 0
private

Definition at line 176 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_nLayers_2ndStage

unsigned FPGATrackSimNNPathfinderExtensionTool::m_nLayers_2ndStage = 0
private

Definition at line 177 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_predictionWindowLength

Gaudi::Property<int> FPGATrackSimNNPathfinderExtensionTool::m_predictionWindowLength { this, "predictionWindowLength", 3, "Length of hits needed for prediction"}
private

Definition at line 171 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_region

Gaudi::Property<std::string> FPGATrackSimNNPathfinderExtensionTool::m_region { this, "OutputRegion", "", "region ID"}
private

Definition at line 149 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_roads

std::vector<FPGATrackSimRoad> FPGATrackSimNNPathfinderExtensionTool::m_roads
private

Definition at line 175 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_slicedHitHeader

FPGATrackSimLogicalEventInputHeader* FPGATrackSimNNPathfinderExtensionTool::m_slicedHitHeader = nullptr
private

Definition at line 189 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_tHistSvc

ServiceHandle<ITHistSvc> FPGATrackSimNNPathfinderExtensionTool::m_tHistSvc {this, "THistSvc", "THistSvc"}
private

Definition at line 146 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_useCartesian

Gaudi::Property<bool> FPGATrackSimNNPathfinderExtensionTool::m_useCartesian { this, "useCartesian", true, "If true, NNs use Cartestian coordinates. If false,they use cylindrical coordiantes"}
private

Definition at line 172 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_windowFineID

Gaudi::Property<std::vector<int> > FPGATrackSimNNPathfinderExtensionTool::m_windowFineID { this, "windowFineID", {0}, "Fine ID indexing for windows"}
private

Definition at line 158 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_windowPhi

Gaudi::Property<std::vector<float> > FPGATrackSimNNPathfinderExtensionTool::m_windowPhi { this, "windowPhi", {0.4}, "Window Size to search in for phi, either pass one value for all layers or use the number of layers"}
private

Definition at line 157 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_windowR

Gaudi::Property<std::vector<float> > FPGATrackSimNNPathfinderExtensionTool::m_windowR { this, "windowR", {20.0}, "Window Size to search in for r, either pass one value for all layers or use the number of layers"}
private

Definition at line 155 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_windowZ

Gaudi::Property<std::vector<float> > FPGATrackSimNNPathfinderExtensionTool::m_windowZ { this, "windowZ", {20.0}, "Window Size to search in for z, either pass one value for all layers or use the number of layers"}
private

Definition at line 156 of file FPGATrackSimNNPathfinderExtensionTool.h.


The documentation for this class was generated from the following files:
FPGATrackSimNNPathfinderExtensionTool::findHitinNextStripLayer
StatusCode findHitinNextStripLayer(std::shared_ptr< const FPGATrackSimHit > hit, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hitList, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:656
OnnxRuntimeBase::runONNXInference
std::vector< float > runONNXInference(std::vector< float > &inputTensorValues) const
Definition: OnnxRuntimeBase.cxx:84
beamspotman.r
def r
Definition: beamspotman.py:672
FPGATrackSimNNPathfinderExtensionTool::getPhiScale
static float getPhiScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:183
FPGATrackSimNNPathfinderExtensionTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimNNPathfinderExtensionTool.h:145
miniRoad::getHit
std::shared_ptr< const FPGATrackSimHit > getHit(size_t layer) const
Definition: FPGATrackSimNNPathfinderExtensionTool.h:44
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
SiliconTech::strip
@ strip
FPGATrackSimNNPathfinderExtensionTool::m_missedHitRScaling
Gaudi::Property< float > m_missedHitRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:166
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
FPGATrackSimNNPathfinderExtensionTool::m_doOutsideIn
Gaudi::Property< bool > m_doOutsideIn
Definition: FPGATrackSimNNPathfinderExtensionTool.h:170
FPGATrackSimNNPathfinderExtensionTool::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: FPGATrackSimNNPathfinderExtensionTool.h:146
FPGATrackSimNNPathfinderExtensionTool::printRoad
void printRoad(miniRoad &currentRoad)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:674
OnnxRuntimeBase::initialize
void initialize(TString)
Definition: OnnxRuntimeBase.cxx:16
FPGATrackSimNNPathfinderExtensionTool::getYScale
static float getYScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:180
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:149
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:40
test_pyathena.pt
pt
Definition: test_pyathena.py:11
miniRoad::addHit
void addHit(const std::shared_ptr< const FPGATrackSimHit > &hit)
Definition: FPGATrackSimNNPathfinderExtensionTool.h:112
FPGATrackSimNNPathfinderExtensionTool::m_nLayers_1stStage
unsigned m_nLayers_1stStage
Definition: FPGATrackSimNNPathfinderExtensionTool.h:176
miniRoad::getNHits
unsigned getNHits() const
Definition: FPGATrackSimNNPathfinderExtensionTool.h:65
HitType::spacepoint
@ spacepoint
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:111
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:147
FPGATrackSimNNPathfinderExtensionTool::getXScale
static float getXScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:179
FPGATrackSimNNPathfinderExtensionTool::getRScale
static float getRScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:182
FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowPhiScaling
Gaudi::Property< float > m_lowPtValueForWindowPhiScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:163
HitType::guessed
@ guessed
FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowRScaling
Gaudi::Property< float > m_lowPtWindowRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:160
FPGATrackSimNNPathfinderExtensionTool::m_slicedHitHeader
FPGATrackSimLogicalEventInputHeader * m_slicedHitHeader
Definition: FPGATrackSimNNPathfinderExtensionTool.h:189
HitType::undefined
@ undefined
FPGATrackSimNNPathfinderExtensionTool::getLastLayer
StatusCode getLastLayer(miniRoad &currentRoad, unsigned &lastHitLayer, std::shared_ptr< const FPGATrackSimHit > &lastHit)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:709
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
pi
#define pi
Definition: TileMuonFitter.cxx:65
FPGATrackSimNNPathfinderExtensionTool::m_nLayers_2ndStage
unsigned m_nLayers_2ndStage
Definition: FPGATrackSimNNPathfinderExtensionTool.h:177
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
EPSILON
constexpr float EPSILON
Definition: FPGATrackSimHoughFunctions.cxx:13
HitType::wildcard
@ wildcard
FPGATrackSimNNPathfinderExtensionTool::m_roads
std::vector< FPGATrackSimRoad > m_roads
Definition: FPGATrackSimNNPathfinderExtensionTool.h:175
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:146
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimNNPathfinderExtensionTool::m_maxBranches
Gaudi::Property< int > m_maxBranches
Definition: FPGATrackSimNNPathfinderExtensionTool.h:169
FPGATrackSimNNPathfinderExtensionTool::getZScale
static float getZScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:181
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimNNPathfinderExtensionTool::getPredictedHit
StatusCode getPredictedHit(std::vector< float > &inputTensorValues, std::vector< float > &outputTensorValues, long &fineID)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:558
FPGATrackSimNNPathfinderExtensionTool::m_windowFineID
Gaudi::Property< std::vector< int > > m_windowFineID
Definition: FPGATrackSimNNPathfinderExtensionTool.h:158
FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowZScaling
Gaudi::Property< float > m_lowPtValueForWindowZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:161
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowPhiScaling
Gaudi::Property< float > m_lowPtWindowPhiScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:164
getFineID
long getFineID(const FPGATrackSimHit &hit)
Definition: FPGATrackSimHoughFunctions.cxx:624
FPGATrackSimLogicalEventInputHeader::addTower
void addTower(const FPGATrackSimTowerInputHeader &s)
Definition: FPGATrackSimLogicalEventInputHeader.h:38
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimRoad::setX
void setX(float v)
Definition: FPGATrackSimRoad.h:77
FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowRScaling
Gaudi::Property< float > m_lowPtValueForWindowRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:159
FPGATrackSimNNPathfinderExtensionTool::m_windowR
Gaudi::Property< std::vector< float > > m_windowR
Definition: FPGATrackSimNNPathfinderExtensionTool.h:155
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:150
FPGATrackSimHit::setPhysLayer
void setPhysLayer(unsigned v)
Definition: FPGATrackSimHit.cxx:55
FPGATrackSimHit::getIdentifierHash
unsigned getIdentifierHash() const
Definition: FPGATrackSimHit.h:81
FPGATrackSimNNPathfinderExtensionTool::m_extensionVolNN
OnnxRuntimeBase m_extensionVolNN
Definition: FPGATrackSimNNPathfinderExtensionTool.h:191
FPGATrackSimNNPathfinderExtensionTool::addHitToRoad
StatusCode addHitToRoad(miniRoad &newroad, miniRoad &currentRoad, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:583
miniRoad::getNWCLayers
size_t getNWCLayers() const
Definition: FPGATrackSimNNPathfinderExtensionTool.h:73
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:151
miniRoad::setHits
void setHits(std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.h:100
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
FPGATrackSimNNPathfinderExtensionTool::m_extensionHitNN
OnnxRuntimeBase m_extensionHitNN
Definition: FPGATrackSimNNPathfinderExtensionTool.h:192
isFineIDInPixel
bool isFineIDInPixel(long ID)
Definition: FPGATrackSimHoughFunctions.cxx:619
FPGATrackSimNNPathfinderExtensionTool::m_debugEvent
bool m_debugEvent
Definition: FPGATrackSimNNPathfinderExtensionTool.h:185
FPGATrackSimRoad::setSubRegion
void setSubRegion(int v)
Definition: FPGATrackSimRoad.h:74
FPGATrackSimRoad::getWCLayers
layer_bitmask_t getWCLayers() const
Definition: FPGATrackSimRoad.h:98
miniRoad::getHits
std::vector< std::shared_ptr< const FPGATrackSimHit > > & getHits()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:50
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:148
FPGATrackSimNNPathfinderExtensionTool::m_maxMiss
Gaudi::Property< unsigned > m_maxMiss
Definition: FPGATrackSimNNPathfinderExtensionTool.h:148
FPGATrackSimNNPathfinderExtensionTool::fillInputTensorForNN
StatusCode fillInputTensorForNN(miniRoad &thisRoad, std::vector< float > &inputTensorValues)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:450
FPGATrackSimHit::getR
float getR() const
Definition: FPGATrackSimHit.h:152
a
TList * a
Definition: liststreamerinfos.cxx:10
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:92
miniRoad
Definition: FPGATrackSimNNPathfinderExtensionTool.h:35
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
layer_bitmask_t
uint32_t layer_bitmask_t
Definition: FPGATrackSimTypes.h:22
miniRoad::addHits
void addHits(const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.h:103
FPGATrackSimRoad::setYBin
void setYBin(unsigned v)
Definition: FPGATrackSimRoad.h:76
FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowZScaling
Gaudi::Property< float > m_lowPtWindowZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:162
FPGATrackSimNNPathfinderExtensionTool::m_predictionWindowLength
Gaudi::Property< int > m_predictionWindowLength
Definition: FPGATrackSimNNPathfinderExtensionTool.h:171
FPGATrackSimRegionMap::getNRegions
int getNRegions() const
Definition: FPGATrackSimRegionMap.h:80
FPGATrackSimNNPathfinderExtensionTool::m_windowPhi
Gaudi::Property< std::vector< float > > m_windowPhi
Definition: FPGATrackSimNNPathfinderExtensionTool.h:157
FPGATrackSimRegionMap
Definition: FPGATrackSimRegionMap.h:62
FPGATrackSimNNPathfinderExtensionTool::m_useCartesian
Gaudi::Property< bool > m_useCartesian
Definition: FPGATrackSimNNPathfinderExtensionTool.h:172
FPGATrackSimRoad::setY
void setY(float v)
Definition: FPGATrackSimRoad.h:78
FPGATrackSimRoad::setRoadID
void setRoadID(int roadID)
Definition: FPGATrackSimRoad.h:58
FPGATrackSimNNPathfinderExtensionTool::m_missedHitPhiScaling
Gaudi::Property< float > m_missedHitPhiScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:168
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer(bool old=false) const
Definition: FPGATrackSimHit.cxx:72
FPGATrackSimRoad::setHitLayers
void setHitLayers(layer_bitmask_t hit_layers)
Definition: FPGATrackSimRoad.h:63
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
calibdata.copy
bool copy
Definition: calibdata.py:26
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
FPGATrackSimNNPathfinderExtensionTool::m_windowZ
Gaudi::Property< std::vector< float > > m_windowZ
Definition: FPGATrackSimNNPathfinderExtensionTool.h:156
isFineIDInStrip
bool isFineIDInStrip(long ID)
Definition: FPGATrackSimHoughFunctions.cxx:614
FPGATrackSimTowerInputHeader
Definition: FPGATrackSimTowerInputHeader.h:18
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
FPGATrackSimNNPathfinderExtensionTool::m_missedHitZScaling
Gaudi::Property< float > m_missedHitZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:167
SiliconTech::pixel
@ pixel
FPGATrackSimRoad::setHits
void setHits(std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit >>> &&hits)
Definition: FPGATrackSimRoad.cxx:141
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:31
FPGATrackSimRoad::setWCLayers
void setWCLayers(layer_bitmask_t wc_layers)
Definition: FPGATrackSimRoad.h:64
FPGATrackSimNNPathfinderExtensionTool::getFakeHit
StatusCode getFakeHit(miniRoad &currentRoad, std::vector< float > &predhit, const long &fineID, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:590
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
FPGATrackSimRoad::setXBin
void setXBin(unsigned v)
Definition: FPGATrackSimRoad.h:75