ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimGNNGraphConstructionTool.h
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATRACKSIMGNNGRAPHCONSTRUCTIONTOOL_H
4#define FPGATRACKSIMGNNGRAPHCONSTRUCTIONTOOL_H
5
17
19
23
26#include <onnxruntime_cxx_api.h>
27
29{
30 public:
31
33 // AthAlgTool
34
35 FPGATrackSimGNNGraphConstructionTool(const std::string&, const std::string&, const IInterface*);
36
37 virtual StatusCode initialize() override;
38
40 // Functions
41
42 virtual StatusCode getEdges(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits,
43 std::vector<std::shared_ptr<FPGATrackSimGNNEdge>> & edges);
44
45 private:
46
48 // Handles
49
50 ToolHandle<AthOnnx::IOnnxRuntimeInferenceTool> m_MLInferenceTool {this, "MLInferenceTool", "AthOnnx::OnnxRuntimeInferenceTool"};
52
54 // Properties
55
56 Gaudi::Property<std::string> m_graphTool { this, "graphTool", "", "Tool for graph construction" };
57 Gaudi::Property<std::string> m_moduleMapType { this, "moduleMapType", "", "Type for Module Map for graph construction" };
58 Gaudi::Property<std::string> m_moduleMapFunc { this, "moduleMapFunc", "", "Function for Module Map for graph construction" };
59 Gaudi::Property<float> m_moduleMapTol { this, "moduleMapTol", 0.0, "Tolerance value for Module Map cut calculations" };
60 Gaudi::Property<float> m_metricLearningR { this, "metricLearningR", 0.0, "Clustering radius for Metric Learning"};
61 Gaudi::Property<int> m_metricLearningMaxN { this, "metricLearningMaxN", 1, "Max number of neighbours for Metric Learning"};
62
64 // Convenience
65
66 // Module Map Information
67 std::string m_moduleMapPath;
68 std::vector<unsigned int> m_mid1{};
69 std::vector<unsigned int> m_mid2{};
70 std::vector<float> m_z0min_12{};
71 std::vector<float> m_dphimin_12{};
72 std::vector<float> m_phislopemin_12{};
73 std::vector<float> m_detamin_12{};
74 std::vector<float> m_z0max_12{};
75 std::vector<float> m_dphimax_12{};
76 std::vector<float> m_phislopemax_12{};
77 std::vector<float> m_detamax_12{};
78
80 // Helpers
81
83 void doModuleMap(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits,
84 std::vector<std::shared_ptr<FPGATrackSimGNNEdge>> & edges);
85 void getDoubletEdges(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits,
86 std::vector<std::shared_ptr<FPGATrackSimGNNEdge>> & edges);
87 void applyDoubletCuts(const std::shared_ptr<FPGATrackSimGNNHit> & hit1, const std::shared_ptr<FPGATrackSimGNNHit> & hit2,
88 std::vector<std::shared_ptr<FPGATrackSimGNNEdge>> & edges,
89 int hit1_index, int hit2_index, unsigned int modulemap_id);
90 bool doMask(float val, float min, float max);
91 bool doMinMaxMask(float val, float min, float max);
92 float featureSign(float feature);
93 void doMetricLearning(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits, std::vector<std::shared_ptr<FPGATrackSimGNNEdge>> & edges);
94 std::vector<float> getNodeFeatures(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits);
95 std::vector<float> embed(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits);
96 void doClustering(const std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & hits, std::vector<std::shared_ptr<FPGATrackSimGNNEdge>> & edges, std::vector<float> & gEmbedded);
97 // Metric Learning Properties
98 StringArrayProperty m_MLFeatureNamesVec{
99 this, "MLFeatureNames",
100 {"r", "phi", "z"},
101 "Feature names for the Metric Learning model"};
102 FloatArrayProperty m_MLFeatureScalesVec{
103 this, "MLFeatureScales",
104 {1000.0, 3.14159265359, 1000.0},
105 "Feature scales for the Metric Learning model"};
106};
107
108#endif // FPGATRACKSIMGNNGRAPHCONSTRUCTIONTOOL_H
FPGATrackSim-specific class to represent an edge as a connection between two hits in the detector use...
FPGATrackSim-specific class to represent an hit in the detector used for GNN pattern recognition.
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
ToolHandle< AthOnnx::IOnnxRuntimeInferenceTool > m_MLInferenceTool
virtual StatusCode getEdges(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits, std::vector< std::shared_ptr< FPGATrackSimGNNEdge > > &edges)
void getDoubletEdges(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits, std::vector< std::shared_ptr< FPGATrackSimGNNEdge > > &edges)
std::vector< float > getNodeFeatures(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits)
void applyDoubletCuts(const std::shared_ptr< FPGATrackSimGNNHit > &hit1, const std::shared_ptr< FPGATrackSimGNNHit > &hit2, std::vector< std::shared_ptr< FPGATrackSimGNNEdge > > &edges, int hit1_index, int hit2_index, unsigned int modulemap_id)
std::vector< float > embed(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits)
void doClustering(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits, std::vector< std::shared_ptr< FPGATrackSimGNNEdge > > &edges, std::vector< float > &gEmbedded)
void doMetricLearning(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits, std::vector< std::shared_ptr< FPGATrackSimGNNEdge > > &edges)
FPGATrackSimGNNGraphConstructionTool(const std::string &, const std::string &, const IInterface *)
void doModuleMap(const std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &hits, std::vector< std::shared_ptr< FPGATrackSimGNNEdge > > &edges)
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping