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

#include <FPGATrackSimNNTrackTool.h>

Inheritance diagram for FPGATrackSimNNTrackTool:
Collaboration diagram for FPGATrackSimNNTrackTool:

Public Member Functions

 FPGATrackSimNNTrackTool (const std::string &, const std::string &, const IInterface *)
 
virtual StatusCode initialize () override
 
StatusCode getTracks_1st (std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads, std::vector< FPGATrackSimTrack > &tracks)
 
StatusCode getTracks_2nd (std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads, std::vector< FPGATrackSimTrack > &tracks)
 
StatusCode getTracks_GNN (std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads, std::vector< FPGATrackSimTrack > &tracks)
 
StatusCode setTrackParameters (std::vector< FPGATrackSimTrack > &tracks, bool isFirst, const FPGATrackSimTrackPars &min, const FPGATrackSimTrackPars &max)
 
StatusCode setRoadSectors (std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads)
 
void matchIdealGeoSector (FPGATrackSimRoad &r)
 
void initialize (TString)
 
std::vector< float > runONNXInference (std::vector< float > &inputTensorValues) const
 
std::vector< std::vector< float > > runONNXInference (std::vector< std::vector< float > > &inputTensorValues) const
 
std::vector< std::vector< float > > runONNXInference (NetworkBatchInput &inputTensorValues) const
 
std::map< int, Eigen::MatrixXf > runONNXInferenceMultilayerOutput (NetworkBatchInput &inputTensorValues) const
 
const std::vector< int64_t > & getInputNodesDims ()
 
const std::vector< int64_t > & getOutputNodesDims ()
 

Static Public Member Functions

static float getXScale ()
 
static float getYScale ()
 
static float getZScale ()
 
static float getQoverPtScale ()
 
static float getEtaScale ()
 
static float getPhiScale ()
 
static float getD0Scale ()
 
static float getZ0Scale ()
 
static float getRScale ()
 

Public Attributes

Gaudi::Property< unsigned int > m_minNumberOfRealHitsInATrack { this, "MinNumberOfRealHitsInATrack", 4, "Minimum number of real hits in a track candidate to process" }
 
Gaudi::Property< bool > m_doGNNTracking { this, "doGNNTracking", false, "Flag to turn on GNN Tracking configuration for road-to-track" }
 
Gaudi::Property< int > m_nInputsGNN { this, "nInputsGNN", 9, "Number of Hit Inputs for NN for GNN configuration. Depends on which model is chosen."}
 
Gaudi::Property< bool > m_useCartesian { this, "useCartesian", true, "If true, NNs use Cartestian coordinates. If false,they use cylindrical coordiantes"}
 
TString m_fileName
 

Protected Attributes

ServiceHandle< IFPGATrackSimBankSvcm_FPGATrackSimBank { this,"FPGATrackSimBankSvc","FPGATrackSimBankSvc" }
 
ToolHandle< IFPGATrackSimRoadFilterToolm_spRoadFilterTool {this, "SPRoadFilterTool", "FPGATrackSimSpacepointRoadFilterTool", "Spacepoint Road Filter Tool"}
 
Gaudi::Property< bool > m_doRegionalMapping { this, "RegionalMapping", false, "Use the sub-region maps to define the sector" }
 
Gaudi::Property< bool > m_doEtaPatternConsts { this, "doEtaPatternConsts", false, "Whether to use the eta pattern tool for constant generation" }
 
Gaudi::Property< bool > m_useSpacePoints { this, "useSpacePoints", false, "Whether we are using spacepoints." }
 
Gaudi::Property< bool > m_useSectors { this, "useSectors", false, "Will reverse calculate the sector for track-fitting purposes" }
 
Gaudi::Property< bool > m_idealGeoRoads { this, "IdealGeoRoads", true, "Set sectors to use ideal geometry fit constants" }
 
Gaudi::Property< bool > m_isSecondStage { this, "isSecondStage", true, "Is this the second stage?" }
 
Gaudi::Property< bool > m_do2ndStage {this, "Do2ndStageTrackFit", false, "Do 2nd stage track fit"}
 

Private Member Functions

void compute_truth (FPGATrackSimTrack &newtrk) const
 
 OnnxRuntimeBase (TString fileName)
 
 OnnxRuntimeBase ()
 

Private Attributes

ServiceHandle< IFPGATrackSimMappingSvcm_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc", ""}
 
ServiceHandle< ITHistSvc > m_tHistSvc {this, "THistSvc","THistSvc"}
 
OnnxRuntimeBase m_paramNN_1st
 
OnnxRuntimeBase m_paramNN_2nd
 
OnnxRuntimeBase m_fakeNN_1st
 
OnnxRuntimeBase m_fakeNN_2nd
 
bool m_useParamNN_1st = true
 
bool m_useParamNN_2nd = true
 
std::vector< float > m_x
 
std::vector< float > m_y
 
std::vector< float > m_z
 
std::vector< float > m_barcodefrac
 
std::vector< int > m_barcode
 
std::vector< int > m_eventindex
 
std::vector< unsigned int > m_isPixel
 
std::vector< unsigned int > m_layer
 
std::vector< unsigned int > m_isBarrel
 
std::vector< unsigned int > m_etawidth
 
std::vector< unsigned int > m_phiwidth
 
std::vector< unsigned int > m_etamodule
 
std::vector< unsigned int > m_phimodule
 
std::vector< unsigned int > m_ID
 
std::vector< float > m_truth_d0
 
std::vector< float > m_truth_z0
 
std::vector< float > m_truth_pt
 
std::vector< float > m_truth_eta
 
std::vector< float > m_truth_phi
 
std::vector< float > m_truth_pdg
 
std::vector< int > m_truth_q
 
std::vector< int > m_truth_barcode
 
std::vector< int > m_truth_eventindex
 
std::vector< const char * > m_input_node_names
 
std::vector< int64_t > m_input_node_dims
 
std::vector< const char * > m_output_node_names
 
std::unique_ptr< Ort::Session > m_session
 ONNX runtime session / model properties. More...
 
std::vector< const char * > m_inputNodeNames
 
std::vector< int64_t > m_inputNodeDims
 
std::vector< const char * > m_outputNodeNames
 
std::vector< int64_t > m_outputNodeDims
 
std::unique_ptr< Ort::Env > m_env
 

Detailed Description

Definition at line 37 of file FPGATrackSimNNTrackTool.h.

Constructor & Destructor Documentation

◆ FPGATrackSimNNTrackTool()

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

Member Function Documentation

◆ compute_truth()

void FPGATrackSimNNTrackTool::compute_truth ( FPGATrackSimTrack newtrk) const
private

Definition at line 973 of file FPGATrackSimNNTrackTool.cxx.

973  {
974  std::vector<FPGATrackSimMultiTruth> mtv;
975 
976  unsigned nl = (m_do2ndStage ? 13 : 5);
977  for (unsigned layer = 0; layer < nl; layer++) {
978  if (!(t.getHitMap() & (1 << layer))) continue;
979 
980  // Sanity check that we have enough hits.
981  if (layer < t.getFPGATrackSimHits().size())
982  mtv.push_back(t.getFPGATrackSimHits().at(layer).getTruth());
983 
984  // adjust weight for hits without (and also with) a truth match, so that
985  // each is counted with the same weight.
986  mtv.back().assign_equal_normalization();
987  }
988 
991  // frac is then the fraction of the total number of hits on the track
992  // attributed to the barcode.
993 
996  const bool ok = mt.best(tbarcode, tfrac);
997  if (ok) {
998  t.setEventIndex(tbarcode.first);
999  t.setBarcode(tbarcode.second);
1000  t.setBarcodeFrac(tfrac);
1001  }
1002 }

◆ getD0Scale()

static float FPGATrackSimNNTrackTool::getD0Scale ( )
inlinestatic

Definition at line 60 of file FPGATrackSimNNTrackTool.h.

60 { return 2.0;};

◆ getEtaScale()

static float FPGATrackSimNNTrackTool::getEtaScale ( )
inlinestatic

Definition at line 58 of file FPGATrackSimNNTrackTool.h.

58 { return 5.0;};

◆ getInputNodesDims()

const std::vector<int64_t>& OnnxRuntimeBase::getInputNodesDims ( )
inlineinherited

Definition at line 33 of file OnnxRuntimeBase.h.

33 {return m_inputNodeDims;};

◆ getOutputNodesDims()

const std::vector<int64_t>& OnnxRuntimeBase::getOutputNodesDims ( )
inlineinherited

Definition at line 34 of file OnnxRuntimeBase.h.

34 {return m_outputNodeDims;};

◆ getPhiScale()

static float FPGATrackSimNNTrackTool::getPhiScale ( )
inlinestatic

Definition at line 59 of file FPGATrackSimNNTrackTool.h.

59 { return 3.15;};

◆ getQoverPtScale()

static float FPGATrackSimNNTrackTool::getQoverPtScale ( )
inlinestatic

Definition at line 57 of file FPGATrackSimNNTrackTool.h.

57 { return 0.001;};

◆ getRScale()

static float FPGATrackSimNNTrackTool::getRScale ( )
inlinestatic

Definition at line 62 of file FPGATrackSimNNTrackTool.h.

62 {return 1015.;};

◆ getTracks_1st()

StatusCode FPGATrackSimNNTrackTool::getTracks_1st ( std::vector< std::shared_ptr< const FPGATrackSimRoad >> &  roads,
std::vector< FPGATrackSimTrack > &  tracks 
)

should be 2 missing coords for pixel

now we have saved our values, time to run inference and get the output

Definition at line 233 of file FPGATrackSimNNTrackTool.cxx.

233  {
234 
235  if(m_doGNNTracking) {
236  ATH_CHECK(getTracks_GNN(roads, tracks));
237  return StatusCode::SUCCESS;
238  }
239 
240  ATH_CHECK(setRoadSectors(roads));
241  int n_track = 0;
242 
243  std::vector<std::vector<float> >inputTensorValuesAll;
244 
245  // Loop over roads
246  for (auto const &iroad : roads) {
247 
248  double y = iroad->getY();
249 
250  // Just used to get number of layers considered
251  const FPGATrackSimPlaneMap *planeMap = m_FPGATrackSimMapping->PlaneMap_1st(iroad->getSubRegion());
252 
253  // Get info on layers with missing hits
254  int nMissing = 0;
255  layer_bitmask_t missing_mask = iroad->getNWCLayers();
256  for (unsigned ilayer = 0; ilayer < planeMap->getNLogiLayers(); ilayer++) {
257  if ((missing_mask >> ilayer) & 0x1) {
258  nMissing++;
259  if (planeMap->isPixel(ilayer)) nMissing++;
260  }
261  }
262 
263 
264  // Create a template track with common parameters filled already for
265  // initializing below
266  FPGATrackSimTrack temp;
268  temp.setNLayers(planeMap->getNLogiLayers());
269  temp.setBankID(-1);
270  temp.setPatternID(iroad->getPID());
271  temp.setFirstSectorID(iroad->getSector());
272  temp.setHitMap(missing_mask);
273  temp.setNMissing(nMissing);
274  temp.setQOverPt(y);
275 
276  temp.setSubRegion(iroad->getSubRegion());
277  temp.setHoughX(iroad->getX());
278  temp.setHoughY(iroad->getY());
279  temp.setHoughXBin(iroad->getXBin());
280  temp.setHoughYBin(iroad->getYBin());
281 
283  // Get a list of indices for all possible combinations given a certain
284  // number of layers
285  std::vector<std::vector<int>> combs;
286 
287  combs = getComboIndices(iroad->getNHits_layer());
288 
289  // Loop over possible combinations for this road
290  for (size_t icomb = 0; icomb < combs.size(); icomb++) {
291  std::vector<float> inputTensorValues;
292  std::vector<std::shared_ptr<const FPGATrackSimHit>> hit_list;
293 
294  // list of indices for this particular combination
295  std::vector<int> const &hit_indices = combs[icomb];
296 
297  // Loop over all layers
298  for (unsigned layer = 0; layer < planeMap->getNLogiLayers(); layer++) {
299 
300  // Check to see if this is a valid hit
301  if (hit_indices[layer] >= 0) {
302 
303  std::shared_ptr<const FPGATrackSimHit> hit = iroad->getHits(layer)[hit_indices[layer]];
304  // Add this hit to the road
305  if (hit->isReal()){
306  hit_list.push_back(hit);
307  }
308  }
309  }
310 
311  // Sort the list by radial distance
312  std::sort(hit_list.begin(), hit_list.end(),
313  [](std::shared_ptr<const FPGATrackSimHit> &hit1, std::shared_ptr<const FPGATrackSimHit> &hit2) {
314  double rho1 = std::hypot(hit1->getX(), hit1->getY());
315  double rho2 = std::hypot(hit2->getX(), hit2->getY());
316  return rho1 < rho2;
317  });
318 
319 
320  int index = 1;
321  bool flipZ = false;
322  double rotateAngle = 0;
323  bool gotSecondSP = false;
324  float tmp_xf;
325  float tmp_yf;
326  float tmp_zf;
327  float tmp_rf;
328  float tmp_phif;
329  // Loop over all hits
330  for (const auto &hit : hit_list) {
331  // Need to rotate hits
332  float x0 = hit->getX();
333  float y0 = hit->getY();
334  float z0 = hit->getZ();
335  float r0 = std::sqrt(x0*x0+y0*y0);
336  float phi0 = hit->getGPhi();
337  float xf = x0;
338  float yf = y0;
339  float zf = z0;
340  float rf = r0;
341  float phif = phi0;
342  if (m_useCartesian) {
343  if (index == 1) {
344  if (z0 < 0)
345  flipZ = true;
346  rotateAngle = std::atan(x0 / y0);
347  if (y0 < 0)
348  rotateAngle += M_PI;
349  }
350  xf = x0 * std::cos(rotateAngle) - y0 * std::sin(rotateAngle);
351  yf = x0 * std::sin(rotateAngle) + y0 * std::cos(rotateAngle);
352  zf = z0;
353  if (flipZ) zf = z0 * -1;
354  }
355 
356  // Get average of values for strip hit pairs
357  // TODO: this needs to be fixed in the future, for this to work for other cases
358  if (hit->isStrip()) {
359 
360  if (hit->getHitType() != HitType::spacepoint) { // this is a strip but not a SP!
361  if (m_useCartesian) {
362  float xf_scaled = (xf) / (getXScale());
363  float yf_scaled = (yf) / (getYScale());
364  float zf_scaled = (zf) / (getZScale());
365 
366  // Get average of two hits for strip hits
367  inputTensorValues.push_back(xf_scaled);
368  inputTensorValues.push_back(yf_scaled);
369  inputTensorValues.push_back(zf_scaled);
370 
371  }
372  else {
373  float rf_scaled = (rf) / (getRScale());
374  float phif_scaled = (phif) / (getPhiScale());
375  float zf_scaled = (zf) / (getZScale());
376  // Get average of two hits for strip hits
377  inputTensorValues.push_back(rf_scaled);
378  inputTensorValues.push_back(phif_scaled);
379  inputTensorValues.push_back(zf_scaled);
380  }
381  }
382  else if (!gotSecondSP) {
383  tmp_xf = xf;
384  tmp_yf = yf;
385  tmp_zf = zf;
386  tmp_phif = phif;
387  tmp_rf = rf;
388  gotSecondSP = true;
389  }
390  else {
391  gotSecondSP = false;
392  if (m_useCartesian) {
393  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
394  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
395  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
396 
397  // Get average of two hits for strip hits
398  inputTensorValues.push_back(xf_scaled);
399  inputTensorValues.push_back(yf_scaled);
400  inputTensorValues.push_back(zf_scaled);
401  index++;
402  }
403  else {
404  float rf_scaled = (rf + tmp_rf) / (2.*getRScale());
405  float phif_scaled = (phif + tmp_phif) / (2.*getPhiScale());
406  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
407  inputTensorValues.push_back(rf_scaled);
408  inputTensorValues.push_back(phif_scaled);
409  inputTensorValues.push_back(zf_scaled);
410  }
411  }
412  }
413  else {
414  if (m_useCartesian) {
415  float xf_scaled = (xf) / (getXScale());
416  float yf_scaled = (yf) / (getYScale());
417  float zf_scaled = (zf) / (getZScale());
418  inputTensorValues.push_back(xf_scaled);
419  inputTensorValues.push_back(yf_scaled);
420  inputTensorValues.push_back(zf_scaled);
421  index++;
422  }
423  else {
424  float rf_scaled = (rf) / (getRScale());
425  float phif_scaled = (phif) / (getPhiScale());
426  float zf_scaled = (zf) / (getZScale());
427  inputTensorValues.push_back(rf_scaled);
428  inputTensorValues.push_back(phif_scaled);
429  inputTensorValues.push_back(zf_scaled);
430  }
431  }
432  }
433 
434  if (inputTensorValues.size() != planeMap->getNLogiLayers()*3) {
435  inputTensorValues.resize(planeMap->getNLogiLayers()*3);
436  }
437  inputTensorValues.resize(15); // Retain only the first 15 values for consistency
438 
439  inputTensorValuesAll.push_back(inputTensorValues);
440  FPGATrackSimTrack track_cand;
441  n_track++;
442  track_cand.setTrackID(n_track);
443  track_cand.setNLayers(planeMap->getNLogiLayers());
444  track_cand.setNMissing(nMissing);
445  for (unsigned ihit = 0; ihit < hit_list.size(); ihit++) {
446  track_cand.setFPGATrackSimHit(ihit, *(hit_list[ihit]));
447  }
448  tracks.push_back(track_cand);
449 
450  ATH_MSG_DEBUG("NN InputTensorValues:");
451  ATH_MSG_DEBUG(inputTensorValues);
452  } // loop over combinations
453  } // loop over roads
454 
456  auto NNoutputs = m_fakeNN_1st.runONNXInference(inputTensorValuesAll);
457 
458  for (unsigned itrack = 0; itrack < NNoutputs.size(); itrack++) {
459 
460  float nn_val = NNoutputs[itrack][0];
461  ATH_MSG_DEBUG("NN output:" << nn_val);
462  double chi2 = (1 - nn_val) * (tracks[itrack].getNCoords() - tracks[itrack].getNMissing() - 5);
463  //std::cout << "1st stage" << chi2 << std::endl;
464  tracks[itrack].setOrigChi2(chi2);
465  tracks[itrack].setChi2(chi2);
466  }
467 
468  // Add truth info
469  for (FPGATrackSimTrack &t : tracks) {
470  compute_truth(t); // match the track to a geant particle using the
471  // channel-level geant info in the hit data.
472  }
473  return StatusCode::SUCCESS;
474 }

◆ getTracks_2nd()

StatusCode FPGATrackSimNNTrackTool::getTracks_2nd ( std::vector< std::shared_ptr< const FPGATrackSimRoad >> &  roads,
std::vector< FPGATrackSimTrack > &  tracks 
)

should be 2 missing coords for pixel

now we have saved our values, time to run inference and get the output

Definition at line 477 of file FPGATrackSimNNTrackTool.cxx.

477  {
478 
479  ATH_CHECK(setRoadSectors(roads));
480  int n_track = 0;
481  std::vector<std::vector<float> >inputTensorValuesAll;
482 
483  // Loop over roads
484  for (auto const &iroad : roads) {
485 
486  double y = iroad->getY();
487 
488  const FPGATrackSimPlaneMap *planeMap = m_FPGATrackSimMapping->PlaneMap_2nd(iroad->getSubRegion());
489  // Get info on layers with missing hits
490  int nMissing = 0;
491  layer_bitmask_t missing_mask = iroad->getNWCLayers();
492  layer_bitmask_t hit_mask = 0x0;
493  for (unsigned ilayer = 0; ilayer < 13; ilayer++) {
494  if ((missing_mask >> ilayer) & 0x1) {
495  nMissing++;
496  if (planeMap->isPixel(ilayer)) nMissing++;
497  }
498  else {
499  hit_mask |= (0x1 << ilayer);
500  }
501  }
502 
503  // Create a template track with common parameters filled already for
504  // initializing below
505  FPGATrackSimTrack temp;
507  temp.setNLayers(13);
508  temp.setBankID(-1);
509  temp.setPatternID(iroad->getPID());
510  temp.setFirstSectorID(iroad->getSector());
511  temp.setHitMap(hit_mask);
512  temp.setNMissing(nMissing);
513  temp.setQOverPt(y);
514 
515  temp.setSubRegion(iroad->getSubRegion());
516  temp.setHoughX(iroad->getX());
517  temp.setHoughY(iroad->getY());
518  temp.setHoughXBin(iroad->getXBin());
519  temp.setHoughYBin(iroad->getYBin());
521  // Get a list of indices for all possible combinations given a certain
522  // number of layers
523  std::vector<std::vector<int>> combs =
524  getComboIndices(iroad->getNHits_layer());
525 
526  // Loop over possible combinations for this road
527  for (size_t icomb = 0; icomb < combs.size(); icomb++) {
528  std::vector<float> inputTensorValues;
529 
530  // list of indices for this particular combination
531  std::vector<int> const &hit_indices = combs[icomb];
532  std::vector<std::shared_ptr<const FPGATrackSimHit>> hit_list;
533 
534  // Loop over all layers
535  for (unsigned layer = 0; layer < 13; layer++) {
536 
537  // Check to see if this is a valid hit
538  if (hit_indices[layer] >= 0) {
539 
540  std::shared_ptr<const FPGATrackSimHit> hit = iroad->getHits(layer)[hit_indices[layer]];
541  // Add this hit to the road
542  if (hit->isReal()){
543  hit_list.push_back(hit);
544  }
545  }
546  }
547 
548  // Sort the list by radial distance
549  std::sort(hit_list.begin(), hit_list.end(),
550  [](std::shared_ptr<const FPGATrackSimHit> &hit1, std::shared_ptr<const FPGATrackSimHit> &hit2) {
551  double rho1 = std::hypot(hit1->getX(), hit1->getY());
552  double rho2 = std::hypot(hit2->getX(), hit2->getY());
553  return rho1 < rho2;
554  });
555 
556 
557  int index = 1;
558  bool flipZ = false;
559  double rotateAngle = 0;
560  bool gotSecondSP = false;
561  float tmp_xf;
562  float tmp_yf;
563  float tmp_zf;
564  float tmp_rf;
565  float tmp_phif;
566  // Loop over all hits
567  for (const auto &hit : hit_list) {
568 
569  // Need to rotate hits
570  float x0 = hit->getX();
571  float y0 = hit->getY();
572  float z0 = hit->getZ();
573  float r0 = std::sqrt(x0*x0+y0*y0);
574  float phi0 = hit->getGPhi();
575  float xf = x0;
576  float yf = y0;
577  float zf = z0;
578  float rf = r0;
579  float phif = phi0;
580 
581  if (m_useCartesian) {
582  if (index == 1) {
583  if (z0 < 0)
584  flipZ = true;
585  rotateAngle = std::atan(x0 / y0);
586  if (y0 < 0)
587  rotateAngle += M_PI;
588  }
589  xf = x0 * std::cos(rotateAngle) - y0 * std::sin(rotateAngle);
590  yf = x0 * std::sin(rotateAngle) + y0 * std::cos(rotateAngle);
591  zf = z0;
592 
593  if (flipZ) zf = z0 * -1;
594  }
595 
596  // Get average of values for strip hit pairs
597  // TODO: this needs to be fixed in the future, for this to work for other cases
598  if (hit->isStrip()) {
599 
600  if (hit->getHitType() != HitType::spacepoint) { // this is a strip but not a SP!
601  if (m_useCartesian) {
602  float xf_scaled = (xf) / (getXScale());
603  float yf_scaled = (yf) / (getYScale());
604  float zf_scaled = (zf) / (getZScale());
605 
606  // Get average of two hits for strip hits
607  inputTensorValues.push_back(xf_scaled);
608  inputTensorValues.push_back(yf_scaled);
609  inputTensorValues.push_back(zf_scaled);
610  }
611  else {
612  float rf_scaled = (rf) / (getRScale());
613  float phif_scaled = (phif) / (getPhiScale());
614  float zf_scaled = (zf) / (getZScale());
615  // Get average of two hits for strip hits
616  inputTensorValues.push_back(rf_scaled);
617  inputTensorValues.push_back(phif_scaled);
618  inputTensorValues.push_back(zf_scaled);
619  }
620  }
621  else if (!gotSecondSP) {
622  tmp_xf = xf;
623  tmp_yf = yf;
624  tmp_zf = zf;
625  tmp_rf = rf;
626  tmp_phif = phif;
627  gotSecondSP = true;
628  }
629  else {
630  gotSecondSP = false;
631  if (m_useCartesian) {
632  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
633  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
634  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
635 
636  // Get average of two hits for strip hits
637  inputTensorValues.push_back(xf_scaled);
638  inputTensorValues.push_back(yf_scaled);
639  inputTensorValues.push_back(zf_scaled);
640  index++;
641  }
642  else {
643  float rf_scaled = (rf + tmp_rf) / (2.*getRScale());
644  float phif_scaled = (phif + tmp_phif) / (2.*getPhiScale());
645  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
646  inputTensorValues.push_back(rf_scaled);
647  inputTensorValues.push_back(phif_scaled);
648  inputTensorValues.push_back(zf_scaled);
649  }
650  }
651  }
652  else {
653  if (m_useCartesian) {
654  float xf_scaled = (xf) / (getXScale());
655  float yf_scaled = (yf) / (getYScale());
656  float zf_scaled = (zf) / (getZScale());
657  inputTensorValues.push_back(xf_scaled);
658  inputTensorValues.push_back(yf_scaled);
659  inputTensorValues.push_back(zf_scaled);
660  index++;
661  }
662  else {
663  float rf_scaled = (rf) / (getRScale());
664  float phif_scaled = (phif) / (getPhiScale());
665  float zf_scaled = (zf) / (getZScale());
666  inputTensorValues.push_back(rf_scaled);
667  inputTensorValues.push_back(phif_scaled);
668  inputTensorValues.push_back(zf_scaled);
669  }
670  }
671  }
672 
673 
674  if (inputTensorValues.size() < 39) {
675  inputTensorValues.resize(39, 0.0f); // Resize to 39 and fill with 0.0f
676  }
677  else if (inputTensorValues.size() > 39) {
678  inputTensorValues.resize(39); // Resize to 39 and keep the first 39 elements
679  }
680  inputTensorValuesAll.push_back(inputTensorValues);
681 
682  ATH_MSG_DEBUG("NN InputTensorValues:");
683  ATH_MSG_DEBUG(inputTensorValues);
684 
685  n_track++;
686  FPGATrackSimTrack track_cand;
687  track_cand.setTrackID(n_track);
688  track_cand.setNLayers(13);
689  track_cand.setNMissing(nMissing);
690  for (unsigned ihit = 0; ihit < hit_list.size(); ihit++) {
691  track_cand.setFPGATrackSimHit(ihit, *(hit_list[ihit]));
692  }
693  tracks.push_back(track_cand);
694 
695  } // loop over combinations
696  } // loop over roads
697 
699  auto NNoutputs = m_fakeNN_2nd.runONNXInference(inputTensorValuesAll);
700  for (unsigned itrack = 0; itrack < NNoutputs.size(); itrack++) {
701 
702  float nn_val = NNoutputs[itrack][0];
703  ATH_MSG_DEBUG("NN output:" << nn_val);
704 
705  double chi2 = (1 - nn_val) * (tracks[itrack].getNCoords() - tracks[itrack].getNMissing() - 5);
706 
707  tracks[itrack].setOrigChi2(chi2);
708  tracks[itrack].setChi2(chi2);
709  }
710 
711  // Add truth info
712  for (FPGATrackSimTrack &t : tracks) {
713  compute_truth(t); // match the track to a geant particle using the
714  // channel-level geant info in the hit data.
715  }
716 
717  return StatusCode::SUCCESS;
718 }

◆ getTracks_GNN()

StatusCode FPGATrackSimNNTrackTool::getTracks_GNN ( std::vector< std::shared_ptr< const FPGATrackSimRoad >> &  roads,
std::vector< FPGATrackSimTrack > &  tracks 
)

should be 2 missing coords for pixel

now we have saved our values, time to run inference and get the output

Definition at line 720 of file FPGATrackSimNNTrackTool.cxx.

