ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
SG::ThinningHandle< T > Class Template Reference

Handle for requesting thinning for a data object. More...

#include <ThinningHandle.h>

Inheritance diagram for SG::ThinningHandle< T >:
Collaboration diagram for SG::ThinningHandle< T >:

Public Types

using Op = ThinningDecision::Op
 

Public Member Functions

 ThinningHandle (const ThinningHandleKey< T > &key)
 Constructor from a ThinningHandleKey. More...
 
 ThinningHandle (const ThinningHandleKey< T > &key, const EventContext &ctx)
 Constructor from a ThinningHandleKey and an explicit event context. More...
 
void thin (size_t ndx)
 Mark that index ndx in the container should be thinned away. More...
 
void thin (const std::vector< bool > &v, Op op=Op::Set)
 Set the thinning state for the container from a bitmask. More...
 
void thin (const ThinningDecisionBase &other, Op op=Op::Set)
 Set the thinning state for the container from a bitmask. More...
 
void keep (size_t ndx)
 Mark that index ndx in the container should be kept (not thinned away). More...
 
void keep (const std::vector< bool > &v, Op op=Op::Set)
 Set the thinning state for the container from a bitmask. More...
 
void keep (const ThinningDecisionBase &other, Op op=Op::Set)
 Set the thinning state for the container from a bitmask. More...
 
void thinAll ()
 Mark that all elements should be thinned away. More...
 
void keepAll ()
 Mark that all elements should be kept (not thinned). More...
 
const ThinningDecisiondecision () const
 Return the thinning object we're building. More...
 

Private Attributes

WriteHandle< ThinningDecisionm_decisionHandle
 Handle for writing the decision object. More...
 
std::unique_ptr< ThinningDecisionm_decision
 The thinning object we're building. More...
 

Detailed Description

template<class T>
class SG::ThinningHandle< T >

Handle for requesting thinning for a data object.

A ThinningHandle + ThinningHandleKey is used to request thinning for a data object for a particular stream.

To use it, you should first create a ThinningHandleKey referencing the object you want to thin, in the same way as for a ReadHandle:

{ this, "ObjKey", "obj", "Object to be thinned." };

When you initialize the key, you should pass it the the name of the stream for which thinning is being done:

