7#ifndef XAODCORE_SHALLOWCOPY_H
8#define XAODCORE_SHALLOWCOPY_H
15#include "AthLinks/DataLink.h"
41 return std::make_unique<T>();
58 template <SG::IsAuxDataVector T>
59 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
73 template <SG::IsAuxDataVector T>
74 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
94 template <SG::IsConstAuxElement T>
95 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo>>
shallowCopy(
96 const T& obj,
const EventContext& ctx);
112 template <SG::IsConstAuxElement T>
113 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo>>
shallowCopy(
122 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
130 std::cout <<
"xAOD::shallowCopyContainer ERROR Couldn't set up "
131 <<
"DataLink to the original container's auxiliary store"
133 std::cout <<
"xAOD::shallowCopyContainer ERROR Are you using the "
134 <<
"xAOD::TEvent::kBranchAccess access mode?" << std::endl;
139 auto newCont = std::make_unique<T>();
142 newCont->reserve(cont.size());
143 for (
size_t i = 0; i < cont.size(); ++i) {
148 auto aux = std::make_unique<ShallowAuxContainer>(link);
151 newCont->setStore(aux.get());
154 return std::make_pair(std::move(newCont), std::move(aux));
178 std::pair<std::unique_ptr<T>, std::unique_ptr<ShallowAuxContainer>>
180 const EventContext& ctx )
205 return std::make_pair(tmp.first.release(), tmp.second.release());
229 std::pair< std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo> >
234 if( ! link.
cptr() ) {
238 std::cout <<
"xAOD::shallowCopyObject ERROR Couldn't set up "
239 <<
"DataLink to the original object's auxiliary store"
241 std::cout <<
"xAOD::shallowCopyObject ERROR Are you using the "
242 <<
"xAOD::TEvent::kBranchAccess access mode?"
244 std::pair< std::unique_ptr<T>, std::unique_ptr<ShallowAuxInfo> > dummy;
249 auto newObj = std::make_unique<T>();
252 auto aux = std::make_unique<ShallowAuxInfo>( link );
255 newObj->setStore( aux.get() );
258 return std::make_pair( std::move(newObj), std::move(aux) );
263 std::pair< T*, ShallowAuxInfo* >
266 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.
const_pointer cptr() const
Dereference the link.
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.
std::unique_ptr< CaloCluster > prepareElementForShallowCopy(const CaloCluster *orgCluster)
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
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.
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.