ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
SystematicsHandles
Root
SysListHandle.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
//
9
// includes
10
//
11
12
#include <
SystematicsHandles/SysListHandle.h
>
13
14
#include <
AsgMessaging/MessageCheck.h
>
15
#include <
AsgMessaging/StatusCode.h
>
16
#include <
PATInterfaces/IReentrantSystematicsTool.h
>
17
#include <
PATInterfaces/SystematicSet.h
>
18
#include <
SystematicsHandles/ISysHandleBase.h
>
19
#include <regex>
20
#include <unordered_set>
21
22
//
23
// method implementations
24
//
25
26
namespace
CP
27
{
28
StatusCode SysListHandle ::
29
addHandle (
ISysHandleBase
& handle)
30
{
31
if
(
isInitialized
())
32
{
33
ANA_MSG_ERROR
(
"trying to add/initialize data handle after initializing SysListHandle"
);
34
return
StatusCode::FAILURE;
35
}
36
if
(handle.empty())
37
{
38
ANA_MSG_ERROR
(
"trying to add/initialize empty data handle"
);
39
return
StatusCode::FAILURE;
40
}
41
m_sysHandles
.push_back (&handle);
42
return
StatusCode::SUCCESS;
43
}
44
45
46
47
StatusCode SysListHandle ::
48
addSystematics (
const
CP::SystematicSet
& recommended,
49
const
CP::SystematicSet
& affecting)
50
{
51
assert (!
isInitialized
());
52
ANA_CHECK
(
m_systematicsService
->addSystematics (recommended, affecting));
53
m_affecting
.insert (affecting);
54
return
StatusCode::SUCCESS;
55
}
56
57
58
59
StatusCode SysListHandle ::
60
addSystematics (
const
IReentrantSystematicsTool
& tool)
61
{
62
return
addSystematics
(tool.recommendedSystematics(),
63
tool.affectingSystematics());
64
}
65
66
67
68
::StatusCode SysListHandle ::
69
initialize ()
70
{
71
for
(
ISysHandleBase
*handle :
m_sysHandles
)
72
m_affecting
.insert (handle->getInputAffecting (*
m_systematicsService
));
73
if
(!
m_affectingFilter
.empty())
74
{
75
std::regex filter (
m_affectingFilter
);
76
auto
affecting = std::move (
m_affecting
);
77
m_affecting
.clear ();
78
for
(
auto
& sys : affecting)
79
{
80
if
(!std::regex_match (sys.basename(), filter))
81
{
82
m_affecting
.insert (sys);
83
}
84
}
85
}
86
ANA_CHECK
(
fillSystematicsVector
());
87
for
(
ISysHandleBase
*handle :
m_sysHandles
)
88
ANA_CHECK
(handle->fillSystematics (*
m_systematicsService
,
m_affecting
,
m_systematicsVector
));
89
m_isInitialized
=
true
;
90
return
StatusCode::SUCCESS;
91
}
92
93
94
95
const
std::vector<CP::SystematicSet>& SysListHandle ::
96
systematicsVector ()
const
97
{
98
assert (
isInitialized
());
99
return
m_systematicsVector
;
100
}
101
102
103
104
StatusCode SysListHandle ::
105
fillSystematicsVector ()
106
{
107
assert (
m_systematicsVector
.empty());
108
109
std::unordered_set<CP::SystematicSet> knownSys;
110
111
for
(
const
auto
& sys :
m_systematicsService
->makeSystematicsVector())
112
{
113
CP::SystematicSet
filtered;
114
ANA_CHECK
(
SystematicSet::filterForAffectingSystematics
(sys,
m_affecting
, filtered));
115
if
(knownSys.find (filtered) == knownSys.end())
116
{
117
m_systematicsVector
.push_back (filtered);
118
knownSys.insert (std::move(filtered));
119
}
120
}
121
return
StatusCode::SUCCESS;
122
}
123
124
125
}
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_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
StatusCode.h
IReentrantSystematicsTool.h
ISysHandleBase.h
SysListHandle.h
SystematicSet.h
CP::IReentrantSystematicsTool
interface for all CP tools supporting systematic variations within a reentrant algorithm
Definition
IReentrantSystematicsTool.h:58
CP::ISysHandleBase
a basic interface for all systematics handles
Definition
ISysHandleBase.h:28
CP::SysListHandle::addSystematics
StatusCode addSystematics(const CP::SystematicSet &recommended, const CP::SystematicSet &affecting)
register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystem...
Definition
SysListHandle.cxx:48
CP::SysListHandle::fillSystematicsVector
StatusCode fillSystematicsVector()
Definition
SysListHandle.cxx:105
CP::SysListHandle::m_affecting
CP::SystematicSet m_affecting
this set of affecting systematics
Definition
SysListHandle.h:126
CP::SysListHandle::m_sysHandles
std::vector< ISysHandleBase * > m_sysHandles
the list of systematics handles we have
Definition
SysListHandle.h:122
CP::SysListHandle::m_systematicsVector
std::vector< CP::SystematicSet > m_systematicsVector
the value of systematicsVector
Definition
SysListHandle.h:130
CP::SysListHandle::isInitialized
bool isInitialized() const noexcept
whether initialize has been called successfully
CP::SysListHandle::m_isInitialized
bool m_isInitialized
the value of isInitialized
Definition
SysListHandle.h:134
CP::SysListHandle::m_systematicsService
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
Definition
SysListHandle.h:114
CP::SysListHandle::m_affectingFilter
std::string m_affectingFilter
an (optional) filter to remove affecting systematics
Definition
SysListHandle.h:118
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition
SystematicSet.h:31
CP::SystematicSet::filterForAffectingSystematics
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Definition
SystematicSet.cxx:212
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
Generated on
for ATLAS Offline Software by
1.17.0