Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 bookTree ()
 
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 ()
 

Private Attributes

ServiceHandle< IFPGATrackSimMappingSvcm_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc", "FPGATrackSimMappingSvc"}
 
ServiceHandle< ITHistSvc > m_tHistSvc {this, "THistSvc", "THistSvc"}
 
Gaudi::Property< int > m_threshold { this, "threshold", 10, "Minimum number of hits to fire a road"}
 
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< 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_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< 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"}
 
TTree * m_tree = nullptr
 
std::vector< unsigned long > m_NcompletedRoads
 
std::vector< unsigned int > m_missingHitsOnRoad
 
std::vector< std::vector< unsigned long > > m_predictedHitsFineID
 
std::vector< std::vector< unsigned int > > m_foundHitITkLayer
 
std::vector< unsigned int > m_nHitsInSearchWindow
 
std::vector< std::vector< float > > m_distanceOfPredictedHitToFoundHit
 
std::vector< std::vector< bool > > m_foundHitIsSP
 
std::vector< FPGATrackSimRoadm_roads
 
unsigned m_nLayers_1stStage = 0
 
unsigned m_nLayers_2ndStage = 0
 
unsigned m_maxMiss = 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 580 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ bookTree()

StatusCode FPGATrackSimNNPathfinderExtensionTool::bookTree ( )
private

Definition at line 58 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

59 {
60  m_tree = new TTree("NNPathFinderMonitoring","NNPathFinderMonitoring");
61  m_tree->Branch("NcompletedRoads", &m_NcompletedRoads);
62  m_tree->Branch("predictedHitsFineID", &m_predictedHitsFineID);
63  m_tree->Branch("foundHitITkLayer", &m_foundHitITkLayer);
64  m_tree->Branch("missingHitsOnRoad", &m_missingHitsOnRoad);
65  m_tree->Branch("nHitsInSearchWindow", &m_nHitsInSearchWindow);
66  m_tree->Branch("distanceOfPredictedHitToFoundHit", &m_distanceOfPredictedHitToFoundHit);
67  m_tree->Branch("foundHitIsSP", &m_foundHitIsSP);
68 
69  ATH_CHECK(m_tHistSvc->regTree(Form("/FPGATRACKSIMOUTPUTNNPATHFINDER/%s", m_tree->GetName()), m_tree));
70 
71  return StatusCode::SUCCESS;
72 }

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

