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

Public Attributes

Gaudi::Property< double > m_chi2_scalefactor { this, "Chi2ScaleFactor", 40 / (1 - 0.1), "Scale factor to use in converting to a chi2, Nominal chi2ndof cut is 40 and we want to use NN>0.0075 (or NN<(1-0.0075)" }
 
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" }
 
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 setTrackParameters_1st (FPGATrackSimTrack &track, std::vector< float > inputTensorValues)
 
void setTrackParameters_2nd (FPGATrackSimTrack &track, std::vector< float > inputTensorValues)
 
void compute_truth (FPGATrackSimTrack &newtrk) const
 
 OnnxRuntimeBase (TString fileName)
 
 OnnxRuntimeBase ()
 

Private Attributes

ServiceHandle< IFPGATrackSimMappingSvcm_FPGATrackSimMapping {this, "FPGATrackSimMappingSvc","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 530 of file FPGATrackSimNNTrackTool.cxx.

530  {
531  std::vector<FPGATrackSimMultiTruth> mtv;
532 
533  const FPGATrackSimPlaneMap* planeMap = nullptr;
534  if (!m_do2ndStage) planeMap = m_FPGATrackSimMapping->PlaneMap_1st(0);
535  else planeMap = m_FPGATrackSimMapping->PlaneMap_2nd(0);
536 
537  for (unsigned layer = 0; layer < planeMap->getNLogiLayers(); layer++) {
538  if (t.getHitMap() & (1 << planeMap->getCoordOffset(layer)))
539  continue; // no hit in this plane
540  // Sanity check that we have enough hits.
541  if (layer < t.getFPGATrackSimHits().size())
542  mtv.push_back(t.getFPGATrackSimHits().at(layer).getTruth());
543 
544  // adjust weight for hits without (and also with) a truth match, so that
545  // each is counted with the same weight.
546  mtv.back().assign_equal_normalization();
547  }
548 
551  // frac is then the fraction of the total number of hits on the track
552  // attributed to the barcode.
553 
556  const bool ok = mt.best(tbarcode, tfrac);
557  if (ok) {
558  t.setEventIndex(tbarcode.first);
559  t.setBarcode(tbarcode.second);
560  t.setBarcodeFrac(tfrac);
561  }
562 }

◆ getInputNodesDims()

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

Definition at line 32 of file OnnxRuntimeBase.h.

32 {return m_inputNodeDims;};

◆ getOutputNodesDims()

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

Definition at line 33 of file OnnxRuntimeBase.h.

33 {return m_outputNodeDims;};

◆ getTracks_1st()

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

Definition at line 100 of file FPGATrackSimNNTrackTool.cxx.

100  {
101 
102  ATH_CHECK(setRoadSectors(roads));
103  int n_track = 0;
104 
105  // Loop over roads
106  for (auto const &iroad : roads) {
107 
108  double y = iroad->getY();
109 
110  // Get info on layers with missing hits
111  int nMissing = 0;
112  layer_bitmask_t missing_mask = 0;
113 
114  // Just used to get number of layers considered
115  const FPGATrackSimPlaneMap *planeMap = m_FPGATrackSimMapping->PlaneMap_1st(iroad->getSubRegion());
116 
117  // Create a template track with common parameters filled already for
118  // initializing below
119  FPGATrackSimTrack temp;
121  temp.setNLayers(planeMap->getNLogiLayers());
122  temp.setBankID(-1);
123  temp.setPatternID(iroad->getPID());
124  temp.setFirstSectorID(iroad->getSector());
125  temp.setHitMap(missing_mask);
126  temp.setNMissing(nMissing);
127  temp.setQOverPt(y);
128 
129  temp.setSubRegion(iroad->getSubRegion());
130  temp.setHoughX(iroad->getX());
131  temp.setHoughY(iroad->getY());
132  temp.setHoughXBin(iroad->getXBin());
133  temp.setHoughYBin(iroad->getYBin());
134 
136  // Get a list of indices for all possible combinations given a certain
137  // number of layers
138  std::vector<std::vector<int>> combs;
139  std::vector<std::shared_ptr<const FPGATrackSimHit>> all_hits;
140 
141  if (m_doGNNTracking) {
142  std::vector<std::shared_ptr<const FPGATrackSimHit>> all_pixel_hits;
143  std::vector<std::shared_ptr<const FPGATrackSimHit>> all_strip_hits;
144  size_t pixelCount = 0;
145 
146  // Temporarily do not make a road if it has more than 40 hits, there is an issue with some big roads which we do not want to work with right now.
147  if (iroad->getNHits() > 40) continue;
148 
149  for (unsigned layer = 0; layer < iroad->getNLayers(); ++layer) {
150  all_hits.insert(all_hits.end(), iroad->getHits(layer).begin(), iroad->getHits(layer).end());
151  }
152 
153  for (const auto& hit : all_hits) {
154  if(hit->isPixel()) {
155  pixelCount++;
156  }
157  }
158 
159  if (pixelCount < 1) continue; // Cannot use a form a track candidate from a road that does not have a pixel hit
160 
161  combs.push_back({}); //Dummy vector such that each road to corresponds to one track combination
162  }
163  else {
164  combs = getComboIndices(iroad->getNHits_layer());
165  }
166 
167  // Loop over possible combinations for this road
168  for (size_t icomb = 0; icomb < combs.size(); icomb++) {
169  std::vector<std::shared_ptr<const FPGATrackSimHit>> hit_list;
170 
171  if (m_doGNNTracking) {
172  for (const auto &hit : all_hits) {
173  if (hit->isReal()) {
174  hit_list.push_back(hit);
175  }
176  }
177 
178  if (hit_list.size() < m_minNumberOfRealHitsInATrack) continue;
179  }
180  else {
181  // list of indices for this particular combination
182  std::vector<int> const &hit_indices = combs[icomb];
183 
184  // Loop over all layers
185  for (unsigned layer = 0; layer < planeMap->getNLogiLayers(); layer++) {
186 
187  // Check to see if this is a valid hit
188  if (hit_indices[layer] >= 0) {
189 
190  std::shared_ptr<const FPGATrackSimHit> hit = iroad->getHits(layer)[hit_indices[layer]];
191  // Add this hit to the road
192  if (hit->isReal()){
193  hit_list.push_back(hit);
194  }
195  }
196  }
197 
198  // TODO: for now ignore roads with non-real hits, because the network needs all hits as input
199  if (hit_list.size() < m_minNumberOfRealHitsInATrack) continue;
200  }
201 
202  // Sort the list by radial distance
203  std::sort(hit_list.begin(), hit_list.end(),
204  [](std::shared_ptr<const FPGATrackSimHit> &hit1, std::shared_ptr<const FPGATrackSimHit> &hit2) {
205  double rho1 = std::hypot(hit1->getX(), hit1->getY());
206  double rho2 = std::hypot(hit2->getX(), hit2->getY());
207  return rho1 < rho2;
208  });
209 
210  std::vector<float> inputTensorValues;
211 
212 
213  int index = 1;
214  bool flipZ = false;
215  double rotateAngle = 0;
216  bool gotSecondSP = false;
217  float tmp_xf;
218  float tmp_yf;
219  float tmp_zf;
220  int missingHits = 10; //For the NN input, we need 5 spacepoints as inputs
221 
222  // Loop over all hits
223  for (const auto &hit : hit_list) {
224  if (m_doGNNTracking) {
225  if (missingHits <= 0) break; // Stop looping once enough hits are found
226  if(hit->isPixel()) missingHits-= 2; // Each pixel counts as two hits so that strip counts half as much
227  else if(hit->isStrip()) missingHits-= 1; // Since two strip hits is a single spacepoints in the GNN algorithm
228  }
229 
230  // Need to rotate hits
231  float x0 = hit->getX();
232  float y0 = hit->getY();
233  float z0 = hit->getZ();
234  if (index == 1) {
235  if (z0 < 0)
236  flipZ = true;
237  rotateAngle = std::atan(x0 / y0);
238  if (y0 < 0)
239  rotateAngle += M_PI;
240  }
241 
242  float xf = x0 * std::cos(rotateAngle) - y0 * std::sin(rotateAngle);
243  float yf = x0 * std::sin(rotateAngle) + y0 * std::cos(rotateAngle);
244  float zf = z0;
245 
246  if (flipZ) zf = z0 * -1;
247 
248  // Get average of values for strip hit pairs
249  // TODO: this needs to be fixed in the future, for this to work for other cases
250  if (hit->isStrip()) {
251  if (!gotSecondSP) {
252  tmp_xf = xf;
253  tmp_yf = yf;
254  tmp_zf = zf;
255  gotSecondSP = true;
256  }
257  else {
258 
259  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
260  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
261  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
262 
263  // Get average of two hits for strip hits
264  inputTensorValues.push_back(xf_scaled);
265  inputTensorValues.push_back(yf_scaled);
266  inputTensorValues.push_back(zf_scaled);
267  index++;
268  gotSecondSP = false;
269  }
270  }
271  else {
272  float xf_scaled = (xf) / (getXScale());
273  float yf_scaled = (yf) / (getYScale());
274  float zf_scaled = (zf) / (getZScale());
275  inputTensorValues.push_back(xf_scaled);
276  inputTensorValues.push_back(yf_scaled);
277  inputTensorValues.push_back(zf_scaled);
278  index++;
279  }
280  }
281 
282  if (!m_doGNNTracking) {
283  if (inputTensorValues.size() != planeMap->getNLogiLayers()*3) {
284  inputTensorValues.resize(planeMap->getNLogiLayers()*3);
285  }
286  }
287 
288  std::vector<float> NNoutput = m_fakeNN_1st.runONNXInference(inputTensorValues);
289 
290  ATH_MSG_DEBUG("NN InputTensorValues:");
291  ATH_MSG_DEBUG(inputTensorValues);
292  ATH_MSG_DEBUG("NN output:" << NNoutput);
293 
294  float nn_val = NNoutput[0];
295 
296  n_track++;
297  FPGATrackSimTrack track_cand;
298  track_cand.setTrackID(n_track);
299  track_cand.setNLayers(planeMap->getNLogiLayers());
300  if(m_doGNNTracking) {
301  for (const auto &ihit : hit_list) {
302  unsigned int layer = ihit->getLayer();
303  track_cand.setFPGATrackSimHit(layer, *ihit);
304  }
305  }
306  else {
307  for (unsigned ihit = 0; ihit < hit_list.size(); ihit++) {
308  track_cand.setFPGATrackSimHit(ihit, *(hit_list[ihit]));
309  }
310  }
311  // Nominal chi2ndof cut is 40 and we want to use NN>0.0075 (or
312  // NN<(1-0.0075) Nominal chi2ndof cut is 40 and we want to use NN>0.001
313  // (or NN<(1-0.1)
314  // the 5 comes from the 5 dof we nominally get from a chi2
315  double scale = m_chi2_scalefactor * (track_cand.getNCoords() - track_cand.getNMissing() - 5);
316  double chi2 = scale * (1 - nn_val);
317  track_cand.setOrigChi2(chi2);
318  track_cand.setChi2(chi2);
319  tracks.push_back(track_cand);
320 
321 
322  if (m_useParamNN_1st) {
323  for (auto& track : tracks) {
324  setTrackParameters_1st(track, inputTensorValues);
325  }
326  }
327  } // loop over combinations
328 
329  } // loop over roads
330 
331  // Add truth info
332  for (FPGATrackSimTrack &t : tracks) {
333  compute_truth(t); // match the track to a geant particle using the
334  // channel-level geant info in the hit data.
335  }
336 
337  return StatusCode::SUCCESS;
338 }

◆ getTracks_2nd()

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

Definition at line 340 of file FPGATrackSimNNTrackTool.cxx.

340  {
341 
342  ATH_CHECK(setRoadSectors(roads));
343  int n_track = 0;
344 
345  // Loop over roads
346  for (auto const &iroad : roads) {
347 
348  double y = iroad->getY();
349 
350  // Get info on layers with missing hits
351  int nMissing = 0;
352  layer_bitmask_t missing_mask = 0;
353 
354  // Just used to get number of layers considered
355  const FPGATrackSimPlaneMap *planeMap = m_FPGATrackSimMapping->PlaneMap_2nd(iroad->getSubRegion());
356 
357  // Create a template track with common parameters filled already for
358  // initializing below
359  FPGATrackSimTrack temp;
361  temp.setNLayers(planeMap->getNLogiLayers());
362  temp.setBankID(-1);
363  temp.setPatternID(iroad->getPID());
364  temp.setFirstSectorID(iroad->getSector());
365  temp.setHitMap(missing_mask);
366  temp.setNMissing(nMissing);
367  temp.setQOverPt(y);
368 
369  temp.setSubRegion(iroad->getSubRegion());
370  temp.setHoughX(iroad->getX());
371  temp.setHoughY(iroad->getY());
372  temp.setHoughXBin(iroad->getXBin());
373  temp.setHoughYBin(iroad->getYBin());
374 
376  // Get a list of indices for all possible combinations given a certain
377  // number of layers
378  std::vector<std::vector<int>> combs =
379  getComboIndices(iroad->getNHits_layer());
380 
381  // Loop over possible combinations for this road
382  for (size_t icomb = 0; icomb < combs.size(); icomb++) {
383 
384  // list of indices for this particular combination
385  std::vector<int> const &hit_indices = combs[icomb];
386  std::vector<std::shared_ptr<const FPGATrackSimHit>> hit_list;
387 
388  // Loop over all layers
389  for (unsigned layer = 0; layer < planeMap->getNLogiLayers(); layer++) {
390 
391  // Check to see if this is a valid hit
392  if (hit_indices[layer] >= 0) {
393 
394  std::shared_ptr<const FPGATrackSimHit> hit = iroad->getHits(layer)[hit_indices[layer]];
395  // Add this hit to the road
396  if (hit->isReal()){
397  hit_list.push_back(hit);
398  }
399  }
400  }
401 
402  // TODO: for now ignore roads with non-real hits, because the network needs all hits as input
403  if (hit_list.size() < m_minNumberOfRealHitsInATrack) continue;
404 
405  // Sort the list by radial distance
406  std::sort(hit_list.begin(), hit_list.end(),
407  [](std::shared_ptr<const FPGATrackSimHit> &hit1, std::shared_ptr<const FPGATrackSimHit> &hit2) {
408  double rho1 = std::hypot(hit1->getX(), hit1->getY());
409  double rho2 = std::hypot(hit2->getX(), hit2->getY());
410  return rho1 < rho2;
411  });
412 
413  std::vector<float> inputTensorValues;
414 
415 
416  int index = 1;
417  bool flipZ = false;
418  double rotateAngle = 0;
419  bool gotSecondSP = false;
420  float tmp_xf;
421  float tmp_yf;
422  float tmp_zf;
423 
424  // Loop over all hits
425  for (const auto &hit : hit_list) {
426 
427  // Need to rotate hits
428  float x0 = hit->getX();
429  float y0 = hit->getY();
430  float z0 = hit->getZ();
431  if (index == 1) {
432  if (z0 < 0)
433  flipZ = true;
434  rotateAngle = std::atan(x0 / y0);
435  if (y0 < 0)
436  rotateAngle += M_PI;
437  }
438 
439  float xf = x0 * std::cos(rotateAngle) - y0 * std::sin(rotateAngle);
440  float yf = x0 * std::sin(rotateAngle) + y0 * std::cos(rotateAngle);
441  float zf = z0;
442 
443  if (flipZ) zf = z0 * -1;
444 
445  // Get average of values for strip hit pairs
446  // TODO: this needs to be fixed in the future, for this to work for other cases
447  if (hit->isStrip()) {
448  if (!gotSecondSP) {
449  tmp_xf = xf;
450  tmp_yf = yf;
451  tmp_zf = zf;
452  gotSecondSP = true;
453  }
454  else {
455 
456  float xf_scaled = (xf + tmp_xf) / (2.*getXScale());
457  float yf_scaled = (yf + tmp_yf) / (2.*getYScale());
458  float zf_scaled = (zf + tmp_zf) / (2.*getZScale());
459 
460  // Get average of two hits for strip hits
461  inputTensorValues.push_back(xf_scaled);
462  inputTensorValues.push_back(yf_scaled);
463  inputTensorValues.push_back(zf_scaled);
464  index++;
465  gotSecondSP = false;
466  }
467  }
468  else {
469  float xf_scaled = (xf) / (getXScale());
470  float yf_scaled = (yf) / (getYScale());
471  float zf_scaled = (zf) / (getZScale());
472  inputTensorValues.push_back(xf_scaled);
473  inputTensorValues.push_back(yf_scaled);
474  inputTensorValues.push_back(zf_scaled);
475  index++;
476  }
477  }
478 
479  if (inputTensorValues.size() != planeMap->getNLogiLayers()*3) {
480  inputTensorValues.resize(planeMap->getNLogiLayers()*3);
481  }
482 
483  std::vector<float> NNoutput = m_fakeNN_2nd.runONNXInference(inputTensorValues);
484 
485  ATH_MSG_DEBUG("NN InputTensorValues:");
486  ATH_MSG_DEBUG(inputTensorValues);
487  ATH_MSG_DEBUG("NN output:" << NNoutput);
488 
489  float nn_val = NNoutput[0];
490 
491  n_track++;
492  FPGATrackSimTrack track_cand;
493  track_cand.setTrackID(n_track);
494  track_cand.setNLayers(planeMap->getNLogiLayers());
495  for (unsigned ihit = 0; ihit < hit_list.size(); ihit++) {
496  track_cand.setFPGATrackSimHit(ihit, *(hit_list[ihit]));
497  }
498  // Nominal chi2ndof cut is 40 and we want to use NN>0.0075 (or
499  // NN<(1-0.0075) Nominal chi2ndof cut is 40 and we want to use NN>0.001
500  // (or NN<(1-0.1)
501  // the 5 comes from the 5 dof we nominally get from a chi2
502  double scale = m_chi2_scalefactor *
503  (track_cand.getNCoords() - track_cand.getNMissing() - 5);
504  double chi2 = scale * (1 - nn_val);
505  track_cand.setOrigChi2(chi2);
506  track_cand.setChi2(chi2);
507  tracks.push_back(track_cand);
508 
509 
510  if (m_useParamNN_2nd) {
511  for (auto& track : tracks) {
512  setTrackParameters_2nd(track, inputTensorValues);
513  }
514  }
515  } // loop over combinations
516 
517  } // loop over roads
518 
519  // Add truth info
520  for (FPGATrackSimTrack &t : tracks) {
521  compute_truth(t); // match the track to a geant particle using the
522  // channel-level geant info in the hit data.
523  }
524 
525  return StatusCode::SUCCESS;
526 }

◆ getXScale()

static float FPGATrackSimNNTrackTool::getXScale ( )
inlinestatic

Definition at line 52 of file FPGATrackSimNNTrackTool.h.

52 { return 1015.;};

◆ getYScale()

static float FPGATrackSimNNTrackTool::getYScale ( )
inlinestatic

Definition at line 53 of file FPGATrackSimNNTrackTool.h.

53 { return 1015.;};

◆ getZScale()

static float FPGATrackSimNNTrackTool::getZScale ( )
inlinestatic

Definition at line 54 of file FPGATrackSimNNTrackTool.h.

54 { 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/2]

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

Definition at line 78 of file OnnxRuntimeBase.cxx.

79 {
80  int batchSize = inputTensorValues.rows();
81  std::vector<int64_t> inputNodeDims = m_inputNodeDims;
82  std::vector<int64_t> outputNodeDims = m_outputNodeDims; //bad. Assumes they all have the same number of nodes.
83 
84  // The first dim node should correspond to the batch size
85  // If it is -1, it is dynamic and should be set to the input size
86  if (inputNodeDims[0] == -1)
87  {
88  inputNodeDims[0] = batchSize;
89  }
90  if (outputNodeDims[0] == -1)
91  {
92  outputNodeDims[0] = batchSize;
93  }
94 
95  if(inputNodeDims[1]*inputNodeDims[2] != inputTensorValues.cols() && inputNodeDims[1] != inputTensorValues.cols())
96  {
97  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()));
98  }
99 
100  if (batchSize != 1 && (inputNodeDims[0] != batchSize || outputNodeDims[0] != batchSize))
101  {
102  throw std::runtime_error("runONNXInference: batch size doesn't match the input or output node size");
103  }
104 
105  // Create input tensor object from data values
106  // note: this assumes the model has only 1 input node
107  Ort::MemoryInfo memoryInfo = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
108  Ort::Value inputTensor = Ort::Value::CreateTensor<float>(memoryInfo, inputTensorValues.data(), inputTensorValues.size(),inputNodeDims.data(), inputNodeDims.size());
109  // Double-check that inputTensor is a Tensor
110  if (!inputTensor.IsTensor())
111  {
112  throw std::runtime_error("runONNXInference: conversion of input to Tensor failed. ");
113  }
114  // Score model on input tensors, get back output tensors
115  Ort::RunOptions run_options;
116  std::vector<Ort::Value> outputTensors =
117  m_session->Run(run_options, m_inputNodeNames.data(), &inputTensor,
118  m_inputNodeNames.size(), m_outputNodeNames.data(),
119  m_outputNodeNames.size());
120  // Double-check that outputTensors contains Tensors and that the count matches
121  // that of output nodes
122  if (!outputTensors[0].IsTensor() || (outputTensors.size() != m_outputNodeNames.size())) {
123  throw std::runtime_error("runONNXInference: calculation of output failed. ");
124  }
125  // Get pointer to output tensor float values
126  // note: this assumes the model has only 1 output value
127  float* outputTensor = outputTensors.front().GetTensorMutableData<float>();
128  // Get the output values
129  std::vector<std::vector<float>> outputTensorValues(batchSize, std::vector<float>(outputNodeDims[1], -1));
130  for (int i = 0; i < outputNodeDims[0]; i++)
131  {
132  for (int j = 0; j < ((outputNodeDims.size() > 1) ? outputNodeDims[1] : 1); j++)
133  {
134  outputTensorValues[i][j] = outputTensor[i * outputNodeDims[1] + j];
135  }
136  }
137 
138  return outputTensorValues;
139 }

