ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
ViewHelper::ViewMerger Class Reference

#include <ViewHelper.h>

Collaboration diagram for ViewHelper::ViewMerger:

Public Member Functions

 ViewMerger (StoreGateSvc *sg, MsgStream &msg)
 
template<typename T >
StatusCode mergeViewCollection (ViewContainer const &viewVector, SG::ReadHandleKey< T > const &queryKey, EventContext const &sourceContext, T &outputData)
 
template<typename T >
StatusCode mergeViewCollection (ViewContainer const &viewVector, SG::ReadHandleKey< DataVector< T > > const &queryKey, EventContext const &sourceContext, DataVector< T > &outputData)
 

Private Attributes

StoreGateSvcm_sg
 
MsgStream & m_msg
 

Detailed Description

Definition at line 135 of file ViewHelper.h.

Constructor & Destructor Documentation

◆ ViewMerger()

ViewHelper::ViewMerger::ViewMerger ( StoreGateSvc sg,
MsgStream &  msg 
)
inline

Definition at line 140 of file ViewHelper.h.

140 : m_sg( sg ), m_msg( msg ) {}

Member Function Documentation

◆ mergeViewCollection() [1/2]

template<typename T >
StatusCode ViewHelper::ViewMerger::mergeViewCollection ( ViewContainer const viewVector,
SG::ReadHandleKey< DataVector< T > > const queryKey,
EventContext const sourceContext,
DataVector< T > &  outputData 
)
inline

Definition at line 173 of file ViewHelper.h.

174  {
175  //Check that there's a non-const aux store for output bookkeeping
176  if ( !outputData.getStore() )
177  {
178  m_msg << MSG::ERROR << "output data does not have the store" << endmsg;
179  return StatusCode::FAILURE;
180  }
181 
182  //Make ReadHandle to access views
183  SG::ReadHandle< DataVector< T > > queryHandle( queryKey, sourceContext );
184 
185  //Make accessor for bookkeeping
187 
188  //Loop over all views
189  unsigned int offset = outputData.size(); //allow for existing objects in the container
190  for ( auto inputView : viewVector )
191  {
192  //Attach the handle to the view
193  StatusCode sc = queryHandle.setProxyDict( inputView );
194  if ( !sc.isSuccess() )
195  {
196  m_msg << MSG::ERROR << "Failed to use view " << inputView->name() << " to read " << queryHandle.key() << endmsg;
197  return sc;
198  }
199 
200  //Nothing to do for empty collections
201  if ( queryHandle->size() == 0 )
202  {
203  if (m_msg.level() <= MSG::DEBUG) {
204  m_msg << MSG::DEBUG << "Empty collection " << queryHandle.key() <<" in a view " << inputView->name() <<endmsg;
205  continue;
206  }
207  }
208 
209  //Merge the data
210  for ( const auto inputObject : *queryHandle.cptr() )
211  {
212  //Element-wise copy data (looks a bit weird, but necessary for xAOD objects)
213  T * outputObject = new T();
214  outputData.push_back( outputObject );
215  *outputObject = *inputObject;
216 
217  //Add aux data for bookkeeping
218  viewBookkeeper( *outputObject ) = inputView->getROI();
219  }
220 
221  if (m_msg.level() <= MSG::DEBUG) {
222  m_msg << MSG::DEBUG << "Copied " << queryHandle->size() << " objects from collection in view " << inputView->name() << endmsg;
223  }
224 
225  //Declare remapping
226  auto proxy = inputView->proxy( queryHandle.clid(), queryHandle.key() ); //shouldn't need to test validity since queryHandle already used
228  proxy->name(),
229  queryHandle.name(),
230  offset );
231  offset += queryHandle->size();
232  }
233 
234  return StatusCode::SUCCESS;
235  }

◆ mergeViewCollection() [2/2]

template<typename T >
StatusCode ViewHelper::ViewMerger::mergeViewCollection ( ViewContainer const viewVector,
SG::ReadHandleKey< T > const queryKey,
EventContext const sourceContext,
T &  outputData 
)
inline

Definition at line 144 of file ViewHelper.h.

145  {
146  //Make a ReadHandle to use
147  SG::ReadHandle<T> queryHandle( queryKey, sourceContext );
148 
149  //Loop over all views
150  for ( SG::View* inputView : viewVector )
151  {
152  //Attach the handle to the view
153  StatusCode sc = queryHandle.setProxyDict( inputView );
154  if ( !sc.isSuccess() )
155  {
156  m_msg << MSG::ERROR <<"Failed to use view " << inputView->name() << " to read " << queryHandle.key() << " resetting output" << endmsg;
157  outputData.clear();
158  return sc;
159  }
160 
161  //Merge the data
162  T inputData = *queryHandle;
163  outputData.insert( outputData.end(), inputData.begin(), inputData.end() );
164  }
165 
166  return StatusCode::SUCCESS;
167  }

Member Data Documentation

◆ m_msg

MsgStream& ViewHelper::ViewMerger::m_msg
private

Definition at line 138 of file ViewHelper.h.

◆ m_sg

StoreGateSvc* ViewHelper::ViewMerger::m_sg
private

Definition at line 137 of file ViewHelper.h.


The documentation for this class was generated from the following file:
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
DataVector< T >
ViewHelper::ViewMerger::m_sg
StoreGateSvc * m_sg
Definition: ViewHelper.h:137
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StoreGateSvc::remap
void remap(CLID clid, const TKEY &source, const TKEY &target, off_t index_offset)
Declare a remapping.
ViewHelper::ViewMerger::m_msg
MsgStream & m_msg
Definition: ViewHelper.h:138
DEBUG
#define DEBUG
Definition: page_access.h:11
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
SG::View
Definition: View.h:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35