77  {
78 
79  // Reset the internal second stage roads storage.
80  roads.clear();
81  m_roads.clear();
82  const FPGATrackSimRegionMap* rmap_2nd = m_FPGATrackSimMapping->SubRegionMap_2nd();
83 
84  // Create one "tower" per slice for this event.
85  // Note that there now might be only one "slice", at least for the time being.
86  if (m_slicedHitHeader) {
87  for (int ireg = 0; ireg < rmap_2nd->getNRegions(); ireg++) {
90  }
91  }
92  // JAA need to update this
93  // for (const std::shared_ptr<const FPGATrackSimHit>& hit : hits) {
94  // // Also Store a copy of the hit object in the header class, for ROOT Output + TV creation.
95  // if (m_slicedHitHeader) m_slicedHitHeader->getTower(i)->addHit(*hit);
96  // }
97  if(m_debugEvent) ATH_MSG_DEBUG("Got: "<<tracks.size()<<" tracks to extrapolate");
98 
99  // Now, loop over the tracks.
100  for (std::shared_ptr<const FPGATrackSimTrack> track : tracks) {
101  if(m_debugEvent) ATH_MSG_DEBUG("\033[1;31m-------------------------- extraploating Track ------------------ \033[0m");
102 
103  if (track->passedOR() == 0) {
104  continue;
105  }
106 
107  const std::vector<FPGATrackSimHit> hitsOnTrack = track->getFPGATrackSimHits();
108  miniRoad road;
109  float pt = track->getPt();
110 
111  for (const auto &thit : hitsOnTrack) {
112  road.addHit(std::make_shared<const FPGATrackSimHit>(thit)); // add all hits, we check if WC later
113  }
114 
115  if(m_debugEvent) {
116  ATH_MSG_DEBUG("-----------------Hits in event");
117  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hits) {
118  ATH_MSG_DEBUG("Hit " << " X: " << hit->getX() << " Y: " << hit->getY() << " Z: " << hit->getZ() << " R: " << hit->getR() << " hitType: " << hit->getHitType() << " getDetType: " << hit->getDetType());
119  }
120  }
121 
122  std::vector<miniRoad> roadsToExtrapolate;
123  roadsToExtrapolate.push_back(road);
124 
125  std::vector<miniRoad> completedRoads;
126 
127  std::vector<unsigned long> currentRoadHitFineIDs;
128  std::vector<std::vector<unsigned long>> tmp_predictedHitsFineID;
129  std::vector<unsigned int> currentRoadHitITkLayer;
130  std::vector<std::vector<unsigned int>> tmp_foundHitITkLayer;
131  std::vector<float> currentRoadHitDistancePredFound;
132  std::vector<std::vector<float>> tmp_foundHitDistancePredFound;
133 
134  for (unsigned int i = 0; i < roadsToExtrapolate.size(); i++){
135  tmp_predictedHitsFineID.push_back(currentRoadHitFineIDs);
136  tmp_foundHitITkLayer.push_back(currentRoadHitITkLayer);
137  tmp_foundHitDistancePredFound.push_back(currentRoadHitDistancePredFound);
138  }
139 
140  int count = 0;
141  while(roadsToExtrapolate.size() > 0) {
142  miniRoad currentRoad = *roadsToExtrapolate.begin();
143  std::vector<unsigned long> tmp_currentRoadHitFineIDs = *tmp_predictedHitsFineID.begin();
144  std::vector<unsigned int> tmp_currentRoadHitITkLayer = *tmp_foundHitITkLayer.begin();
145  std::vector<float> tmp_currentRoadHitDistancePredFound = *tmp_foundHitDistancePredFound.begin();
146  // Erase this road from the vector
147  roadsToExtrapolate.erase(roadsToExtrapolate.begin());
148  tmp_predictedHitsFineID.erase(tmp_predictedHitsFineID.begin());
149  tmp_foundHitITkLayer.erase(tmp_foundHitITkLayer.begin());
150  tmp_foundHitDistancePredFound.erase(tmp_foundHitDistancePredFound.begin());
151  count ++;
152 
153  if(m_debugEvent) {
154  ATH_MSG_DEBUG("\033[1;31m-------------------------- extraploating road "<< count << "------------------ \033[0m");
155  printRoad(currentRoad);
156  }
157  // Check exit condition
158  if (currentRoad.getNHits() >= (m_nLayers_1stStage+m_nLayers_2ndStage))
159  {
160  completedRoads.push_back(currentRoad);
161  m_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
162  m_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
163  m_distanceOfPredictedHitToFoundHit.push_back(tmp_currentRoadHitDistancePredFound);
164  continue; // this one is done
165  }
166  // Other try to find the next hit in this road
167  std::vector<float> inputTensorValues;
168  if (!fillInputTensorForNN(currentRoad, inputTensorValues)) {
169  ATH_MSG_WARNING("Failed to create input tensor for this road");
170  continue;
171  }
172  std::vector<float> predhit;
173  long fineID;
174  if (!getPredictedHit(inputTensorValues, predhit, fineID)) {
175  ATH_MSG_WARNING("Failed to predict hit for this road");
176  continue;
177  }
178  // Check if exist conditions are there
179  if (m_doOutsideIn) {
180  // Make sure we are not predicting inside the inner most layer (x and y < 25)
181  // If we are, road is done
182  if (abs(predhit[0]) < 25 && abs(predhit[1]) < 25) {
183  completedRoads.push_back(currentRoad);
184  m_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
185  m_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
186  m_distanceOfPredictedHitToFoundHit.push_back(tmp_currentRoadHitDistancePredFound);
187  continue;
188  }
189  }
190  else {
191  // Make sure we are not predicting outside the outer most layer
192  // if we are, road is done
193  double rad = std::sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
194  if (abs(predhit[0]) > 1024 || abs(predhit[1]) > 1024 || rad > 1024 || abs(predhit[2]) > 3000) {
195  completedRoads.push_back(currentRoad);
196  m_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
197  m_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
198  m_distanceOfPredictedHitToFoundHit.push_back(tmp_currentRoadHitDistancePredFound);
199  continue;
200  }
201  }
202 
203  if(m_debugEvent) {
204  ATH_MSG_DEBUG("Predicted hit at: " << predhit[0] << " " << predhit[1] << " " << predhit[2]);
205  }
206 
207  // Now search for the hits
208  bool foundhitForRoad = false;
209  if(fineID == 215){
210  ATH_MSG_DEBUG("Stopping condition reached");
211  completedRoads.push_back(currentRoad);
212  continue;
213  }
214 
215  // Get the last layer and hit in the road
216  unsigned lastLayerInRoad = 0;
217  std::shared_ptr<const FPGATrackSimHit> lastHit;
218  if(!getLastLayer(currentRoad, lastLayerInRoad, lastHit) or !lastHit) {
219  ATH_MSG_WARNING("Failed to find last layer this road");
220  continue;
221  }
222  unsigned layer = lastLayerInRoad+1; // the layer we're looking to find
223  bool lastHitWasReal = lastHit->isReal();
224  float lastHitR = lastHit->getR();
226  completedRoads.push_back(currentRoad);
227  continue;
228  }
229 
230  unsigned int hitsInWindow = 0;
231 
232  // List of all the hits, with their distances to the predicted point
233  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> listofHitsFound;
234 
235  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hits) {
236  if (m_doOutsideIn && (hit->getR() > lastHitR)) continue;
237  if (!m_doOutsideIn && (hit->getR() < lastHitR)) continue;
238  if ((hit->getHitType() == HitType::spacepoint) && ((hit->getPhysLayer(true)) %2 == 1)) continue; // ignore outer parts of SP, they get added separately
239  if(m_debugEvent) {
240  ATH_MSG_DEBUG("In the hit loop hit at: " << hit->getX() << " " << hit->getY() << " " << hit->getZ());
241  }
242 
243  // loop over hits in that layer
244  if (getFineID(*hit) == fineID && hit->isReal()) {
245  // a hit is in the right fine ID == layer
246  double hitz = hit->getZ();
247  double hitr = hit->getR();
248  double predr = sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
249  double predz = predhit[2];
250  double windowR = m_windowR[0]; // default for all layers
251  double windowZ = m_windowZ[0]; // default for all layers
252  // But if available pick up per-window values
253  if (m_windowR.size() > 1) {
254  windowR = m_windowR[layer-m_nLayers_1stStage]; // offset by n1st stage
255  }
256  if (m_windowZ.size() > 1) {
257  windowZ = m_windowZ[layer-m_nLayers_1stStage]; // offset by n1st stage
258  }
259 
260  // If last hit was not real and we want to, scale the window
261  if (m_missedHitRScaling > 0 && !lastHitWasReal) windowR *= m_missedHitRScaling;
262  if (m_missedHitZScaling > 0 && !lastHitWasReal) windowZ *= m_missedHitZScaling;
263 
264  // now scale windows for low pt, if desired
265  if (pt < m_lowPtValueForWindowRScaling.value()) windowR *= m_lowPtWindowRScaling.value();
266  if (pt < m_lowPtValueForWindowZScaling.value()) windowZ *= m_lowPtWindowZScaling.value();
267 
268  if (abs(hitr - predr) < windowR && abs(hitz - predz) < windowZ) {
269  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits {hit};
270  hitsInWindow = hitsInWindow + 1;
271  // 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
272  if(hit->isStrip()) {
273  if (hit->getHitType() == HitType::spacepoint) {
274  // find the hit in the next layer
275  if(!findHitinNextStripLayer(hit, hits, theseHits)) {
276  ATH_MSG_WARNING("For a SP in layer " << layer << " Couldn't find a matching strip SP");
277  }
278  }
279  else {
280  std::shared_ptr<FPGATrackSimHit> guessedSecondHitPtr = std::make_shared<FPGATrackSimHit>();
281  guessedSecondHitPtr->setX(0);
282  guessedSecondHitPtr->setY(0);
283  guessedSecondHitPtr->setZ(0);
284  guessedSecondHitPtr->setPhysLayer(lastHit->getPhysLayer(true)+1);
285  guessedSecondHitPtr->setHitType(HitType::undefined);
286  if(isFineIDInStrip(fineID)) guessedSecondHitPtr->setDetType(SiliconTech::strip);
287  else guessedSecondHitPtr->setDetType(SiliconTech::pixel);
288 
289  theseHits.push_back(guessedSecondHitPtr);
290  }
291  }
292  // Store the hits for now
293  listofHitsFound.push_back(theseHits);
294  }
295  }
296  }
297 
298  // Sort the hit by the distance
299  std::sort(listofHitsFound.begin(), listofHitsFound.end(), [&predhit](auto& a, auto& b){
300  double predr = sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
301  double predz = predhit[2];
302 
303  // HitA
304  double hitz = a[0]->getZ();
305  double hitr = a[0]->getR();
306  float distance_a = sqrt((hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz));
307 
308  // HitB
309  hitz = b[0]->getZ();
310  hitr = b[0]->getR();
311  float distance_b = sqrt((hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz));
312 
313  return distance_a < distance_b;
314  });
315 
316  // Select the top N hits
317  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> cleanHitsToGrow;
318 
319  // If max branches are limited, pick only the top N from the list of hits found at each level
320  if (m_maxBranches.value() >= 0) {
321  int nHitsToChoose = std::min(int(m_maxBranches.value()), int(listofHitsFound.size()));
322  cleanHitsToGrow.reserve(nHitsToChoose);
323  std::copy(listofHitsFound.begin(), listofHitsFound.begin() + nHitsToChoose, std::back_inserter(cleanHitsToGrow));
324  }
325  else {
326  cleanHitsToGrow = std::move(listofHitsFound);
327  }
328 
329 
330  for (auto& hitsFound: cleanHitsToGrow) {
331  // get the first hit
332  auto hit = hitsFound[0];
333 
334  // a hit is in the right fine ID == layer
335  double hitz = hit->getZ();
336  double hitr = hit->getR();
337  double predr = sqrt(predhit[0] * predhit[0] + predhit[1] * predhit[1]);
338  double predz = predhit[2];
339  float distancePredFound = sqrt((hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz));
340 
341  // We got a hit, lets make a road
342  miniRoad newRoad;
343  if(!addHitToRoad(newRoad, currentRoad, std::move(hitsFound))) {
344  ATH_MSG_WARNING("Failed to make a new road");
345  continue;
346  }
347  roadsToExtrapolate.push_back(newRoad);
348  foundhitForRoad = true;
349  tmp_currentRoadHitFineIDs.push_back(fineID);
350  tmp_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
351  tmp_currentRoadHitITkLayer.push_back(hit->getLayerDisk());
352  tmp_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
353  tmp_currentRoadHitDistancePredFound.push_back(distancePredFound);
354  tmp_foundHitDistancePredFound.push_back(tmp_currentRoadHitDistancePredFound);
355  if(m_debugEvent) {
356  ATH_MSG_DEBUG("------ road grown with hit from layer "<<layer<<" to");
357  printRoad(newRoad);
358  }
359  }
360  if (hitsInWindow != 0) m_nHitsInSearchWindow.push_back(hitsInWindow);
361  // If the hit wasn't found, push a fake hit
362  if (!foundhitForRoad) {
363  // 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
364  m_nHitsInSearchWindow.push_back(0);
365  if (currentRoad.getNWCLayers() >= m_maxMiss) {
366  // we don't want this road, so we continue
367  continue;
368  }
369  else {
370  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits;
371  // first make the fake hit that we will add
372  if (!getFakeHit(currentRoad, predhit, fineID, theseHits)) {
373  ATH_MSG_WARNING("Failed adding a guessed hit in extrapolation");
374  continue;
375  }
376 
377  if((isFineIDInPixel(fineID) && theseHits.size() != 1) || (isFineIDInStrip(fineID) && theseHits.size() != 2)) {
378  continue;
379  }
380  // add the hit to the road
381  miniRoad newroad;
382  if (!addHitToRoad(newroad, currentRoad, std::move(theseHits))) {
383  ATH_MSG_WARNING("Failed making a new road with fake hit");
384  continue;
385  }
386  roadsToExtrapolate.push_back(newroad);
387  tmp_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
388  tmp_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
389  tmp_foundHitDistancePredFound.push_back(tmp_currentRoadHitDistancePredFound);
390  }
391  }
392  }
393 
394  m_NcompletedRoads.push_back(completedRoads.size());
395  // This track has been extrapolated, copy the completed tracks to the full list with full road objects
396  for (const auto &miniroad : completedRoads) {
397  FPGATrackSimRoad road;
398  road.setWCLayers(miniroad.getWCLayers());
399  road.setHitLayers(miniroad.getHitLayers());
400  m_missingHitsOnRoad.push_back(miniroad.getNWCLayers());
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  currentRoadHitFineIDs.clear();
437  tmp_predictedHitsFineID.clear();
438  currentRoadHitITkLayer.clear();
439  tmp_foundHitITkLayer.clear();
440  currentRoadHitDistancePredFound.clear();
441  tmp_foundHitDistancePredFound.clear();
442  }
443 
444  // Copy the roads we found into the output argument and return success.
445  roads.reserve(m_roads.size());
446  for (FPGATrackSimRoad & r : m_roads)
447  {
448  if (r.getNWCLayers() >= m_maxMiss) continue; // extra check on this
449  roads.emplace_back(std::make_shared<const FPGATrackSimRoad>(r));
450  }
451  ATH_MSG_DEBUG("Found " << roads.size() << " new roads in second stage.");
452  m_tree->Fill();
453  m_NcompletedRoads.clear();
454  m_predictedHitsFineID.clear();
455  m_missingHitsOnRoad.clear();
456  m_nHitsInSearchWindow.clear();
458  m_foundHitITkLayer.clear();
459  m_foundHitIsSP.clear();
460  return StatusCode::SUCCESS;
461 }