◆ runONNXInference() [2/2]

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

Definition at line 66 of file OnnxRuntimeBase.cxx.

67 {
68  NetworkBatchInput vectorInput(1, inputTensorValues.size());
69  for (size_t i = 0; i < inputTensorValues.size(); i++) {
70  vectorInput(0, i) = inputTensorValues[i];
71  }
72  auto vectorOutput = runONNXInference(vectorInput);
73  return vectorOutput[0];
74 }

◆ runONNXInferenceMultilayerOutput()

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

Definition at line 144 of file OnnxRuntimeBase.cxx.

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

◆ 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_1st()

void FPGATrackSimNNTrackTool::setTrackParameters_1st ( FPGATrackSimTrack track,
std::vector< float >  inputTensorValues 
)
private

Definition at line 65 of file FPGATrackSimNNTrackTool.cxx.

65  {
66 
67  ATH_MSG_DEBUG("Running NN-based track parameter estimation!");
68  std::vector<float> paramNNoutput = m_paramNN_1st.runONNXInference(inputTensorValues);
69 
70  ATH_MSG_DEBUG("Estimated Track Parameters");
71  for (unsigned int i = 0; i < paramNNoutput.size(); i++) {
72  ATH_MSG_DEBUG(paramNNoutput[i]);
73  }
74 
75  track.setQOverPt(paramNNoutput[0]);
76  track.setEta(paramNNoutput[1]);
77  track.setPhi(paramNNoutput[2]);
78  track.setD0(paramNNoutput[3]);
79  track.setZ0(paramNNoutput[4]);
80 }

