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
std::unique_ptr< const Acts::Logger > m_logger
ServiceHandle< IChronoStatSvc > m_chronoSvc {"ChronoStatSvc", name()}
const PixelIDm_pixelIdHelper {nullptr}
const SCT_IDm_stripIdHelper {nullptr}
std::unique_ptr< ActsPlugins::GnnPipeline > m_gnnPipeline
std::optional< std::counting_semaphore<> > m_gpuInstanceCount ATLAS_THREAD_SAFE {}

Detailed Description

Definition at line 32 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 26 of file GnnPipelineTool.cxx.

29 : 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 features.assign(nFeatures * nSP, 0.f);
108 ids.resize(nSP);
109
110 for (std::size_t k = 0; k < nSP; ++k) {
111 ids.at(k) = static_cast<int>(k);
112 auto i = idxs.at(k);
113
114 std::span<float> f(features.data() + k * nFeatures, nFeatures);
115 const auto& sp = *allSPPtrs.at(i);
116
117 using namespace Acts::VectorHelpers;
118
119 Acts::Vector3 spp{sp.x(), sp.y(), sp.z()};
120
121 if (sp.measurements().size() == 1) {
122 for (std::size_t j = 0; j < nFeatures; j += 4) {
123 f[j + 0] = perp(spp) / 1000.f;
124 f[j + 1] = phi(spp) / std::numbers::pi_v<float>;
125 f[j + 2] = sp.z() / 1000.f;
126 f[j + 3] = eta(spp);
127 }
128 } else {
129 std::size_t j = 0;
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 for (const auto* m : sp.measurements()) {
136 const auto* cl = static_cast<const xAOD::StripCluster*>(m);
137 auto gp = cl->globalPosition();
138 j += 4;
139 f[j + 0] = perp(gp) / 1000.f;
140 f[j + 1] = phi(gp) / std::numbers::pi_v<float>;
141 f[j + 2] = gp.z() / 1000.f;
142 f[j + 3] = eta(gp);
143 }
144 }
145 }
146
147 return StatusCode::SUCCESS;
148}
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 174 of file GnnPipelineTool.cxx.

176 {
177 return StatusCode::FAILURE;
178}

◆ initialize()

StatusCode ActsTrk::GnnPipelineTool::initialize ( )
override

Definition at line 168 of file GnnPipelineTool.cxx.

168 {
169 m_logger = makeActsAthenaLogger(this, "ActsGnn");
170 ACTS_ERROR("Cannot initialize ActsGnn without the Acts GNN plugin");
171 return StatusCode::FAILURE;
172}
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 66 of file GnnPipelineTool.h.

66{ 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 84 of file GnnPipelineTool.h.

84{};

◆ m_chronoSvc

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

Definition at line 69 of file GnnPipelineTool.h.

69{"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 63 of file GnnPipelineTool.h.

63 {this, "cudaDeviceIndex", 0,
64 "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 58 of file GnnPipelineTool.h.

58 {this, "edgeCut", 0.5,
59 "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 48 of file GnnPipelineTool.h.

48 {this, "gnnPath", "",
49 "Path to the gnn file"};

◆ m_gnnPipeline

std::unique_ptr<ActsPlugins::GnnPipeline> ActsTrk::GnnPipelineTool::m_gnnPipeline
private

Definition at line 82 of file GnnPipelineTool.h.

◆ m_logger

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

Definition at line 67 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 53 of file GnnPipelineTool.h.

53 {
54 this, "maxGpuInstances", 1,
55 "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 60 of file GnnPipelineTool.h.

60 {
61 this, "minCandidateMeasurements", 7,
62 "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 46 of file GnnPipelineTool.h.

46 {this, "moduleMapPath", "",
47 "Path to the module map files"};

◆ 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 56 of file GnnPipelineTool.h.

56 {
57 this, "numTrtContexts", 1, "Number of TensorRT contexts to allocate"};

◆ m_pixelIdHelper

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

Definition at line 71 of file GnnPipelineTool.h.

71{nullptr};

◆ m_stripIdHelper

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

Definition at line 72 of file GnnPipelineTool.h.

72{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 50 of file GnnPipelineTool.h.

50 {
51 this, "usePhiOverlapSps", false,
52 "Whether to use phi overlap spacepoints"};

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