StringProperty m_stream{ this, "Stream", "OutStream", "Stream name for thinning" };
...
ATH_CHECK( m_objkey.initialize (m_streamName);

Then you can create a ThinningHandle from the key in the way in which you would create a ReadHandle:

This handle can then be used to access the object in the same way in which you would use a ReadHandle. In addition, you can call methods on the handle to specify objects to thin:

size_t iobj = 0;
for (const MyObject* obj : *h) {
if (obj->pt() < m_thresh) {
h.thin (iobj);
}
++iobj;
}

See ThinningHandleBase for a full list of the methods that may be used to specify the thinning.

The thinning request will be committed when the ThinningHandle is destroyed.

If the same object is thinned for the same stream in multiple algorithms, then the result will be the AND of all of them; that is, an element will be thinned on the output only if it has been requested to be thinned by all algorithms.

For a complete example, see DataModelTestDataCommon/xAODTestThinCVec.

Definition at line 82 of file ThinningHandle.h.

Member Typedef Documentation

◆ Op

template<class T >
using SG::ThinningHandle< T >::Op = ThinningDecision::Op

Definition at line 86 of file ThinningHandle.h.

Constructor & Destructor Documentation

◆ ThinningHandle() [1/2]

template<class T >
SG::ThinningHandle< T >::ThinningHandle ( const ThinningHandleKey< T > &  key)
inlineexplicit

Constructor from a ThinningHandleKey.

Parameters
keyThe key object holding the clid/key/store.

This will raise an exception if the StoreGate key is blank, or if the event store cannot be found.

Definition at line 96 of file ThinningHandle.h.

97  : ThinningHandle (key, Gaudi::Hive::currentContext())
98  {
99  }

◆ ThinningHandle() [2/2]

template<class T >
SG::ThinningHandle< T >::ThinningHandle ( const ThinningHandleKey< T > &  key,
const EventContext &  ctx 
)
inlineexplicit

Constructor from a ThinningHandleKey and an explicit event context.

Parameters
keyThe key object holding the clid/key/store.
ctxThe event context.

This will raise an exception if the StoreGate key is blank, or if the event store cannot be found.

If the default event store has been requested, then the thread-specific store from the event context will be used.

Definition at line 113 of file ThinningHandle.h.

115  : ReadHandle<T> (key, ctx),
116  ThinningHandleBase (key.decisionHandleKey(), key.key(), ctx)
117  {
118  }

Member Function Documentation

◆ decision()

const ThinningDecision & SG::ThinningHandleBase::decision ( ) const
inherited

Return the thinning object we're building.

Definition at line 154 of file ThinningHandleBase.cxx.

155 {
156  return *m_decision;
157 }

◆ keep() [1/3]

void SG::ThinningHandleBase::keep ( const std::vector< bool > &  v,
Op  op = Op::Set 
)
inherited

Set the thinning state for the container from a bitmask.

Parameters
vThinning state mask; should have the same size as the container. Element ndx should be kept if bit ndx is set in the map.
opLogical operation for combining with existing thinning state. Set — Keep if flag is true (overwriting anything originally set for this element). And — Keep if flag is true and element was originally kept, else not. Or — Keep if flag is true or element was originally kept, else not.

Definition at line 98 of file ThinningHandleBase.cxx.

99 {
100  m_decision->keep (v, op);
101 }

◆ keep() [2/3]

void SG::ThinningHandleBase::keep ( const ThinningDecisionBase other,
Op  op = Op::Set 
)
inherited

Set the thinning state for the container from a bitmask.

Parameters
otherThinning state mask; should have the same size as the container. Element ndx should be kept if bit ndx is set in the map.
opLogical operation for combining with existing thinning state. Set — Keep if flag is true (overwriting anything originally set for this element). And — Keep if flag is true and element was originally kept, else not. Or — Keep if flag is true or element was originally kept, else not.

Definition at line 127 of file ThinningHandleBase.cxx.

128 {
129  m_decision->keep (other, op);
130 }

◆ keep() [3/3]

void SG::ThinningHandleBase::keep ( size_t  ndx)
inherited

Mark that index ndx in the container should be kept (not thinned away).

Parameters
ndxIndex of element to keep.

Definition at line 68 of file ThinningHandleBase.cxx.

69 {
70  m_decision->keep (ndx);
71 }

◆ keepAll()

void SG::ThinningHandleBase::keepAll ( )
inherited

Mark that all elements should be kept (not thinned).

Definition at line 145 of file ThinningHandleBase.cxx.

146 {
147  return m_decision->keepAll();
148 }

◆ thin() [1/3]

void SG::ThinningHandleBase::thin ( const std::vector< bool > &  v,
Op  op = Op::Set 
)
inherited

Set the thinning state for the container from a bitmask.

Parameters
vThinning state mask; should have the same size as the container. Element ndx should be thinned if bit ndx is set in the map.
opLogical operation for combining with existing thinning state. Set — Thin if flag is true (overwriting anything originally set for this element). And — Thin if flag is true and element was originally thinned, else not. Or — Thin if flag is true or element was originally thinned, else not.

Definition at line 83 of file ThinningHandleBase.cxx.

84 {
85  m_decision->thin (v, op);
86 }

◆ thin() [2/3]

void SG::ThinningHandleBase::thin ( const ThinningDecisionBase other,
Op  op = Op::Set 
)
inherited

Set the thinning state for the container from a bitmask.

Parameters
otherThinning state mask; should have the same size as the container. Element ndx should be thinned if bit ndx is set in the map.
opLogical operation for combining with existing thinning state. Set — Thin if flag is true (overwriting anything originally set for this element). And — Thin if flag is true and element was originally thinned, else not. Or — Thin if flag is true or element was originally thinned, else not.

Definition at line 112 of file ThinningHandleBase.cxx.

113 {
114  m_decision->thin (other, op);
115 }

◆ thin() [3/3]

void SG::ThinningHandleBase::thin ( size_t  ndx)
inherited

Mark that index ndx in the container should be thinned away.

Parameters
ndxIndex of element to thin.

Definition at line 57 of file ThinningHandleBase.cxx.

58 {
59  m_decision->thin (ndx);
60 }

◆ thinAll()

void SG::ThinningHandleBase::thinAll ( )
inherited

Mark that all elements should be thinned away.

Definition at line 136 of file ThinningHandleBase.cxx.

137 {
138  return m_decision->thinAll();
139 }

Member Data Documentation

◆ m_decision

std::unique_ptr<ThinningDecision> SG::ThinningHandleBase::m_decision
privateinherited

The thinning object we're building.

Definition at line 141 of file ThinningHandleBase.h.

◆ m_decisionHandle

WriteHandle<ThinningDecision> SG::ThinningHandleBase::m_decisionHandle
privateinherited

Handle for writing the decision object.

Definition at line 138 of file ThinningHandleBase.h.


The documentation for this class was generated from the following file:
SG::ThinningHandleKey
HandleKey object for adding thinning to an object.
Definition: ThinningHandleKey.h:38
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
ReadHandle< T >
a smart pointer to an object of a given type in an IProxyDict (such as StoreGateSvc)....
extractSporadic.h
list h
Definition: extractSporadic.py:97
SG::ThinningHandle::ThinningHandle
ThinningHandle(const ThinningHandleKey< T > &key)
Constructor from a ThinningHandleKey.
Definition: ThinningHandle.h:96
SG::ThinningHandleBase::ThinningHandleBase
ThinningHandleBase(const WriteHandleKey< ThinningDecision > &dkey, const std::string &sgkey, const EventContext &ctx)
Constructor.
Definition: ThinningHandleBase.cxx:27
SG::ThinningHandleBase::m_decision
std::unique_ptr< ThinningDecision > m_decision
The thinning object we're building.
Definition: ThinningHandleBase.h:141
python.PyAthena.v
v
Definition: PyAthena.py:154
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
h
python.PyAthena.obj
obj
Definition: PyAthena.py:132
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37