ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::GnnPipelineTool Class Reference

#include <GnnPipelineTool.h>

Inheritance diagram for ActsTrk::GnnPipelineTool:
Collaboration diagram for ActsTrk::GnnPipelineTool:

Public Member Functions

 GnnPipelineTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~GnnPipelineTool ()
StatusCode initialize () override
StatusCode buildSeed (const std::vector< const xAOD::SpacePointContainer * > &spacePointCollections, ActsTrk::SeedContainer &seeds) const override

Private Member Functions

const Acts::Logger & logger () const
StatusCode buildFeatures (const std::vector< const xAOD::SpacePointContainer * > &spacePointCollections, std::vector< float > &features, std::vector< std::uint64_t > &moduleIds, std::vector< int > &ids, std::vector< const xAOD::SpacePoint * > &allSPPtrs, std::size_t nFeatures=12) const

Private Attributes

Gaudi::Property< std::string > m_moduleMapPath
Gaudi::Property< std::string > m_gnnPath
Gaudi::Property< bool > m_usePhiOverlapSps
Gaudi::Property< unsigned int > m_maxGpuInstances
Gaudi::Property< unsigned int > m_numTrtContexts
Gaudi::Property< double > m_edgeCut
Gaudi::Property< unsigned int > m_minCandidateMeasurements
Gaudi::Property< int > m_cudaDeviceIndex
Gaudi::Property< unsigned int > m_numFeatures
std::unique_ptr< const Acts::Logger > m_logger
ServiceHandle< IChronoStatSvc > m_chronoSvc {"ChronoStatSvc", name()}
const PixelID * m_pixelIdHelper {nullptr}
const SCT_ID * m_stripIdHelper {nullptr}
std::optional< std::counting_semaphore<> > m_gpuInstanceCount ATLAS_THREAD_SAFE {}

Detailed Description

Definition at line 34 of file GnnPipelineTool.h.

Constructor & Destructor Documentation

◆ GnnPipelineTool()

ActsTrk::GnnPipelineTool::GnnPipelineTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 27 of file GnnPipelineTool.cxx.

30 : base_class(type, name, parent) {}

◆ ~GnnPipelineTool()

ActsTrk::GnnPipelineTool::~GnnPipelineTool ( )
virtualdefault

Member Function Documentation

◆ buildFeatures()

StatusCode ActsTrk::GnnPipelineTool::buildFeatures ( const std::vector< const xAOD::SpacePointContainer * > & spacePointCollections,
std::vector< float > & features,
std::vector< std::uint64_t > & moduleIds,
std::vector< int > & ids,
std::vector< const xAOD::SpacePoint * > & allSPPtrs,
std::size_t nFeatures = 12 ) const
inlineprivate

Definition at line 48 of file GnnFeatures.h.