720  {
721 
722  ATH_CHECK(setRoadSectors(roads));
723  int n_track = 0;
724 
725  std::vector<std::vector<float> >inputTensorValuesAll;
726 
727  // Loop over roads
728  for (auto const &iroad : roads) {
729  // Just used to get number of layers considered
730  const FPGATrackSimPlaneMap *planeMap = m_FPGATrackSimMapping->PlaneMap_1st(iroad->getSubRegion());
731 
732  double y = iroad->getY();
733 
734  // Get info on layers with missing hits
735  int nMissing = 0;
736  layer_bitmask_t missing_mask = 0;
737  layer_bitmask_t hit_mask = 0x0;
738  for (unsigned ilayer = 0; ilayer < 13; ilayer++) {
739  if ((missing_mask >> ilayer) & 0x1) {
740  nMissing++;
741  if (planeMap->isPixel(ilayer)) nMissing++;
742  }
743  else {
744  hit_mask |= (0x1 << ilayer);
745  }
746  }
747 
748 
749  // Create a template track with common parameters filled already for
750  // initializing below
751  FPGATrackSimTrack temp;
753  temp.setNLayers(planeMap->getNLogiLayers());
754  temp.setBankID(-1);
755  temp.setPatternID(iroad->getPID());
756  temp.setFirstSectorID(iroad->getSector());
757  temp.setHitMap(hit_mask);
758  temp.setNMissing(nMissing);
759  temp.setQOverPt(y);
760 
761  temp.setSubRegion(iroad->getSubRegion());
762  temp.setHoughX(iroad->getX());
763  temp.setHoughY(iroad->getY());
764  temp.setHoughXBin(iroad->getXBin());
765  temp.setHoughYBin(iroad->getYBin());
766 
768  // Get a list of indices for all possible combinations given a certain
769  // number of layers
770  std::vector<std::vector<int>> combs;
771  std::vector<std::shared_ptr<const FPGATrackSimHit>> all_hits;
772 
773  std::vector<std::shared_ptr<const FPGATrackSimHit>> all_pixel_hits;
774  std::vector<std::shared_ptr<const FPGATrackSimHit>> all_strip_hits;
775  size_t pixelCount = 0;
776 
777  for (unsigned layer = 0; layer < iroad->getNLayers(); ++layer) {
778  all_hits.insert(all_hits.end(), iroad->getHits(layer).begin(), iroad->getHits(layer).end());
779  }
780 
781  for (const auto& hit : all_hits) {
782  if(hit->isPixel()) {
783  pixelCount++;
784  }
785  }
786 
787  if (pixelCount < 1) continue; // Cannot use a form a track candidate from a road that does not have a pixel hit
788 
789  std::vector<float> inputTensorValues;
790  std::vector<std::shared_ptr<const FPGATrackSimHit>> hit_list;
791 
792  for (const auto &hit : all_hits) {
793  if (hit->isReal()) {
794  hit_list.push_back(hit);
795  }
796  }
797 
798  if (hit_list.size() < m_minNumberOfRealHitsInATrack) continue;
799 
800  // Sort the list by radial distance
801  std::sort(hit_list.begin(), hit_list.end(),
802  [](std::shared_ptr<const FPGATrackSimHit> &hit1, std::shared_ptr<const FPGATrackSimHit> &hit2) {
803  double rho1 = std::hypot(hit1->getX(), hit1->getY());
804  double rho2 = std::hypot(hit2->getX(), hit2->getY());
805  return rho1 < rho2;
806  });
807 
808 
809  int index = 1;
810  bool flipZ = false;
811  double rotateAngle = 0;
812  bool gotSecondSP = false;
813  float tmp_xf;
814  float tmp_yf;
815  float tmp_zf;
816  float tmp_phif;
817  float tmp_rf;
818 
819  // Loop over all hits
820  for (const auto &hit : hit_list) {
821  // Need to rotate hits
822  float x0 = hit->getX();
823  float y0 = hit->getY();
824  float z0 = hit->getZ();
825  float r0 = std::sqrt(x0*x0+y0*y0);
826  float phi0 = hit->getGPhi();
827  float xf = x0;
828  float yf = y0;
829  float zf = z0;
830  float rf = r0;
831  float phif = phi0;
832 
833  if (m_useCartesian) {
834  if (index == 1) {
835  if (z0 < 0)
836  flipZ = true;
837  rotateAngle = std::atan(x0 / y0);
838  if (y0 < 0)
839  rotateAngle += M_PI;
840  }
841  xf = x0 * std::cos(rotateAngle) - y0 * std::sin(rotateAngle);
842  yf = x0 * std::sin(rotateAngle) + y0 * std::cos(rotateAngle);
843  zf = z0;
844 
845  if (flipZ) zf = z0 * -1;
846  }
847 
848  // Get average of values for strip hit pairs
849  // TODO: this needs to be fixed in the future, for this to work for other cases
850  if (hit->isStrip()) {
851 
852  if (hit->getHitType() != HitType::spacepoint) { // this is a strip but not a SP!
853  if (m_useCartesian) {
854  float xf_scaled = (xf) / (getXScale());
855  float yf_scaled = (yf) / (getYScale());
856  float zf_scaled = (zf) / (getZScale());
857 
858  // Get average of two hits for strip hits
859  inputTensorValues.push_back(xf_scaled);
860  inputTensorValues.push_back(yf_scaled);
861  inputTensorValues.push_back(zf_scaled);
862 
863  }
864  else {
865  float rf_scaled = (rf) / (getRScale());
866  float phif_scaled = (phif) / (getPhiScale());
867  float zf_scaled = (zf) / (getZScale());
868  // Get average of two hits for strip hits
869  inputTensorValues.push_back(rf_scaled);
870  inputTensorValues.push_back(phif_scaled);
871  inputTensorValues.push_back(zf_scaled);
872  }
873  }
874  else if (!gotSecondSP) {
875  tmp_xf = xf;
876  tmp_yf = yf;
877  tmp_zf = zf;
878  tmp_phif = phif;
879  tmp_rf = rf;
880  gotSecondSP = true;
881  }
882  else {
883  gotSecondSP = false;
884  if (m_useCartesian) {
885  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
886  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
887  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
888 
889  // Get average of two hits for strip hits
890  inputTensorValues.push_back(xf_scaled);
891  inputTensorValues.push_back(yf_scaled);
892  inputTensorValues.push_back(zf_scaled);
893  index++;
894  }
895  else {
896  float rf_scaled = (rf + tmp_rf) / (2.*getRScale());
897  float phif_scaled = (phif + tmp_phif) / (2.*getPhiScale());
898  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
899  inputTensorValues.push_back(rf_scaled);
900  inputTensorValues.push_back(phif_scaled);
901  inputTensorValues.push_back(zf_scaled);
902  }
903  }
904  }
905  else {
906  if (m_useCartesian) {
907  float xf_scaled = (xf) / (getXScale());
908  float yf_scaled = (yf) / (getYScale());
909  float zf_scaled = (zf) / (getZScale());
910  inputTensorValues.push_back(xf_scaled);
911  inputTensorValues.push_back(yf_scaled);
912  inputTensorValues.push_back(zf_scaled);
913  index++;
914  }
915  else {
916  float rf_scaled = (rf) / (getRScale());
917  float phif_scaled = (phif) / (getPhiScale());
918  float zf_scaled = (zf) / (getZScale());
919  inputTensorValues.push_back(rf_scaled);
920  inputTensorValues.push_back(phif_scaled);
921  inputTensorValues.push_back(zf_scaled);
922  }
923  }
924  }
925 
926  // NN Estimator can either be 5 or 9 spacepoints as inputs
927  // Let this be decided by m_nInputsGNN
928 
929  // NN Estimator needs 9 spacepoints -> 27 inputs
930  // If there are more than 9 spacepoints entered, then it accepts the first 9
931  // If there are less than 9 spacepoints, then it enters no values for it (although I actually probably need to just reject these)
932  inputTensorValues.resize(m_nInputsGNN * 3);
933 
934  inputTensorValuesAll.push_back(inputTensorValues);
935  FPGATrackSimTrack track_cand;
936  track_cand.setTrackID(n_track);
937  track_cand.setNLayers(hit_list.size());
938  for (unsigned ihit = 0; ihit < hit_list.size(); ihit++) {
939  track_cand.setFPGATrackSimHit(ihit, *(hit_list[ihit]));
940  }
941  tracks.push_back(track_cand);
942 
943 
944  ATH_MSG_DEBUG("NN InputTensorValues:");
945  ATH_MSG_DEBUG(inputTensorValues);
946  } // loop over roads
947 
949  auto NNoutputs = m_fakeNN_1st.runONNXInference(inputTensorValuesAll);
950 
951  for (unsigned itrack = 0; itrack < NNoutputs.size(); itrack++) {
952 
953  float nn_val = NNoutputs[itrack][0];
954  ATH_MSG_DEBUG("NN output:" << nn_val);
955  double chi2 = (1 - nn_val) * (tracks[itrack].getNCoords() - tracks[itrack].getNMissing() - 5);
956  tracks[itrack].setOrigChi2(chi2);
957  tracks[itrack].setChi2(chi2);
958  }
959 
960  // Add truth info
961  for (FPGATrackSimTrack &t : tracks) {
962  compute_truth(t); // match the track to a geant particle using the
963  // channel-level geant info in the hit data.
964  }
965 
966  return StatusCode::SUCCESS;
967 }

◆ getXScale()

static float FPGATrackSimNNTrackTool::getXScale ( )
inlinestatic

Definition at line 54 of file FPGATrackSimNNTrackTool.h.

54 { return 1015.;};

◆ getYScale()

static float FPGATrackSimNNTrackTool::getYScale ( )
inlinestatic

Definition at line 55 of file FPGATrackSimNNTrackTool.h.

55 { return 1015.;};

◆ getZ0Scale()

static float FPGATrackSimNNTrackTool::getZ0Scale ( )
inlinestatic

Definition at line 61 of file FPGATrackSimNNTrackTool.h.

61 { return 200.;};

◆ getZScale()

static float FPGATrackSimNNTrackTool::getZScale ( )
inlinestatic

Definition at line 56 of file FPGATrackSimNNTrackTool.h.

56 { return 3000.;};

◆ initialize() [1/2]

StatusCode FPGATrackSimNNTrackTool::initialize ( )
overridevirtual

Definition at line 25 of file FPGATrackSimNNTrackTool.cxx.

25  {
26  ATH_CHECK(m_FPGATrackSimMapping.retrieve());
27  ATH_CHECK(m_tHistSvc.retrieve());
28  if (m_useSpacePoints) ATH_CHECK(m_spRoadFilterTool.retrieve(EnableTool{m_spRoadFilterTool}));
29 
30  if (m_FPGATrackSimMapping->getFakeNNMapString() != "") {
31  m_fakeNN_1st.initialize(m_FPGATrackSimMapping->getFakeNNMapString());
32  }
33  else {
34  ATH_MSG_ERROR("Path to 1st stage NN-based fake track removal ONNX file is empty! If you want to run this pipeline, you need to provide an input file.");
35  return StatusCode::FAILURE;
36  }
37 
38  if (m_FPGATrackSimMapping->getParamNNMapString() != "") {
39  m_paramNN_1st.initialize(m_FPGATrackSimMapping->getParamNNMapString());
40  }
41  else {
42  ATH_MSG_INFO("Path 1st stage to NN-based track parameter estimation ONNX file is empty! Estimation is not run...");
43  m_useParamNN_1st = false;
44  }
45 
46  if (m_FPGATrackSimMapping->getFakeNNMap2ndString() != "") {
47  m_fakeNN_2nd.initialize(m_FPGATrackSimMapping->getFakeNNMap2ndString());
48  }
49  else {
50  ATH_MSG_ERROR("Path to 2nd stage NN-based fake track 1st stage removal ONNX file is empty! If you want to run this pipeline, you need to provide an input file.");
51  return StatusCode::FAILURE;
52  }
53 
54  if (m_FPGATrackSimMapping->getParamNNMap2ndString() != "") {
55  m_paramNN_2nd.initialize(m_FPGATrackSimMapping->getParamNNMap2ndString());
56  }
57  else {
58  ATH_MSG_INFO("Path to 2nd stage NN-based track parameter estimation 2nd ONNX file is empty! Estimation is not run...");
59  m_useParamNN_2nd = false;
60  }
61 
62  return StatusCode::SUCCESS;
63 }

◆ initialize() [2/2]

void OnnxRuntimeBase::initialize ( TString  fileName)
inherited

Definition at line 16 of file OnnxRuntimeBase.cxx.

17 {
18  m_fileName = std::move(fileName);
19  //load the onnx model to memory using the path m_path_to_onnx
20  m_env = std::make_unique< Ort::Env >(ORT_LOGGING_LEVEL_WARNING, "");
21 
22  // Set the ONNX runtime session options
23  Ort::SessionOptions session_options;
24  // Set graph optimization level
25  session_options.SetIntraOpNumThreads(1);
26  session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
27  // Create the Ort session
28  m_session = std::make_unique< Ort::Session >(*m_env, m_fileName.Data(), session_options);
29  // Default allocator
30  Ort::AllocatorWithDefaultOptions allocator;
31  // Get the names of the input nodes of the model
32  size_t numInputNodes = m_session->GetInputCount();
33  // Iterate over all input nodes and get the name
34  for (size_t i = 0; i < numInputNodes; i++)
35  {
36  auto name = m_session->GetInputNameAllocated(i, allocator);
37  char* input_name = new char[strlen(name.get()) + 1];
38  strcpy(input_name, name.get());
39 
40  m_inputNodeNames.push_back(input_name);
41  // Get the dimensions of the input nodes,
42  // here we assume that all input nodes have the same dimensions
43  Ort::TypeInfo inputTypeInfo = m_session->GetInputTypeInfo(i);
44  auto tensorInfo = inputTypeInfo.GetTensorTypeAndShapeInfo();
45 
46  m_inputNodeDims = tensorInfo.GetShape();
47  }
48  // Get the names of the output nodes
49  size_t numOutputNodes = m_session->GetOutputCount();
50  // Iterate over all output nodes and get the name
51  for (size_t i = 0; i < numOutputNodes; i++)
52  {
53  auto name = m_session->GetOutputNameAllocated(i, allocator);
54  char* output_name = new char[strlen(name.get()) + 1];
55  strcpy(output_name, name.get());
56  m_outputNodeNames.push_back(output_name);
57  // Get the dimensions of the output nodes
58  // here we assume that all output nodes have the dimensions
59  Ort::TypeInfo outputTypeInfo = m_session->GetOutputTypeInfo(i);
60  auto tensorInfo = outputTypeInfo.GetTensorTypeAndShapeInfo();
61  m_outputNodeDims = tensorInfo.GetShape();
62  }
63 }

◆ matchIdealGeoSector()

void FPGATrackSimTrackingToolBase::matchIdealGeoSector ( FPGATrackSimRoad r)
inherited

Definition at line 36 of file FPGATrackSimTrackingToolBase.cxx.

37 {
38  // We now look up the binning information in the sector bank.
39  const FPGATrackSimSectorBank* sectorbank = nullptr;
40  if(! m_do2ndStage)
41  sectorbank = m_FPGATrackSimBank->SectorBank_1st();
42  else
43  sectorbank = m_FPGATrackSimBank->SectorBank_2nd();
44 
45  // Look up q/pt (or |q/pt|) from the Hough road, convert to MeV.
46  double qoverpt = r.getY()*0.001;
47  if (sectorbank->isAbsQOverPtBinning()) {
48  qoverpt = std::abs(qoverpt);
49  }
50 
51  // Retrieve the bin boundaries from the sector bank; map this onto them.
52  const std::vector<double> &qoverpt_bins = sectorbank->getQOverPtBins();
53  auto bounds = std::equal_range(qoverpt_bins.begin(), qoverpt_bins.end(), qoverpt);
54 
55  // estimate sectorbin
56  int sectorbin = fpgatracksim::QPT_SECTOR_OFFSET * (bounds.first - qoverpt_bins.begin() - 1);
57  sectorbin = std::clamp(sectorbin, 0, 10 * static_cast<int>(qoverpt_bins.size() - 2));
58  if (m_do2ndStage) sectorbin = 0;
59 
61  int subregion = r.getSubRegion();
62  sectorbin += subregion*fpgatracksim::SUBREGION_SECTOR_OFFSET;
63  }
64 
65  std::vector<module_t> modules(r.getNLayers(), -1);
66  layer_bitmask_t wc_layers = r.getWCLayers();
67  for (unsigned int il = 0; il < r.getNLayers(); il++) {
68  if (r.getNHits_layer()[il] == 0) {
69 
70  // set corresponding bit to 1 in case of wc in the current layer
71  wc_layers |= (0x1 << il);
72 
73  std::unique_ptr<FPGATrackSimHit> wcHit = std::make_unique<FPGATrackSimHit>();
75  wcHit->setLayer(il);
76  if(! m_do2ndStage)
77  wcHit->setDetType(m_FPGATrackSimMapping->PlaneMap_1st(0)->getDetType(il));
78  else
79  wcHit->setDetType(m_FPGATrackSimMapping->PlaneMap_2nd(0)->getDetType(il));
80 
81  // Now store wc hit in a "std::vector<std::shared_ptr<const FPGATrackSimHit>>" format.
82  // We can probably avoid initializing an intermediate variable wcHits as we used to do
83  r.setHits(il,{std::move(wcHit)});
84  }
85  else {
86  modules[il]= sectorbin;
87  }
88  }
89  r.setWCLayers(wc_layers);
90 
91 
92  // If we are using eta patterns. We need to first run the roads through the road filter.
93  // Then the filter will be responsible for setting the actual sector.
94  // As a hack, we can store the sector bin ID in the road for now.
95  // This is fragile! If we want to store a different ID for each layer, it will break.
96 
97  // Similarly, we do the same thing for spacepoints. this probably means we can't combine the two.
98  // maybe better to store the module array instead of just a number?
99 
100  r.setSectorBin(sectorbin);
102  r.setSector(sectorbank->findSector(modules));
103  }
104 }

◆ OnnxRuntimeBase() [1/2]

OnnxRuntimeBase::OnnxRuntimeBase
private

Definition at line 24 of file OnnxRuntimeBase.cxx.

14 {}

◆ OnnxRuntimeBase() [2/2]

OnnxRuntimeBase::OnnxRuntimeBase
private

Definition at line 23 of file OnnxRuntimeBase.cxx.

10 {
11  initialize(std::move(fileName));
12 }

◆ runONNXInference() [1/3]

std::vector< std::vector< float > > OnnxRuntimeBase::runONNXInference ( NetworkBatchInput inputTensorValues) const
inherited

Definition at line 96 of file OnnxRuntimeBase.cxx.

97 {
98  int batchSize = inputTensorValues.rows();
99  std::vector<int64_t> inputNodeDims = m_inputNodeDims;
100  std::vector<int64_t> outputNodeDims = m_outputNodeDims; //bad. Assumes they all have the same number of nodes.
101 
102  // The first dim node should correspond to the batch size
103  // If it is -1, it is dynamic and should be set to the input size
104  if (inputNodeDims[0] == -1)
105  {
106  inputNodeDims[0] = batchSize;
107  }
108  if (outputNodeDims[0] == -1)
109  {
110  outputNodeDims[0] = batchSize;
111  }
112 
113  if(inputNodeDims[1]*inputNodeDims[2] != inputTensorValues.cols() && inputNodeDims[1] != inputTensorValues.cols())
114  {
115  throw std::runtime_error("runONNXInference: feature size doesn't match the input size: inputSize required: " + std::to_string(inputNodeDims[1]*inputNodeDims[2]) + " inputSize provided: " + std::to_string(inputTensorValues.cols()));
116  }
117 
118  if (batchSize != 1 && (inputNodeDims[0] != batchSize || outputNodeDims[0] != batchSize))
119  {
120  throw std::runtime_error("runONNXInference: batch size doesn't match the input or output node size");
121  }
122 
123  // Create input tensor object from data values
124  // note: this assumes the model has only 1 input node
125  Ort::MemoryInfo memoryInfo = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
126  Ort::Value inputTensor = Ort::Value::CreateTensor<float>(memoryInfo, inputTensorValues.data(), inputTensorValues.size(),inputNodeDims.data(), inputNodeDims.size());
127  // Double-check that inputTensor is a Tensor
128  if (!inputTensor.IsTensor())
129  {
130  throw std::runtime_error("runONNXInference: conversion of input to Tensor failed. ");
131  }
132  // Score model on input tensors, get back output tensors
133  Ort::RunOptions run_options;
134  std::vector<Ort::Value> outputTensors =
135  m_session->Run(run_options, m_inputNodeNames.data(), &inputTensor,
136  m_inputNodeNames.size(), m_outputNodeNames.data(),
137  m_outputNodeNames.size());
138  // Double-check that outputTensors contains Tensors and that the count matches
139  // that of output nodes
140  if (!outputTensors[0].IsTensor() || (outputTensors.size() != m_outputNodeNames.size())) {
141  throw std::runtime_error("runONNXInference: calculation of output failed. ");
142  }
143  // Get pointer to output tensor float values
144  // note: this assumes the model has only 1 output value
145  float* outputTensor = outputTensors.front().GetTensorMutableData<float>();
146  // Get the output values
147  std::vector<std::vector<float>> outputTensorValues(batchSize, std::vector<float>(outputNodeDims[1], -1));
148  for (int i = 0; i < outputNodeDims[0]; i++)
149  {
150  for (int j = 0; j < ((outputNodeDims.size() > 1) ? outputNodeDims[1] : 1); j++)
151  {
152  outputTensorValues[i][j] = outputTensor[i * outputNodeDims[1] + j];
153  }
154  }
155 
156  return outputTensorValues;
157 }

◆ runONNXInference() [2/3]

std::vector< float > OnnxRuntimeBase::runONNXInference ( std::vector< float > &  inputTensorValues) const
inherited

Definition at line 84 of file OnnxRuntimeBase.cxx.

85 {
86  NetworkBatchInput vectorInput(1, inputTensorValues.size());
87  for (size_t i = 0; i < inputTensorValues.size(); i++) {
88  vectorInput(0, i) = inputTensorValues[i];
89  }
90  auto vectorOutput = runONNXInference(vectorInput);
91  return vectorOutput[0];
92 }

◆ runONNXInference() [3/3]

std::vector< std::vector< float > > OnnxRuntimeBase::runONNXInference ( std::vector< std::vector< float > > &  inputTensorValues) const
inherited

Definition at line 66 of file OnnxRuntimeBase.cxx.

67 {
68  std::vector<std::vector<float> > output;
69  if (inputTensorValues.size() == 0) return output;
70 
71  NetworkBatchInput vectorInput(inputTensorValues.size(), inputTensorValues[0].size());
72  for (size_t i = 0; i < inputTensorValues.size(); i++) {
73  for (size_t j = 0; j < inputTensorValues[i].size(); j++) {
74  vectorInput(i,j) = inputTensorValues[i][j];
75  }
76  }
77  output = runONNXInference(vectorInput);
78  return output;
79 }

◆ runONNXInferenceMultilayerOutput()

std::map< int, Eigen::MatrixXf > OnnxRuntimeBase::runONNXInferenceMultilayerOutput ( NetworkBatchInput inputTensorValues) const
inherited

Definition at line 162 of file OnnxRuntimeBase.cxx.

