8#ifndef SYSTEMATICS_HANDLES__COPY_HELPERS_H
9#define SYSTEMATICS_HANDLES__COPY_HELPERS_H
51 static const int value = ( std::is_same< std::true_type, decltype( test_iparticle< T >(
nullptr ) ) >
::value ?
63 template<typename T, int type = ContainerType<T>::value>
67 "Type can not be shallow copied");
75 typedef std::decay<
decltype(
80 T*&
object,
const T *inputObject,
81 const std::string& outputName,
const std::string& auxName)
91 assert (inputObject !=
nullptr);
94 if( ! inputObject->getConstStore() ) {
97 if( inputObject->size() ) {
100 const T* originContainer =
101 dynamic_cast< const T*
>( ( *inputObject )[ 0 ]->container() );
102 if (!originContainer){
104 return StatusCode::FAILURE;
108 for(
size_t i = 1; i < inputObject->size(); ++i ) {
109 if( ( *inputObject )[ i ]->container() != originContainer ) {
111 "container come from the same container!" );
112 return StatusCode::FAILURE;
116 static const char*
const ORIGIN_POSTFIX =
"_ShallowCopyOrigin";
119 if( ( ! originCopy.first ) || ( ! originCopy.second ) ) {
120 ANA_MSG_ERROR(
"Failed to shallow copy the origin of a view "
121 <<
"container, meant for: " << outputName );
122 return StatusCode::FAILURE;
126 auto viewCopyPtr = viewCopy.get();
127 for(
const auto* element : *inputObject ) {
128 viewCopy->push_back( originCopy.first->at( element->index() ) );
133 outputName + ORIGIN_POSTFIX ) );
135 outputName + ORIGIN_POSTFIX +
"Aux." ) );
141 for(
size_t i = 0; i < inputObject->size(); ++i ) {
143 *( ( *viewCopy )[ i ] ) ) ) {
144 return StatusCode::FAILURE;
150 object = viewCopyPtr;
151 return StatusCode::SUCCESS;
156 auto viewCopyPtr = viewCopy.get();
159 object = viewCopyPtr;
160 return StatusCode::SUCCESS;
167 if (!copy.first || !copy.second)
169 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
171 return StatusCode::FAILURE;
175 return StatusCode::FAILURE;
178 object = copy.first.get();
181 return StatusCode::SUCCESS;
191 typedef std::decay<
decltype(
196 T*&
object,
const T *inputObject,
197 const std::string& outputName,
const std::string& auxName)
207 assert (inputObject !=
nullptr);
210 if( ! inputObject->getConstStore() ) {
213 if( inputObject->size() ) {
216 const T* originContainer =
dynamic_cast< const T*
>( ( *inputObject )[ 0 ]->container() );
217 if (!originContainer){
219 return StatusCode::FAILURE;
223 for(
size_t i = 1; i < inputObject->size(); ++i ) {
224 if( ( *inputObject )[ i ]->container() != originContainer ) {
226 "container come from the same container!" );
227 return StatusCode::FAILURE;
231 static const char*
const ORIGIN_POSTFIX =
"_ShallowCopyOrigin";
234 if( ( ! originCopy.first ) || ( ! originCopy.second ) ) {
235 ANA_MSG_ERROR(
"Failed to shallow copy the origin of a view "
236 <<
"container, meant for: " << outputName );
237 return StatusCode::FAILURE;
242 auto viewCopyPtr = viewCopy.get();
243 for(
const auto* element : *inputObject ) {
244 viewCopy->push_back( originCopy.first->at( element->index() ) );
249 outputName + ORIGIN_POSTFIX ) );
251 outputName + ORIGIN_POSTFIX +
257 object = viewCopyPtr;
258 return StatusCode::SUCCESS;
263 auto viewCopyPtr = viewCopy.get();
266 object = viewCopyPtr;
267 return StatusCode::SUCCESS;
274 if (!copy.first || !copy.second)
276 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
278 return StatusCode::FAILURE;
282 object = copy.first.get();
285 return StatusCode::SUCCESS;
295 typedef std::decay<
decltype(
300 T*&
object,
const T *inputObject,
301 const std::string& outputName,
const std::string& auxName)
312 if (!copy.first || !copy.second)
314 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
316 return StatusCode::FAILURE;
319 object = copy.first.get();
322 return StatusCode::SUCCESS;
331 typedef std::decay<
decltype(
337 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< 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.
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