ATLAS Offline Software
Loading...
Searching...
No Matches
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
19
21{
22 ATH_MSG_DEBUG("Initializing xAODTrackStateAuxContainerCnv ...");
24}
25
26namespace {
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}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t sz
bool test(bit_t bit) const
Test to see if a bit is set.
const SG::AuxVectorData * container() const
Return the container holding this element.
size_t index() const
Return the index of this element within its container.
Helper class to provide constant type-safe access to aux data.
SG::auxid_t auxid() const
Return the aux id for this variable.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
SG::auxid_t auxid() const
Return the aux id for this variable.
virtual xAOD::TrackStateAuxContainer * createPersistentWithKey(xAOD::TrackStateAuxContainer *trans, const std::string &key) override
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
virtual xAOD::TrackStateAuxContainer * createPersistentWithKey(xAOD::TrackStateAuxContainer *trans, const std::string &key) override
Convert a transient object to persistent form.
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition index.py:1
TrackStateAuxContainer_v1 TrackStateAuxContainer
UncalibratedMeasurementContainer_v1 UncalibratedMeasurementContainer
Define the version of the uncalibrated measurement container.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
T_AthenaPoolAuxContainerCnv< xAOD::TrackStateAuxContainer > xAODTrackStateAuxContainerCnvBase