ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonPhaseII
MuonLearning
MuonInference
src
DVInferenceAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
DVInferenceAlg.h
"
5
6
#include "
xAODTrigger/TrigCompositeAuxContainer.h
"
7
8
namespace
MuonML
{
9
10
StatusCode
DVInferenceAlg::initialize
() {
11
ATH_CHECK
(
m_inferenceTool
.retrieve());
12
ATH_CHECK
(
m_trigCompositeKey
.initialize(
m_writeDVoutput
));
13
14
m_thresholdModeName
=
m_thresholdMode
;
15
if
(
m_thresholdModeName
!=
"score"
&&
m_thresholdModeName
!=
"raw"
) {
16
ATH_MSG_ERROR
(
"ThresholdMode must be either 'score' or 'raw', got "
<<
m_thresholdModeName
);
17
return
StatusCode::FAILURE;
18
}
19
m_useRawThreshold
= (
m_thresholdModeName
==
"raw"
);
20
const
float
scoreThreshold =
m_scoreThreshold
;
21
ATH_MSG_INFO
(
"Initialized DVInferenceAlg with ScoreThreshold="
<< scoreThreshold
22
<<
", ThresholdMode="
<<
m_thresholdModeName
23
<<
", WriteDVoutput="
<<
m_writeDVoutput
);
24
return
StatusCode::SUCCESS;
25
}
26
27
StatusCode
DVInferenceAlg::execute
(
const
EventContext& ctx)
const
{
28
DVInferenceResult
result{};
29
ATH_CHECK
(
m_inferenceTool
->inferEvent(ctx, result));
30
31
if
(!result.valid) {
32
ATH_MSG_WARNING
(
"DV event classifier did not produce a finite score for event "
33
<< ctx.eventID().event_number());
34
}
35
36
const
float
decisionValue =
m_useRawThreshold
? result.rawOutput : result.probability;
37
const
float
cutValue =
m_scoreThreshold
;
38
const
bool
pass = result.valid && decisionValue >= cutValue;
39
if
(
m_printEveryEvent
) {
40
ATH_MSG_INFO
(
"DV event classifier: event="
<< ctx.eventID().event_number()
41
<<
" score="
<< result.probability
42
<<
" raw="
<< result.rawOutput
43
<<
" decisionValue="
<< decisionValue
44
<<
" cutValue="
<< cutValue
45
<<
" thresholdMode="
<<
m_thresholdModeName
46
<<
" pass="
<< pass
47
<<
" nodes="
<< result.nNodes
48
<<
" edges="
<< result.nEdges);
49
}
else
{
50
ATH_MSG_DEBUG
(
"DV event classifier: event="
<< ctx.eventID().event_number()
51
<<
" score="
<< result.probability
52
<<
" raw="
<< result.rawOutput
53
<<
" decisionValue="
<< decisionValue
54
<<
" cutValue="
<< cutValue
55
<<
" thresholdMode="
<<
m_thresholdModeName
56
<<
" pass="
<< pass
57
<<
" nodes="
<< result.nNodes
58
<<
" edges="
<< result.nEdges);
59
}
60
61
if
(
m_writeDVoutput
) {
62
SG::WriteHandle<xAOD::TrigCompositeContainer>
outputHandle{
m_trigCompositeKey
, ctx};
63
ATH_CHECK
(outputHandle.
record
(std::make_unique<xAOD::TrigCompositeContainer>(),
64
std::make_unique<xAOD::TrigCompositeAuxContainer>()));
65
66
xAOD::TrigComposite
* trigComposite = outputHandle->push_back(std::make_unique<xAOD::TrigComposite>());
67
68
trigComposite->
setDetail
<
float
>(
"Score"
, result.valid ? result.probability : -1.f);
69
trigComposite->
setDetail
<
float
>(
"RawOutput"
, result.valid ? result.rawOutput : -1.f);
70
trigComposite->
setDetail
<
char
>(
"Pass"
, pass ? 1 : 0);
71
trigComposite->
setDetail
<
unsigned
int
>(
"NNodes"
,
static_cast<
unsigned
int
>
(result.nNodes));
72
trigComposite->
setDetail
<
unsigned
int
>(
"NEdges"
,
static_cast<
unsigned
int
>
(result.nEdges));
73
}
74
75
return
StatusCode::SUCCESS;
76
}
77
78
}
// namespace MuonML
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:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
DVInferenceAlg.h
TrigCompositeAuxContainer.h
MuonML::DVInferenceAlg::m_thresholdMode
Gaudi::Property< std::string > m_thresholdMode
Definition
DVInferenceAlg.h:39
MuonML::DVInferenceAlg::m_trigCompositeKey
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_trigCompositeKey
Definition
DVInferenceAlg.h:34
MuonML::DVInferenceAlg::m_useRawThreshold
bool m_useRawThreshold
Definition
DVInferenceAlg.h:43
MuonML::DVInferenceAlg::m_writeDVoutput
Gaudi::Property< bool > m_writeDVoutput
Definition
DVInferenceAlg.h:31
MuonML::DVInferenceAlg::m_inferenceTool
ToolHandle< MuonML::DVInferenceToolBase > m_inferenceTool
Definition
DVInferenceAlg.h:28
MuonML::DVInferenceAlg::m_printEveryEvent
Gaudi::Property< bool > m_printEveryEvent
Definition
DVInferenceAlg.h:41
MuonML::DVInferenceAlg::m_thresholdModeName
std::string m_thresholdModeName
Definition
DVInferenceAlg.h:44
MuonML::DVInferenceAlg::initialize
StatusCode initialize() override
Definition
DVInferenceAlg.cxx:10
MuonML::DVInferenceAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition
DVInferenceAlg.cxx:27
MuonML::DVInferenceAlg::m_scoreThreshold
Gaudi::Property< float > m_scoreThreshold
Definition
DVInferenceAlg.h:37
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::TrigComposite_v1::setDetail
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
MuonML
Definition
BucketGraphUtils.h:18
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition
TrigComposite.h:16
MuonML::DVInferenceResult
Definition
DVInferenceToolBase.h:30
Generated on
for ATLAS Offline Software by
1.17.0