ATLAS Offline Software
Loading...
Searching...
No Matches
xAODSpacePointAuxContainerCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local include(s):
7
8// EDM include(s):
11
12// Other includes
13#include "AthLinks/ElementLink.h"
14
18
20{
21 ATH_MSG_DEBUG("Initializing xAODSpacePointAuxContainerCnv ...");
23}
24
26 const std::string& key )
27{
28 ATH_MSG_DEBUG("Calling xAODSpacePointAuxContainerCnv::createPersistentWithKey for our xAOD space points");
29
30 // Load the necessary ROOT class(es):
31 static char const* const NAME =
32 "std::vector<std::vector<ElementLink<xAOD::UncalibratedMeasurementContainer> > >";
33 static TClass const* const cls = TClass::GetClass( NAME );
34 if( ! cls ) {
35 ATH_MSG_ERROR( "Couldn't load dictionary for type: " << NAME );
36 }
37
38 // This makes a copy of the container, with any thinning applied.
39 std::unique_ptr< xAOD::SpacePointAuxContainer > result
41
42 // see if we can get the variable from trans
43 using measurement_collection_t = std::vector< const xAOD::UncalibratedMeasurement* >;
44 static const SG::ConstAccessor< measurement_collection_t > uncalibMeasurementAcc("measurements");
45 static const SG::auxid_t measurementAuxId = uncalibMeasurementAcc.auxid();
46
47 // Create a helper object for the Element Links
49 for (std::size_t i(0); i<result->size(); ++i) {
50 helper.push_back( std::make_unique< xAOD::SpacePoint >() );
51 }
52 helper.setStore( result.get() );
53
54 // Convert the bare pointer(s) to Element Link(s)
56
57 for (xAOD::SpacePoint *sp : helper) {
58 accesor(*sp).clear();
59
60 // get values from the trans aux container directly
61 const void* ptrToSomething = trans->getData (measurementAuxId);
62 const measurement_collection_t& measurements = static_cast<const measurement_collection_t*>(ptrToSomething)[sp->index()];
63 accesor(*sp).reserve( measurements.size() );
64 for (std::size_t idx(0); idx<measurements.size(); ++idx) {
65 accesor(*sp).push_back( ElementLink< xAOD::UncalibratedMeasurementContainer >(*dynamic_cast<const xAOD::UncalibratedMeasurementContainer*>(measurements[idx]->container()), measurements[idx]->index()) );
66 }
67 }
68
69 return result.release();
70}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sp
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Helper class to provide constant type-safe access to aux data.
SG::auxid_t auxid() const
Return the aux id for this variable.
virtual xAOD::SpacePointAuxContainer * createPersistentWithKey(xAOD::SpacePointAuxContainer *trans, const std::string &key) override
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
virtual xAOD::SpacePointAuxContainer * createPersistentWithKey(xAOD::SpacePointAuxContainer *trans, const std::string &key) override
Convert a transient object to persistent form.
virtual const void * getData(auxid_t auxid) const override
Get a pointer to a given array.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
SpacePointAuxContainer_v1 SpacePointAuxContainer
Definition of the current space point auxiliary container.
UncalibratedMeasurementContainer_v1 UncalibratedMeasurementContainer
Define the version of the uncalibrated measurement container.
T_AthenaPoolAuxContainerCnv< xAOD::SpacePointAuxContainer > xAODSpacePointAuxContainerCnvBase