◆ setTrackParameters_2nd()

void FPGATrackSimNNTrackTool::setTrackParameters_2nd ( FPGATrackSimTrack track,
std::vector< float >  inputTensorValues 
)
private

Definition at line 82 of file FPGATrackSimNNTrackTool.cxx.

82  {
83 
84  ATH_MSG_DEBUG("Running NN-based track parameter estimation!");
85  std::vector<float> paramNNoutput = m_paramNN_2nd.runONNXInference(inputTensorValues);
86 
87  ATH_MSG_DEBUG("Estimated Track Parameters");
88  for (unsigned int i = 0; i < paramNNoutput.size(); i++) {
89  ATH_MSG_DEBUG(paramNNoutput[i]);
90  }
91 
92  track.setQOverPt(paramNNoutput[0]);
93  track.setEta(paramNNoutput[1]);
94  track.setPhi(paramNNoutput[2]);
95  track.setD0(paramNNoutput[3]);
96  track.setZ0(paramNNoutput[4]);
97 }

Member Data Documentation

◆ m_barcode

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

Definition at line 81 of file FPGATrackSimNNTrackTool.h.

◆ m_barcodefrac

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

Definition at line 80 of file FPGATrackSimNNTrackTool.h.

◆ m_chi2_scalefactor

Gaudi::Property<double> FPGATrackSimNNTrackTool::m_chi2_scalefactor { this, "Chi2ScaleFactor", 40 / (1 - 0.1), "Scale factor to use in converting to a chi2, Nominal chi2ndof cut is 40 and we want to use NN>0.0075 (or NN<(1-0.0075)" }

