ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonPhaseII
MuonLearning
MuonInference
src
InferenceUtils.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#ifndef MUONINFERENCE_INFERENCEUTILS_H
5
#define MUONINFERENCE_INFERENCEUTILS_H
6
7
#include "
AthOnnxComps/OnnxRuntimeSessionToolCUDA.h
"
8
#include "
MuonTrackEvent/TrackingHelpers.h
"
9
#include "
xAODMuon/MuonSegment.h
"
10
11
#include <algorithm>
12
#include <cmath>
13
14
namespace
MuonML::InferenceUtils
{
15
16
struct
SessionBackend
{
17
bool
isCuda
{
false
};
18
int
cudaDeviceId
{0};
19
};
20
21
template
<
class
SessionToolHandle>
22
SessionBackend
sessionBackend
(
const
SessionToolHandle& sessionTool) {
23
if
(
const
auto
* cudaTool =
dynamic_cast<
const
AthOnnx::OnnxRuntimeSessionToolCUDA
*
>
(sessionTool.get())) {
24
return
SessionBackend
{
true
, cudaTool->deviceId()};
25
}
26
return
SessionBackend
{};
27
}
28
29
inline
float
sigmoid
(
float
x
) {
30
if
(
x
>= 0.f) {
31
const
float
z
= std::exp(-
x
);
32
return
1.f / (1.f +
z
);
33
}
34
const
float
z
= std::exp(
x
);
35
return
z
/ (1.f +
z
);
36
}
37
38
inline
float
reducedChi2
(
const
xAOD::MuonSegment
& segment) {
39
return
segment.
chiSquared
() / std::max(1.f, segment.
numberDoF
());
40
}
41
43
inline
int
compareFloat
(
float
first,
float
second) {
44
if
(std::isnan(first))
return
std::isnan(second) ? 0 : 1;
45
if
(std::isnan(second))
return
-1;
46
if
(first < second)
return
-1;
47
if
(first > second)
return
1;
48
return
0;
49
}
50
52
inline
int
compareFloatDescending
(
float
first,
float
second) {
53
if
(std::isnan(first))
return
std::isnan(second) ? 0 : 1;
54
if
(std::isnan(second))
return
-1;
55
if
(first > second)
return
-1;
56
if
(first < second)
return
1;
57
return
0;
58
}
59
62
using
SegmentQualityOrder
=
MuonR4::SegmentQualitySorter
;
63
64
}
// namespace MuonML::InferenceUtils
65
66
#endif
// MUONINFERENCE_INFERENCEUTILS_H
MuonSegment.h
OnnxRuntimeSessionToolCUDA.h
TrackingHelpers.h
x
#define x
z
#define z
AthOnnx::OnnxRuntimeSessionToolCUDA
Definition
OnnxRuntimeSessionToolCUDA.h:21
xAOD::MuonSegment_v1::numberDoF
float numberDoF() const
Returns the numberDoF.
xAOD::MuonSegment_v1::chiSquared
float chiSquared() const
MuonML::InferenceUtils
Definition
InferenceUtils.h:14
MuonML::InferenceUtils::compareFloat
int compareFloat(float first, float second)
Three-way float comparison which orders NaN after all numeric values.
Definition
InferenceUtils.h:43
MuonML::InferenceUtils::sessionBackend
SessionBackend sessionBackend(const SessionToolHandle &sessionTool)
Definition
InferenceUtils.h:22
MuonML::InferenceUtils::sigmoid
float sigmoid(float x)
Definition
InferenceUtils.h:29
MuonML::InferenceUtils::SegmentQualityOrder
MuonR4::SegmentQualitySorter SegmentQualityOrder
Common quality ordering for segment representatives, shared with MlMsTrackSeeder so that graph constr...
Definition
InferenceUtils.h:62
MuonML::InferenceUtils::compareFloatDescending
int compareFloatDescending(float first, float second)
Three-way descending comparison which also orders NaN last.
Definition
InferenceUtils.h:52
MuonML::InferenceUtils::reducedChi2
float reducedChi2(const xAOD::MuonSegment &segment)
Definition
InferenceUtils.h:38
xAOD::MuonSegment
MuonSegment_v1 MuonSegment
Reference the current persistent version:
Definition
Event/xAOD/xAODMuon/xAODMuon/MuonSegment.h:13
MuonML::InferenceUtils::SessionBackend
Definition
InferenceUtils.h:16
MuonML::InferenceUtils::SessionBackend::cudaDeviceId
int cudaDeviceId
Definition
InferenceUtils.h:18
MuonML::InferenceUtils::SessionBackend::isCuda
bool isCuda
Definition
InferenceUtils.h:17
MuonR4::SegmentQualitySorter
Auxiliary class to rank segments by quality: more precision hits first, then more phi layers,...
Definition
TrackingHelpers.h:72
Generated on
for ATLAS Offline Software by
1.17.0