8#ifndef SYSTEMATICS_HANDLES__COPY_HELPERS_H
9#define SYSTEMATICS_HANDLES__COPY_HELPERS_H
47 static const int value = ( std::is_same< std::true_type, decltype( test_iparticle< T >(
nullptr ) ) >
::value ?
59 template<typename T, int type = ContainerType<T>::value>
63 "Type can not be shallow copied");
71 typedef std::decay<
decltype(
76 T*&
object,
const T *inputObject,
77 const std::string& outputName,
const std::string& auxName)
87 assert (inputObject !=
nullptr);
90 if( ! inputObject->getConstStore() ) {
93 if( inputObject->size() ) {
96 const T* originContainer =
97 dynamic_cast< const T*
>( ( *inputObject )[ 0 ]->container() );
100 for(
size_t i = 1; i < inputObject->size(); ++i ) {
101 if( ( *inputObject )[ i ]->
container() != originContainer ) {
103 "container come from the same container!" );
104 return StatusCode::FAILURE;
108 static const char*
const ORIGIN_POSTFIX =
"_ShallowCopyOrigin";
111 if( ( ! originCopy.first ) || ( ! originCopy.second ) ) {
112 ANA_MSG_ERROR(
"Failed to shallow copy the origin of a view "
113 <<
"container, meant for: " << outputName );
114 return StatusCode::FAILURE;
118 outputName + ORIGIN_POSTFIX ) );
120 outputName + ORIGIN_POSTFIX +
"Aux." ) );
123 auto viewCopyPtr = viewCopy.get();
124 for(
const auto* element : *inputObject ) {
125 viewCopy->push_back( originCopy.first->at( element->index() ) );
131 for(
size_t i = 0; i < inputObject->size(); ++i ) {
133 *( ( *viewCopy )[ i ] ) ) ) {
134 return StatusCode::FAILURE;
140 object = viewCopyPtr;
141 return StatusCode::SUCCESS;
146 auto viewCopyPtr = viewCopy.get();
149 object = viewCopyPtr;
150 return StatusCode::SUCCESS;
157 if (!copy.first || !copy.second)
159 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
161 return StatusCode::FAILURE;
165 return StatusCode::FAILURE;
171 return StatusCode::SUCCESS;
181 typedef std::decay<
decltype(
186 T*&
object,
const T *inputObject,
187 const std::string& outputName,
const std::string& auxName)
197 assert (inputObject !=
nullptr);
200 if( ! inputObject->getConstStore() ) {
203 if( inputObject->size() ) {
206 const T* originContainer =
207 dynamic_cast< const T*
>( ( *inputObject )[ 0 ]->container() );
210 for(
size_t i = 1; i < inputObject->size(); ++i ) {
211 if( ( *inputObject )[ i ]->
container() != originContainer ) {
213 "container come from the same container!" );
214 return StatusCode::FAILURE;
218 static const char*
const ORIGIN_POSTFIX =
"_ShallowCopyOrigin";
221 if( ( ! originCopy.first ) || ( ! originCopy.second ) ) {
222 ANA_MSG_ERROR(
"Failed to shallow copy the origin of a view "
223 <<
"container, meant for: " << outputName );
224 return StatusCode::FAILURE;
228 outputName + ORIGIN_POSTFIX ) );
230 outputName + ORIGIN_POSTFIX +
234 auto viewCopyPtr = viewCopy.get();
235 for(
const auto* element : *inputObject ) {
236 viewCopy->push_back( originCopy.first->at( element->index() ) );
241 object = viewCopyPtr;
242 return StatusCode::SUCCESS;
247 auto viewCopyPtr = viewCopy.get();
250 object = viewCopyPtr;
251 return StatusCode::SUCCESS;
258 if (!copy.first || !copy.second)
260 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
262 return StatusCode::FAILURE;
268 return StatusCode::SUCCESS;
278 typedef std::decay<
decltype(
283 T*&
object,
const T *inputObject,
284 const std::string& outputName,
const std::string& auxName)
295 if (!copy.first || !copy.second)
297 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
299 return StatusCode::FAILURE;
305 return StatusCode::SUCCESS;
314 typedef std::decay<
decltype(
320 const std::string& outputName,
const std::string& auxName);
Define macros for attributes used to control the static checker.
void record(const T *p, const std::string &key)
Manage index tracking and synchronization of auxiliary data.
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
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.
bool setOriginalObjectLink(const IParticle &original, IParticle ©)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...
std::pair< T *, ShallowAuxInfo * > shallowCopyObject(const T &obj)
Function making a shallow copy of a constant standalone object.
void ClearTransientTrees ATLAS_NOT_THREAD_SAFE()
Function cleaning up the managed memory.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
check what kind of object/container the argument is
static std::true_type test_container(checker< C, decltype((*(const SG::AuxVectorBase **) nullptr)=((C *) nullptr))> *)
static const int value
Value evaluating to:
static std::false_type test_iparticle(...)
static std::false_type test_container(...)
static std::true_type test_iparticle(checker< C, decltype((*(const xAOD::IParticle **) nullptr)=((C *) nullptr) ->at(0))> *)
std::decay< decltype(*(std::declval< EL::AnaAlgorithm >().evtStore()))>::type StoreType
the type of the event store we use
static StatusCode getCopy(MsgStream &msgStream, StoreType &store, T *&object, const T *inputObject, const std::string &outputName, const std::string &auxName)
static StatusCode getCopy(MsgStream &msgStream, StoreType &store, T *&object, const T *inputObject, const std::string &outputName, const std::string &auxName)
std::decay< decltype(*(std::declval< EL::AnaAlgorithm >().evtStore()))>::type StoreType
the type of the event store we use
std::decay< decltype(*(std::declval< EL::AnaAlgorithm >().evtStore()))>::type StoreType
the type of the event store we use
static StatusCode getCopy(MsgStream &msgStream, StoreType &store, T *&object, const T *inputObject, const std::string &outputName, const std::string &auxName)
std::decay< decltype(*(std::declval< EL::AnaAlgorithm >().evtStore()))>::type StoreType
the type of the event store we use
static StatusCode getCopy(MsgStream &msgStream, StoreType &store, xAOD::IParticleContainer *&object, const xAOD::IParticleContainer *inputObject, const std::string &outputName, const std::string &auxName)
a helper class to create shallow copies and register them in the event store