ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
17
18//
19// method implementations
20//
21
22namespace 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}
macros for messaging and checking status codes
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
a ISysHandleBase for a handle to a specific object/container
virtual StatusCode addDecorationDependency(const ISystematicsSvc &svc, const std::string &decoName, bool decoWrite)=0
add dependency information for the given decoration
virtual std::string getNamePattern() const =0
get the name pattern before substitution
the interface for the central systematics service
std::unordered_map< CP::SystematicSet, std::tuple< std::string, std::unique_ptr< ISelectionReadAccessor > > > m_dataCache
the map of accessor we use
std::string m_selectionName
the selectionName for this accessor
Class to wrap a set of SystematicVariations.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Base class for elements of a container that can have aux data.
Definition AuxElement.h:484
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
Select isolated Photons, Electrons and Muons.
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
uint32_t SelectionType
the type for selection decorations that are meant to hold a asg::AcceptData