163 {
164  const int batchSize = inputTensorValues.rows();
165  std::vector<int64_t> inputNodeDims = m_inputNodeDims;
166  std::vector<int64_t> outputNodeDims = m_outputNodeDims;
167 
168  // The first dim node should correspond to the batch size
169  // If it is -1, it is dynamic and should be set to the input size
170  if (inputNodeDims[0] == -1)
171  {
172  inputNodeDims[0] = batchSize;
173  }
174  if (outputNodeDims[0] == -1)
175  {
176  outputNodeDims[0] = batchSize;
177  }
178 
179  if(inputNodeDims[1] != inputTensorValues.cols())
180  {
181  throw std::runtime_error("runONNXInference: feature size doesn't match the input size: inputSize required: " + std::to_string(inputNodeDims[1]) + " inputSize provided: " + std::to_string(inputTensorValues.cols()));
182  }
183 
184  if (batchSize != 1 &&(inputNodeDims[0] != batchSize || outputNodeDims[0] != batchSize))
185  {
186  throw std::runtime_error("runONNXInference: batch size doesn't match the input or output node size");
187  }
188  // Create input tensor object from data values
189  // note: this assumes the model has only 1 input node
190  Ort::MemoryInfo memoryInfo = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
191  Ort::Value inputTensor = Ort::Value::CreateTensor<float>(memoryInfo, inputTensorValues.data(), inputTensorValues.size(), inputNodeDims.data(), inputNodeDims.size());
192  // Double-check that inputTensor is a Tensor
193  if (!inputTensor.IsTensor())
194  {
195  throw std::runtime_error("runONNXInference: conversion of input to Tensor failed. ");
196  }
197  // Score model on input tensors, get back output tensors
198  Ort::RunOptions run_options;
199  std::vector<Ort::Value> outputTensors =
200  m_session->Run(run_options, m_inputNodeNames.data(), &inputTensor,
201  m_inputNodeNames.size(), m_outputNodeNames.data(),
202  m_outputNodeNames.size());
203  // Double-check that outputTensors contains Tensors and that the count matches
204  // that of output nodes
205  if (!outputTensors[0].IsTensor() || (outputTensors.size() != m_outputNodeNames.size())) {
206  throw std::runtime_error("runONNXInference: calculation of output failed. ");
207  }
208  // Get pointers to output tensor float values
209  // note: this assumes the model has multiple output layers
210  std::map<int, Eigen::MatrixXf> outputTensorMap;
211  size_t numOutputNodes = m_session->GetOutputCount();
212  for (size_t i=0; i<numOutputNodes; i++){ // two output layers
213 
214  // retrieve pointer to output float tenor
215  float* output = outputTensors.at(i).GetTensorMutableData<float>();
216  Ort::TypeInfo outputTypeInfo = m_session->GetOutputTypeInfo(i);
217  auto outputTensorInfo = outputTypeInfo.GetTensorTypeAndShapeInfo();
218  // Not all outputNodes have the same shape. Get the new shape.
219  // First dimension should be batch size
220  outputNodeDims = outputTensorInfo.GetShape();
221 
222  int nNodes = outputNodeDims.size() > 1 ? outputNodeDims[1] : 1;
223  Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> batchMatrix(batchSize, nNodes);
224  for (int j = 0; j < batchSize; j++)
225  {
226  Eigen::VectorXf vec(nNodes);
227  for (int k = 0; k<nNodes; k++)
228  {
229  float val = output[j * outputNodeDims[1] + k];
230  vec(k) = val;
231  }
232  batchMatrix.row(j) = vec;
233  } // batch
234  outputTensorMap[i] = std::move(batchMatrix);
235  } // output layers
236  return outputTensorMap;
237 }

◆ setRoadSectors()

StatusCode FPGATrackSimTrackingToolBase::setRoadSectors ( std::vector< std::shared_ptr< const FPGATrackSimRoad >> &  roads)
inherited

Definition at line 11 of file FPGATrackSimTrackingToolBase.cxx.

12 {
13  for (auto& road: roads)
14  {
15  std::shared_ptr<FPGATrackSimRoad> nonConstRoad = std::const_pointer_cast<FPGATrackSimRoad>(road);
16  if (m_useSectors) {
17  if(! m_do2ndStage)
18  nonConstRoad->setSector(m_FPGATrackSimBank->SectorBank_1st()->findSector(nonConstRoad->getAllHits()));
19  else
20  nonConstRoad->setSector(m_FPGATrackSimBank->SectorBank_2nd()->findSector(nonConstRoad->getAllHits()));
21  }
22  else if (m_idealGeoRoads) matchIdealGeoSector(*nonConstRoad);
23  }
24  // Spacepoint road filter tool. Needed when fitting to spacepoints.
25  if (m_useSpacePoints)
26  {
27  std::vector<std::shared_ptr<const FPGATrackSimRoad>> postfilter_roads;
28  ATH_CHECK(m_spRoadFilterTool->filterRoads(roads, postfilter_roads));
29  roads = std::move(postfilter_roads);
30  }
31  return StatusCode::SUCCESS;
32 }

◆ setTrackParameters()

StatusCode FPGATrackSimNNTrackTool::setTrackParameters ( std::vector< FPGATrackSimTrack > &  tracks,
bool  isFirst,
const FPGATrackSimTrackPars min,
const FPGATrackSimTrackPars max 
)

only set this for tracks passing goodness of fit AND overlap removal

Definition at line 66 of file FPGATrackSimNNTrackTool.cxx.

66  {
67 
68  ATH_MSG_DEBUG("Running NN-based track parameter estimation!");
69  std::vector<float> paramNNoutputs;
70  if (!m_useParamNN_1st && isFirst) return StatusCode::SUCCESS;
71  if (!m_useParamNN_2nd && !isFirst) return StatusCode::SUCCESS;
72 
73  for (auto &track : tracks) {
74  if (!track.passedOR()) continue;
75  std::vector<float> inputTensorValues;
76  const std::vector <FPGATrackSimHit>& hits = track.getFPGATrackSimHits();
77  bool gotSecondSP = false;
78  float tmp_xf;
79  float tmp_yf;
80  float tmp_zf;
81  float tmp_rf;
82  float tmp_phif;
83 
84  for (const auto& hit : hits) {
85  if (!hit.isReal()) continue;
86 
87  // Need to rotate hits
88  float xf = hit.getX();
89  float yf = hit.getY();
90  float zf = hit.getZ();
91  float rf = std::sqrt(xf*xf+yf*yf);
92  float phif = hit.getGPhi();
93 
94  // Get average of values for strip hit pairs
95  // TODO: this needs to be fixed in the future, for this to work for other cases
96  if (hit.isStrip()) {
97  if (hit.getHitType() != HitType::spacepoint) { // this is a strip but not a SP!
98  if (m_useCartesian) {
99  float xf_scaled = (xf) / (getXScale());
100  float yf_scaled = (yf) / (getYScale());
101  float zf_scaled = (zf) / (getZScale());
102 
103  // Get average of two hits for strip hits
104  inputTensorValues.push_back(xf_scaled);
105  inputTensorValues.push_back(yf_scaled);
106  inputTensorValues.push_back(zf_scaled);
107 
108  }
109  else {
110  float rf_scaled = (rf) / (getRScale());
111  float phif_scaled = (phif) / (getPhiScale());
112  float zf_scaled = (zf) / (getZScale());
113  // Get average of two hits for strip hits
114  inputTensorValues.push_back(rf_scaled);
115  inputTensorValues.push_back(phif_scaled);
116  inputTensorValues.push_back(zf_scaled);
117  }
118  }
119  else if (!gotSecondSP) {
120  tmp_xf = xf;
121  tmp_yf = yf;
122  tmp_zf = zf;
123  tmp_rf = rf;
124  tmp_phif = phif;
125  gotSecondSP = true;
126  }
127  else {
128  gotSecondSP = false;
129 
130  if (m_useCartesian) {
131  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
132  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
133  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
134 
135  // Get average of two hits for strip hits
136  inputTensorValues.push_back(xf_scaled);
137  inputTensorValues.push_back(yf_scaled);
138  inputTensorValues.push_back(zf_scaled);
139 
140  }
141  else {
142  float rf_scaled = (rf+tmp_rf) / (2.*getRScale());
143  float phif_scaled = (phif+tmp_phif) / (2.*getPhiScale());
144  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
145  // Get average of two hits for strip hits
146  inputTensorValues.push_back(rf_scaled);
147  inputTensorValues.push_back(phif_scaled);
148  inputTensorValues.push_back(zf_scaled);
149  }
150  }
151  }
152  else {
153  if (m_useCartesian) {
154  float xf_scaled = (xf) / (getXScale());
155  float yf_scaled = (yf) / (getYScale());
156  float zf_scaled = (zf) / (getZScale());
157  inputTensorValues.push_back(xf_scaled);
158  inputTensorValues.push_back(yf_scaled);
159  inputTensorValues.push_back(zf_scaled);
160  }
161  else {
162  float rf_scaled = (rf) / (getRScale());
163  float phif_scaled = (phif) / (getPhiScale());
164  float zf_scaled = (zf) / (getZScale());
165  // Get average of two hits for strip hits
166  inputTensorValues.push_back(rf_scaled);
167  inputTensorValues.push_back(phif_scaled);
168  inputTensorValues.push_back(zf_scaled);
169  }
170  }
171  }
172 
173  if (isFirst){
174  if (inputTensorValues.size() < 15) {
175  inputTensorValues.resize(15, 0.0f); // Resize to 15 and fill with 0.0f
176  }
177 
178  if (m_doGNNTracking) {
179  inputTensorValues.resize(m_nInputsGNN * 3);
180  }
181  }
182  else {
183  if (inputTensorValues.size() < 39) {
184  inputTensorValues.resize(39, 0.0f); // Resize to 39 and fill with 0.0f
185  }
186  else if (inputTensorValues.size() > 39) {
187  inputTensorValues.resize(39); // Resize to 39 and keep the first e9 elements
188  }
189  }
190 
191  if (m_doGNNTracking) {
192  inputTensorValues.resize(m_nInputsGNN * 3);
193  }
194 
195 
196  if (isFirst) paramNNoutputs = m_paramNN_1st.runONNXInference(inputTensorValues);
197  else paramNNoutputs = m_paramNN_2nd.runONNXInference(inputTensorValues);
198 
199  ATH_MSG_DEBUG("Estimated Track Parameters");
200  for (unsigned int i = 0; i < paramNNoutputs.size(); i++) {
201  ATH_MSG_DEBUG(paramNNoutputs[i]);
202  }
203 
204 
205  double qopt = paramNNoutputs[0]*getQoverPtScale();
206  double eta = paramNNoutputs[1]*getEtaScale();
207  double phi = paramNNoutputs[2]*getPhiScale();
208  double d0 = paramNNoutputs[3]*getD0Scale();
209  double z0 = paramNNoutputs[4]*getZ0Scale();
210 
211 
222 
223  track.setQOverPt(qopt);
224  track.setEta(eta);
225  track.setPhi(phi);
226  track.setD0(d0);
227  track.setZ0(z0);
228  }
229  return StatusCode::SUCCESS;
230 }

Member Data Documentation

◆ m_barcode

std::vector<int> FPGATrackSimNNTrackTool::m_barcode
private

Definition at line 87 of file FPGATrackSimNNTrackTool.h.

◆ m_barcodefrac

std::vector<float> FPGATrackSimNNTrackTool::m_barcodefrac
private

Definition at line 86 of file FPGATrackSimNNTrackTool.h.

◆ m_do2ndStage

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_do2ndStage {this, "Do2ndStageTrackFit", false, "Do 2nd stage track fit"}
protectedinherited

Definition at line 40 of file FPGATrackSimTrackingToolBase.h.

◆ m_doEtaPatternConsts

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_doEtaPatternConsts { this, "doEtaPatternConsts", false, "Whether to use the eta pattern tool for constant generation" }
protectedinherited

Definition at line 35 of file FPGATrackSimTrackingToolBase.h.

◆ m_doGNNTracking

Gaudi::Property<bool> FPGATrackSimNNTrackTool::m_doGNNTracking { this, "doGNNTracking", false, "Flag to turn on GNN Tracking configuration for road-to-track" }

Definition at line 66 of file FPGATrackSimNNTrackTool.h.

◆ m_doRegionalMapping

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_doRegionalMapping { this, "RegionalMapping", false, "Use the sub-region maps to define the sector" }
protectedinherited

Definition at line 34 of file FPGATrackSimTrackingToolBase.h.

◆ m_env

