Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FPGATrackSimNNPathfinderExtensionTool.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 
13 
14 
16 
17 #include <cmath>
18 #include <algorithm>
19 
20 FPGATrackSimNNPathfinderExtensionTool::FPGATrackSimNNPathfinderExtensionTool(const std::string& algname, const std::string &name, const IInterface *ifc) :
21  base_class(algname, name, ifc) {
22  declareInterface<IFPGATrackSimTrackExtensionTool>(this);
23  }
24 
25 
27 
28  // Retrieve the mapping service.
29  ATH_CHECK(m_FPGATrackSimMapping.retrieve());
30 
31  m_nLayers_1stStage = m_FPGATrackSimMapping->PlaneMap_1st(0)->getNLogiLayers();
32  m_nLayers_2ndStage = m_FPGATrackSimMapping->PlaneMap_2nd(0)->getNLogiLayers() - m_nLayers_1stStage;
33 
34  if (m_windowR.size() != 1 && m_windowR.size() != m_nLayers_2ndStage) {
35  ATH_MSG_ERROR("Window r size = " << m_windowR << " is not equal to 1 (for all layers) and not equal to " << m_nLayers_2ndStage);
36  return StatusCode::FAILURE;
37  }
38 
39  if (m_windowZ.size() != 1 && m_windowZ.size() != m_nLayers_2ndStage) {
40  ATH_MSG_ERROR("Window z size = " << m_windowZ << " is not equal to 1 (for all layers) and not equal to " << m_nLayers_2ndStage);
41  return StatusCode::FAILURE;
42  }
43 
44 
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  // This now needs to be done once for each slice.
59  for (size_t j=0; j<m_FPGATrackSimMapping->GetPlaneMap_2ndSliceSize(); j++){
60  ATH_MSG_INFO("Processing second stage slice " << j);
61  m_phits_atLayer[j] = std::map<unsigned, std::vector<std::shared_ptr<const FPGATrackSimHit>>>();
62  for (unsigned i = m_nLayers_1stStage; i < m_nLayers_2ndStage +m_nLayers_1stStage ; i++) {
63  ATH_MSG_INFO("Processing layer " << i);
64  m_phits_atLayer[j][i] = std::vector<std::shared_ptr<const FPGATrackSimHit>>();
65  }
66  }
67  ATH_CHECK(m_tHistSvc.retrieve());
69 
70  return StatusCode::SUCCESS;
71 }
72 
74 {
75  m_tree = new TTree("NNPathFinderMonitoring","NNPathFinderMonitoring");
76  m_tree->Branch("NcompletedRoads", &m_NcompletedRoads);
77  m_tree->Branch("predictedHitsFineID", &m_predictedHitsFineID);
78  m_tree->Branch("foundHitITkLayer", &m_foundHitITkLayer);
79  m_tree->Branch("missingHitsOnRoad", &m_missingHitsOnRoad);
80  m_tree->Branch("nHitsInSearchWindow", &m_nHitsInSearchWindow);
81  m_tree->Branch("distanceOfPredictedHitToFoundHit", &m_distanceOfPredictedHitToFoundHit);
82  m_tree->Branch("foundHitIsSP", &m_foundHitIsSP);
83 
84  ATH_CHECK(m_tHistSvc->regTree(Form("/FPGATRACKSIMOUTPUTNNPATHFINDER/%s", m_tree->GetName()), m_tree));
85 
86  return StatusCode::SUCCESS;
87 }
88 
89 
90 StatusCode FPGATrackSimNNPathfinderExtensionTool::extendTracks(const std::vector<std::shared_ptr<const FPGATrackSimHit>> & hits,
91  const std::vector<std::shared_ptr<const FPGATrackSimTrack>> & tracks,
92  std::vector<std::shared_ptr<const FPGATrackSimRoad>> & roads) {
93 
94  // Reset the internal second stage roads storage.
95  roads.clear();
96  m_roads.clear();
97  for (auto& sliceEntry : m_phits_atLayer){
98  for (auto& entry : sliceEntry.second) {
99  entry.second.clear();
100  }
101  }
102  const FPGATrackSimRegionMap* rmap_2nd = m_FPGATrackSimMapping->SubRegionMap_2nd();
103  const FPGATrackSimPlaneMap *pmap_2nd = nullptr;
104 
105  // Create one "tower" per slice for this event.
106  // Note that there now might be only one "slice", at least for the time being.
107  if (m_slicedHitHeader) {
108  for (int ireg = 0; ireg < rmap_2nd->getNRegions(); ireg++) {
110  m_slicedHitHeader->addTower(tower);
111  }
112  }
113 
114  // Second stage hits may be unmapped, in which case map them.
115  // For now allow mapping into all subregions, may not be necessary in the future
116  for (size_t i=0; i<m_FPGATrackSimMapping->GetPlaneMap_2ndSliceSize(); i++){
117  pmap_2nd = m_FPGATrackSimMapping->PlaneMap_2nd(i);
118  for (const std::shared_ptr<const FPGATrackSimHit>& hit : hits) {
119  std::shared_ptr<FPGATrackSimHit> hitCopy = std::make_shared<FPGATrackSimHit>(*hit);
120  pmap_2nd->map(*hitCopy);
121  if (!hitCopy->isMapped()){
122  continue;
123  }
124  if (rmap_2nd->isInRegion(i, *hitCopy)) {
125  m_phits_atLayer[i][hitCopy->getLayer()].push_back(hitCopy);
126  // Also store a copy of the hit object in the header class, for ROOT Output + TV creation.
128  }
129  }
130  }
131 
132  if(m_debugEvent) ATH_MSG_DEBUG("Got: "<<tracks.size()<<" tracks to extrapolate");
133 
134  // Now, loop over the tracks.
135  for (std::shared_ptr<const FPGATrackSimTrack> track : tracks)
136  {
137 
138  if(m_debugEvent) ATH_MSG_DEBUG("\033[1;31m-------------------------- extraploating Track ------------------ \033[0m");
139 
140  if (track->passedOR() == 0) {
141  continue;
142  }
143 
144  const std::vector<FPGATrackSimHit> hitsOnTrack = track->getFPGATrackSimHits();
145 
146  FPGATrackSimRoad road;
148 
149 
150  size_t slice = track->getSubRegion();
151  float pt = track->getPt();
152  layer_bitmask_t hitLayers = 0;
153  layer_bitmask_t wcLayers = 0;
154  // Loop over all hits
155 
156  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> road_hits;
157  road_hits.resize(m_nLayers_1stStage + m_nLayers_2ndStage);
158  for (auto &thit : hitsOnTrack)
159  {
160  // Don't care about wildcard hits in extrapolation
161  if(thit.getHitType() == HitType::wildcard) continue;
162 
163  // add this hit to the road, start with all of them
164  road_hits[thit.getLayer()].push_back(std::make_shared<const FPGATrackSimHit>(thit));
165  if (thit.isReal()) hitLayers |= 1 << thit.getLayer();
166  else wcLayers |= 1 << thit.getLayer();
167  }
168 
169  road.setHits(std::move(road_hits));
170  road.setHitLayers(hitLayers);
171  road.setWCLayers(wcLayers);
172 
173 
174  if(m_debugEvent)
175  {
176  ATH_MSG_DEBUG("-----------------Hits in event");
178  {
179  for (const std::shared_ptr<const FPGATrackSimHit>& hit: m_phits_atLayer[slice][layer])
180  {
181  ATH_MSG_DEBUG("Hit "<<" X: "<<hit->getX()<<" Y: "<<hit->getY()<<" Z: "<<hit->getZ()<<" R: "<<hit->getR()<<" layer: "<<hit->getLayer()<<" hitType: "<<hit->getHitType()<<" getDetType: "<<hit->getDetType());
182  }
183  }
184  }
185 
186  std::vector<FPGATrackSimRoad> roadsToExtrapolate;
187  roadsToExtrapolate.push_back(road);
188 
189  std::vector<FPGATrackSimRoad> completedRoads;
190 
191  std::vector<unsigned long> currentRoadHitFineIDs;
192  std::vector<std::vector<unsigned long>> tmp_predictedHitsFineID;
193 
194  std::vector<unsigned int> currentRoadHitITkLayer;
195  std::vector<std::vector<unsigned int>> tmp_foundHitITkLayer;
196 
197  std::vector<float> currentRoadHitDistancePredFound;
198  std::vector<std::vector<float>> tmp_foundHitDistancePredFound;
199 
200 
201  for (unsigned int i = 0; i < roadsToExtrapolate.size(); i++){
202  tmp_predictedHitsFineID.push_back(currentRoadHitFineIDs);
203  tmp_foundHitITkLayer.push_back(currentRoadHitITkLayer);
204  tmp_foundHitDistancePredFound.push_back(currentRoadHitDistancePredFound);
205  }
206 
207 
208  int count = 0;
209 
210  while(roadsToExtrapolate.size() > 0)
211  {
212  FPGATrackSimRoad currentRoad = *roadsToExtrapolate.begin();
213  std::vector<unsigned long> tmp_currentRoadHitFineIDs = *tmp_predictedHitsFineID.begin();
214  std::vector<unsigned int> tmp_currentRoadHitITkLayer = *tmp_foundHitITkLayer.begin();
215  std::vector<float> tmp_currentRoadHitDistancePredFound = *tmp_foundHitDistancePredFound.begin();
216  // Erase this road from the vector
217  roadsToExtrapolate.erase(roadsToExtrapolate.begin());
218  tmp_predictedHitsFineID.erase(tmp_predictedHitsFineID.begin());
219  tmp_foundHitITkLayer.erase(tmp_foundHitITkLayer.begin());
220  tmp_foundHitDistancePredFound.erase(tmp_foundHitDistancePredFound.begin());
221 
222  count ++;
223 
224  if(m_debugEvent) ATH_MSG_DEBUG("\033[1;31m-------------------------- extraploating road "<< count << "------------------ \033[0m");
225  printRoad(currentRoad);
226 
227 
228 
229  // Check exit condition
230  if (currentRoad.getHits_flat().size() >= (m_nLayers_1stStage+m_nLayers_2ndStage))
231  {
232  completedRoads.push_back(currentRoad);
233  m_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
234  m_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
235  m_distanceOfPredictedHitToFoundHit.push_back(tmp_currentRoadHitDistancePredFound);
236  continue; // this one is done
237  }
238 
239  // Other try to find the next hit in this road
240  std::vector<float> inputTensorValues;
241  if(!fillInputTensorForNN(currentRoad, inputTensorValues))
242  {
243  ATH_MSG_WARNING("Failed to create input tensor for this road");
244  continue;
245  }
246 
247 
248  std::vector<float> predhit;
249  long fineID;
250  if(!getPredictedHit(inputTensorValues, predhit, fineID))
251  {
252  ATH_MSG_WARNING("Failed to predict hit for this road");
253  continue;
254  }
255 
256  // Check if exist conditions are there
257  if(m_doOutsideIn)
258  {
259  // Make sure we are not predicting inside the inner most layer (x and y < 25)
260  // If we are, road is done
261  if (abs(predhit[0]) < 25 && abs(predhit[1]) < 25)
262  {
263  completedRoads.push_back(currentRoad);
264  m_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
265  m_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
266  m_distanceOfPredictedHitToFoundHit.push_back(tmp_currentRoadHitDistancePredFound);
267  continue;
268  }
269  }
270  else
271  {
272  // Make sure we are not predicting outside the outer most layer
273  // if we are, road is done
274  double rad = std::sqrt(std::pow(predhit[0], 2) + std::pow(predhit[1], 2));
275  if (abs(predhit[0]) > 1024 || abs(predhit[1]) > 1024 || rad > 1024 || abs(predhit[2]) > 3000)
276  {
277  completedRoads.push_back(currentRoad);
278  m_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
279  m_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
280  m_distanceOfPredictedHitToFoundHit.push_back(tmp_currentRoadHitDistancePredFound);
281  continue;
282  }
283  }
284 
285  if(m_debugEvent)
286  {
287  ATH_MSG_DEBUG("Predicted hit at: "<<predhit[0]<<" "<<predhit[1]<<" "<<predhit[2]);
288  }
289 
290  // Now search for the hits
291  bool foundhitForRoad = false;
292  bool skipSPInNextLayer = false;
293 
294  if(fineID == 215){
295  ATH_MSG_DEBUG("Stopping condition reached");
296  completedRoads.push_back(currentRoad);
297  break;
298  }
299 
300  // Get the last layer in the road. And only check layers above that
301  unsigned lastLayerInRoad = 0;
302  std::shared_ptr<const FPGATrackSimHit> lastHit;
303  if(!getLastLayer(currentRoad, lastLayerInRoad, lastHit) or !lastHit)
304  {
305  ATH_MSG_WARNING("Failed to find last layer this road");
306  continue;
307  }
308 
309  bool lastHitWasReal = lastHit->isReal();
310 
311  // if the last layer is m_nLayers_1stStage + m_nLayers_2ndStage, then we have hit the end already
312  if((lastLayerInRoad + 1) >= m_nLayers_1stStage + m_nLayers_2ndStage)
313  {
314  completedRoads.push_back(currentRoad);
315  continue;
316  }
317 
319  {
320  // Local var for the internal loop
321  bool skipSP = false;
322  // loop over layers, probably only one will be found
323  if(skipSPInNextLayer)
324  {
325  skipSP = true;
326  skipSPInNextLayer = false;
327  }
328  // Only check the layers above the last layer in the road
329  if(layer <= lastLayerInRoad)
330  {
331  continue;
332  }
333  unsigned int hitsInWindow = 0;
334 
335  // List of all the hits, with their distances to the predicted point
336  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> listofHitsFound;
337 
338  for (const std::shared_ptr<const FPGATrackSimHit>& hit: m_phits_atLayer[slice][layer])
339  {
340  if(skipSP && hit->isStrip() && hit->getHitType() == HitType::spacepoint) continue;
341 
342  // loop over hits in that layer
343  if (getFineID(*hit) == fineID && hit->isReal())
344  {
345  // a hit is in the right fine ID == layer
346  double hitz = hit->getZ();
347  double hitr = hit->getR();
348  double predr = sqrt(predhit[0]*predhit[0] + predhit[1] * predhit[1]);
349  double predz = predhit[2];
350  double windowR = m_windowR[0]; // default for all layers
351  double windowZ = m_windowZ[0]; // default for all layers
352 
353  // But if available pick up per-window values
354  if (m_windowR.size() > 1) {
355  windowR = m_windowR[layer-m_nLayers_1stStage]; // offset by n1st stage
356  }
357  if (m_windowZ.size() > 1) {
358  windowZ = m_windowZ[layer-m_nLayers_1stStage]; // offset by n1st stage
359  }
360 
361  // If last hit was not real and we want to, scale the window
362  if (m_missedHitRScaling > 0 && !lastHitWasReal) windowR *= m_missedHitRScaling;
363  if (m_missedHitZScaling > 0 && !lastHitWasReal) windowZ *= m_missedHitZScaling;
364 
365  // now scale windows for low pt, if desired
366  if (pt < m_lowPtValueForWindowRScaling.value()) windowR *= m_lowPtWindowRScaling.value();
367  if (pt < m_lowPtValueForWindowZScaling.value()) windowZ *= m_lowPtWindowZScaling.value();
368 
369  if (abs(hitr - predr) < windowR && abs(hitz - predz) < windowZ)
370  {
371  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits {hit};
372  hitsInWindow = hitsInWindow + 1;
373 
374  // If the hit is a space point, skip the next layer, as it will be duplicated space point and we have already taken care of that in the adding of the hits
375  if(hit->isStrip())
376  {
377  // If we are in odd layer, the corresponding surface is +1
378  // if we are in an even layer, the corresponsding surface is at -1
379  int layerToCheck = layer + 1;
380  if((layer % 2) == 0) layerToCheck = layer - 1;
381 
382  if (hit->getHitType() == HitType::spacepoint) {
383  skipSPInNextLayer = true;
384  // find the hit in the next layer
385  if(!findHitinNextStripLayer(hit, m_phits_atLayer[slice][layerToCheck], theseHits))
386  {
387  ATH_MSG_WARNING("For a SP in layer "<<layer<<" Couldn't find a matching strip SP in layer "<<layerToCheck);
388  }
389  }
390  else {
391  std::shared_ptr<FPGATrackSimHit> guessedSecondHitPtr = std::make_shared<FPGATrackSimHit>();
392  guessedSecondHitPtr->setX(0);
393  guessedSecondHitPtr->setY(0);
394  guessedSecondHitPtr->setZ(0);
395  guessedSecondHitPtr->setLayer(layerToCheck);
396  guessedSecondHitPtr->setHitType(HitType::undefined);
397  if(isFineIDInStrip(fineID)) guessedSecondHitPtr->setDetType(SiliconTech::strip);
398  else guessedSecondHitPtr->setDetType(SiliconTech::pixel);
399 
400  theseHits.push_back(guessedSecondHitPtr);
401  }
402  }
403  // Store the hits for now
404  listofHitsFound.push_back(theseHits);
405  }
406  }
407  }
408 
409  // Sort the hit by the distance
410  std::sort(listofHitsFound.begin(), listofHitsFound.end(), [&predhit](auto& a, auto& b){
411  double predr = sqrt(predhit[0]*predhit[0] + predhit[1] * predhit[1]);
412  double predz = predhit[2];
413 
414  // HitA
415  double hitz = a[0]->getZ();
416  double hitr = a[0]->getR();
417  float distance_a= sqrt((hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz));
418 
419  // HitB
420  hitz = b[0]->getZ();
421  hitr = b[0]->getR();
422  float distance_b= sqrt((hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz));
423 
424  return distance_a < distance_b;
425  });
426 
427  // Select the top N hits
428  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> cleanHitsToGrow;
429 
430  // If max branches are limited, pick only the top N from the list of hits found at each level
431  if (m_maxBranches.value() >= 0)
432  {
433  int nHitsToChoose = std::min(int(m_maxBranches.value()), int(listofHitsFound.size()));
434  cleanHitsToGrow.reserve(nHitsToChoose);
435  std::copy(listofHitsFound.begin(), listofHitsFound.begin() + nHitsToChoose, std::back_inserter(cleanHitsToGrow));
436  }
437  else
438  {
439  cleanHitsToGrow = std::move(listofHitsFound);
440  }
441 
442 
443  for (auto& hitsFound: cleanHitsToGrow)
444  {
445  // get the first hit
446  auto hit = hitsFound[0];
447 
448  // a hit is in the right fine ID == layer
449  double hitz = hit->getZ();
450  double hitr = hit->getR();
451  double predr = sqrt(predhit[0]*predhit[0] + predhit[1] * predhit[1]);
452  double predz = predhit[2];
453  float distancePredFound = sqrt((hitr - predr)*(hitr - predr) + (hitz - predz)*(hitz - predz));
454 
455  // We got a hit, lets make a road
456  FPGATrackSimRoad newroad;
457  if(!addHitToRoad(newroad, currentRoad, std::move(hitsFound)))
458  {
459  ATH_MSG_WARNING("Failed to make a new road");
460  continue;
461  }
462 
463  roadsToExtrapolate.push_back(newroad);
464  foundhitForRoad = true;
465  tmp_currentRoadHitFineIDs.push_back(fineID);
466  tmp_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
467  tmp_currentRoadHitITkLayer.push_back(hit->getLayerDisk());
468  tmp_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
469  tmp_currentRoadHitDistancePredFound.push_back(distancePredFound);
470  tmp_foundHitDistancePredFound.push_back(tmp_currentRoadHitDistancePredFound);
471 
472  if(m_debugEvent)
473  {
474  ATH_MSG_DEBUG("------ road grown with hit from layer "<<layer<<" to");
475  printRoad(newroad);
476  }
477  }
478 
479  if (hitsInWindow != 0) m_nHitsInSearchWindow.push_back(hitsInWindow);
480  }
481  // If the hit wasn't found, push a fake hit
482  if (!foundhitForRoad)
483  {
484 
485  // 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
486  m_nHitsInSearchWindow.push_back(0);
487  if (currentRoad.getNWCLayers() >= m_maxMiss)
488  {
489  // we don't want this road, so we continue
490  continue;
491  }
492  else
493  {
494  std::vector<std::shared_ptr<const FPGATrackSimHit>> theseHits;
495  // first make the fake hit that we will add
496  if (!getFakeHit(currentRoad, slice, predhit, fineID, theseHits)) {
497  ATH_MSG_WARNING("Failed adding a guessed hit in extrapolation");
498  continue;
499  }
500 
501  if((isFineIDInPixel(fineID) && theseHits.size() != 1) || (isFineIDInStrip(fineID) && theseHits.size() != 2))
502  {
503  continue;
504  }
505 
506  // add the hit to the road
507  FPGATrackSimRoad newroad;
508 
509  if (!addHitToRoad(newroad, currentRoad, std::move(theseHits))) {
510  ATH_MSG_WARNING("Failed making a new road with fake hit");
511  continue;
512  }
513  roadsToExtrapolate.push_back(newroad);
514  tmp_predictedHitsFineID.push_back(tmp_currentRoadHitFineIDs);
515  tmp_foundHitITkLayer.push_back(tmp_currentRoadHitITkLayer);
516  tmp_foundHitDistancePredFound.push_back(tmp_currentRoadHitDistancePredFound);
517  }
518  }
519  }
520 
521  m_NcompletedRoads.push_back(completedRoads.size());
522  // This track has been extrapolated, copy the completed tracks to the full list
523  for (auto road : completedRoads) {
524 
525  m_missingHitsOnRoad.push_back(road.getNWCLayers());
526  road.setRoadID(roads.size() - 1);
527  // Set the "Hough x" and "Hough y" using the track parameters.
528  road.setX(track->getPhi());
529  road.setY(track->getQOverPt());
530  road.setXBin(track->getHoughXBin());
531  road.setYBin(track->getHoughYBin());
532  road.setSubRegion(track->getSubRegion());
533  m_roads.push_back(road);
534  }
535  currentRoadHitFineIDs.clear();
536  tmp_predictedHitsFineID.clear();
537  currentRoadHitITkLayer.clear();
538  tmp_foundHitITkLayer.clear();
539  currentRoadHitDistancePredFound.clear();
540  tmp_foundHitDistancePredFound.clear();
541  }
542 
543  // Copy the roads we found into the output argument and return success.
544  roads.reserve(m_roads.size());
545  for (FPGATrackSimRoad & r : m_roads)
546  {
547 
548  if (r.getNWCLayers() >= m_maxMiss) continue; // extra check on this
549  roads.emplace_back(std::make_shared<const FPGATrackSimRoad>(r));
550  }
551  ATH_MSG_DEBUG("Found " << roads.size() << " new roads in second stage.");
552 
553  m_tree->Fill();
554  m_NcompletedRoads.clear();
555  m_predictedHitsFineID.clear();
556  m_missingHitsOnRoad.clear();
557  m_nHitsInSearchWindow.clear();
559  m_foundHitITkLayer.clear();
560  m_foundHitIsSP.clear();
561 
562  return StatusCode::SUCCESS;
563 }
564 
566 {
567  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsR;
568 
569  for (auto &hit : thisroad.getHits_flat()) {
570  hitsR.push_back(hit);
571  }
572 
573  // Sort in increasing R. We will reverise it for inside out after the cleanup
574  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
575  if(a->getLayer() == b->getLayer()) return a->getR() < b->getR();
576  return a->getLayer() < b->getLayer();
577  });
578 
579 
580  if(m_debugEvent) ATH_MSG_DEBUG("hitsR");
581  for (auto thit : hitsR)
582  {
583  if(m_debugEvent) ATH_MSG_DEBUG(thit->getX()<<" "<<thit->getY()<<" "<<thit->getZ());
584  }
585 
586  // Remove all the duplicate space points
587  std::vector<std::shared_ptr<const FPGATrackSimHit>> cleanHits;
588  bool skipHit = false;
589  for (auto thit : hitsR)
590  {
591  if(skipHit)
592  {
593  skipHit = false;
594  continue;
595  }
596  if (thit->isPixel())
597  {
598  cleanHits.push_back(thit);
599  }
600  else if (thit->isStrip() && (thit->getHitType() == HitType::spacepoint))
601  {
602  // This is a proper strips SP, push the first hit back and skip the next one since its a duplicate
603  cleanHits.push_back(thit);
604  skipHit = true;
605  }
606  else if (thit->isStrip() && (thit->getHitType() == HitType::guessed))
607  {
608  // this is a guessed strip SP, push the first hit back and skip the next one since its a duplicate
609  cleanHits.push_back(thit);
610  skipHit = true;
611  }
612  else if (thit->isStrip() && (thit->getHitType() == HitType::undefined))
613  {
614  // this is a fake hit, inserted for a unpaired SP, continue
615  continue;
616  }
617  else if (thit->isStrip() && thit->isReal())
618  {
619  // What is left here is a unpaired hit, push it back
620  cleanHits.push_back(thit);
621  }
622  else
623  {
624  ATH_MSG_WARNING("No clue how to deal with this hit in the NN predicition ");
625  continue;
626  }
627  }
628 
629  // Reverse the hits as we changed the ordering before
630  if(!m_doOutsideIn)
631  {
632  std::reverse(cleanHits.begin(), cleanHits.end());
633  }
634 
635  // Select the top N hits
636  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsToEncode;
637  std::copy(cleanHits.begin(), cleanHits.begin() + m_predictionWindowLength, std::back_inserter(hitsToEncode));
638 
639  if(m_debugEvent) ATH_MSG_DEBUG("Clean hits");
640  for (auto thit : cleanHits)
641  {
642  if(m_debugEvent) ATH_MSG_DEBUG(thit->getX()<<" "<<thit->getY()<<" "<<thit->getZ()<<" "<<thit->isStrip());
643  }
644 
645  // Reverse this vector so we can encode it the format as expected from the NN
646  std::reverse(hitsToEncode.begin(), hitsToEncode.end());
647 
648  if(m_debugEvent) ATH_MSG_DEBUG("Input for NN prediction");
649  for (auto thit : hitsToEncode)
650  {
651  inputTensorValues.push_back(thit->getX()/ getXScale());
652  inputTensorValues.push_back(thit->getY()/ getYScale());
653  inputTensorValues.push_back(thit->getZ()/ getZScale());
654 
655  if(m_debugEvent) ATH_MSG_DEBUG(thit->getX()<<" "<<thit->getY()<<" "<<thit->getZ());
656  }
657 
658  return StatusCode::SUCCESS;
659 
660 }
661 
662 
663 StatusCode FPGATrackSimNNPathfinderExtensionTool::getPredictedHit(std::vector<float>& inputTensorValues, std::vector<float>& outputTensorValues, long& fineID)
664 {
665  std::vector<float> NNVoloutput = m_extensionVolNN.runONNXInference(inputTensorValues);
666  fineID = std::distance(NNVoloutput.begin(),std::max_element(NNVoloutput.begin(), NNVoloutput.end()));
667 
668  // Insert the output for the second stage NN
669  inputTensorValues.insert(inputTensorValues.end(), NNVoloutput.begin(), NNVoloutput.end()); //now we append the first NN to the list of coordinates
670 
671  // use the above to predict the next hit position
672  outputTensorValues = m_extensionHitNN.runONNXInference(inputTensorValues);
673 
674  // now scale back
675  outputTensorValues[0] *= getXScale();
676  outputTensorValues[1] *= getYScale();
677  outputTensorValues[2] *= getZScale();
678 
679  return StatusCode::SUCCESS;
680 }
681 
682 StatusCode FPGATrackSimNNPathfinderExtensionTool::addHitToRoad(FPGATrackSimRoad& newroad, FPGATrackSimRoad& currentRoad, const std::vector<std::shared_ptr<const FPGATrackSimHit>>& hits)
683 {
685  std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> these_hits;
686  these_hits.resize(m_nLayers_1stStage + m_nLayers_2ndStage);
687  for (auto &thishit : currentRoad.getHits_flat()) {
688  these_hits[thishit->getLayer()].push_back(thishit);
689  }
690 
691  // add this hit to the road, real or not
692  for (auto& hit: hits)
693  {
694  if(hit->getLayer() >= these_hits.size())
695  {
696  ATH_MSG_WARNING("Adding a hit with layer: "<<hit->getLayer()<<" which is beyond the total size of the layers");
697  continue;
698  }
699  these_hits[hit->getLayer()].push_back(hit);
700  }
701  const auto nTheseHits = these_hits.size();
702  newroad.setHits(std::move(these_hits));
703 
704  // Update the bitmasks depending on whether this was real or not
705  unsigned wcLayers = currentRoad.getWCLayers();
706  unsigned hitLayers = currentRoad.getHitLayers();
707 
708  for (auto& hit: hits)
709  {
710  if(hit->getLayer() > nTheseHits)
711  {
712  ATH_MSG_WARNING("Adding a hit with layer: "<<hit->getLayer()<<" which is beyond the total size of the layers");
713  continue;
714  }
715 
716  if (!hit->isReal()) { // add a WC hit
717  wcLayers |= (0x1 << hit->getLayer());
718  }
719  else { // add a real hit
720  hitLayers |= 1 << hit->getLayer();
721  }
722  }
723 
724  newroad.setHitLayers(hitLayers);
725  newroad.setWCLayers(wcLayers);
726 
727  return StatusCode::SUCCESS;
728 }
729 
730 StatusCode FPGATrackSimNNPathfinderExtensionTool::getFakeHit(FPGATrackSimRoad& currentRoad, size_t slice, std::vector<float>& predhit, const long& fineID, std::vector<std::shared_ptr<const FPGATrackSimHit>>& hits) {
731 
732  const FPGATrackSimRegionMap* rmap_2nd = m_FPGATrackSimMapping->SubRegionMap_2nd();
733 
734  int guessedLayer(0);
735 
736  std::shared_ptr<FPGATrackSimHit> guessedHitPtr = std::make_shared<FPGATrackSimHit>();
737  guessedHitPtr->setX(predhit[0]);
738  guessedHitPtr->setY(predhit[1]);
739  guessedHitPtr->setZ(predhit[2]);
740 
741  if (m_doOutsideIn) { // outside in
742  unsigned lastHitLayer(9999);
743  double lastHitR(9999);
744 
745  for (auto &hit : currentRoad.getHits_flat())
746  {
747  int layer = hit->getLayer();
748  double r = hit->getR();
749  if (r < 5) {// happens for guessed hits from pattern reco
750  r = rmap_2nd->getAvgRadius(slice,layer); // use avg hit radius instead just to find the ordering of hits
751  }
752  if (r < lastHitR) {
753  lastHitLayer = layer;
754  lastHitR = r;
755  }
756  }
757 
758  if (lastHitLayer == 0) { // this is the inner most 1st stage, so guess the last layer in 2nd stage
759  guessedLayer = m_nLayers_2ndStage-1;
760  }
761  else if (lastHitLayer < m_nLayers_1stStage) {
762  guessedLayer = lastHitLayer-1; // still in 1st stage, go in by one
763  }
764  else {
765  guessedLayer = lastHitLayer-1; // in 2nd stage, go in by one
766  }
767  }
768  else { // nope, inside out
769  unsigned lastHitLayer(0);
770 
771  for (auto &hit : currentRoad.getHits_flat())
772  {
773  unsigned layer = hit->getLayer();
774  if (layer > lastHitLayer)
775  {
776  lastHitLayer = layer;
777  }
778  }
779  guessedLayer = lastHitLayer+1;
780  }
781 
782  guessedHitPtr->setLayer(guessedLayer);
783  guessedHitPtr->setHitType(HitType::guessed);
784 
785  if(isFineIDInStrip(fineID)) guessedHitPtr->setDetType(SiliconTech::strip);
786  else guessedHitPtr->setDetType(SiliconTech::pixel);
787 
788 
789  // Make sure that the hit is inside the boundaries of the layers
790  if(guessedHitPtr->getLayer() < m_nLayers_1stStage + m_nLayers_2ndStage )
791  {
792  hits.push_back(guessedHitPtr);
793  }
794 
795  // if in strips, add the second hit into the list
796  if(isFineIDInStrip(fineID))
797  {
798  std::shared_ptr<FPGATrackSimHit> guessedSecondHitPtr = std::make_shared<FPGATrackSimHit>();
799  guessedSecondHitPtr->setX(0);
800  guessedSecondHitPtr->setY(0);
801  guessedSecondHitPtr->setZ(0);
802  guessedSecondHitPtr->setLayer( guessedHitPtr->getLayer() + 1 );
803  guessedSecondHitPtr->setHitType(HitType::guessed);
804 
805  guessedSecondHitPtr->setDetType(SiliconTech::strip);
806 
807  // Make sure that the hit is inside the boundaries of the layers
808  if(guessedSecondHitPtr->getLayer() < m_nLayers_1stStage + m_nLayers_2ndStage )
809  {
810  hits.push_back(guessedSecondHitPtr);
811  }
812  }
813 
814 
815 
816  return StatusCode::SUCCESS;
817 
818 }
819 
820 StatusCode FPGATrackSimNNPathfinderExtensionTool::findHitinNextStripLayer(std::shared_ptr<const FPGATrackSimHit> hitToSearch, std::vector<std::shared_ptr<const FPGATrackSimHit>>& hitList, std::vector<std::shared_ptr<const FPGATrackSimHit>>& hits)
821 {
822  float EPSILON = 0.00001;
823  for (const std::shared_ptr<const FPGATrackSimHit>& hit: hitList)
824  {
825  if (abs(hit->getX() - hitToSearch->getX()) < EPSILON && abs(hit->getY() - hitToSearch->getY()) < EPSILON && abs(hit->getZ() - hitToSearch->getZ()) < EPSILON)
826  {
827  hits.push_back(hit);
828  return StatusCode::SUCCESS;
829  }
830 
831  }
832 
833  ATH_MSG_WARNING("Didn't find a matching space point");
834 
835  return StatusCode::FAILURE;
836 }
837 
839 {
840  if(!m_debugEvent) return;
841 
842  // print this road
843  if(m_debugEvent)
844  {
845  std::vector<std::shared_ptr<const FPGATrackSimHit>> hitsR;
846  for (auto &hit : currentRoad.getHits_flat()) {
847  hitsR.push_back(hit);
848  }
849 
850  // If outside in, sort in increasing R, otherwise, decreasing R
851  if(m_doOutsideIn)
852  {
853  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
854  if(a->getR() == b->getR()) return a->getLayer() < b->getLayer();
855  return a->getR() < b->getR();
856  });
857  }
858  else
859  {
860  std::sort(hitsR.begin(), hitsR.end(), [](auto& a, auto& b){
861  if(a->getLayer() == b->getLayer()) return a->getR() > b->getR();
862  return a->getLayer() > b->getLayer();
863  });
864  }
865 
866  for (unsigned long i = 0; i < hitsR.size(); i++)
867  {
868  ATH_MSG_DEBUG("Hit i "<<i<<" X: "<<hitsR[i]->getX()<<" Y: "<<hitsR[i]->getY()<<" Z: "<<hitsR[i]->getZ()<<" R: "<<hitsR[i]->getR()<<" layer: "<<hitsR[i]->getLayer()<<" hitType: "<<hitsR[i]->getHitType()<<" getDetType: "<<hitsR[i]->getDetType());
869  }
870  }
871 
872 }
873 
874 
875 StatusCode FPGATrackSimNNPathfinderExtensionTool::getLastLayer(FPGATrackSimRoad& currentRoad, unsigned& lastHitLayer, std::shared_ptr<const FPGATrackSimHit>& lastHit)
876 {
877  // Reset to inner most
878  lastHitLayer = 0;
879 
880  for (auto &hit : currentRoad.getHits_flat())
881  {
882  unsigned layer = hit->getLayer();
883  if (layer > lastHitLayer)
884  {
885  lastHitLayer = layer;
886  lastHit = hit;
887  }
888  }
889 
890  return StatusCode::SUCCESS;
891 
892 }
OnnxRuntimeBase::runONNXInference
std::vector< float > runONNXInference(std::vector< float > &inputTensorValues) const
Definition: OnnxRuntimeBase.cxx:66
beamspotman.r
def r
Definition: beamspotman.py:676
FPGATrackSimNNPathfinderExtensionTool::fillInputTensorForNN
StatusCode fillInputTensorForNN(FPGATrackSimRoad &thisRoad, std::vector< float > &inputTensorValues)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:565
FPGATrackSimRoad::getHitLayers
layer_bitmask_t getHitLayers() const
Definition: FPGATrackSimRoad.h:95
FPGATrackSimNNPathfinderExtensionTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimNNPathfinderExtensionTool.h:54
getMenu.algname
algname
Definition: getMenu.py:54
FPGATrackSimNNPathfinderExtensionTool::FPGATrackSimNNPathfinderExtensionTool
FPGATrackSimNNPathfinderExtensionTool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:20
FPGATrackSimNNPathfinderExtensionTool::m_missingHitsOnRoad
std::vector< unsigned int > m_missingHitsOnRoad
Definition: FPGATrackSimNNPathfinderExtensionTool.h:79
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
SiliconTech::strip
@ strip
FPGATrackSimNNPathfinderExtensionTool::m_missedHitRScaling
Gaudi::Property< float > m_missedHitRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:70
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimNNPathfinderExtensionTool::findHitinNextStripLayer
StatusCode findHitinNextStripLayer(std::shared_ptr< const FPGATrackSimHit > hit, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hitList, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:820
FPGATrackSimNNPathfinderExtensionTool::m_tree
TTree * m_tree
Definition: FPGATrackSimNNPathfinderExtensionTool.h:77
FPGATrackSimNNPathfinderExtensionTool::m_doOutsideIn
Gaudi::Property< bool > m_doOutsideIn
Definition: FPGATrackSimNNPathfinderExtensionTool.h:73
FPGATrackSimNNPathfinderExtensionTool::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: FPGATrackSimNNPathfinderExtensionTool.h:55
FPGATrackSimHoughFunctions.h
OnnxRuntimeBase::initialize
void initialize(TString)
Definition: OnnxRuntimeBase.cxx:16
FPGATrackSimRoad::getNWCLayers
size_t getNWCLayers() const
Definition: FPGATrackSimRoad.h:109
FPGATrackSimNNPathfinderExtensionTool::getYScale
static float getYScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:94
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
FPGATrackSimNNPathfinderExtensionTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:26
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:140
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:40
FPGATrackSimNNPathfinderExtensionTool::addHitToRoad
StatusCode addHitToRoad(FPGATrackSimRoad &newroad, FPGATrackSimRoad &currentRoad, const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:682
FPGATrackSimHit::getLayer
unsigned getLayer() const
Definition: FPGATrackSimHit.cxx:77
test_pyathena.pt
pt
Definition: test_pyathena.py:11
FPGATrackSimNNPathfinderExtensionTool::m_nLayers_1stStage
unsigned m_nLayers_1stStage
Definition: FPGATrackSimNNPathfinderExtensionTool.h:89
HitType::spacepoint
@ spacepoint
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:138
FPGATrackSimNNPathfinderExtensionTool::getXScale
static float getXScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:93
FPGATrackSimNNPathfinderExtensionTool::printRoad
void printRoad(FPGATrackSimRoad &currentRoad)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:838
module_driven_slicing.getLayer
def getLayer(trk, hit_idx)
Definition: module_driven_slicing.py:172
HitType::guessed
@ guessed
FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowRScaling
Gaudi::Property< float > m_lowPtWindowRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:67
FPGATrackSimNNPathfinderExtensionTool::m_slicedHitHeader
FPGATrackSimLogicalEventInputHeader * m_slicedHitHeader
Definition: FPGATrackSimNNPathfinderExtensionTool.h:100
HitType::undefined
@ undefined
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
FPGATrackSimNNPathfinderExtensionTool::m_nLayers_2ndStage
unsigned m_nLayers_2ndStage
Definition: FPGATrackSimNNPathfinderExtensionTool.h:90
FPGATrackSimNNPathfinderExtensionTool::m_foundHitITkLayer
std::vector< std::vector< unsigned int > > m_foundHitITkLayer
Definition: FPGATrackSimNNPathfinderExtensionTool.h:81
FPGATrackSimTowerInputHeader::addHit
void addHit(const FPGATrackSimHit &s)
Definition: FPGATrackSimTowerInputHeader.h:48
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
EPSILON
constexpr float EPSILON
Definition: FPGATrackSimHoughFunctions.cxx:10
HitType::wildcard
@ wildcard
FPGATrackSimNNPathfinderExtensionTool::m_NcompletedRoads
std::vector< unsigned long > m_NcompletedRoads
Definition: FPGATrackSimNNPathfinderExtensionTool.h:78
FPGATrackSimNNPathfinderExtensionTool::m_roads
std::vector< FPGATrackSimRoad > m_roads
Definition: FPGATrackSimNNPathfinderExtensionTool.h:86
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:137
FPGATrackSimLogicalEventInputHeader::getTower
FPGATrackSimTowerInputHeader * getTower(size_t index)
Definition: FPGATrackSimLogicalEventInputHeader.h:39
FPGATrackSimNNPathfinderExtensionTool::m_foundHitIsSP
std::vector< std::vector< bool > > m_foundHitIsSP
Definition: FPGATrackSimNNPathfinderExtensionTool.h:84
FPGATrackSimNNPathfinderExtensionTool::m_nHitsInSearchWindow
std::vector< unsigned int > m_nHitsInSearchWindow
Definition: FPGATrackSimNNPathfinderExtensionTool.h:82
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimNNPathfinderExtensionTool::m_maxBranches
Gaudi::Property< int > m_maxBranches
Definition: FPGATrackSimNNPathfinderExtensionTool.h:72
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
FPGATrackSimRoad::getHits_flat
std::unordered_set< std::shared_ptr< const FPGATrackSimHit > > getHits_flat() const
Definition: FPGATrackSimRoad.cxx:113
FPGATrackSimNNPathfinderExtensionTool::getZScale
static float getZScale()
Definition: FPGATrackSimNNPathfinderExtensionTool.h:95
FPGATrackSimPlaneMap::map
void map(FPGATrackSimHit &hit) const
Definition: FPGATrackSimPlaneMap.cxx:234
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:663
FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowZScaling
Gaudi::Property< float > m_lowPtValueForWindowZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:68
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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:448
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
FPGATrackSimRegionMap::isInRegion
bool isInRegion(uint32_t region, const FPGATrackSimHit &hit) const
Definition: FPGATrackSimRegionMap.cxx:225
FPGATrackSimNNPathfinderExtensionTool::m_lowPtValueForWindowRScaling
Gaudi::Property< float > m_lowPtValueForWindowRScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:66
FPGATrackSimNNPathfinderExtensionTool::m_windowR
Gaudi::Property< std::vector< float > > m_windowR
Definition: FPGATrackSimNNPathfinderExtensionTool.h:64
FPGATrackSimNNPathfinderExtensionTool::m_phits_atLayer
std::map< unsigned, std::map< unsigned, std::vector< std::shared_ptr< const FPGATrackSimHit > > > > m_phits_atLayer
Definition: FPGATrackSimNNPathfinderExtensionTool.h:88
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:141
FPGATrackSimNNPathfinderExtensionTool::m_extensionVolNN
OnnxRuntimeBase m_extensionVolNN
Definition: FPGATrackSimNNPathfinderExtensionTool.h:102
FPGATrackSimRoad::setNLayers
void setNLayers(unsigned layers)
Definition: FPGATrackSimRoad.h:66
FPGATrackSimNNPathfinderExtensionTool::m_threshold
Gaudi::Property< int > m_threshold
Definition: FPGATrackSimNNPathfinderExtensionTool.h:58
FPGATrackSimNNPathfinderExtensionTool::m_distanceOfPredictedHitToFoundHit
std::vector< std::vector< float > > m_distanceOfPredictedHitToFoundHit
Definition: FPGATrackSimNNPathfinderExtensionTool.h:83
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:142
FPGATrackSimPlaneMap
Definition: FPGATrackSimPlaneMap.h:62
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
FPGATrackSimNNPathfinderExtensionTool::m_extensionHitNN
OnnxRuntimeBase m_extensionHitNN
Definition: FPGATrackSimNNPathfinderExtensionTool.h:103
isFineIDInPixel
bool isFineIDInPixel(long ID)
Definition: FPGATrackSimHoughFunctions.cxx:443
FPGATrackSimNNPathfinderExtensionTool::m_debugEvent
bool m_debugEvent
Definition: FPGATrackSimNNPathfinderExtensionTool.h:96
FPGATrackSimRoad::setSubRegion
void setSubRegion(int v)
Definition: FPGATrackSimRoad.h:74
FPGATrackSimRoad::getWCLayers
layer_bitmask_t getWCLayers() const
Definition: FPGATrackSimRoad.h:96
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:139
FPGATrackSimNNPathfinderExtensionTool::extendTracks
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
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:90
FPGATrackSimHit::isMapped
bool isMapped() const
Definition: FPGATrackSimHit.cxx:13
a
TList * a
Definition: liststreamerinfos.cxx:10
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:92
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:80
FPGATrackSimNNPathfinderExtensionTool::getFakeHit
StatusCode getFakeHit(FPGATrackSimRoad &currentRoad, size_t slice, std::vector< float > &predhit, const long &fineID, std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:730
FPGATrackSimNNPathfinderExtensionTool.h
Default track extension algorithm to produce "second stage" roads.
FPGATrackSimRoad::setYBin
void setYBin(unsigned v)
Definition: FPGATrackSimRoad.h:76
FPGATrackSimNNPathfinderExtensionTool::m_lowPtWindowZScaling
Gaudi::Property< float > m_lowPtWindowZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:69
FPGATrackSimNNPathfinderExtensionTool::m_predictionWindowLength
Gaudi::Property< int > m_predictionWindowLength
Definition: FPGATrackSimNNPathfinderExtensionTool.h:74
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
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:73
FPGATrackSimNNPathfinderExtensionTool::m_windowZ
Gaudi::Property< std::vector< float > > m_windowZ
Definition: FPGATrackSimNNPathfinderExtensionTool.h:65
isFineIDInStrip
bool isFineIDInStrip(long ID)
Definition: FPGATrackSimHoughFunctions.cxx:438
FPGATrackSimTowerInputHeader
Definition: FPGATrackSimTowerInputHeader.h:18
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
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:91
FPGATrackSimNNPathfinderExtensionTool::m_missedHitZScaling
Gaudi::Property< float > m_missedHitZScaling
Definition: FPGATrackSimNNPathfinderExtensionTool.h:71
SiliconTech::pixel
@ pixel
FPGATrackSimSectorBank.h
This file declares a class that stores the module IDs of the sectors.
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
FPGATrackSimNNPathfinderExtensionTool::getLastLayer
StatusCode getLastLayer(FPGATrackSimRoad &currentRoad, unsigned &lastHitLayer, std::shared_ptr< const FPGATrackSimHit > &lastHit)
Definition: FPGATrackSimNNPathfinderExtensionTool.cxx:875
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
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
FPGATrackSimRegionMap::getAvgRadius
double getAvgRadius(unsigned region, unsigned layer) const
Definition: FPGATrackSimRegionMap.cxx:369
FPGATrackSimRoad::setXBin
void setXBin(unsigned v)
Definition: FPGATrackSimRoad.h:75