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 134 of file ViewHelper.h.

Constructor & Destructor Documentation

◆ ViewMerger()

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

Definition at line 139 of file ViewHelper.h.

139 : 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 172 of file ViewHelper.h.

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

◆ 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 143 of file ViewHelper.h.

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

Member Data Documentation

◆ m_msg

MsgStream& ViewHelper::ViewMerger::m_msg
private

Definition at line 137 of file ViewHelper.h.

◆ m_sg

StoreGateSvc* ViewHelper::ViewMerger::m_sg
private

Definition at line 136 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:66
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:136
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:137
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