ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
SelectionHelpers
Root
OutOfValidityHelper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
//
9
// includes
10
//
11
12
#include <
SelectionHelpers/OutOfValidityHelper.h
>
13
14
#include <
AsgMessaging/MessageCheck.h
>
15
#include <
AsgMessaging/StatusCode.h
>
16
#include <
PATInterfaces/CorrectionCode.h
>
17
18
//
19
// method implementations
20
//
21
22
namespace
CP
23
{
24
::StatusCode OutOfValidityHelper ::
25
initialize ()
26
{
27
if
(!
m_decorationName
.empty())
28
{
29
ANA_CHECK
(
makeSelectionWriteAccessor
(
m_decorationName
,
m_write_accessor
));
30
ANA_CHECK
(
makeSelectionReadAccessor
(
m_decorationName
,
m_read_accessor
));
31
}
32
33
m_isInitialized
=
true
;
34
return
StatusCode::SUCCESS;
35
}
36
37
38
::StatusCode OutOfValidityHelper ::
39
check (
const
xAOD::IParticle
& particle,
40
const
CP::CorrectionCode
& code,
41
const
char
*context)
const
42
{
43
assert (
m_isInitialized
);
44
45
switch
(code)
46
{
47
case
CP::CorrectionCode::Ok
:
48
if
(
m_write_accessor
)
m_write_accessor
->setBool (particle,
true
);
49
return
StatusCode::SUCCESS;
50
case
CP::CorrectionCode::Error
:
51
return
StatusCode::FAILURE;
52
case
CP::CorrectionCode::OutOfValidityRange
:
53
if
(
m_write_accessor
)
m_write_accessor
->setBool (particle,
false
);
54
switch
(
OutOfValidityAction
(
m_action
))
55
{
56
case
OutOfValidityAction::ABORT
:
57
ANA_MSG_ERROR
(
"encountered OutOfValidity: "
<< context);
58
return
StatusCode::FAILURE;
59
case
OutOfValidityAction::WARNING
:
60
ANA_MSG_WARNING
(
"encountered OutOfValidity: "
<< context);
61
return
StatusCode::SUCCESS;
62
case
OutOfValidityAction::SILENT
:
63
return
StatusCode::SUCCESS;
64
}
65
}
66
ANA_MSG_ERROR
(__FILE__ <<
":"
<< __LINE__ <<
": invalid enum value encountered "
<< code <<
" "
<<
int
(
m_action
));
67
return
StatusCode::FAILURE;
68
}
69
70
bool
OutOfValidityHelper ::
71
get (
const
xAOD::IParticle
& particle)
const
{
72
return
m_read_accessor
->getBool(particle);
73
}
74
75
76
}
MessageCheck.h
macros for messaging and checking status codes
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
StatusCode.h
CorrectionCode.h
OutOfValidityHelper.h
CP::CorrectionCode
Return value from object correction CP tools.
Definition
CorrectionCode.h:31
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition
CorrectionCode.h:36
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition
CorrectionCode.h:37
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition
CorrectionCode.h:38
CP::OutOfValidityHelper::m_decorationName
std::string m_decorationName
the decoration name we use (if we have one)
Definition
OutOfValidityHelper.h:106
CP::OutOfValidityHelper::m_write_accessor
std::unique_ptr< ISelectionWriteAccessor > m_write_accessor
the accessor if we apply one
Definition
OutOfValidityHelper.h:101
CP::OutOfValidityHelper::m_action
unsigned m_action
the action to take
Definition
OutOfValidityHelper.h:97
CP::OutOfValidityHelper::m_isInitialized
bool m_isInitialized
whether we have been initialized
Definition
OutOfValidityHelper.h:114
CP::OutOfValidityHelper::m_read_accessor
std::unique_ptr< ISelectionReadAccessor > m_read_accessor
Definition
OutOfValidityHelper.h:102
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
CP::makeSelectionWriteAccessor
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
Definition
ISelectionAccessor.cxx:169
CP::makeSelectionReadAccessor
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition
ISelectionAccessor.cxx:53
CP::OutOfValidityAction
OutOfValidityAction
the action to perform on encountering an OutOfValidityRange in OutOfValidityHelper
Definition
OutOfValidityHelper.h:36
CP::OutOfValidityAction::WARNING
@ WARNING
print a warning message and return a success status code.
Definition
OutOfValidityHelper.h:52
CP::OutOfValidityAction::SILENT
@ SILENT
don't print anything and return success
Definition
OutOfValidityHelper.h:59
CP::OutOfValidityAction::ABORT
@ ABORT
print an error message and return a failure status code (triggering an abort)
Definition
OutOfValidityHelper.h:45
Generated on
for ATLAS Offline Software by
1.17.0