|
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 ) {
111 for (
auto iter = viewVector->
rbegin(); iter != viewVector->
rend(); ++iter ) {
116 return StatusCode::FAILURE;
126 return StatusCode::FAILURE;
132 return StatusCode::SUCCESS;
143 template<
typename T >
150 for (
SG::View* inputView : viewVector )
154 if ( !
sc.isSuccess() )
156 m_msg << MSG::ERROR <<
"Failed to use view " << inputView->name() <<
" to read " << queryHandle.
key() <<
" resetting output" <<
endmsg;
162 T inputData = *queryHandle;
163 outputData.insert( outputData.end(), inputData.begin(), inputData.end() );
166 return StatusCode::SUCCESS;
172 template<
typename T >
176 if ( !outputData.getStore() )
178 m_msg << MSG::ERROR <<
"output data does not have the store" <<
endmsg;
179 return StatusCode::FAILURE;
190 for (
auto inputView : viewVector )
194 if ( !
sc.isSuccess() )
196 m_msg << MSG::ERROR <<
"Failed to use view " << inputView->name() <<
" to read " << queryHandle.
key() <<
endmsg;
201 if ( queryHandle->size() == 0 )
210 for (
const auto inputObject : *queryHandle.
cptr() )
213 T * outputObject =
new T();
215 *outputObject = *inputObject;
218 viewBookkeeper( *outputObject ) = inputView->getROI();
222 m_msg <<
MSG::DEBUG <<
"Copied " << queryHandle->size() <<
" objects from collection in view " << inputView->
name() <<
endmsg;
226 auto proxy = inputView->proxy( queryHandle.
clid(), queryHandle.
key() );
231 offset += queryHandle->size();
234 return StatusCode::SUCCESS;
242 inline SG::View*
makeView(
const std::string& common_name,
int const unique_index = -1,
bool const allowFallThrough =
true )
245 if ( common_name.find(
' ' ) != std::string::npos )
250 return new SG::View( common_name, unique_index, allowFallThrough );
264 if ( handle.setProxyDict( nview ).isFailure() ) {
272 template<
typename T,
typename CONT>
277 auto handle = SG::makeHandle<T>(dKey, context );
278 if ( handle.setProxyDict( nview ).isFailure() ) {
294 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.
reverse_iterator rbegin()
std::vector< Identifier > ID
const_pointer_type cptr()
Dereference the pointer.
Helper class to provide type-safe access to aux data.
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.
SG::ReadHandle< T > makeHandle(const SG::View *view, const SG::ReadHandleKey< T > &rhKey, const EventContext &context)
navigate from the TrigComposite to nearest view and fetch object from it
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)
const std::string & key() const
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid from which a ReadHandle is made.
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.
The Athena Transient Store API.
void push_back(SG::View *ptr)
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.
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.
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.
Base class for elements of a container that can have aux data.