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
16
17//
18// method implementations
19//
20
21namespace CP
22{
23 SelectionAccessorReadSys ::
24 SelectionAccessorReadSys (const std::string& val_selectionName)
25 : m_selectionName (val_selectionName)
26 {}
27
28
29
30 SelectionType SelectionAccessorReadSys ::
31 getBits (const SG::AuxElement& element,
32 const CP::SystematicSet *sys) const
33 {
34 if (sys == nullptr)
35 throw std::logic_error ("trying to read systematics accessor without systematic");
36 auto iter = m_dataCache.find (*sys);
37 if (iter == m_dataCache.end())
38 throw std::logic_error ("unknown systematic: " + sys->name());
39 return std::get<1>(iter->second)->getBits (element, sys);
40 }
41
42
43
44 bool SelectionAccessorReadSys ::
45 getBool (const SG::AuxElement& element,
46 const CP::SystematicSet *sys) const
47 {
48 if (sys == nullptr)
49 throw std::logic_error ("trying to read systematics accessor without systematic");
50 auto iter = m_dataCache.find (*sys);
51 if (iter == m_dataCache.end())
52 throw std::logic_error ("unknown systematic: " + sys->name());
53 return std::get<1>(iter->second)->getBool (element, sys);
54 }
55
56
57 std::string SelectionAccessorReadSys ::
58 label () const
59 {
60 return m_selectionName;
61 }
62
63
64
65 bool SelectionAccessorReadSys ::
66 isBool () const
67 {
68 for (auto& item : m_dataCache)
69 if (!std::get<1>(item.second)->isBool())
70 return false;
71 return true;
72 }
73
74
75
76 CP::SystematicSet SelectionAccessorReadSys ::
77 getInputAffecting (const ISystematicsSvc& svc,
78 const std::string& objectName) const
79 {
80 std::string baseName = m_selectionName;
81 if (auto split = baseName.find (',');
82 split != std::string::npos)
83 baseName.resize (split);
84 return svc.getDecorSystematics (objectName, baseName);
85 }
86
87
88
89 StatusCode SelectionAccessorReadSys ::
90 fillSystematics (const ISystematicsSvc& svc,
91 const std::vector<CP::SystematicSet>& sysList,
92 const std::string& objectName)
93 {
94 using namespace msgSelectionHelpers;
95
96 std::string baseName = m_selectionName;
97 std::string suffix;
98 if (auto split = baseName.find (',');
99 split != std::string::npos)
100 {
101 suffix = baseName.substr (split);
102 baseName.resize (split);
103 }
104
105 const CP::SystematicSet affecting
106 = svc.getDecorSystematics (objectName, baseName);
107 for (auto& sys : sysList)
108 {
109 CP::SystematicSet inputSys;
110 ANA_CHECK (SystematicSet::filterForAffectingSystematics (sys, affecting, inputSys));
111 std::string decorName;
112 ANA_CHECK (svc.makeSystematicsName (decorName, baseName, inputSys));
113 ANA_MSG_DEBUG ("SysReadDecorHandle: " << decorName << " (" << sys.name() << ")");
114 std::unique_ptr<ISelectionReadAccessor> accessor;
115 ANA_CHECK (makeSelectionReadAccessor (decorName + suffix, accessor));
116 m_dataCache.emplace (sys, std::make_tuple (decorName, std::move (accessor)));
117 }
118 return StatusCode::SUCCESS;
119 }
120}
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
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:483
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