ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODCore
Root
SafeDeepCopy.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id: SafeDeepCopy.cxx 676241 2015-06-18 06:15:44Z krasznaa $
6
7
// EDM include(s):
8
//#define protected public
9
# include "
AthContainers/AuxElement.h
"
10
//#undef protected
11
#include "
AthContainers/exceptions.h
"
12
#include "
AthContainers/AuxTypeRegistry.h
"
13
14
// Local include(s):
15
#include "
xAODCore/tools/SafeDeepCopy.h
"
16
17
namespace
xAOD
{
18
19
void
safeDeepCopy
(
const
SG::AuxElement
& orig,
SG::AuxElement
& copy ) {
20
21
//
22
// Check that the target object is healthy:
23
//
24
if
( ! copy.container() ) {
25
return
;
26
}
27
if
( ! copy.container()->hasStore() ) {
28
return
;
29
}
30
if
( ! copy.container()->hasNonConstStore() ) {
31
throw
SG::ExcConstAuxData
(
"safeDeepCopy"
);
32
}
33
34
//
35
// Access the original's data:
36
//
37
const
SG::AuxVectorData
* ocont = orig.container();
38
if
( ( ! ocont ) || ( ! ocont->
hasStore
() ) ) {
39
// In this case let the assignment operator of SG::AuxElement take
40
// care of clearing out the target object.
41
copy = orig;
42
return
;
43
}
44
45
//
46
// Do the copy:
47
//
48
const
size_t
iindex = orig.index();
49
const
size_t
oindex = copy.index();
50
SG::auxid_set_t
other_ids = ocont->
getAuxIDs
();
51
SG::AuxTypeRegistry
&
r
=
SG::AuxTypeRegistry::instance
();
52
SG::AuxVectorData
& copy_container = *copy.container();
53
54
// Copy the variables that exist on the input object:
55
for
(
SG::auxid_t
auxid : other_ids ) {
56
r
.copy( auxid, copy_container, oindex, *ocont, iindex, 1 );
57
}
58
// Clear out the variables that only exist on the output object:
59
for
(
SG::auxid_t
auxid : copy.container()->getWritableAuxIDs() ) {
60
if
( !other_ids.test( auxid ) ) {
61
r
.clear( auxid, copy_container, oindex, 1 );
62
}
63
}
64
}
65
66
}
// namespace xAOD
AuxElement.h
Base class for elements of a container that can have aux data.
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
exceptions.h
Exceptions that can be thrown from AthContainers.
SafeDeepCopy.h
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition
AuxTypeRegistry.h:61
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition
AuxTypeRegistry.cxx:640
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition
AuxVectorData.h:164
SG::AuxVectorData::getAuxIDs
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items in store associated with this object.
Definition
AuxVectorData.cxx:203
SG::AuxVectorData::hasStore
bool hasStore() const
Return true if this object has an associated store.
SG::ExcConstAuxData
Exception — Non-const operation performed on const aux data.
Definition
Control/AthContainers/AthContainers/exceptions.h:77
SG::auxid_set_t
A set of aux data identifiers.
Definition
AuxTypes.h:47
r
int r
Definition
globals.cxx:22
SG::AuxElement
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition
AuxTypes.h:27
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition
ICaloAffectedTool.h:24
xAOD::safeDeepCopy
void safeDeepCopy(const SG::AuxElement &orig, SG::AuxElement ©)
Function that can deep-copy "problematic" objects.
Definition
SafeDeepCopy.cxx:19
Generated on
for ATLAS Offline Software by
1.17.0