8#ifndef SYSTEMATICS_HANDLES__COPY_HELPERS_H
9#define SYSTEMATICS_HANDLES__COPY_HELPERS_H
50 static const int value = ( std::is_same< std::true_type, decltype( test_iparticle< T >(
nullptr ) ) >
::value ?
62 template<typename T, int type = ContainerType<T>::value>
66 "Type can not be shallow copied");
74 typedef std::decay<
decltype(
79 T*&
object,
const T *inputObject,
80 const std::string& outputName,
const std::string& auxName)
90 assert (inputObject !=
nullptr);
93 if( ! inputObject->getConstStore() ) {
96 if( inputObject->size() ) {
99 const T* originContainer =
100 dynamic_cast< const T*
>( ( *inputObject )[ 0 ]->container() );
101 if (!originContainer){
103 return StatusCode::FAILURE;
107 for(
size_t i = 1; i < inputObject->size(); ++i ) {
108 if( ( *inputObject )[ i ]->
container() != originContainer ) {
110 "container come from the same container!" );
111 return StatusCode::FAILURE;
115 static const char*
const ORIGIN_POSTFIX =
"_ShallowCopyOrigin";
118 if( ( ! originCopy.first ) || ( ! originCopy.second ) ) {
119 ANA_MSG_ERROR(
"Failed to shallow copy the origin of a view "
120 <<
"container, meant for: " << outputName );
121 return StatusCode::FAILURE;
125 outputName + ORIGIN_POSTFIX ) );
127 outputName + ORIGIN_POSTFIX +
"Aux." ) );
130 auto viewCopyPtr = viewCopy.get();
131 for(
const auto* element : *inputObject ) {
132 viewCopy->push_back( originCopy.first->at( element->index() ) );
138 for(
size_t i = 0; i < inputObject->size(); ++i ) {
140 *( ( *viewCopy )[ i ] ) ) ) {
141 return StatusCode::FAILURE;
147 object = viewCopyPtr;
148 return StatusCode::SUCCESS;
153 auto viewCopyPtr = viewCopy.get();
156 object = viewCopyPtr;
157 return StatusCode::SUCCESS;
164 if (!copy.first || !copy.second)
166 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
168 return StatusCode::FAILURE;
172 return StatusCode::FAILURE;
178 return StatusCode::SUCCESS;
188 typedef std::decay<
decltype(
193 T*&
object,
const T *inputObject,
194 const std::string& outputName,
const std::string& auxName)
204 assert (inputObject !=
nullptr);
207 if( ! inputObject->getConstStore() ) {
210 if( inputObject->size() ) {
213 const T* originContainer =
dynamic_cast< const T*
>( ( *inputObject )[ 0 ]->container() );
214 if (!originContainer){
216 return StatusCode::FAILURE;
220 for(
size_t i = 1; i < inputObject->size(); ++i ) {
221 if( ( *inputObject )[ i ]->
container() != originContainer ) {
223 "container come from the same container!" );
224 return StatusCode::FAILURE;
228 static const char*
const ORIGIN_POSTFIX =
"_ShallowCopyOrigin";
231 if( ( ! originCopy.first ) || ( ! originCopy.second ) ) {
232 ANA_MSG_ERROR(
"Failed to shallow copy the origin of a view "
233 <<
"container, meant for: " << outputName );
234 return StatusCode::FAILURE;
238 outputName + ORIGIN_POSTFIX ) );
240 outputName + ORIGIN_POSTFIX +
244 auto viewCopyPtr = viewCopy.get();
245 for(
const auto* element : *inputObject ) {
246 viewCopy->push_back( originCopy.first->at( element->index() ) );
251 object = viewCopyPtr;
252 return StatusCode::SUCCESS;
257 auto viewCopyPtr = viewCopy.get();
260 object = viewCopyPtr;
261 return StatusCode::SUCCESS;
268 if (!copy.first || !copy.second)
270 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
272 return StatusCode::FAILURE;
278 return StatusCode::SUCCESS;
288 typedef std::decay<
decltype(
293 T*&
object,
const T *inputObject,
294 const std::string& outputName,
const std::string& auxName)
305 if (!copy.first || !copy.second)
307 ANA_MSG_ERROR (
"failed to shallow copy object: " << outputName);
309 return StatusCode::FAILURE;
315 return StatusCode::SUCCESS;
324 typedef std::decay<
decltype(
330 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