◆ fillInputTensorForNN()

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

Definition at line 463 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

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

644 {
645  float EPSILON = 0.00001;
646  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hitList)
647  {
648  if (abs(hit->getX() - hitToSearch->getX()) < EPSILON && abs(hit->getY() - hitToSearch->getY()) < EPSILON && abs(hit->getZ() - hitToSearch->getZ()) < EPSILON)
649  {
650  hits.push_back(hit);
651  return StatusCode::SUCCESS;
652  }
653 
654  }
655 
656  ATH_MSG_WARNING("Didn't find a matching space point");
657 
658  return StatusCode::FAILURE;
659 }

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

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

◆ getLastLayer()

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

Definition at line 696 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

697 {
698  lastHitLayer = currentRoad.getNHits()-1;
699  lastHit = currentRoad.getHit(lastHitLayer);
700  return StatusCode::SUCCESS;
701 
702 }

◆ getPredictedHit()

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

Definition at line 562 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

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

◆ getXScale()

static float FPGATrackSimNNPathfinderExtensionTool::getXScale ( )
inlinestaticprivate

Definition at line 182 of file FPGATrackSimNNPathfinderExtensionTool.h.

182 { return 1015.;};

◆ getYScale()

static float FPGATrackSimNNPathfinderExtensionTool::getYScale ( )
inlinestaticprivate

Definition at line 183 of file FPGATrackSimNNPathfinderExtensionTool.h.

183 { return 1015.;};

◆ getZScale()

static float FPGATrackSimNNPathfinderExtensionTool::getZScale ( )
inlinestaticprivate

Definition at line 184 of file FPGATrackSimNNPathfinderExtensionTool.h.

184 { return 3000.;};

◆ initialize()

StatusCode FPGATrackSimNNPathfinderExtensionTool::initialize ( )
overridevirtual

Definition at line 21 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

21  {
22 
23  // Retrieve the mapping service.
24  ATH_CHECK(m_FPGATrackSimMapping.retrieve());
25 
26  m_nLayers_1stStage = m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers();
27  m_nLayers_2ndStage = m_FPGATrackSimMapping->PlaneMap_2nd(0)->getNLogiLayers() - m_nLayers_1stStage;
28 
29  if (m_windowR.size() != 1 && m_windowR.size() != m_nLayers_2ndStage) {
30  ATH_MSG_ERROR("Window r size = " << m_windowR << " is not equal to 1 (for all layers) and not equal to " << m_nLayers_2ndStage);
31  return StatusCode::FAILURE;
32  }
33 
34  if (m_windowZ.size() != 1 && m_windowZ.size() != m_nLayers_2ndStage) {
35  ATH_MSG_ERROR("Window z size = " << m_windowZ << " is not equal to 1 (for all layers) and not equal to " << m_nLayers_2ndStage);
36  return StatusCode::FAILURE;
37  }
38 
40 
41  if (m_FPGATrackSimMapping->getExtensionNNVolMapString() != "" && m_FPGATrackSimMapping->getExtensionNNHitMapString() != "") {
42  ATH_MSG_INFO("Initializing extension hit NN with string = " << m_FPGATrackSimMapping->getExtensionNNHitMapString());
43  m_extensionHitNN.initialize(m_FPGATrackSimMapping->getExtensionNNHitMapString());
44  ATH_MSG_INFO("Initializing volume NN with string = " << m_FPGATrackSimMapping->getExtensionNNVolMapString());
45  m_extensionVolNN.initialize(m_FPGATrackSimMapping->getExtensionNNVolMapString());
46  }
47  else {
48  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.");
49  return StatusCode::FAILURE;
50  }
51 
52  ATH_CHECK(m_tHistSvc.retrieve());
54 
55  return StatusCode::SUCCESS;
56 }