Definition at line 57 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 59 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 44 of file OnnxRuntimeBase.h.

◆ m_etamodule

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

Definition at line 88 of file FPGATrackSimNNTrackTool.h.

◆ m_etawidth

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

Definition at line 86 of file FPGATrackSimNNTrackTool.h.

◆ m_eventindex

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

Definition at line 82 of file FPGATrackSimNNTrackTool.h.

◆ m_fakeNN_1st

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_fakeNN_1st
private

Definition at line 68 of file FPGATrackSimNNTrackTool.h.

◆ m_fakeNN_2nd

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_fakeNN_2nd
private

Definition at line 69 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","FPGATrackSimMappingSvc"}
private

Definition at line 63 of file FPGATrackSimNNTrackTool.h.

◆ m_ID

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

Definition at line 90 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 105 of file FPGATrackSimNNTrackTool.h.

◆ m_input_node_names

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

Definition at line 104 of file FPGATrackSimNNTrackTool.h.

◆ m_inputNodeDims

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

Definition at line 40 of file OnnxRuntimeBase.h.

◆ m_inputNodeNames

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

Definition at line 39 of file OnnxRuntimeBase.h.

◆ m_isBarrel

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

Definition at line 85 of file FPGATrackSimNNTrackTool.h.

◆ m_isPixel

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

Definition at line 83 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 84 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 58 of file FPGATrackSimNNTrackTool.h.

◆ m_output_node_names

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

Definition at line 106 of file FPGATrackSimNNTrackTool.h.

◆ m_outputNodeDims

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

Definition at line 42 of file OnnxRuntimeBase.h.

◆ m_outputNodeNames

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

Definition at line 41 of file OnnxRuntimeBase.h.

◆ m_paramNN_1st

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_paramNN_1st
private

Definition at line 66 of file FPGATrackSimNNTrackTool.h.

◆ m_paramNN_2nd

OnnxRuntimeBase FPGATrackSimNNTrackTool::m_paramNN_2nd
private

Definition at line 67 of file FPGATrackSimNNTrackTool.h.

◆ m_phimodule

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

Definition at line 89 of file FPGATrackSimNNTrackTool.h.

◆ m_phiwidth

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

Definition at line 87 of file FPGATrackSimNNTrackTool.h.

◆ m_session

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

ONNX runtime session / model properties.

Definition at line 37 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 64 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_barcode

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

Definition at line 99 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_d0

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

Definition at line 92 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_eta

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

Definition at line 95 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_eventindex

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

Definition at line 100 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_pdg

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

Definition at line 97 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_phi

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

Definition at line 96 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_pt

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