53 {
54
55 std::size_t nSP = 0;
56 for (const auto* spc : spacePointCollections) {
57 nSP += spc->size();
58 }
59 moduleIds.reserve(nSP);
60 allSPPtrs.reserve(nSP);
61
62 std::size_t skipped = 0;
63 for (const auto* spc : spacePointCollections) {
64 for (const auto* sp : *spc) {
65 const auto* cl1 = sp->measurements().front();
66 Identifier atlasIdCl1(
67 static_cast<Identifier::value_type>(cl1->identifier()));
68
69 if (!m_usePhiOverlapSps.value() && sp->measurements().size() == 2) {
70 const auto* cl2 = sp->measurements().at(1);
71 Identifier atlasIdCl2(
72 static_cast<Identifier::value_type>(cl2->identifier()));
73
74 int overlapFlag = detail::computeOverlapSpFlag(
75 m_stripIdHelper->eta_module(atlasIdCl1),
76 m_stripIdHelper->phi_module(atlasIdCl1),
77 m_stripIdHelper->eta_module(atlasIdCl2),
78 m_stripIdHelper->phi_module(atlasIdCl2));
79
80 if (overlapFlag == 2 || overlapFlag == 3) {
81 ++skipped;
82 ACTS_VERBOSE("Skip phi overlap spacepoint (flag=" << overlapFlag
83 << ")");
84 continue;
85 }
86 }
87
88 Identifier waferIdCl1 =
90 ? m_pixelIdHelper->wafer_id(atlasIdCl1)
91 : m_stripIdHelper->wafer_id(atlasIdCl1);
92 moduleIds.push_back(waferIdCl1.get_compact());
93 allSPPtrs.push_back(sp);
94 }
95 }
96
97 ACTS_DEBUG("Skipped " << skipped << " SPs because of phi overlap");
98 nSP = allSPPtrs.size();
99 ACTS_DEBUG("Keep " << nSP << " SPs for feature creation");
100
101 std::vector<std::size_t> idxs(nSP);
102 std::iota(idxs.begin(), idxs.end(), 0);
103 std::ranges::sort(
104 idxs, [&](auto a, auto b) { return moduleIds.at(a) < moduleIds.at(b); });
105 std::ranges::sort(moduleIds);
106
107 // Reorder the space point pointers to match the sorted module ids, so that
108 // the node ids returned by the pipeline index allSPPtrs directly
109 std::vector<const xAOD::SpacePoint*> sortedSPPtrs(nSP);
110 for (std::size_t k = 0; k < nSP; ++k) {
111 sortedSPPtrs.at(k) = allSPPtrs.at(idxs.at(k));
112 }
113 allSPPtrs.swap(sortedSPPtrs);
114
115 features.assign(nFeatures * nSP, 0.f);
116 ids.resize(nSP);
117
118 for (std::size_t k = 0; k < nSP; ++k) {
119 ids.at(k) = static_cast<int>(k);
120
121 std::span<float> f(features.data() + k * nFeatures, nFeatures);
122 const auto& sp = *allSPPtrs.at(k);
123
124 using namespace Acts::VectorHelpers;
125
126 Acts::Vector3 spp{sp.x(), sp.y(), sp.z()};
127
128 if (sp.measurements().size() == 1) {
129 for (std::size_t j = 0; j < nFeatures; j += 4) {
130 f[j + 0] = perp(spp) / 1000.f;
131 f[j + 1] = phi(spp) / std::numbers::pi_v<float>;
132 f[j + 2] = sp.z() / 1000.f;
133 f[j + 3] = eta(spp);
134 }
135 } else {
136 std::size_t j = 0;
137 f[j + 0] = perp(spp) / 1000.f;
138 f[j + 1] = phi(spp) / std::numbers::pi_v<float>;
139 f[j + 2] = sp.z() / 1000.f;
140 f[j + 3] = eta(spp);
141
142 for (const auto* m : sp.measurements()) {
143 const auto* cl = static_cast<const xAOD::StripCluster*>(m);
144 auto gp = cl->globalPosition();
145 j += 4;
146 f[j + 0] = perp(gp) / 1000.f;
147 f[j + 1] = phi(gp) / std::numbers::pi_v<float>;
148 f[j + 2] = gp.z() / 1000.f;
149 f[j + 3] = eta(gp);
150 }
151 }
152 }
153
154 return StatusCode::SUCCESS;
155}
Scalar eta() const
pseudorapidity method
Scalar perp() const
perp method - perpendicular length
Scalar phi() const
phi method
static Double_t sp
static Double_t a
const SCT_ID * m_stripIdHelper
Gaudi::Property< bool > m_usePhiOverlapSps
const PixelID * m_pixelIdHelper
value_type get_compact() const
Get the compact id.
int computeOverlapSpFlag(int etaModuleCl1, int phiModuleCl1, int etaModuleCl2, int phiModuleCl2)
Definition GnnFeatures.h:30
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
StripCluster_v1 StripCluster
Define the version of the strip cluster class.

◆ buildSeed()

StatusCode ActsTrk::GnnPipelineTool::buildSeed ( const std::vector< const xAOD::SpacePointContainer * > & spacePointCollections,
ActsTrk::SeedContainer & seeds ) const
override

Definition at line 187 of file GnnPipelineTool.cxx.

189 {
190 return StatusCode::FAILURE;
191}

◆ initialize()

StatusCode ActsTrk::GnnPipelineTool::initialize ( )
override

Definition at line 181 of file GnnPipelineTool.cxx.

181 {
182 m_logger = makeActsAthenaLogger(this, "ActsGnn");
183 ACTS_ERROR("Cannot initialize ActsGnn without the Acts GNN plugin");
184 return StatusCode::FAILURE;
185}
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition Logger.cxx:64
std::unique_ptr< const Acts::Logger > m_logger

◆ logger()

const Acts::Logger & ActsTrk::GnnPipelineTool::logger ( ) const
inlineprivate

Definition at line 72 of file GnnPipelineTool.h.

72{ return *m_logger; }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::optional<std::counting_semaphore<> > m_gpuInstanceCount ActsTrk::GnnPipelineTool::ATLAS_THREAD_SAFE {}
mutableprivate

Definition at line 92 of file GnnPipelineTool.h.

92{};

◆ m_chronoSvc

ServiceHandle<IChronoStatSvc> ActsTrk::GnnPipelineTool::m_chronoSvc {"ChronoStatSvc", name()}
private

Definition at line 75 of file GnnPipelineTool.h.

75{"ChronoStatSvc", name()};

◆ m_cudaDeviceIndex

Gaudi::Property<int> ActsTrk::GnnPipelineTool::m_cudaDeviceIndex
private
Initial value:
{this, "cudaDeviceIndex", 0,
"CUDA device index for GNN inference"}

Definition at line 65 of file GnnPipelineTool.h.

65 {this, "cudaDeviceIndex", 0,
66 "CUDA device index for GNN inference"};

◆ m_edgeCut

Gaudi::Property<double> ActsTrk::GnnPipelineTool::m_edgeCut
private
Initial value:
{this, "edgeCut", 0.5,
"Edge cut to apply after the GNN"}

Definition at line 60 of file GnnPipelineTool.h.

60 {this, "edgeCut", 0.5,
61 "Edge cut to apply after the GNN"};

◆ m_gnnPath

Gaudi::Property<std::string> ActsTrk::GnnPipelineTool::m_gnnPath
private
Initial value:
{this, "gnnPath", "",
"Path to the gnn file"}

Definition at line 50 of file GnnPipelineTool.h.

50 {this, "gnnPath", "",
51 "Path to the gnn file"};

◆ m_logger

std::unique_ptr<const Acts::Logger> ActsTrk::GnnPipelineTool::m_logger
private

Definition at line 73 of file GnnPipelineTool.h.

◆ m_maxGpuInstances

Gaudi::Property<unsigned int> ActsTrk::GnnPipelineTool::m_maxGpuInstances
private
Initial value:
{
this, "maxGpuInstances", 1,
"Number of events that can be on GPU in parallel"}

Definition at line 55 of file GnnPipelineTool.h.

55 {
56 this, "maxGpuInstances", 1,
57 "Number of events that can be on GPU in parallel"};

◆ m_minCandidateMeasurements

Gaudi::Property<unsigned int> ActsTrk::GnnPipelineTool::m_minCandidateMeasurements
private
Initial value:
{
this, "minCandidateMeasurements", 7,
"Minimum number of spacepoints to cut for in the GNN candidates"}

Definition at line 62 of file GnnPipelineTool.h.

62 {
63 this, "minCandidateMeasurements", 7,
64 "Minimum number of spacepoints to cut for in the GNN candidates"};

◆ m_moduleMapPath

Gaudi::Property<std::string> ActsTrk::GnnPipelineTool::m_moduleMapPath
private
Initial value:
{this, "moduleMapPath", "",
"Path to the module map files"}

Definition at line 48 of file GnnPipelineTool.h.

48 {this, "moduleMapPath", "",
49 "Path to the module map files"};

◆ m_numFeatures

Gaudi::Property<unsigned int> ActsTrk::GnnPipelineTool::m_numFeatures
private
Initial value:
{
this, "numFeatures", 12,
"Number of input features per spacepoint: 12 (spacepoint and both strip "
"clusters) or 4 (spacepoint only, pixel-only models)"}

Definition at line 67 of file GnnPipelineTool.h.

67 {
68 this, "numFeatures", 12,
69 "Number of input features per spacepoint: 12 (spacepoint and both strip "
70 "clusters) or 4 (spacepoint only, pixel-only models)"};

◆ m_numTrtContexts

Gaudi::Property<unsigned int> ActsTrk::GnnPipelineTool::m_numTrtContexts
private
Initial value:
{
this, "numTrtContexts", 1, "Number of TensorRT contexts to allocate"}

Definition at line 58 of file GnnPipelineTool.h.

58 {
59 this, "numTrtContexts", 1, "Number of TensorRT contexts to allocate"};

◆ m_pixelIdHelper

const PixelID* ActsTrk::GnnPipelineTool::m_pixelIdHelper {nullptr}
private

Definition at line 77 of file GnnPipelineTool.h.

77{nullptr};

◆ m_stripIdHelper

const SCT_ID* ActsTrk::GnnPipelineTool::m_stripIdHelper {nullptr}
private

Definition at line 78 of file GnnPipelineTool.h.

78{nullptr};

◆ m_usePhiOverlapSps

Gaudi::Property<bool> ActsTrk::GnnPipelineTool::m_usePhiOverlapSps
private
Initial value:
{
this, "usePhiOverlapSps", false,
"Whether to use phi overlap spacepoints"}

Definition at line 52 of file GnnPipelineTool.h.

52 {
53 this, "usePhiOverlapSps", false,
54 "Whether to use phi overlap spacepoints"};

The documentation for this class was generated from the following files: