Skip to content
Snippets Groups Projects
Commit 61e47d16 authored by Carlo Varni's avatar Carlo Varni Committed by Tadej Novak
Browse files

Use ReadDecorHandle when reading ACTS SPs from file

Use ReadDecorHandle when reading ACTS SPs from file
parent 0a940a43
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@
#include "SpacePointReader.h"
#include "xAODMeasurementBase/UncalibratedMeasurementContainer.h"
#include "AthLinks/ElementLink.h"
#include "StoreGate/ReadDecorHandle.h"
#include "StoreGate/WriteDecorHandle.h"
namespace ActsTrk {
......@@ -18,13 +19,16 @@ namespace ActsTrk {
{
ATH_MSG_DEBUG("Initializing " << name() << " ... ");
m_linkDecoration = m_spacePointKey.key() + "." + m_linkDecoration.key();
m_clusterDecoration = m_spacePointKey.key() + "." + m_clusterDecoration.key();
ATH_MSG_DEBUG("Properties:");
ATH_MSG_DEBUG(m_spacePointKey);
ATH_MSG_DEBUG(m_linkDecoration);
ATH_MSG_DEBUG(m_clusterDecoration);
ATH_CHECK(m_spacePointKey.initialize());
ATH_CHECK(m_linkDecoration.initialize());
ATH_CHECK(m_clusterDecoration.initialize());
return StatusCode::SUCCESS;
......@@ -40,21 +44,23 @@ namespace ActsTrk {
const xAOD::SpacePointContainer* spacePoints = spHandle.cptr();
ATH_MSG_DEBUG("Retrieved " << spacePoints->size() << " elements from space point container");
ATH_MSG_DEBUG("Reading decoration to space point collection: element links to clusters");
ATH_MSG_DEBUG("Decoration name: " << m_linkDecoration.key());
using link_type = std::vector< ElementLink<xAOD::UncalibratedMeasurementContainer> >;
SG::ReadDecorHandle< xAOD::SpacePointContainer,
link_type > elementLinksToClusters( m_linkDecoration, ctx );
ATH_CHECK(elementLinksToClusters.isAvailable());
ATH_MSG_DEBUG("Adding decoration to space point collection: bare pointers to clusters");
ATH_MSG_DEBUG("Decoration name: " << m_clusterDecoration.key());
using decoration_type = std::vector<const xAOD::UncalibratedMeasurement*>;
SG::WriteDecorHandle< xAOD::SpacePointContainer,
decoration_type > barePointersToClusters( m_clusterDecoration, ctx );
ATH_MSG_DEBUG("Retrieving Element Links to Clusters from the Space Points and attaching the bare pointers to the object");
static const SG::AuxElement::Accessor< std::vector<ElementLink<xAOD::UncalibratedMeasurementContainer>> > accesor("measurementLink");
for (const xAOD::SpacePoint* sp : *spacePoints) {
if (not accesor.isAvailable(*sp)) {
ATH_MSG_ERROR("Space point does not possess element link to cluster. Decoration `measurementLink` is not available and this should not happen!");
return StatusCode::FAILURE;
}
const std::vector< ElementLink< xAOD::UncalibratedMeasurementContainer > >& els = accesor(*sp);
const link_type& els = elementLinksToClusters(*sp);
std::vector< const xAOD::UncalibratedMeasurement* > meas;
meas.reserve(els.size());
for (const ElementLink< xAOD::UncalibratedMeasurementContainer >& el : els) {
......@@ -63,7 +69,8 @@ namespace ActsTrk {
barePointersToClusters(*sp) = meas;
}
ATH_MSG_DEBUG("Decorations have been attached to space point collection");
return StatusCode::SUCCESS;
}
......
......@@ -8,6 +8,7 @@
#include "AthenaBaseComps/AthReentrantAlgorithm.h"
#include "GaudiKernel/EventContext.h"
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/ReadDecorHandleKey.h"
#include "StoreGate/WriteDecorHandleKey.h"
// EDM
......@@ -29,6 +30,9 @@ class SpacePointReader
{this, "SpacePointKey", "",
"Key for input space point container"};
SG::ReadDecorHandleKey< xAOD::SpacePointContainer > m_linkDecoration
{this, "LinkDecorationKey", "measurementLink",
"Decoration key for the element link to clusters"};
SG::WriteDecorHandleKey< xAOD::SpacePointContainer > m_clusterDecoration
{this, "ClusterDecorationKey", "measurements",
"Decoration key for the cluster bare pointer"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment