ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetGNNTracking
src
GNNTrackFinderTritonTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
GNNTrackFinderTritonTool.h
"
6
7
#include "ExaTrkXUtils.hpp"
8
#include "
CxxUtils/StringUtils.h
"
9
10
// Framework include(s).
11
#include <cmath>
12
13
#include "
PathResolver/PathResolver.h
"
14
15
StatusCode
InDet::GNNTrackFinderTritonTool::initialize
() {
16
ATH_CHECK
(
m_gnnTrackingTritonTool
.retrieve());
17
ATH_CHECK
(
m_spacepointFeatureTool
.retrieve());
18
19
// tokenize the feature names by comma and push to the vector
20
m_featureNamesVec
=
CxxUtils::tokenize
(
m_featureNames
,
","
);
21
return
StatusCode::SUCCESS;
22
}
23
24
StatusCode
InDet::GNNTrackFinderTritonTool::getTracks
(
25
const
std::vector<const Trk::SpacePoint*>& spacepoints,
26
std::vector<std::vector<uint32_t> >& tracks,
27
std::unordered_map<
int
, std::unordered_map<int, float>>*
/*edgeMap*/
)
const
{
28
int64_t numSpacepoints = (int64_t)spacepoints.size();
29
std::vector<float> inputValues;
30
std::vector<uint32_t> spacepointIDs;
31
32
int64_t spacepointFeatures =
m_featureNamesVec
.size();
33
int
sp_idx = 0;
34
for
(
const
auto
&
sp
: spacepoints) {
35
// depending on the trained embedding and GNN models, the input features
36
// may need to be updated.
37
auto
featureMap =
m_spacepointFeatureTool
->getFeatures(
sp
);
38
for
(
int
i = 0; i < spacepointFeatures; i++){
39
// if the feature is "hit_id", use sp_idx as its value
40
if
(
m_featureNamesVec
[i] ==
"hit_id"
){
41
inputValues.push_back((
float
)sp_idx);
42
continue
;
43
}
44
inputValues.push_back(featureMap[
m_featureNamesVec
[i]]);
45
}
46
sp_idx++;
47
}
48
49
AthInfer::InputDataMap
inputData;
50
inputData[
"FEATURES"
] = std::make_pair(
51
std::vector<int64_t>{numSpacepoints, spacepointFeatures}, std::move(inputValues));
52
53
AthInfer::OutputDataMap
outputData;
54
outputData[
"LABELS"
] = std::make_pair(std::vector<int64_t>{numSpacepoints, 1}, std::vector<int64_t>{});
55
56
ATH_CHECK
(
m_gnnTrackingTritonTool
->inference(inputData, outputData));
57
58
auto
& trackLabels = std::get<std::vector<int64_t>>(outputData[
"LABELS"
].second);
59
if
(trackLabels.size() == 0){
60
ATH_MSG_DEBUG
(
"No tracks found in the event."
);
61
return
StatusCode::SUCCESS;
62
}
63
64
tracks.clear();
65
std::vector<uint32_t> this_track;
66
for
(
auto
label
: trackLabels) {
67
if
(
label
== -1) {
68
if
(this_track.size() > 0) {
69
tracks.push_back(this_track);
70
this_track.clear();
71
}
72
}
else
{
73
this_track.push_back(
label
);
74
}
75
}
76
77
return
StatusCode::SUCCESS;
78
}
79
80
MsgStream&
InDet::GNNTrackFinderTritonTool::dump
( MsgStream& out )
const
81
{
82
out<<std::endl;
83
return
dumpevent
(out);
84
}
85
86
std::ostream&
InDet::GNNTrackFinderTritonTool::dump
( std::ostream& out )
const
87
{
88
return
out;
89
}
90
91
MsgStream&
InDet::GNNTrackFinderTritonTool::dumpevent
( MsgStream& out )
const
92
{
93
out<<
"|---------------------------------------------------------------------|"
94
<<std::endl;
95
out<<
"| Number output tracks | "
<<std::setw(12)
96
<<
" |"
<<std::endl;
97
out<<
"|---------------------------------------------------------------------|"
98
<<std::endl;
99
return
out;
100
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
StringUtils.h
GNNTrackFinderTritonTool.h
sp
static Double_t sp
Definition
LArPhysWaveHECTool.cxx:37
PathResolver.h
InDet::GNNTrackFinderTritonTool::m_featureNames
StringProperty m_featureNames
Definition
GNNTrackFinderTritonTool.h:61
InDet::GNNTrackFinderTritonTool::getTracks
virtual StatusCode getTracks(const std::vector< const Trk::SpacePoint * > &spacepoints, std::vector< std::vector< uint32_t > > &tracks, std::unordered_map< int, std::unordered_map< int, float > > *edgeMap=nullptr) const override
Get track candidates from a list of space points.
Definition
GNNTrackFinderTritonTool.cxx:24
InDet::GNNTrackFinderTritonTool::dumpevent
MsgStream & dumpevent(MsgStream &out) const
Definition
GNNTrackFinderTritonTool.cxx:91
InDet::GNNTrackFinderTritonTool::m_gnnTrackingTritonTool
ToolHandle< AthInfer::IAthInferenceTool > m_gnnTrackingTritonTool
Definition
GNNTrackFinderTritonTool.h:56
InDet::GNNTrackFinderTritonTool::m_featureNamesVec
std::vector< std::string > m_featureNamesVec
Definition
GNNTrackFinderTritonTool.h:65
InDet::GNNTrackFinderTritonTool::initialize
virtual StatusCode initialize() override
Definition
GNNTrackFinderTritonTool.cxx:15
InDet::GNNTrackFinderTritonTool::m_spacepointFeatureTool
ToolHandle< ISpacepointFeatureTool > m_spacepointFeatureTool
Definition
GNNTrackFinderTritonTool.h:58
InDet::GNNTrackFinderTritonTool::dump
virtual MsgStream & dump(MsgStream &out) const override
Definition
GNNTrackFinderTritonTool.cxx:80
label
std::string label(const std::string &format, int i)
Definition
label.h:19
AthInfer::OutputDataMap
std::map< std::string, InferenceData > OutputDataMap
Definition
IAthInferenceTool.h:18
AthInfer::InputDataMap
std::map< std::string, InferenceData > InputDataMap
Definition
IAthInferenceTool.h:17
CxxUtils::tokenize
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Definition
Control/CxxUtils/Root/StringUtils.cxx:12
Generated on
for ATLAS Offline Software by
1.17.0