ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
SelectionHelpers
Root
SelectionWriteAccessorSys.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/SelectionWriteAccessorSys.h
>
13
14
#include <
AsgMessaging/MessageCheck.h
>
15
#include <
SystematicsHandles/ISystematicsSvc.h
>
16
#include <
SystematicsHandles/ISysHandleBase.h
>
17
18
//
19
// method implementations
20
//
21
22
namespace
CP
23
{
24
SelectionWriteAccessorSys ::
25
SelectionWriteAccessorSys (
const
std::string& val_selectionName)
26
:
m_selectionName
(val_selectionName)
27
{}
28
29
30
31
void
SelectionWriteAccessorSys ::
32
setBits (
const
SG::AuxElement
& element,
33
SelectionType
selection
,
34
const
CP::SystematicSet
*sys)
const
35
{
36
if
(sys ==
nullptr
)
37
throw
std::logic_error (
"trying to write systematics accessor without systematic"
);
38
auto
iter =
m_dataCache
.find (*sys);
39
if
(iter ==
m_dataCache
.end())
40
throw
std::logic_error (
"unknown systematic: "
+ sys->name());
41
return
std::get<1>(iter->second)->setBits (element,
selection
, sys);
42
}
43
44
45
46
void
SelectionWriteAccessorSys ::
47
setBool (
const
SG::AuxElement
& element,
48
bool
selection
,
49
const
CP::SystematicSet
*sys)
const
50
{
51
if
(sys ==
nullptr
)
52
throw
std::logic_error (
"trying to write systematics accessor without systematic"
);
53
auto
iter =
m_dataCache
.find (*sys);
54
if
(iter ==
m_dataCache
.end())
55
throw
std::logic_error (
"unknown systematic: "
+ sys->name());
56
return
std::get<1>(iter->second)->setBool (element,
selection
, sys);
57
}
58
59
60
61
std::string SelectionWriteAccessorSys ::
62
label ()
const
63
{
64
return
m_selectionName
;
65
}
66
67
68
69
StatusCode SelectionWriteAccessorSys ::
70
fillSystematics (
const
ISystematicsSvc
& svc,
71
const
CP::SystematicSet
& fullAffecting,
72
const
std::vector<CP::SystematicSet>& sysList,
73
ISysObjectHandleBase
& objectHandle)
74
{
75
using namespace
msgSelectionHelpers;
76
77
std::string baseName =
m_selectionName
;
78
std::string suffix;
79
if
(
auto
split
= baseName.find (
','
);
80
split
!= std::string::npos)
81
{
82
suffix = baseName.substr (
split
);
83
baseName.resize (
split
);
84
}
85
86
for
(
auto
& sys : sysList)
87
{
88
std::string decorName;
89
ANA_CHECK
(svc.makeSystematicsName (decorName, baseName, sys));
90
ANA_MSG_DEBUG
(
"SelectionWriteAccessorSys: "
<< decorName <<
" ("
<< sys.name() <<
")"
);
91
std::unique_ptr<ISelectionWriteAccessor> accessor;
92
ANA_CHECK
(
makeSelectionWriteAccessor
(decorName + suffix, accessor));
93
m_dataCache
.emplace (sys, std::make_tuple (decorName, std::move (accessor)));
94
}
95
ANA_CHECK
(svc.setDecorSystematics (objectHandle.
getNamePattern
(), baseName, fullAffecting));
96
ANA_CHECK
(objectHandle.
addDecorationDependency
(svc, baseName,
true
));
97
return
StatusCode::SUCCESS;
98
}
99
}
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
SelectionWriteAccessorSys.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::SelectionWriteAccessorSys::m_dataCache
std::unordered_map< CP::SystematicSet, std::tuple< std::string, std::unique_ptr< ISelectionWriteAccessor > > > m_dataCache
the map of accessor we use
Definition
SelectionWriteAccessorSys.h:59
CP::SelectionWriteAccessorSys::m_selectionName
std::string m_selectionName
the selectionName for this accessor
Definition
SelectionWriteAccessorSys.h:63
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition
SystematicSet.h:31
selection
const std::string selection
Definition
fbtTestBasics.cxx:75
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::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::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