ATLAS Offline Software
Loading...
Searching...
No Matches
SelectionAccessorList.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
15
16//
17// method implementations
18//
19
20namespace CP
21{
22 SelectionAccessorList ::
23 SelectionAccessorList (std::vector<std::unique_ptr<ISelectionReadAccessor> > val_list)
24 : m_list (std::move (val_list))
25 {
26 for (const std::unique_ptr<ISelectionReadAccessor> &acc : m_list)
27 {
28 if (!m_label.empty())
29 m_label.append(" && ");
30
31 m_label.append(acc->label());
32 }
33
34 m_label = "( " + m_label + " )";
35 }
36
37
38
39 SelectionType SelectionAccessorList ::
40 getBits (const SG::AuxElement& element,
41 const CP::SystematicSet *sys) const
42 {
43 // total number of bits in SelectionType
44 constexpr size_t SelectionTotalBits = 8 * sizeof (SelectionType);
45
46 // if we have more cuts than bits, just return true/false
47 if (m_list.size() > SelectionTotalBits)
48 {
49 if (getBool (element, sys))
50 return selectionAccept();
51 else
52 return 0;
53 }
54
56 for (std::size_t iter = 0; iter != m_list.size(); ++ iter)
57 {
58 if (m_list[iter]->getBool (element, sys) == false)
59 {
60 result = result & ~(SelectionType (1) << iter);
61 }
62 }
63 return result;
64 }
65
66
67
68 bool SelectionAccessorList ::
69 getBool (const SG::AuxElement& element,
70 const CP::SystematicSet *sys) const
71 {
72 for (auto& accessor : m_list)
73 {
74 if (!accessor->getBool (element, sys))
75 return false;
76 }
77 return true;
78 }
79
80
81 std::string SelectionAccessorList ::
82 label () const
83 {
84 return m_label;
85 }
86
87
88
89 bool SelectionAccessorList ::
90 isBool () const
91 {
92 return false;
93 }
94
95
96
97 CP::SystematicSet SelectionAccessorList ::
98 getInputAffecting (const ISystematicsSvc& svc,
99 const std::string& objectName) const
100 {
102
103 for (auto& base : m_list)
104 result.insert (base->getInputAffecting (svc, objectName));
105 return result;
106 }
107
108
109
110 StatusCode SelectionAccessorList ::
111 fillSystematics (const ISystematicsSvc& svc,
112 const std::vector<CP::SystematicSet>& sysList,
113 const std::string& objectName)
114 {
115 using namespace msgSelectionHelpers;
116
117 for (auto& base : m_list)
118 ANA_CHECK (base->fillSystematics (svc, sysList, objectName));
119 return StatusCode::SUCCESS;
120 }
121}
#define ANA_CHECK(EXP)
check whether the given expression was successful
the interface for the central systematics service
std::string m_label
the label of the accessor
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_list
the list of selection accessors I rely on
virtual bool getBool(const SG::AuxElement &element, const CP::SystematicSet *sys) const override
get the selection decoration
Class to wrap a set of SystematicVariations.
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
std::string base
Definition hcg.cxx:81
Select isolated Photons, Electrons and Muons.
uint32_t SelectionType
the type for selection decorations that are meant to hold a asg::AcceptData
constexpr SelectionType selectionAccept()
the selection decoration to apply for objects that are selected
STL namespace.
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.