std::unique_ptr< Ort::Env > OnnxRuntimeBase::m_env
privateinherited

Definition at line 45 of file OnnxRuntimeBase.h.

◆ m_etamodule

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_etamodule
private

Definition at line 94 of file FPGATrackSimNNTrackTool.h.

◆ m_etawidth

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_etawidth
private

Definition at line 92 of file FPGATrackSimNNTrackTool.h.

◆ m_eventindex

std::vector<int> FPGATrackSimNNTrackTool::m_eventindex
private

Definition at line 88 of file FPGATrackSimNNTrackTool.h.

◆ m_fakeNN_1st

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_fakeNN_1st
private

Definition at line 77 of file FPGATrackSimNNTrackTool.h.

◆ m_fakeNN_2nd

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_fakeNN_2nd
private

Definition at line 78 of file FPGATrackSimNNTrackTool.h.

◆ m_fileName

TString OnnxRuntimeBase::m_fileName
inherited

Definition at line 17 of file OnnxRuntimeBase.h.

◆ m_FPGATrackSimBank

ServiceHandle<IFPGATrackSimBankSvc> FPGATrackSimTrackingToolBase::m_FPGATrackSimBank { this,"FPGATrackSimBankSvc","FPGATrackSimBankSvc" }
protectedinherited

Definition at line 30 of file FPGATrackSimTrackingToolBase.h.

◆ m_FPGATrackSimMapping

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

Definition at line 72 of file FPGATrackSimNNTrackTool.h.

◆ m_ID

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_ID
private

Definition at line 96 of file FPGATrackSimNNTrackTool.h.

◆ m_idealGeoRoads

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_idealGeoRoads { this, "IdealGeoRoads", true, "Set sectors to use ideal geometry fit constants" }
protectedinherited

Definition at line 38 of file FPGATrackSimTrackingToolBase.h.

◆ m_input_node_dims

std::vector<int64_t> FPGATrackSimNNTrackTool::m_input_node_dims
private

Definition at line 111 of file FPGATrackSimNNTrackTool.h.

◆ m_input_node_names

std::vector<const char*> FPGATrackSimNNTrackTool::m_input_node_names
private

Definition at line 110 of file FPGATrackSimNNTrackTool.h.

◆ m_inputNodeDims

std::vector<int64_t> OnnxRuntimeBase::m_inputNodeDims
privateinherited

Definition at line 41 of file OnnxRuntimeBase.h.

◆ m_inputNodeNames

std::vector<const char*> OnnxRuntimeBase::m_inputNodeNames
privateinherited

Definition at line 40 of file OnnxRuntimeBase.h.

◆ m_isBarrel

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_isBarrel
private

Definition at line 91 of file FPGATrackSimNNTrackTool.h.

◆ m_isPixel

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_isPixel
private

Definition at line 89 of file FPGATrackSimNNTrackTool.h.

◆ m_isSecondStage

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_isSecondStage { this, "isSecondStage", true, "Is this the second stage?" }
protectedinherited

Definition at line 39 of file FPGATrackSimTrackingToolBase.h.

◆ m_layer

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_layer
private

Definition at line 90 of file FPGATrackSimNNTrackTool.h.

◆ m_minNumberOfRealHitsInATrack

Gaudi::Property<unsigned int> FPGATrackSimNNTrackTool::m_minNumberOfRealHitsInATrack { this, "MinNumberOfRealHitsInATrack", 4, "Minimum number of real hits in a track candidate to process" }

Definition at line 65 of file FPGATrackSimNNTrackTool.h.

◆ m_nInputsGNN

Gaudi::Property<int> FPGATrackSimNNTrackTool::m_nInputsGNN { this, "nInputsGNN", 9, "Number of Hit Inputs for NN for GNN configuration. Depends on which model is chosen."}

Definition at line 67 of file FPGATrackSimNNTrackTool.h.

◆ m_output_node_names

std::vector<const char*> FPGATrackSimNNTrackTool::m_output_node_names
private

Definition at line 112 of file FPGATrackSimNNTrackTool.h.

◆ m_outputNodeDims

std::vector<int64_t> OnnxRuntimeBase::m_outputNodeDims
privateinherited

Definition at line 43 of file OnnxRuntimeBase.h.

◆ m_outputNodeNames

std::vector<const char*> OnnxRuntimeBase::m_outputNodeNames
privateinherited

Definition at line 42 of file OnnxRuntimeBase.h.

◆ m_paramNN_1st

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_paramNN_1st
private

Definition at line 75 of file FPGATrackSimNNTrackTool.h.

◆ m_paramNN_2nd

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_paramNN_2nd
private

Definition at line 76 of file FPGATrackSimNNTrackTool.h.

◆ m_phimodule

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_phimodule
private

Definition at line 95 of file FPGATrackSimNNTrackTool.h.

◆ m_phiwidth

std::vector<unsigned int> FPGATrackSimNNTrackTool::m_phiwidth
private

Definition at line 93 of file FPGATrackSimNNTrackTool.h.

◆ m_session

std::unique_ptr<Ort::Session> OnnxRuntimeBase::m_session
privateinherited

ONNX runtime session / model properties.

Definition at line 38 of file OnnxRuntimeBase.h.

◆ m_spRoadFilterTool

ToolHandle<IFPGATrackSimRoadFilterTool> FPGATrackSimTrackingToolBase::m_spRoadFilterTool {this, "SPRoadFilterTool", "FPGATrackSimSpacepointRoadFilterTool", "Spacepoint Road Filter Tool"}
protectedinherited

Definition at line 32 of file FPGATrackSimTrackingToolBase.h.

◆ m_tHistSvc

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

Definition at line 73 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_barcode

std::vector<int> FPGATrackSimNNTrackTool::m_truth_barcode
private

Definition at line 105 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_d0

std::vector<float> FPGATrackSimNNTrackTool::m_truth_d0
private

Definition at line 98 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_eta

std::vector<float> FPGATrackSimNNTrackTool::m_truth_eta
private

Definition at line 101 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_eventindex

std::vector<int> FPGATrackSimNNTrackTool::m_truth_eventindex
private

Definition at line 106 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_pdg

std::vector<float> FPGATrackSimNNTrackTool::m_truth_pdg
private

Definition at line 103 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_phi

std::vector<float> FPGATrackSimNNTrackTool::m_truth_phi
private

Definition at line 102 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_pt

std::vector<float> FPGATrackSimNNTrackTool::m_truth_pt
private

Definition at line 100 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_q

std::vector<int> FPGATrackSimNNTrackTool::m_truth_q
private

Definition at line 104 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_z0

std::vector<float> FPGATrackSimNNTrackTool::m_truth_z0
private

Definition at line 99 of file FPGATrackSimNNTrackTool.h.

◆ m_useCartesian

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

Definition at line 68 of file FPGATrackSimNNTrackTool.h.

◆ m_useParamNN_1st

bool FPGATrackSimNNTrackTool::m_useParamNN_1st = true
private

Definition at line 80 of file FPGATrackSimNNTrackTool.h.

◆ m_useParamNN_2nd

bool FPGATrackSimNNTrackTool::m_useParamNN_2nd = true
private

Definition at line 81 of file FPGATrackSimNNTrackTool.h.

◆ m_useSectors

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_useSectors { this, "useSectors", false, "Will reverse calculate the sector for track-fitting purposes" }
protectedinherited

Definition at line 37 of file FPGATrackSimTrackingToolBase.h.

◆ m_useSpacePoints

Gaudi::Property<bool> FPGATrackSimTrackingToolBase::m_useSpacePoints { this, "useSpacePoints", false, "Whether we are using spacepoints." }
protectedinherited

Definition at line 36 of file FPGATrackSimTrackingToolBase.h.

◆ m_x

std::vector<float> FPGATrackSimNNTrackTool::m_x
private

Definition at line 83 of file FPGATrackSimNNTrackTool.h.

◆ m_y

std::vector<float> FPGATrackSimNNTrackTool::m_y
private

Definition at line 84 of file FPGATrackSimNNTrackTool.h.

◆ m_z

std::vector<float> FPGATrackSimNNTrackTool::m_z
private

Definition at line 85 of file FPGATrackSimNNTrackTool.h.