◆ printRoad()

void FPGATrackSimNNPathfinderExtensionTool::printRoad ( miniRoad currentRoad)
private

Definition at line 661 of file FPGATrackSimNNPathfinderExtensionTool.cxx.

662 {
663  if(!m_debugEvent) return;
664 
665  // print this road
666  if(m_debugEvent)
667  {
668  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsR;
669  for (auto &hit : currentRoad.getHits()) {
670  hitsR.push_back(hit);
671  }
672 
673  // If outside in, sort in increasing R, otherwise, decreasing R
674  if(m_doOutsideIn)
675  {
676  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
677  if(a->getR() == b->getR()) return a->getLayer() < b->getLayer();
678  return a->getR() < b->getR();
679  });
680  }
681  else
682  {
683  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
684  return a->getR() > b->getR();
685  });
686  }
687 
688  for (unsigned long i = 0; i < hitsR.size(); i++)
689  {
690  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());
691  }
692  }
693 
694 }

◆ 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_distanceOfPredictedHitToFoundHit

std::vector<std::vector<float> > FPGATrackSimNNPathfinderExtensionTool::m_distanceOfPredictedHitToFoundHit
private

Definition at line 174 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 164 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_foundHitIsSP

std::vector<std::vector<bool> > FPGATrackSimNNPathfinderExtensionTool::m_foundHitIsSP
private

