ATLAS Offline Software
ThinningHandleBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
13 #include "StoreGate/exceptions.h"
15 
16 
17 namespace SG {
18 
19 
28  const std::string& sgkey,
29  const EventContext& ctx)
30  : m_decisionHandle (dkey, ctx),
31  m_decision (std::make_unique<ThinningDecision> (sgkey))
32 {
33 }
34 
35 
42 {
43  StatusCode sc = StatusCode::FAILURE;
44  try {
45  sc = m_decisionHandle.record (std::move (m_decision));
46  }
47  catch (const GaudiException&) {
48  sc = StatusCode::FAILURE;
49  }
50  if (sc.isFailure()) {
51  MsgStream msg (Athena::getMessageSvc(), "ThinningHandleBase");
52  msg << MSG::ERROR
53  << "Can't record SG::ThinningDecision object: "
54  << m_decisionHandle.store() << "+" << m_decisionHandle.key()
55  << endmsg;
56  }
57 }
58 
59 
64 void ThinningHandleBase::thin (size_t ndx)
65 {
66  m_decision->thin (ndx);
67 }
68 
69 
75 void ThinningHandleBase::keep (size_t ndx)
76 {
77  m_decision->keep (ndx);
78 }
79 
80 
90 void ThinningHandleBase::thin (const std::vector<bool>& v, Op op /*= Op::Set*/)
91 {
92  m_decision->thin (v, op);
93 }
94 
95 
105 void ThinningHandleBase::keep (const std::vector<bool>& v, Op op /*= Op::Set*/)
106 {
107  m_decision->keep (v, op);
108 }
109 
119 void ThinningHandleBase::thin (const ThinningDecisionBase& other, Op op /*= Op::Set*/)
120 {
121  m_decision->thin (other, op);
122 }
123 
124 
134 void ThinningHandleBase::keep (const ThinningDecisionBase& other, Op op /*= Op::Set*/)
135 {
136  m_decision->keep (other, op);
137 }
138 
139 
144 {
145  return m_decision->thinAll();
146 }
147 
148 
153 {
154  return m_decision->keepAll();
155 }
156 
157 
162 {
163  return *m_decision;
164 }
165 
166 
167 } // namespace SG
SG::ThinningHandleBase::thinAll
void thinAll()
Mark that all elements should be thinned away.
Definition: ThinningHandleBase.cxx:143
common.sgkey
def sgkey(tool)
Definition: common.py:1027
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
SG::ThinningHandleBase::keepAll
void keepAll()
Mark that all elements should be kept (not thinned).
Definition: ThinningHandleBase.cxx:152
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::ThinningDecisionBase
Hold thinning decisions for one container.
Definition: ThinningDecisionBase.h:39
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::ThinningHandleBase::keep
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Definition: ThinningHandleBase.cxx:75
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
exceptions.h
Exceptions that can be thrown from StoreGate.
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ThinningHandleBase::ThinningHandleBase
ThinningHandleBase(const WriteHandleKey< ThinningDecision > &dkey, const std::string &sgkey, const EventContext &ctx)
Constructor.
Definition: ThinningHandleBase.cxx:27
SG::ThinningDecision
Hold thinning decisions for one container.
Definition: ThinningDecision.h:40
SG::ThinningHandleBase::decision
const ThinningDecision & decision() const
Return the thinning object we're building.
Definition: ThinningHandleBase.cxx:161
SG::ThinningHandleBase::m_decision
std::unique_ptr< ThinningDecision > m_decision
The thinning object we're building.
Definition: ThinningHandleBase.h:141
SG::ThinningHandleBase::thin
void thin(size_t ndx)
Mark that index ndx in the container should be thinned away.
Definition: ThinningHandleBase.cxx:64
SG::ThinningDecisionBase::Op
Op
Definition: ThinningDecisionBase.h:44
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::ThinningHandleBase::~ThinningHandleBase
~ThinningHandleBase()
Destructor.
Definition: ThinningHandleBase.cxx:41
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::ThinningHandleBase::m_decisionHandle
WriteHandle< ThinningDecision > m_decisionHandle
Handle for writing the decision object.
Definition: ThinningHandleBase.h:138
ThinningHandleBase.h
Handle for requesting thinning: factor out type-independent code.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7