ATLAS Offline Software
xAODTrackStateAuxContainerCnv.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 // Local include(s):
7 
8 // EDM include(s):
12 
13 // Other includes
14 #include "AthLinks/ElementLink.h"
15 
18 {}
19 
21 {
22  ATH_MSG_DEBUG("Initializing xAODTrackStateAuxContainerCnv ...");
24 }
25 
26 namespace {
27 
28  template <typename T>
29  using const_span = std::span<T const>;
30 
31  template <typename T, typename T_AuxContainer>
32  const_span<T> getElementVector(const T_AuxContainer &aux_container, const SG::ConstAccessor<T> &accessor) {
33  const T *data = static_cast<const T *>(aux_container.getData (accessor.auxid()));
34  const_span<T> ret( data, aux_container.size() );
35  return ret;
36  }
37  template <typename T, typename T_AuxContainer>
38  std::span<T> createDecoration(T_AuxContainer &aux_container, const SG::Decorator<T> &decor) {
39  std::size_t sz=aux_container.size();
40  T *data = static_cast<T *>(aux_container.getDecoration(decor.auxid(), sz, sz));
41  return std::span<T>( data, sz );
42  }
43 }
44 
46  const std::string& key )
47 {
48  // Load the necessary ROOT class(es):
49  static char const* const NAME =
50  "std::vector<ElementLink<xAOD::UncalibratedMeasurementContainer> >";
51  static TClass const* const cls = TClass::GetClass( NAME );
52  if( ! cls ) {
53  ATH_MSG_ERROR( "Couldn't load dictionary for type: " << NAME );
54  }
55 
56  // This makes a copy of the container, with any thinning applied.
57  std::unique_ptr< xAOD::TrackStateAuxContainer > result
59 
60  // see if we can get the variable from trans
61  static const SG::ConstAccessor<const xAOD::UncalibratedMeasurement*> uncalibMeasurement_acc("uncalibratedMeasurement");
62  if (trans->getAuxIDs().test(uncalibMeasurement_acc.auxid())){
63 
64  const_span<const xAOD::UncalibratedMeasurement*>
65  uncalibratedMeasurements = getElementVector(*trans, uncalibMeasurement_acc);
66 
67  static const SG::Decorator< ElementLink<xAOD::UncalibratedMeasurementContainer> > link_decor("uncalibratedMeasurementLink");
68  std::span<decltype(link_decor)::element_type> links = createDecoration(*result, link_decor);
69  // @TODD thinning is not supported for Acts tracks but this would break if thinning was somehow implemented
70  assert( links.size() == uncalibratedMeasurements.size() );
71  // Convert the bare pointer(s) to Element Link(s)
72  for (unsigned int index =0; index < uncalibratedMeasurements.size(); ++index) {
73  const xAOD::UncalibratedMeasurement *measurement = uncalibratedMeasurements[index];
74  if (measurement) {
75  links[index]
77  measurement->index());
78  }
79  }
80  }
81  else {
82  ATH_MSG_WARNING("No uncalibratedMeasurement aux data.");
83  }
84 
85  return result.release();
86 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
fitman.sz
sz
Definition: fitman.py:527
get_generator_info.result
result
Definition: get_generator_info.py:21
xAODTrackStateAuxContainerCnv.h
index
Definition: index.py:1
SG::ConstAccessor::auxid
SG::auxid_t auxid() const
Return the aux id for this variable.
xAOD::AuxContainerBase::getAuxIDs
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition: AuxContainerBase.cxx:265
TrackState.h
xAODTrackStateAuxContainerCnv::xAODTrackStateAuxContainerCnv
xAODTrackStateAuxContainerCnv(ISvcLocator *svcLoc)
Definition: xAODTrackStateAuxContainerCnv.cxx:16
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
T_AthenaPoolAuxContainerCnv
Athena pool converter for aux store classes.
Definition: T_AthenaPoolAuxContainerCnv.h:39
SG::ConstAccessor< T >
SG::Decorator::auxid
SG::auxid_t auxid() const
Return the aux id for this variable.
TrackStateContainer.h
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator< T >
ret
T ret(T t)
Definition: rootspy.cxx:260
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::links
links
Definition: CLinks_v1.cxx:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
UncalibratedMeasurementContainer.h
xAODTrackStateAuxContainerCnv::createPersistentWithKey
virtual xAOD::TrackStateAuxContainer * createPersistentWithKey(xAOD::TrackStateAuxContainer *trans, const std::string &key) override
Definition: xAODTrackStateAuxContainerCnv.cxx:45
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
T_AthenaPoolAuxContainerCnv::createPersistentWithKey
virtual AUXSTORE * createPersistentWithKey(AUXSTORE *trans, const std::string &key) override
Convert a transient object to persistent form.
xAOD::JetAttributeAccessor::accessor
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
Definition: JetAccessorMap.h:26
DeMoScan.index
string index
Definition: DeMoScan.py:362
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::TrackStateAuxContainer_v1
Definition: TrackStateAuxContainer_v1.h:18
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
T_AthenaPoolCustCnv< AUXSTORE, AUXSTORE >::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
xAODTrackStateAuxContainerCnv::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: xAODTrackStateAuxContainerCnv.cxx:20
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
CxxUtils::ConcurrentBitset::test
bool test(bit_t bit) const
Test to see if a bit is set.