ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
16
17//
18// method implementations
19//
20
21namespace CP
22{
23 SelectionWriteAccessorSys ::
24 SelectionWriteAccessorSys (const std::string& val_selectionName)
25 : m_selectionName (val_selectionName)
26 {}
27
28
29
30 void SelectionWriteAccessorSys ::
31 setBits (const SG::AuxElement& element,
33 const CP::SystematicSet *sys) const
34 {
35 if (sys == nullptr)
36 throw std::logic_error ("trying to write 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)->setBits (element, selection, sys);
41 }
42
43
44
45 void SelectionWriteAccessorSys ::
46 setBool (const SG::AuxElement& element,
47 bool selection,
48 const CP::SystematicSet *sys) const
49 {
50 if (sys == nullptr)
51 throw std::logic_error ("trying to write systematics accessor without systematic");
52 auto iter = m_dataCache.find (*sys);
53 if (iter == m_dataCache.end())
54 throw std::logic_error ("unknown systematic: " + sys->name());
55 return std::get<1>(iter->second)->setBool (element, selection, sys);
56 }
57
58
59
60 std::string SelectionWriteAccessorSys ::
61 label () const
62 {
63 return m_selectionName;
64 }
65
66
67
68 StatusCode SelectionWriteAccessorSys ::
69 fillSystematics (const ISystematicsSvc& svc,
70 const CP::SystematicSet& fullAffecting,
71 const std::vector<CP::SystematicSet>& sysList,
72 const std::string& objectName)
73 {
74 using namespace msgSelectionHelpers;
75
76 std::string baseName = m_selectionName;
77 std::string suffix;
78 if (auto split = baseName.find (',');
79 split != std::string::npos)
80 {
81 suffix = baseName.substr (split);
82 baseName.resize (split);
83 }
84
85 for (auto& sys : sysList)
86 {
87 std::string decorName;
88 ANA_CHECK (svc.makeSystematicsName (decorName, baseName, sys));
89 ANA_MSG_DEBUG ("SelectionWriteAccessorSys: " << decorName << " (" << sys.name() << ")");
90 std::unique_ptr<ISelectionWriteAccessor> accessor;
91 ANA_CHECK (makeSelectionWriteAccessor (decorName + suffix, accessor));
92 m_dataCache.emplace (sys, std::make_tuple (decorName, std::move (accessor)));
93 }
94 ANA_CHECK (svc.setDecorSystematics (objectName, baseName, fullAffecting));
95 return StatusCode::SUCCESS;
96 }
97}
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< ISelectionWriteAccessor > > > m_dataCache
the map of accessor we use
std::string m_selectionName
the selectionName for this accessor
Class to wrap a set of SystematicVariations.
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
const std::string selection
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
Select isolated Photons, Electrons and Muons.
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
uint32_t SelectionType
the type for selection decorations that are meant to hold a asg::AcceptData