The documentation for this class was generated from the following files:
FPGATrackSimTrack::setHitMap
void setHitMap(unsigned int v)
Definition: FPGATrackSimTrack.h:101
fpgatracksim::SUBREGION_SECTOR_OFFSET
constexpr int SUBREGION_SECTOR_OFFSET
Definition: FPGATrackSimConstants.h:24
FPGATrackSimNNTrackTool::m_minNumberOfRealHitsInATrack
Gaudi::Property< unsigned int > m_minNumberOfRealHitsInATrack
Definition: FPGATrackSimNNTrackTool.h:65
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
OnnxRuntimeBase::runONNXInference
std::vector< float > runONNXInference(std::vector< float > &inputTensorValues) const
Definition: OnnxRuntimeBase.cxx:84
FPGATrackSimTrackPars::IHIP
@ IHIP
Definition: FPGATrackSimTrackPars.h:49
beamspotman.r
def r
Definition: beamspotman.py:672
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:215
FPGATrackSimTrackPars::ID0
@ ID0
Definition: FPGATrackSimTrackPars.h:49
getMenu.algname
algname
Definition: getMenu.py:54
FPGATrackSimTrackingToolBase::m_FPGATrackSimBank
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBank
Definition: FPGATrackSimTrackingToolBase.h:30
FPGATrackSimNNTrackTool::getRScale
static float getRScale()
Definition: FPGATrackSimNNTrackTool.h:62
FPGATrackSimPlaneMap::getNLogiLayers
uint32_t getNLogiLayers() const
Definition: FPGATrackSimPlaneMap.h:75
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
OnnxRuntimeBase::m_env
std::unique_ptr< Ort::Env > m_env
Definition: OnnxRuntimeBase.h:45
FPGATrackSimHit::isStrip
bool isStrip() const
Definition: FPGATrackSimHit.h:65
FPGATrackSimTrack::setBankID
void setBankID(int v)
Definition: FPGATrackSimTrack.h:84
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimNNTrackTool::m_useCartesian
Gaudi::Property< bool > m_useCartesian
Definition: FPGATrackSimNNTrackTool.h:68
FPGATrackSimTrack
Definition: FPGATrackSimTrack.h:18
FPGATrackSimTrackingToolBase::m_doRegionalMapping
Gaudi::Property< bool > m_doRegionalMapping
Definition: FPGATrackSimTrackingToolBase.h:34
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
OnnxRuntimeBase::initialize
void initialize(TString)
Definition: OnnxRuntimeBase.cxx:16
FPGATrackSimTrack::setPatternID
void setPatternID(int v)
Definition: FPGATrackSimTrack.h:85
index
Definition: index.py:1
FPGATrackSimMultiTruth::Weight
float Weight
Definition: FPGATrackSimMultiTruth.h:50
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
FPGATrackSimTrackPars::IZ0
@ IZ0
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:149
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
python.HLT.MinBias.MinBiasMenuSequences.zf
zf
Definition: MinBiasMenuSequences.py:224
FPGATrackSimTrack::setNMissing
void setNMissing(int v)
Definition: FPGATrackSimTrack.h:99
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:40
FPGATrackSimNNTrackTool::m_doGNNTracking
Gaudi::Property< bool > m_doGNNTracking
Definition: FPGATrackSimNNTrackTool.h:66
M_PI
#define M_PI
Definition: ActiveFraction.h:11
FPGATrackSimTrack::setHoughXBin
void setHoughXBin(unsigned v)
Definition: FPGATrackSimTrack.h:109
FPGATrackSimTrack::setFirstSectorID
void setFirstSectorID(int v)
Definition: FPGATrackSimTrack.h:86
HitType::spacepoint
@ spacepoint
FPGATrackSimNNTrackTool::getXScale
static float getXScale()
Definition: FPGATrackSimNNTrackTool.h:54
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
OnnxRuntimeBase::m_outputNodeDims
std::vector< int64_t > m_outputNodeDims
Definition: OnnxRuntimeBase.h:43
FPGATrackSimTrack::setFPGATrackSimHit
void setFPGATrackSimHit(unsigned i, const FPGATrackSimHit &hit)
Definition: FPGATrackSimTrack.cxx:98
FPGATrackSimTrackingToolBase::FPGATrackSimTrackingToolBase
FPGATrackSimTrackingToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Definition: FPGATrackSimTrackingToolBase.cxx:6
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
FPGATrackSimSectorBank::getQOverPtBins
const std::vector< double > & getQOverPtBins() const
Definition: FPGATrackSimSectorBank.h:52
FPGATrackSimNNTrackTool::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: FPGATrackSimNNTrackTool.h:73
OnnxRuntimeBase::m_inputNodeDims
std::vector< int64_t > m_inputNodeDims
Definition: OnnxRuntimeBase.h:41
FPGATrackSimHit::getGPhi
float getGPhi() const
Definition: FPGATrackSimHit.h:153
HitType::wildcard
@ wildcard
FPGATrackSimNNTrackTool::m_paramNN_1st
OnnxRuntimeBase m_paramNN_1st
Definition: FPGATrackSimNNTrackTool.h:75
FPGATrackSimPlaneMap::isPixel
bool isPixel(int pl) const
Definition: FPGATrackSimPlaneMap.h:107
OnnxRuntimeBase::m_session
std::unique_ptr< Ort::Session > m_session
ONNX runtime session / model properties.
Definition: OnnxRuntimeBase.h:34
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
FPGATrackSimTrackingToolBase::matchIdealGeoSector
void matchIdealGeoSector(FPGATrackSimRoad &r)
Definition: FPGATrackSimTrackingToolBase.cxx:36
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimTrack::setHoughYBin
void setHoughYBin(unsigned v)
Definition: FPGATrackSimTrack.h:110
OnnxRuntimeBase::m_inputNodeNames
std::vector< const char * > m_inputNodeNames
Definition: OnnxRuntimeBase.h:40
FPGATrackSimNNTrackTool::getEtaScale
static float getEtaScale()
Definition: FPGATrackSimNNTrackTool.h:58
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
FPGATrackSimTrackingToolBase::setRoadSectors
StatusCode setRoadSectors(std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads)
Definition: FPGATrackSimTrackingToolBase.cxx:11
FPGATrackSimSectorBank::findSector
sector_t findSector(std::vector< module_t > const &modules) const
Definition: FPGATrackSimSectorBank.cxx:121
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FPGATrackSimTrackingToolBase::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimTrackingToolBase.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
TrackStage::FIRST
@ FIRST
FPGATrackSimMultiTruth::Barcode
std::pair< unsigned long, unsigned long > Barcode
Definition: FPGATrackSimMultiTruth.h:49
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
TRT_PAI_physicsConstants::r0
const double r0
electron radius{cm}
Definition: TRT_PAI_physicsConstants.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimNNTrackTool::m_nInputsGNN
Gaudi::Property< int > m_nInputsGNN
Definition: FPGATrackSimNNTrackTool.h:67
TrackStage::SECOND
@ SECOND
hist_file_dump.f
f
Definition: hist_file_dump.py:140
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:150
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
FPGATrackSimNNTrackTool::getD0Scale
static float getD0Scale()
Definition: FPGATrackSimNNTrackTool.h:60
FPGATrackSimSectorBank
Definition: FPGATrackSimSectorBank.h:32
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:151
getComboIndices
std::vector< std::vector< int > > getComboIndices(std::vector< size_t > const &sizes)
Given a vector of sizes (of arrays), generates a vector of all combinations of indices to index one e...
Definition: FPGATrackSimFunctions.cxx:21
FPGATrackSimNNTrackTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimNNTrackTool.h:72
FPGATrackSimTrackingToolBase::m_useSpacePoints
Gaudi::Property< bool > m_useSpacePoints
Definition: FPGATrackSimTrackingToolBase.h:36
FPGATrackSimPlaneMap
Definition: FPGATrackSimPlaneMap.h:62
OnnxRuntimeBase::m_fileName
TString m_fileName
Definition: OnnxRuntimeBase.h:17
merge.output
output
Definition: merge.py:16
FPGATrackSimNNTrackTool::getZScale
static float getZScale()
Definition: FPGATrackSimNNTrackTool.h:56
FPGATrackSimTrack::setTrackStage
void setTrackStage(TrackStage v)
Definition: FPGATrackSimTrack.h:82
FPGATrackSimNNTrackTool::m_fakeNN_2nd
OnnxRuntimeBase m_fakeNN_2nd
Definition: FPGATrackSimNNTrackTool.h:78
FPGATrackSimNNTrackTool::getYScale
static float getYScale()
Definition: FPGATrackSimNNTrackTool.h:55
fpgatracksim::QPT_SECTOR_OFFSET
constexpr int QPT_SECTOR_OFFSET
Definition: FPGATrackSimConstants.h:23
FPGATrackSimTrackingToolBase::m_idealGeoRoads
Gaudi::Property< bool > m_idealGeoRoads
Definition: FPGATrackSimTrackingToolBase.h:38
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimMultiTruth::AddAccumulator
Definition: FPGATrackSimMultiTruth.h:57
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
FPGATrackSimTrackingToolBase::m_useSectors
Gaudi::Property< bool > m_useSectors
Definition: FPGATrackSimTrackingToolBase.h:37
FPGATrackSimNNTrackTool::m_fakeNN_1st
OnnxRuntimeBase m_fakeNN_1st
Definition: FPGATrackSimNNTrackTool.h:77
FPGATrackSimTrack::setHoughY
void setHoughY(float v)
Definition: FPGATrackSimTrack.h:91
OnnxRuntimeBase::m_outputNodeNames
std::vector< const char * > m_outputNodeNames
Definition: OnnxRuntimeBase.h:42
FPGATrackSimTrack::setTrackID
void setTrackID(int v)
Definition: FPGATrackSimTrack.h:88
FPGATrackSimTrack::setQOverPt
void setQOverPt(float v)
Definition: FPGATrackSimTrack.h:92
FPGATrackSimNNTrackTool::compute_truth
void compute_truth(FPGATrackSimTrack &newtrk) const
Definition: FPGATrackSimNNTrackTool.cxx:973
FPGATrackSimTrackPars::IPHI
@ IPHI
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimNNTrackTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimNNTrackTool.cxx:25
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:107
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:92
y
#define y
FPGATrackSimRoad::setSector
void setSector(sector_t sector)
Definition: FPGATrackSimRoad.h:60
FPGATrackSimNNTrackTool::getZ0Scale
static float getZ0Scale()
Definition: FPGATrackSimNNTrackTool.h:61
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
FPGATrackSimNNTrackTool::m_paramNN_2nd
OnnxRuntimeBase m_paramNN_2nd
Definition: FPGATrackSimNNTrackTool.h:76
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
layer_bitmask_t
uint32_t layer_bitmask_t
Definition: FPGATrackSimTypes.h:22
FPGATrackSimSectorBank::isAbsQOverPtBinning
bool isAbsQOverPtBinning() const
Definition: FPGATrackSimSectorBank.h:54
FPGATrackSimTrack::setSubRegion
void setSubRegion(unsigned v)
Definition: FPGATrackSimTrack.h:107
FPGATrackSimTrackingToolBase::m_doEtaPatternConsts
Gaudi::Property< bool > m_doEtaPatternConsts
Definition: FPGATrackSimTrackingToolBase.h:35
FPGATrackSimNNTrackTool::getPhiScale
static float getPhiScale()
Definition: FPGATrackSimNNTrackTool.h:59
FPGATrackSimNNTrackTool::m_useParamNN_2nd
bool m_useParamNN_2nd
Definition: FPGATrackSimNNTrackTool.h:81
OnnxRuntimeBase::OnnxRuntimeBase
OnnxRuntimeBase()
Definition: OnnxRuntimeBase.cxx:14
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
FPGATrackSimNNTrackTool::getQoverPtScale
static float getQoverPtScale()
Definition: FPGATrackSimNNTrackTool.h:57
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
FPGATrackSimTrack::setNLayers
void setNLayers(int)
set the number of layers in the track.
Definition: FPGATrackSimTrack.cxx:107
FPGATrackSimNNTrackTool::m_useParamNN_1st
bool m_useParamNN_1st
Definition: FPGATrackSimNNTrackTool.h:80
FPGATrackSimRoad::getAllHits
const std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit > > > & getAllHits() const
Definition: FPGATrackSimRoad.h:103
FPGATrackSimTrackingToolBase::m_do2ndStage
Gaudi::Property< bool > m_do2ndStage
Definition: FPGATrackSimTrackingToolBase.h:40
FPGATrackSimTrackingToolBase::m_spRoadFilterTool
ToolHandle< IFPGATrackSimRoadFilterTool > m_spRoadFilterTool
Definition: FPGATrackSimTrackingToolBase.h:32
FPGATrackSimNNTrackTool::getTracks_GNN
StatusCode getTracks_GNN(std::vector< std::shared_ptr< const FPGATrackSimRoad >> &roads, std::vector< FPGATrackSimTrack > &tracks)
Definition: FPGATrackSimNNTrackTool.cxx:720
NetworkBatchInput
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > NetworkBatchInput
Definition: OnnxRuntimeBase.h:9
FPGATrackSimTrack::setHoughX
void setHoughX(float v)
Definition: FPGATrackSimTrack.h:90
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
fitman.k
k
Definition: fitman.py:528
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
FPGATrackSimTrackPars::IETA
@ IETA
Definition: FPGATrackSimTrackPars.h:49