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 581 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ 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  fineID_index = fineID_it - m_windowFineID.begin();
218  }
219  if (m_windowR.size() > 1) {
220  if (fineID_index == -1) {
221  windowR = *std::max_element(m_windowR.begin(), m_windowR.end());
222  }
223  else {
224  windowR = m_windowR[fineID_index];
225  }
226  }
227  if (m_windowZ.size() > 1) {
228  if (fineID_index == -1) {
229  windowZ = *std::max_element(m_windowZ.begin(), m_windowZ.end());
230  }
231  else {
232  windowZ = m_windowZ[fineID_index];
233  }
234  }
235  if (m_windowPhi.size() > 1) {
236  if (fineID_index == -1) {
237  windowPhi = *std::max_element(m_windowPhi.begin(), m_windowPhi.end());
238  }
239  else {
240  windowPhi = m_windowPhi[fineID_index];
241  }
242  }
243 
244  // If last hit was not real and we want to, scale the window
245  if (m_missedHitRScaling > 0 && !lastHitWasReal) windowR *= m_missedHitRScaling;
246  if (m_missedHitZScaling > 0 && !lastHitWasReal) windowZ *= m_missedHitZScaling;
247  if (m_missedHitPhiScaling > 0 && !lastHitWasReal) windowPhi *= m_missedHitPhiScaling;
248  // now scale windows for low pt, if desired
249  if (pt < m_lowPtValueForWindowRScaling.value()) windowR *= m_lowPtWindowRScaling.value();
250  if (pt < m_lowPtValueForWindowZScaling.value()) windowZ *= m_lowPtWindowZScaling.value();
251  if (pt < m_lowPtValueForWindowPhiScaling.value()) windowPhi *= m_lowPtWindowPhiScaling.value();
252 
253  double dr = abs(hitr - predr);
254  double dz = abs(hitz - predz);
255  double dphi = abs(hitphi - predphi);
256  while (dphi > pi) dphi -= pi;
257  if ((m_useCartesian && dr < windowR && dz < windowZ) ||
258  (!m_useCartesian && dphi < windowPhi && dz < windowZ && dr < windowR))
259  {
260  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits {hit};
261  hitsInWindow = hitsInWindow + 1;
262  // 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
263  if(hit->isStrip()) {
264  if (hit->getHitType() == HitType::spacepoint) {
265  // find the hit in the next layer
266  if(!findHitinNextStripLayer(hit, hits, theseHits)) {
267  ATH_MSG_WARNING("For a SP in layer " << layer << " Couldn't find a matching strip SP");
268  }
269  }
270  else {
271  std::shared_ptr<FPGATrackSimHit> guessedSecondHitPtr = std::make_shared<FPGATrackSimHit>();
272  guessedSecondHitPtr->setX(0);
273  guessedSecondHitPtr->setY(0);
274  guessedSecondHitPtr->setZ(0);
275  guessedSecondHitPtr->setPhysLayer(lastHit->getPhysLayer(true)+1);
276  guessedSecondHitPtr->setHitType(HitType::undefined);
277  if(isFineIDInStrip(fineID)) guessedSecondHitPtr->setDetType(SiliconTech::strip);
278  else guessedSecondHitPtr->setDetType(SiliconTech::pixel);
279 
280  theseHits.push_back(guessedSecondHitPtr);
281  }
282  }
283  // Store the hits for now
284  listofHitsFound.push_back(theseHits);
285  }
286  }
287  }
288  // Sort the hit by the distance
289  if (m_useCartesian) {
290  std::sort(listofHitsFound.begin(), listofHitsFound.end(), [&predhit](auto& a, auto& b){
291  double predr = sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
292  double predz = predhit[2];
293 
294  // HitA
295  double hitz = a[0]->getZ();
296  double hitr = a[0]->getR();
297  float distance_a = (hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz);
298 
299  // HitB
300  hitz = b[0]->getZ();
301  hitr = b[0]->getR();
302  float distance_b = (hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz);
303 
304  return distance_a < distance_b;
305  });
306  }
307  else {
308  std::sort(listofHitsFound.begin(), listofHitsFound.end(), [&predhit](auto& a, auto& b){
309 
310  double predr = predhit[0];
311  double predphi = predhit[1];
312  double predz = predhit[2];
313  // HitA
314  double hitr = a[0]->getR();
315  double hitphi = a[0]->getGPhi();
316  double hitz = a[0]->getZ();
317  double dz = abs(hitz - predz);
318  double dr = abs(hitr - predr);
319  double dphi = abs(hitphi - predphi);
320  while (dphi > pi) dphi -= pi;
321 
322  // scaled distance because z and phi and r are not in same units
323  float distance_a = dz*dz/(getZScale()*getZScale()) + dphi*dphi/(getPhiScale()*getPhiScale()) + dr*dr/(getRScale()*getRScale());
324 
325  // HitB
326  hitr = b[0]->getR();
327  hitphi = b[0]->getGPhi();
328  hitz = b[0]->getZ();
329  dz = abs(hitz - predz);
330  dr = abs(hitr - predr);
331  dphi = abs(hitphi - predphi);
332  while (dphi > pi) dphi -= pi;
333 
334  // scaled distance because z and phi and r are not in same units
335  float distance_b = dz*dz/(getZScale()*getZScale()) + dphi*dphi/(getPhiScale()*getPhiScale()) + dr*dr/(getRScale()*getRScale());
336 
337  return distance_a < distance_b;
338  });
339  }
340  // Select the top N hits
341  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> cleanHitsToGrow;
342 
343  // If max branches are limited, pick only the top N from the list of hits found at each level
344  if (m_maxBranches.value() >= 0) {
345  int nHitsToChoose = std::min(int(m_maxBranches.value()), int(listofHitsFound.size()));
346  cleanHitsToGrow.reserve(nHitsToChoose);
347  std::copy(listofHitsFound.begin(), listofHitsFound.begin() + nHitsToChoose, std::back_inserter(cleanHitsToGrow));
348  }
349  else {
350  cleanHitsToGrow = std::move(listofHitsFound);
351  }
352 
353  for (auto& hitsFound: cleanHitsToGrow) {
354 
355  // We got a hit, lets make a road
356  miniRoad newRoad;
357  if(!addHitToRoad(newRoad, currentRoad, std::move(hitsFound))) {
358  ATH_MSG_WARNING("Failed to make a new road");
359  continue;
360  }
361  roadsToExtrapolate.push_back(newRoad);
362  foundhitForRoad = true;
363  if(m_debugEvent) {
364  ATH_MSG_DEBUG("------ road grown with hit from layer "<<layer<<" to");
365  printRoad(newRoad);
366  }
367  }
368  // If the hit wasn't found, push a fake hit
369  if (!foundhitForRoad) {
370  // 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
371  if (currentRoad.getNWCLayers() >= m_maxMiss) {
372  // we don't want this road, so we continue
373  continue;
374  }
375  else {
376  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits;
377  // first make the fake hit that we will add
378  if (!getFakeHit(currentRoad, predhit, fineID, theseHits)) {
379  ATH_MSG_WARNING("Failed adding a guessed hit in extrapolation");
380  continue;
381  }
382 
383  if((isFineIDInPixel(fineID) && theseHits.size() != 1) || (isFineIDInStrip(fineID) && theseHits.size() != 2)) {
384  continue;
385  }
386  // add the hit to the road
387  miniRoad newroad;
388  if (!addHitToRoad(newroad, currentRoad, std::move(theseHits))) {
389  ATH_MSG_WARNING("Failed making a new road with fake hit");
390  continue;
391  }
392  roadsToExtrapolate.push_back(newroad);
393  }
394  }
395  }
396  // This track has been extrapolated, copy the completed tracks to the full list with full road objects
397  for (const auto &miniroad : completedRoads) {
398  FPGATrackSimRoad road;
399  road.setWCLayers(miniroad.getWCLayers());
400  road.setHitLayers(miniroad.getHitLayers());
401  road.setRoadID(m_roads.size() - 1);
402  // Set the "Hough x" and "Hough y" using the track parameters.
403  road.setX(track->getPhi());
404  road.setY(track->getQOverPt());
405  road.setXBin(track->getHoughXBin());
406  road.setYBin(track->getHoughYBin());
407  road.setSubRegion(track->getSubRegion());
408 
409  // just force the right number of layers now, in case we find fewer than expected (needed downstream)
410  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> roadhits = miniroad.getVecHits();
411  unsigned nexpected = m_nLayers_1stStage+m_nLayers_2ndStage;
412  if (roadhits.size() > nexpected) { // cut off the last ones
413  roadhits.resize(nexpected);
414  }
415  else if (roadhits.size() < nexpected) { // fill with missing hits
416  for (unsigned layer = roadhits.size(); layer < nexpected; layer++) {
417  std::shared_ptr<FPGATrackSimHit> emptyHitPtr = std::make_shared<FPGATrackSimHit>();
418  emptyHitPtr->setX(0);
419  emptyHitPtr->setY(0);
420  emptyHitPtr->setZ(0);
421  emptyHitPtr->setLayer(layer);
422  emptyHitPtr->setHitType(HitType::wildcard);
423  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitVec;
424  hitVec.push_back(emptyHitPtr);
425  roadhits.push_back(hitVec);
426  layer_bitmask_t wclayers = road.getWCLayers();
427  wclayers |= (1 << layer);
428  road.setWCLayers(wclayers);
429  }
430  }
431  road.setHits(std::move(roadhits));
432 
433  m_roads.push_back(road);
434  }
435  }
436  // Copy the roads we found into the output argument and return success.
437  roads.reserve(m_roads.size());
438  for (FPGATrackSimRoad & r : m_roads)
439  {
440  if (r.getNWCLayers() >= m_maxMiss) continue; // extra check on this
441  roads.emplace_back(std::make_shared<const FPGATrackSimRoad>(r));
442  }
443  ATH_MSG_DEBUG("Found " << roads.size() << " new roads in second stage.");
444 
445  return StatusCode::SUCCESS;
446 }