Definition at line 175 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_foundHitITkLayer

std::vector<std::vector<unsigned int> > FPGATrackSimNNPathfinderExtensionTool::m_foundHitITkLayer
private

Definition at line 172 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_FPGATrackSimMapping

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

Definition at line 145 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 157 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 159 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 158 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 160 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 163 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_maxMiss

unsigned FPGATrackSimNNPathfinderExtensionTool::m_maxMiss = 0
private

Definition at line 180 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 161 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 162 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_missingHitsOnRoad

std::vector<unsigned int> FPGATrackSimNNPathfinderExtensionTool::m_missingHitsOnRoad
private

Definition at line 170 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_NcompletedRoads

std::vector<unsigned long> FPGATrackSimNNPathfinderExtensionTool::m_NcompletedRoads
private

Definition at line 169 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_nHitsInSearchWindow

std::vector<unsigned int> FPGATrackSimNNPathfinderExtensionTool::m_nHitsInSearchWindow
private

Definition at line 173 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_nLayers_1stStage

unsigned FPGATrackSimNNPathfinderExtensionTool::m_nLayers_1stStage = 0
private

Definition at line 178 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_nLayers_2ndStage

unsigned FPGATrackSimNNPathfinderExtensionTool::m_nLayers_2ndStage = 0
private

Definition at line 179 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_predictedHitsFineID

std::vector<std::vector<unsigned long> > FPGATrackSimNNPathfinderExtensionTool::m_predictedHitsFineID
private

Definition at line 171 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 165 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_roads

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

