ATLAS Offline Software
Decoration.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "Acts/Utilities/HashedString.hpp"
5 #include "ActsEvent/Decoration.h"
6 
7 
8 namespace ActsTrk::detail {
9 std::vector<Decoration> restoreDecorations(
10  const SG::IConstAuxStore* container,
11  const std::set<std::string>& staticVariables) {
12  std::vector<Decoration> decorations;
13  for (auto id : container->getAuxIDs()) {
14  const std::string name = SG::AuxTypeRegistry::instance().getName(id);
15  const std::type_info* typeInfo =
17  if (staticVariables.count(name) == 1) {
18  continue;
19  }
20 
21  // try making decoration accessor of matching type
22  // there is a fixed set of supported types (as there is a fixed set
23  // available in MutableMTJ) setters are not needed so replaced by a
24  // "nullptr"
25  if (*typeInfo == typeid(float)) {
26  decorations.emplace_back(
27  decoration<float>(name, ActsTrk::detail::constDecorationGetter<float>,
28  ActsTrk::detail::decorationCopier<float>));
29  } else if (*typeInfo == typeid(double)) {
30  decorations.emplace_back(decoration<double>(
31  name, ActsTrk::detail::constDecorationGetter<double>,
32  ActsTrk::detail::decorationCopier<double>));
33  } else if (*typeInfo == typeid(short)) {
34  decorations.emplace_back(
35  decoration<short>(name, ActsTrk::detail::constDecorationGetter<short>,
36  ActsTrk::detail::decorationCopier<short>));
37  } else if (*typeInfo == typeid(uint32_t)) {
38  decorations.emplace_back(decoration<uint32_t>(
39  name, ActsTrk::detail::constDecorationGetter<uint32_t>,
40  ActsTrk::detail::decorationCopier<uint32_t>));
41  } else {
42  throw std::runtime_error("Can't restore decoration of " + name +
43  " because it is of an unsupported type");
44  }
45  }
46  return decorations;
47 }
48 } // namespace ActsTrk::detail
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:277
SG::AuxTypeRegistry::getType
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
Definition: AuxTypeRegistry.cxx:302
ActsTrk::detail::restoreDecorations
std::vector< Decoration > restoreDecorations(const SG::IConstAuxStore *container, const std::set< std::string > &staticVariables)
Definition: Decoration.cxx:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Decoration.h
ActsTrk::detail
Definition: Decoration.h:14
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
SG::IConstAuxStore::getAuxIDs
virtual const SG::auxid_set_t & getAuxIDs() const =0
Return a set of identifiers for existing data items in this store.