|  | ATLAS Offline Software
    | 
 
 
 
Go to the documentation of this file.
    5 #ifndef ATHVIEWS_VIEWHELPER_HH 
    6 #define ATHVIEWS_VIEWHELPER_HH 
    8 #include "GaudiKernel/SmartIF.h" 
    9 #include "GaudiKernel/IScheduler.h" 
   10 #include "GaudiKernel/EventContext.h" 
   11 #include "GaudiKernel/StatusCode.h" 
   24   template< 
typename T >
 
   27                                      std::vector< T > 
const& inputData, 
bool const allowFallThrough = 
true )
 
   30     if ( viewNameRoot.find( 
' ' ) != std::string::npos )
 
   32       return StatusCode::FAILURE;
 
   39     unsigned int const viewNumber = inputData.size();
 
   40     for ( 
unsigned int viewIndex = 0; viewIndex < viewNumber; ++viewIndex )
 
   43       SG::View * outputView = 
new SG::View( viewNameRoot, viewIndex, allowFallThrough );
 
   48       if ( !
sc.isSuccess() )
 
   55       sc = populateHandle.
record( std::make_unique< T >( inputData[ viewIndex ] ) );
 
   56       if ( !
sc.isSuccess() )
 
   63     return StatusCode::SUCCESS;
 
   71     auto viewContext = std::make_unique< EventContext >( sourceContext );
 
   72     if ( 
view->getROI().isValid() ) {
 
   81     return scheduler->scheduleEventView( &sourceContext, nodeName, std::move( viewContext ) );
 
   86                                    EventContext 
const& sourceContext, SmartIF<IScheduler> scheduler, 
bool reverseOrder = 
false  )
 
   90       return StatusCode::FAILURE;
 
   95     if ( 
dynamic_cast< SG::View* 
>( extendedContext.proxy() ) ) {
 
   96       return StatusCode::FAILURE;
 
  101       return StatusCode::FAILURE;
 
  104     if ( viewVector->
empty() ) {
 
  107       return scheduler->scheduleEventView( &sourceContext, nodeName, 0 );
 
  110       if ( reverseOrder ) {
 
  116             return StatusCode::FAILURE;
 
  126             return StatusCode::FAILURE;
 
  132     return StatusCode::SUCCESS;
 
  143     template< 
typename T >
 
  150       for ( 
const SG::View* inputView : viewVector )
 
  156         if ( !
sc.isSuccess() )
 
  158           m_msg << MSG::ERROR <<
"Failed to use view " << inputView->name() << 
" to read " << queryHandle.
key() << 
" resetting output" << 
endmsg;
 
  164         T inputData = *queryHandle;
 
  165         outputData.insert( outputData.end(), inputData.begin(), inputData.end() );
 
  168       return StatusCode::SUCCESS;
 
  174     template< 
typename T >
 
  178       if ( !outputData.getStore() )
 
  180         m_msg << MSG::ERROR << 
"output data does not have the store"  << 
endmsg;
 
  181         return StatusCode::FAILURE;
 
  192       for ( 
const SG::View* inputView : viewVector )
 
  198         if ( !
sc.isSuccess() )
 
  200           m_msg << MSG::ERROR << 
"Failed to use view " << inputView->name() << 
" to read " << queryHandle.
key() << 
endmsg;
 
  205         if ( queryHandle->empty() )
 
  214         for ( 
SG::auxid_t decor : queryHandle->getDecorIDs() ) {
 
  216           m_msg << MSG::WARNING << 
"mergeViewCollection: skipped unlocked decoration " << queryHandle.
key() << 
"." << 
r.getName( decor ) << 
endmsg;
 
  220         for ( 
const auto inputObject : *queryHandle.
cptr() )
 
  223           T * outputObject = 
new T();
 
  225           *outputObject = *inputObject;
 
  228           viewBookkeeper( *outputObject ) = inputView->getROI();
 
  232           m_msg << 
MSG::DEBUG << 
"Copied " << queryHandle->size() << 
" objects from collection in view  " << inputView->
name() << 
endmsg;
 
  236         auto proxy = inputView->proxy( queryHandle.
clid(), queryHandle.
key() ); 
 
  241         offset += queryHandle->size();
 
  244       return StatusCode::SUCCESS;
 
  252   inline SG::View* 
makeView( 
const std::string& common_name, 
int const unique_index = -1, 
bool const allowFallThrough = 
true )
 
  255     if ( common_name.find( 
' ' ) != std::string::npos )
 
  260     return new SG::View( common_name, unique_index, allowFallThrough );
 
  272   template<
typename KEY>
 
  278     handle.setProxyDict( nview ).ignore();  
 
  292   template<
typename T, 
typename CONT>
 
  294                                             const EventContext& context )
 
  298     auto handle = SG::makeHandle<T>(dKey, context );
 
  299     handle.setProxyDict( nview ).ignore();   
 
  312     if ( 
proxy == 
nullptr ) 
throw std::runtime_error( 
"Attempting to make element link with invalid key " + handle.
key() );
 
  
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
std::vector< Identifier > ID
const_pointer_type cptr()
Dereference the pointer.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Helper class to provide type-safe access to aux data.
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
EventIDBase::number_type conditionsRun() const
const std::string & name() const
Return the StoreGate ID for the referenced object.
ElementLink< T > makeLink(const SG::View *view, const SG::ReadHandle< T > &handle, size_t index)
Create EL to a collection in view.
CLID clid() const
Return the class ID for the referenced object.
bool hasExtendedEventContext(const EventContext &ctx)
Test whether a context object has an extended context installed.
StatusCode scheduleSingleView(SG::View *view, std::string const &nodeName, EventContext const &sourceContext, EventIDBase::number_type conditionsRun, SmartIF< IScheduler > scheduler)
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
Property holding a SG store/key/clid from which a ReadHandle is made.
Handle mappings between names and auxid_t.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Handle class for recording to StoreGate.
size_t auxid_t
Identifier for a particular aux data item.
The Athena Transient Store API.
Property holding a SG store/key/clid from which a WriteHandle is made.
virtual StatusCode setProxyDict(IProxyDict *store)
Explicitly set the event store.
SG::View * makeView(const std::string &common_name, int const unique_index=-1, bool const allowFallThrough=true)
::StatusCode StatusCode
StatusCode definition for legacy code.
StatusCode scheduleViews(ViewContainer *viewVector, std::string const &nodeName, EventContext const &sourceContext, SmartIF< IScheduler > scheduler, bool reverseOrder=false)
Handle class for adding a decoration to an object.
Default, invalid implementation of ClassID_traits.
Handle class for adding a decoration to an object.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
void clear()
Erase all the elements in the collection.
StatusCode makeAndPopulate(std::string const &viewNameRoot, ViewContainer *viewVector, SG::WriteHandleKey< T > const &populateKey, EventContext const &sourceContext, std::vector< T > const &inputData, bool const allowFallThrough=true)
StatusCode mergeViewCollection(ViewContainer const &viewVector, SG::ReadHandleKey< DataVector< T > > const &queryKey, EventContext const &sourceContext, DataVector< T > &outputData)
ViewMerger(StoreGateSvc *sg, MsgStream &msg)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode mergeViewCollection(ViewContainer const &viewVector, SG::ReadHandleKey< T > const &queryKey, EventContext const &sourceContext, T &outputData)
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
An STL vector of pointers that by default owns its pointed-to elements.
void remap(CLID clid, const TKEY &source, const TKEY &target, off_t index_offset)
Declare a remapping.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
#define ATLAS_THREAD_SAFE
Handle class for reading from StoreGate.
A "view" of the event store (IProxyDict).
size_type size() const noexcept
Returns the number of elements in the collection.
void setExtendedEventContext(EventContext &ctx, ExtendedEventContext &&ectx)
Move an extended context into a context object.
bool empty() const noexcept
Returns true if the collection is empty.
Base class for elements of a container that can have aux data.