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::println(
"xAOD::shallowCopyContainer ERROR Couldn't set up "
153 "DataLink to the original container's auxiliary store" );
154 std::println(
"xAOD::shallowCopyContainer ERROR Are you using the "
155 "xAOD::TEvent::kBranchAccess access mode?" );
160 auto newCont = std::make_unique<T>();
163 newCont->reserve(cont.size());
164 for (
size_t i = 0; i < cont.size(); ++i) {
169 auto aux = std::make_unique<ShallowAuxContainer>(link);
172 newCont->setStore(aux.get());
175 return std::make_pair(std::move(newCont), std::move(aux));
199 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
201 const EventContext& ctx )
223 [[deprecated(
"Please switch to xAOD::shallowCopy(...), which returns unique_ptr")]]
227 return std::make_pair(tmp.first.release(), tmp.second.release());
251 std::pair< std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo> >
256 if( ! link.cptr() ) {
260 std::println(
"xAOD::shallowCopyObject ERROR Couldn't set up "
261 "DataLink to the original object's auxiliary store" );
262 std::println (
"xAOD::shallowCopyObject ERROR Are you using the "
263 "xAOD::TEvent::kBranchAccess access mode?" );
264 std::pair< std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo> > dummy;
269 auto newObj = std::make_unique<T>();
272 auto aux = std::make_unique<ShallowAuxInfo>( link );
275 newObj->setStore( aux.get() );
278 return std::make_pair( std::move(newObj), std::move(aux) );
283 [[deprecated(
"Please switch to xAOD::shallowCopy(...), which returns unique_ptr")]]
284 std::pair< T*, ShallowAuxInfo* >
287 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.