7#ifndef XAODCORE_SHALLOWCOPY_H
8#define XAODCORE_SHALLOWCOPY_H
15#include "AthLinks/DataLink.h"
41 return std::make_unique<T>();
50 template <SG::IsAuxDataVector T>
55 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>;
59 template <SG::IsConstAuxElement T>
63 using type = std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo>>;
84 template <SG::IsAuxDataVector T>
98 template <SG::IsAuxDataVector T>
118 template <SG::IsConstAuxElement T>
135 template <SG::IsConstAuxElement T>
144 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
152 std::cout <<
"xAOD::shallowCopyContainer ERROR Couldn't set up "
153 <<
"DataLink to the original container's auxiliary store"
155 std::cout <<
"xAOD::shallowCopyContainer ERROR Are you using the "
156 <<
"xAOD::TEvent::kBranchAccess access mode?" << std::endl;
161 auto newCont = std::make_unique<T>();
164 newCont->reserve(cont.size());
165 for (
size_t i = 0; i < cont.size(); ++i) {
170 auto aux = std::make_unique<ShallowAuxContainer>(link);
173 newCont->setStore(aux.get());
176 return std::make_pair(std::move(newCont), std::move(aux));
200 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
202 const EventContext& ctx )
224 [[deprecated(
"Please switch to xAOD::shallowCopy(...), which returns unique_ptr")]]
228 return std::make_pair(tmp.first.release(), tmp.second.release());
252 std::pair< std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo> >
257 if( ! link.cptr() ) {
261 std::cout <<
"xAOD::shallowCopyObject ERROR Couldn't set up "
262 <<
"DataLink to the original object's auxiliary store"
264 std::cout <<
"xAOD::shallowCopyObject ERROR Are you using the "
265 <<
"xAOD::TEvent::kBranchAccess access mode?"
267 std::pair< std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo> > dummy;
272 auto newObj = std::make_unique<T>();
275 auto aux = std::make_unique<ShallowAuxInfo>( link );
278 newObj->setStore( aux.get() );
281 return std::make_pair( std::move(newObj), std::move(aux) );
286 [[deprecated(
"Please switch to xAOD::shallowCopy(...), which returns unique_ptr")]]
287 std::pair< T*, ShallowAuxInfo* >
290 return std::make_pair (ptrs.first.release(), ptrs.second.release());
Interface for const operations on an auxiliary store.
Object reference supporting deferred reading from StoreGate.
Concept for "xAOD style" DataVector interface containers.
Test if T is compatible with ConstAuxElement.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainerImpl(const T &cont, DataLink< SG::IConstAuxStore > &link)
Impl function for shallow copy container.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
std::unique_ptr< CaloCluster > prepareElementForShallowCopy(const CaloCluster *orgCluster)
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxInfo > > shallowCopyObject(const T &obj, const EventContext &ctx)
Function making a shallow copy of a constant standalone object.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > type
The type returned by xAOD::shallowCopy when called with a container of type T.
Base trait for the return type of xAOD::shallowCopy.