◆ fillInputTensorForNN()

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

Definition at line 448 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ 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 654 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ 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 588 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ getLastLayer()

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

Definition at line 707 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ 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 556 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ 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 672 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

673 {
674  if(!m_debugEvent) return;
675 
676  // print this road
677  if(m_debugEvent)
678  {
679  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsR;
680  for (auto &hit : currentRoad.getHits()) {
681  hitsR.push_back(hit);
682  }
683 
684  // If outside in, sort in increasing R, otherwise, decreasing R
685  if(m_doOutsideIn)
686  {
687  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
688  if(a->getR() == b->getR()) return a->getLayer() < b->getLayer();
689  return a->getR() < b->getR();
690  });
691  }
692  else
693  {
694  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
695  return a->getR() > b->getR();
696  });
697  }
698 
699  for (unsigned long i = 0; i < hitsR.size(); i++)
700  {
701  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());
702  }
703  }
704 
705 }

◆ 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:654
OnnxRuntimeBase::runONNXInference
std::vector< float > runONNXInference(std::vector< float > &inputTensorValues) const
Definition: OnnxRuntimeBase.cxx:84
beamspotman.r
def r
Definition: beamspotman.py:674
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:672
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:707
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:556
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:581
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:448
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:588
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
FPGATrackSimRoad::setXBin
void setXBin(unsigned v)
Definition: FPGATrackSimRoad.h:75