ATLAS Offline Software
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
10 //#undef protected
13 
14 // Local include(s):
16 
17 namespace xAOD {
18 
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();
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
beamspotman.r
def r
Definition: beamspotman.py:676
SafeDeepCopy.h
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:446
exceptions.h
Exceptions that can be thrown from AthContainers.
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
SG::ExcConstAuxData
Exception — Non-const operation performed on const aux data.
Definition: Control/AthContainers/AthContainers/exceptions.h:77
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:201
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
SG::AuxVectorData::hasStore
bool hasStore() const
Return true if this object has an associated store.
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
xAOD::safeDeepCopy
void safeDeepCopy(const SG::AuxElement &orig, SG::AuxElement &copy)
Function that can deep-copy "problematic" objects.
Definition: SafeDeepCopy.cxx:19
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:167
calibdata.copy
bool copy
Definition: calibdata.py:27
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
AuxElement.h
Base class for elements of a container that can have aux data.