ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
SelectionHelpers
Root
SelectionAccessorReadSys.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
//
9
// includes
10
//
11
12
#include <
SelectionHelpers/SelectionAccessorReadSys.h
>
13
14
#include <
AsgMessaging/MessageCheck.h
>
15
#include <
SystematicsHandles/ISysHandleBase.h
>
16
#include <
SystematicsHandles/ISystematicsSvc.h
>
17
18
//
19
// method implementations
20
//
21
22
namespace
CP
23
{
24
SelectionAccessorReadSys ::
25
SelectionAccessorReadSys (
const
std::string& val_selectionName)
26
:
m_selectionName
(val_selectionName)
27
{}
28
29
30
31
SelectionType
SelectionAccessorReadSys ::
32
getBits (
const
SG::AuxElement
& element,
33
const
CP::SystematicSet
*sys)
const
34
{
35
if
(sys ==
nullptr
)
36
throw
std::logic_error (
"trying to read systematics accessor without systematic"
);
37
auto
iter =
m_dataCache
.find (*sys);
38
if
(iter ==
m_dataCache
.end())
39
throw
std::logic_error (
"unknown systematic: "
+ sys->name());
40
return
std::get<1>(iter->second)->getBits (element, sys);
41
}
42
43
44
45
bool
SelectionAccessorReadSys ::
46
getBool (
const
SG::AuxElement
& element,
47
const
CP::SystematicSet
*sys)
const
48
{
49
if
(sys ==
nullptr
)
50
throw
std::logic_error (
"trying to read systematics accessor without systematic"
);
51
auto
iter =
m_dataCache
.find (*sys);
52
if
(iter ==
m_dataCache
.end())
53
throw
std::logic_error (
"unknown systematic: "
+ sys->name());
54
return
std::get<1>(iter->second)->getBool (element, sys);
55
}
56
57
58
std::string SelectionAccessorReadSys ::
59
label ()
const
60
{
61
return
m_selectionName
;
62
}
63
64
65
66
bool
SelectionAccessorReadSys ::
67
isBool ()
const
68
{
69
for
(
auto
& item :
m_dataCache
)
70
if
(!std::get<1>(item.second)->isBool())
71
return
false
;
72
return
true
;
73
}
74
75
76
77
CP::SystematicSet
SelectionAccessorReadSys ::
78
getInputAffecting (
const
ISystematicsSvc
& svc,
79
const
std::string& objectName)
const
80
{
81
std::string baseName =
m_selectionName
;
82
if
(
auto
split
= baseName.find (
','
);
83
split
!= std::string::npos)
84
baseName.resize (
split
);
85
return
svc.getDecorSystematics (objectName, baseName);
86
}
87
88
89
90
StatusCode SelectionAccessorReadSys ::
91
fillSystematics (
const
ISystematicsSvc
& svc,
92
const
std::vector<CP::SystematicSet>& sysList,
93
ISysObjectHandleBase
& objectHandle)
94
{
95
using namespace
msgSelectionHelpers;
96
97
std::string baseName =
m_selectionName
;
98
std::string suffix;
99
if
(
auto
split
= baseName.find (
','
);
100
split
!= std::string::npos)
101
{
102
suffix = baseName.substr (
split
);
103
baseName.resize (
split
);
104
}
105
106
const
CP::SystematicSet
affecting
107
= svc.getDecorSystematics (objectHandle.
getNamePattern
(), baseName);
108
for
(
auto
& sys : sysList)
109
{
110
CP::SystematicSet
inputSys;
111
ANA_CHECK
(
SystematicSet::filterForAffectingSystematics
(sys, affecting, inputSys));
112
std::string decorName;
113
ANA_CHECK
(svc.makeSystematicsName (decorName, baseName, inputSys));
114
ANA_MSG_DEBUG
(
"SysReadDecorHandle: "
<< decorName <<
" ("
<< sys.name() <<
")"
);
115
std::unique_ptr<ISelectionReadAccessor> accessor;
116
ANA_CHECK
(
makeSelectionReadAccessor
(decorName + suffix, accessor));
117
m_dataCache
.emplace (sys, std::make_tuple (decorName, std::move (accessor)));
118
}
119
ANA_CHECK
(objectHandle.
addDecorationDependency
(svc, baseName,
false
));
120
return
StatusCode::SUCCESS;
121
}
122
}
MessageCheck.h
macros for messaging and checking status codes
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
ISysHandleBase.h
ISystematicsSvc.h
SelectionAccessorReadSys.h
CP::ISysObjectHandleBase
a ISysHandleBase for a handle to a specific object/container
Definition
ISysHandleBase.h:58
CP::ISysObjectHandleBase::addDecorationDependency
virtual StatusCode addDecorationDependency(const ISystematicsSvc &svc, const std::string &decoName, bool decoWrite)=0
add dependency information for the given decoration
CP::ISysObjectHandleBase::getNamePattern
virtual std::string getNamePattern() const =0
get the name pattern before substitution
CP::ISystematicsSvc
the interface for the central systematics service
Definition
ISystematicsSvc.h:26
CP::SelectionAccessorReadSys::m_dataCache
std::unordered_map< CP::SystematicSet, std::tuple< std::string, std::unique_ptr< ISelectionReadAccessor > > > m_dataCache
the map of accessor we use
Definition
SelectionAccessorReadSys.h:65
CP::SelectionAccessorReadSys::m_selectionName
std::string m_selectionName
the selectionName for this accessor
Definition
SelectionAccessorReadSys.h:69
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
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
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::SelectionType
uint32_t SelectionType
the type for selection decorations that are meant to hold a asg::AcceptData
Definition
SelectionHelpers.h:26
SG::AuxElement
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
Generated on
for ATLAS Offline Software by
1.17.0