ATLAS Offline Software
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 
20 namespace CP
21 {
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 
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 
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 
82  label () const
83  {
84  return m_label;
85  }
86 
87 
88 
90  isBool () const
91  {
92  return false;
93  }
94 
95 
96 
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 
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 }
base
std::string base
Definition: hcg.cxx:78
get_generator_info.result
result
Definition: get_generator_info.py:21
CP::ISystematicsSvc
the interface for the central systematics service
Definition: ISystematicsSvc.h:25
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:446
CP::SelectionType
uint32_t SelectionType
the type for selection decorations that are meant to hold a asg::AcceptData
Definition: SelectionHelpers.h:26
CP::SelectionAccessorList::isBool
virtual bool isBool() const override
whether this accessor returns a simple boolean
Definition: SelectionAccessorList.cxx:90
SystematicSet.h
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
SelectionAccessorList.h
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SelectionAccessorList::m_label
std::string m_label
the label of the accessor
Definition: SelectionAccessorList.h:68
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SelectionAccessorList::getInputAffecting
virtual CP::SystematicSet getInputAffecting(const ISystematicsSvc &svc, const std::string &objectName) const override
get the systematics when reading from the decoration
Definition: SelectionAccessorList.cxx:98
CP::SelectionAccessorList::SelectionAccessorList
SelectionAccessorList(std::vector< std::unique_ptr< ISelectionReadAccessor > > val_list)
Definition: SelectionAccessorList.cxx:23
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
CP::SelectionAccessorList::label
virtual std::string label() const override
get the label of the accessor
Definition: SelectionAccessorList.cxx:82
CP::SelectionAccessorList::getBool
virtual bool getBool(const SG::AuxElement &element, const CP::SystematicSet *sys) const override
get the selection decoration
Definition: SelectionAccessorList.cxx:69
CP::SelectionAccessorList::getBits
virtual SelectionType getBits(const SG::AuxElement &element, const CP::SystematicSet *sys) const override
get the selection decoration
Definition: SelectionAccessorList.cxx:40
xAOD::JetAttributeAccessor::accessor
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
Definition: JetAccessorMap.h:26
CP::SelectionAccessorList::m_list
std::vector< std::unique_ptr< ISelectionReadAccessor > > m_list
the list of selection accessors I rely on
Definition: SelectionAccessorList.h:64
CP::SelectionAccessorList::fillSystematics
virtual StatusCode fillSystematics(const ISystematicsSvc &svc, const std::vector< CP::SystematicSet > &sysList, const std::string &objectName) override
fill the systematic variations
Definition: SelectionAccessorList.cxx:111
CP::selectionAccept
constexpr SelectionType selectionAccept()
the selection decoration to apply for objects that are selected
Definition: SelectionHelpers.h:35