Definition at line 177 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_threshold

Gaudi::Property<int> FPGATrackSimNNPathfinderExtensionTool::m_threshold { this, "threshold", 10, "Minimum number of hits to fire a road"}
private

Definition at line 149 of file FPGATrackSimNNPathfinderExtensionTool.h.

◆ m_tree

TTree* FPGATrackSimNNPathfinderExtensionTool::m_tree = nullptr
private

Definition at line 168 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:643
OnnxRuntimeBase::runONNXInference
std::vector< float > runONNXInference(std::vector< float > &inputTensorValues) const
Definition: OnnxRuntimeBase.cxx:66
beamspotman.r
def r
Definition: beamspotman.py:676
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
FPGATrackSimNNPathfinderExtensionTool::m_missingHitsOnRoad
std::vector< unsigned int > m_missingHitsOnRoad
Definition: FPGATrackSimNNPathfinderExtensionTool.h:170
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
SiliconTech::strip
@ strip
FPGATrackSimNNPathfinderExtensionTool::m_missedHitRScaling
Gaudi::Property< float > m_missedHitRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:161
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimNNPathfinderExtensionTool::m_tree
TTree * m_tree
Definition: FPGATrackSimNNPathfinderExtensionTool.h:168
FPGATrackSimNNPathfinderExtensionTool::m_doOutsideIn
Gaudi::Property< bool > m_doOutsideIn
Definition: FPGATrackSimNNPathfinderExtensionTool.h:164
FPGATrackSimNNPathfinderExtensionTool::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: FPGATrackSimNNPathfinderExtensionTool.h:146
FPGATrackSimNNPathfinderExtensionTool::printRoad
void printRoad(miniRoad &currentRoad)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:661
OnnxRuntimeBase::initialize
void initialize(TString)
Definition: OnnxRuntimeBase.cxx:16
FPGATrackSimNNPathfinderExtensionTool::getYScale
static float getYScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:183
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:140
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:178
miniRoad::getNHits
unsigned getNHits() const
Definition: FPGATrackSimNNPathfinderExtensionTool.h:65
HitType::spacepoint
@ spacepoint
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:138
FPGATrackSimNNPathfinderExtensionTool::getXScale
static float getXScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:182
HitType::guessed
@ guessed
FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowRScaling
Gaudi::Property< float > m_lowPtWindowRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:158
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:696
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
FPGATrackSimNNPathfinderExtensionTool::m_nLayers_2ndStage
unsigned m_nLayers_2ndStage
Definition: FPGATrackSimNNPathfinderExtensionTool.h:179
FPGATrackSimNNPathfinderExtensionTool::m_foundHitITkLayer
std::vector< std::vector< unsigned int > > m_foundHitITkLayer
Definition: FPGATrackSimNNPathfinderExtensionTool.h:172
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
EPSILON
constexpr float EPSILON
Definition: FPGATrackSimHoughFunctions.cxx:13
HitType::wildcard
@ wildcard
FPGATrackSimNNPathfinderExtensionTool::m_NcompletedRoads
std::vector< unsigned long > m_NcompletedRoads
Definition: FPGATrackSimNNPathfinderExtensionTool.h:169
FPGATrackSimNNPathfinderExtensionTool::m_roads
std::vector< FPGATrackSimRoad > m_roads
Definition: FPGATrackSimNNPathfinderExtensionTool.h:177
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:137
FPGATrackSimNNPathfinderExtensionTool::m_foundHitIsSP
std::vector< std::vector< bool > > m_foundHitIsSP
Definition: FPGATrackSimNNPathfinderExtensionTool.h:175
FPGATrackSimNNPathfinderExtensionTool::m_nHitsInSearchWindow
std::vector< unsigned int > m_nHitsInSearchWindow
Definition: FPGATrackSimNNPathfinderExtensionTool.h:173
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimNNPathfinderExtensionTool::m_maxBranches
Gaudi::Property< int > m_maxBranches
Definition: FPGATrackSimNNPathfinderExtensionTool.h:163
FPGATrackSimNNPathfinderExtensionTool::getZScale
static float getZScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:184
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:562
FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowZScaling
Gaudi::Property< float > m_lowPtValueForWindowZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:159
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
getFineID
long getFineID(const FPGATrackSimHit &hit)
Definition: FPGATrackSimHoughFunctions.cxx:532
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:157
FPGATrackSimNNPathfinderExtensionTool::m_windowR
Gaudi::Property< std::vector< float > > m_windowR
Definition: FPGATrackSimNNPathfinderExtensionTool.h:155
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:141
FPGATrackSimHit::setPhysLayer
void setPhysLayer(unsigned v)
Definition: FPGATrackSimHit.cxx:55
FPGATrackSimNNPathfinderExtensionTool::m_extensionVolNN
OnnxRuntimeBase m_extensionVolNN
Definition: FPGATrackSimNNPathfinderExtensionTool.h:191
FPGATrackSimNNPathfinderExtensionTool::m_threshold
Gaudi::Property< int > m_threshold
Definition: FPGATrackSimNNPathfinderExtensionTool.h:149
FPGATrackSimNNPathfinderExtensionTool::m_distanceOfPredictedHitToFoundHit
std::vector< std::vector< float > > m_distanceOfPredictedHitToFoundHit
Definition: FPGATrackSimNNPathfinderExtensionTool.h:174
FPGATrackSimNNPathfinderExtensionTool::addHitToRoad
StatusCode addHitToRoad(miniRoad &newroad, miniRoad &currentRoad, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:580
miniRoad::getNWCLayers
size_t getNWCLayers() const
Definition: FPGATrackSimNNPathfinderExtensionTool.h:73
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:142
miniRoad::setHits
void setHits(std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.h:100
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
FPGATrackSimNNPathfinderExtensionTool::m_extensionHitNN
OnnxRuntimeBase m_extensionHitNN
Definition: FPGATrackSimNNPathfinderExtensionTool.h:192
isFineIDInPixel
bool isFineIDInPixel(long ID)
Definition: FPGATrackSimHoughFunctions.cxx:527
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:96
miniRoad::getHits
std::vector< std::shared_ptr< const FPGATrackSimHit > > & getHits()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:50
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:139
FPGATrackSimNNPathfinderExtensionTool::fillInputTensorForNN
StatusCode fillInputTensorForNN(miniRoad &thisRoad, std::vector< float > &inputTensorValues)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:463
FPGATrackSimHit::getR
float getR() const
Definition: FPGATrackSimHit.h:143
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
FPGATrackSimNNPathfinderExtensionTool::m_predictedHitsFineID
std::vector< std::vector< unsigned long > > m_predictedHitsFineID
Definition: FPGATrackSimNNPathfinderExtensionTool.h:171
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:160
FPGATrackSimNNPathfinderExtensionTool::m_predictionWindowLength
Gaudi::Property< int > m_predictionWindowLength
Definition: FPGATrackSimNNPathfinderExtensionTool.h:165
FPGATrackSimRegionMap::getNRegions
int getNRegions() const
Definition: FPGATrackSimRegionMap.h:80
FPGATrackSimRegionMap
Definition: FPGATrackSimRegionMap.h:62
FPGATrackSimRoad::setY
void setY(float v)
Definition: FPGATrackSimRoad.h:78
FPGATrackSimRoad::setRoadID
void setRoadID(int roadID)
Definition: FPGATrackSimRoad.h:58
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:27
FPGATrackSimNNPathfinderExtensionTool::bookTree
StatusCode bookTree()
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:58
FPGATrackSimNNPathfinderExtensionTool::m_windowZ
Gaudi::Property< std::vector< float > > m_windowZ
Definition: FPGATrackSimNNPathfinderExtensionTool.h:156
isFineIDInStrip
bool isFineIDInStrip(long ID)
Definition: FPGATrackSimHoughFunctions.cxx:522
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_maxMiss
unsigned m_maxMiss
Definition: FPGATrackSimNNPathfinderExtensionTool.h:180
FPGATrackSimNNPathfinderExtensionTool::m_missedHitZScaling
Gaudi::Property< float > m_missedHitZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:162
SiliconTech::pixel
@ pixel
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
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:587
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
FPGATrackSimRoad::setXBin
void setXBin(unsigned v)
Definition: FPGATrackSimRoad.h:75