Definition at line 94 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_q

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

Definition at line 98 of file FPGATrackSimNNTrackTool.h.

◆ m_truth_z0

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

Definition at line 93 of file FPGATrackSimNNTrackTool.h.

◆ m_useParamNN_1st

bool FPGATrackSimNNTrackTool::m_useParamNN_1st = true
private

Definition at line 71 of file FPGATrackSimNNTrackTool.h.

◆ m_useParamNN_2nd

bool FPGATrackSimNNTrackTool::m_useParamNN_2nd = true
private

Definition at line 72 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 77 of file FPGATrackSimNNTrackTool.h.

◆ m_y

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

Definition at line 78 of file FPGATrackSimNNTrackTool.h.

◆ m_z

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

Definition at line 79 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:58
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
OnnxRuntimeBase::runONNXInference
std::vector< float > runONNXInference(std::vector< float > &inputTensorValues) const
Definition: OnnxRuntimeBase.cxx:66
beamspotman.r
def r
Definition: beamspotman.py:676
getMenu.algname
algname
Definition: getMenu.py:54
FPGATrackSimTrackingToolBase::m_FPGATrackSimBank
ServiceHandle< IFPGATrackSimBankSvc > m_FPGATrackSimBank
Definition: FPGATrackSimTrackingToolBase.h:30
FPGATrackSimPlaneMap::getNLogiLayers
uint32_t getNLogiLayers() const
Definition: FPGATrackSimPlaneMap.h:75
OnnxRuntimeBase::m_env
std::unique_ptr< Ort::Env > m_env
Definition: OnnxRuntimeBase.h:44
FPGATrackSimHit::isStrip
bool isStrip() const
Definition: FPGATrackSimHit.h:65
FPGATrackSimTrack::setBankID
void setBankID(int v)
Definition: FPGATrackSimTrack.h:84
FPGATrackSimTrack::getNMissing
int getNMissing() const
Definition: FPGATrackSimTrack.h:52
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimTrack
Definition: FPGATrackSimTrack.h:18
FPGATrackSimTrackingToolBase::m_doRegionalMapping
Gaudi::Property< bool > m_doRegionalMapping
Definition: FPGATrackSimTrackingToolBase.h:34
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
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:140
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:59
M_PI
#define M_PI
Definition: ActiveFraction.h:11
FPGATrackSimTrack::setHoughXBin
void setHoughXBin(unsigned v)
Definition: FPGATrackSimTrack.h:108
FPGATrackSimTrack::setFirstSectorID
void setFirstSectorID(int v)
Definition: FPGATrackSimTrack.h:86
FPGATrackSimTrack::getNCoords
int getNCoords() const
Definition: FPGATrackSimTrack.cxx:89
FPGATrackSimNNTrackTool::getXScale
static float getXScale()
Definition: FPGATrackSimNNTrackTool.h:52
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:42
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
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
FPGATrackSimTrack::setOrigChi2
void setOrigChi2(float v)
Definition: FPGATrackSimTrack.h:98
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:64
OnnxRuntimeBase::m_inputNodeDims
std::vector< int64_t > m_inputNodeDims
Definition: OnnxRuntimeBase.h:40
HitType::wildcard
@ wildcard
FPGATrackSimPlaneMap::getCoordOffset
uint32_t getCoordOffset(size_t logiLayer) const
Definition: FPGATrackSimPlaneMap.h:92
FPGATrackSimNNTrackTool::m_paramNN_1st
OnnxRuntimeBase m_paramNN_1st
Definition: FPGATrackSimNNTrackTool.h:66
OnnxRuntimeBase::m_session
std::unique_ptr< Ort::Session > m_session
ONNX runtime session / model properties.
Definition: OnnxRuntimeBase.h:33
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:109
FPGATrackSimNNTrackTool::m_chi2_scalefactor
Gaudi::Property< double > m_chi2_scalefactor
Definition: FPGATrackSimNNTrackTool.h:57
OnnxRuntimeBase::m_inputNodeNames
std::vector< const char * > m_inputNodeNames
Definition: OnnxRuntimeBase.h:39
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:141
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
MuonR4::SegmentFit::ParamDefs::x0
@ x0
FPGATrackSimHit::isPixel
bool isPixel() const
Definition: FPGATrackSimHit.h:64
FPGATrackSimSectorBank
Definition: FPGATrackSimSectorBank.h:32
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:142
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:63
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:17
FPGATrackSimNNTrackTool::setTrackParameters_2nd
void setTrackParameters_2nd(FPGATrackSimTrack &track, std::vector< float > inputTensorValues)
Definition: FPGATrackSimNNTrackTool.cxx:82
FPGATrackSimNNTrackTool::getZScale
static float getZScale()
Definition: FPGATrackSimNNTrackTool.h:54
FPGATrackSimTrack::setTrackStage
void setTrackStage(TrackStage v)
Definition: FPGATrackSimTrack.h:82
FPGATrackSimNNTrackTool::m_fakeNN_2nd
OnnxRuntimeBase m_fakeNN_2nd
Definition: FPGATrackSimNNTrackTool.h:69
FPGATrackSimNNTrackTool::getYScale
static float getYScale()
Definition: FPGATrackSimNNTrackTool.h:53
MuonR4::SegmentFit::ParamDefs::y0
@ y0
fpgatracksim::QPT_SECTOR_OFFSET
constexpr int QPT_SECTOR_OFFSET
Definition: FPGATrackSimConstants.h:23
FPGATrackSimNNTrackTool::setTrackParameters_1st
void setTrackParameters_1st(FPGATrackSimTrack &track, std::vector< float > inputTensorValues)
Definition: FPGATrackSimNNTrackTool.cxx:65
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:68
FPGATrackSimTrack::setHoughY
void setHoughY(float v)
Definition: FPGATrackSimTrack.h:91
OnnxRuntimeBase::m_outputNodeNames
std::vector< const char * > m_outputNodeNames
Definition: OnnxRuntimeBase.h:41
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:530
FPGATrackSimNNTrackTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimNNTrackTool.cxx:25
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:63
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:92
y
#define y
FPGATrackSimTrack::setChi2
void setChi2(float v)
Definition: FPGATrackSimTrack.h:97
FPGATrackSimRoad::setSector
void setSector(sector_t sector)
Definition: FPGATrackSimRoad.h:60
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:67
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::m_useParamNN_2nd
bool m_useParamNN_2nd
Definition: FPGATrackSimNNTrackTool.h:72
OnnxRuntimeBase::OnnxRuntimeBase
OnnxRuntimeBase()
Definition: OnnxRuntimeBase.cxx:14
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
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:71
FPGATrackSimRoad::getAllHits
const std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit > > > & getAllHits() const
Definition: FPGATrackSimRoad.h:101
FPGATrackSimTrackingToolBase::m_do2ndStage
Gaudi::Property< bool > m_do2ndStage
Definition: FPGATrackSimTrackingToolBase.h:40
FPGATrackSimTrackingToolBase::m_spRoadFilterTool
ToolHandle< IFPGATrackSimRoadFilterTool > m_spRoadFilterTool
Definition: FPGATrackSimTrackingToolBase.h:32
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
fitman.k
k
Definition: fitman.py:528
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54