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 975 of file FPGATrackSimNNTrackTool.cxx.

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

◆ 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 
282  temp.setBinIdx(iroad->getBinIdx());
283 
285  // Get a list of indices for all possible combinations given a certain
286  // number of layers
287  std::vector<std::vector<int>> combs;
288 
289  combs = getComboIndices(iroad->getNHits_layer());
290 
291  // Loop over possible combinations for this road
292  for (size_t icomb = 0; icomb < combs.size(); icomb++) {
293  std::vector<float> inputTensorValues;
294  std::vector<std::shared_ptr<const FPGATrackSimHit>> hit_list;
295 
296  // list of indices for this particular combination
297  std::vector<int> const &hit_indices = combs[icomb];
298 
299  // Loop over all layers
300  for (unsigned layer = 0; layer < planeMap->getNLogiLayers(); layer++) {
301 
302  // Check to see if this is a valid hit
303  if (hit_indices[layer] >= 0) {
304 
305  std::shared_ptr<const FPGATrackSimHit> hit = iroad->getHits(layer)[hit_indices[layer]];
306  // Add this hit to the road
307  if (hit->isReal()){
308  hit_list.push_back(std::move(hit));
309  }
310  }
311  }
312 
313  // Sort the list by radial distance
314  std::sort(hit_list.begin(), hit_list.end(),
315  [](std::shared_ptr<const FPGATrackSimHit> &hit1, std::shared_ptr<const FPGATrackSimHit> &hit2) {
316  double rho1 = std::hypot(hit1->getX(), hit1->getY());
317  double rho2 = std::hypot(hit2->getX(), hit2->getY());
318  return rho1 < rho2;
319  });
320 
321 
322  int index = 1;
323  bool flipZ = false;
324  double rotateAngle = 0;
325  bool gotSecondSP = false;
326  float tmp_xf;
327  float tmp_yf;
328  float tmp_zf;
329  float tmp_rf;
330  float tmp_phif;
331  // Loop over all hits
332  for (const auto &hit : hit_list) {
333  // Need to rotate hits
334  float x0 = hit->getX();
335  float y0 = hit->getY();
336  float z0 = hit->getZ();
337  float r0 = std::sqrt(x0*x0+y0*y0);
338  float phi0 = hit->getGPhi();
339  float xf = x0;
340  float yf = y0;
341  float zf = z0;
342  float rf = r0;
343  float phif = phi0;
344  if (m_useCartesian) {
345  if (index == 1) {
346  if (z0 < 0)
347  flipZ = true;
348  rotateAngle = std::atan(x0 / y0);
349  if (y0 < 0)
350  rotateAngle += M_PI;
351  }
352  xf = x0 * std::cos(rotateAngle) - y0 * std::sin(rotateAngle);
353  yf = x0 * std::sin(rotateAngle) + y0 * std::cos(rotateAngle);
354  zf = z0;
355  if (flipZ) zf = z0 * -1;
356  }
357 
358  // Get average of values for strip hit pairs
359  // TODO: this needs to be fixed in the future, for this to work for other cases
360  if (hit->isStrip()) {
361 
362  if (hit->getHitType() != HitType::spacepoint) { // this is a strip but not a SP!
363  if (m_useCartesian) {
364  float xf_scaled = (xf) / (getXScale());
365  float yf_scaled = (yf) / (getYScale());
366  float zf_scaled = (zf) / (getZScale());
367 
368  // Get average of two hits for strip hits
369  inputTensorValues.push_back(xf_scaled);
370  inputTensorValues.push_back(yf_scaled);
371  inputTensorValues.push_back(zf_scaled);
372 
373  }
374  else {
375  float rf_scaled = (rf) / (getRScale());
376  float phif_scaled = (phif) / (getPhiScale());
377  float zf_scaled = (zf) / (getZScale());
378  // Get average of two hits for strip hits
379  inputTensorValues.push_back(rf_scaled);
380  inputTensorValues.push_back(phif_scaled);
381  inputTensorValues.push_back(zf_scaled);
382  }
383  }
384  else if (!gotSecondSP) {
385  tmp_xf = xf;
386  tmp_yf = yf;
387  tmp_zf = zf;
388  tmp_phif = phif;
389  tmp_rf = rf;
390  gotSecondSP = true;
391  }
392  else {
393  gotSecondSP = false;
394  if (m_useCartesian) {
395  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
396  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
397  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
398 
399  // Get average of two hits for strip hits
400  inputTensorValues.push_back(xf_scaled);
401  inputTensorValues.push_back(yf_scaled);
402  inputTensorValues.push_back(zf_scaled);
403  index++;
404  }
405  else {
406  float rf_scaled = (rf + tmp_rf) / (2.*getRScale());
407  float phif_scaled = (phif + tmp_phif) / (2.*getPhiScale());
408  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
409  inputTensorValues.push_back(rf_scaled);
410  inputTensorValues.push_back(phif_scaled);
411  inputTensorValues.push_back(zf_scaled);
412  }
413  }
414  }
415  else {
416  if (m_useCartesian) {
417  float xf_scaled = (xf) / (getXScale());
418  float yf_scaled = (yf) / (getYScale());
419  float zf_scaled = (zf) / (getZScale());
420  inputTensorValues.push_back(xf_scaled);
421  inputTensorValues.push_back(yf_scaled);
422  inputTensorValues.push_back(zf_scaled);
423  index++;
424  }
425  else {
426  float rf_scaled = (rf) / (getRScale());
427  float phif_scaled = (phif) / (getPhiScale());
428  float zf_scaled = (zf) / (getZScale());
429  inputTensorValues.push_back(rf_scaled);
430  inputTensorValues.push_back(phif_scaled);
431  inputTensorValues.push_back(zf_scaled);
432  }
433  }
434  }
435 
436  if (inputTensorValues.size() != planeMap->getNLogiLayers()*3) {
437  inputTensorValues.resize(planeMap->getNLogiLayers()*3);
438  }
439  inputTensorValues.resize(15); // Retain only the first 15 values for consistency
440 
441  inputTensorValuesAll.push_back(inputTensorValues);
442  FPGATrackSimTrack track_cand;
443  n_track++;
444  track_cand.setTrackID(n_track);
445  track_cand.setNLayers(planeMap->getNLogiLayers());
446  track_cand.setNMissing(nMissing);
447  for (unsigned ihit = 0; ihit < hit_list.size(); ihit++) {
448  track_cand.setFPGATrackSimHit(ihit, *(hit_list[ihit]));
449  }
450  tracks.push_back(track_cand);
451 
452  ATH_MSG_DEBUG("NN InputTensorValues:");
453  ATH_MSG_DEBUG(inputTensorValues);
454  } // loop over combinations
455  } // loop over roads
456 
458  auto NNoutputs = m_fakeNN_1st.runONNXInference(inputTensorValuesAll);
459 
460  for (unsigned itrack = 0; itrack < NNoutputs.size(); itrack++) {
461 
462  float nn_val = NNoutputs[itrack][0];
463  ATH_MSG_DEBUG("NN output:" << nn_val);
464  double chi2 = (1 - nn_val) * (tracks[itrack].getNCoords() - tracks[itrack].getNMissing() - 5);
465  //std::cout << "1st stage" << chi2 << std::endl;
466  tracks[itrack].setOrigChi2(chi2);
467  tracks[itrack].setChi2(chi2);
468  }
469 
470  // Add truth info
471  for (FPGATrackSimTrack &t : tracks) {
472  compute_truth(t); // match the track to a geant particle using the
473  // channel-level geant info in the hit data.
474  }
475  return StatusCode::SUCCESS;
476 }

◆ 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 479 of file FPGATrackSimNNTrackTool.cxx.

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

◆ 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 722 of file FPGATrackSimNNTrackTool.cxx.

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

◆ 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
FPGATrackSimTrack::setBinIdx
void setBinIdx(std::vector< unsigned > x)
Definition: FPGATrackSimTrack.h:116
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
runITkAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runITkAlign.py:62
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:225
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
MuonR4::to_string
std::string to_string(const SectorProjector proj)
Definition: MsTrackSeeder.cxx:66
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:122
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
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:975
FPGATrackSimTrackPars::IPHI
@ IPHI
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimNNTrackTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimNNTrackTool.cxx:25
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:722
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