ATLAS Offline Software
Loading...
Searching...
No Matches
SpacePointReader.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#include "SpacePointReader.h"
7#include "AthLinks/ElementLink.h"
10
11namespace InDet {
12
13 SpacePointReader::SpacePointReader(const std::string& name,
14 ISvcLocator* pSvcLocator)
15 : AthReentrantAlgorithm(name, pSvcLocator)
16 {}
17
19 {
20 ATH_MSG_DEBUG("Initializing " << name() << " ... ");
21
24
25 ATH_MSG_DEBUG("Properties:");
29
30 ATH_CHECK(m_spacePointKey.initialize());
31 ATH_CHECK(m_linkDecoration.initialize());
32 ATH_CHECK(m_clusterDecoration.initialize());
33
34 return StatusCode::SUCCESS;
35 }
36
37 StatusCode SpacePointReader::execute(const EventContext& ctx) const
38 {
39 ATH_MSG_DEBUG("Executing " << name() << " ...");
40
41 ATH_MSG_DEBUG("Retrieving input space point collection with key: " << m_spacePointKey.key());
43 ATH_CHECK(spHandle.isValid());
44 const xAOD::SpacePointContainer* spacePoints = spHandle.cptr();
45 ATH_MSG_DEBUG("Retrieved " << spacePoints->size() << " elements from space point container");
46
47 ATH_MSG_DEBUG("Reading decoration to space point collection: element links to clusters");
48 ATH_MSG_DEBUG("Decoration name: " << m_linkDecoration.key());
49 using link_type = std::vector< ElementLink<xAOD::UncalibratedMeasurementContainer> >;
51 link_type > elementLinksToClusters( m_linkDecoration, ctx );
52 ATH_CHECK(elementLinksToClusters.isAvailable());
53
54 ATH_MSG_DEBUG("Adding decoration to space point collection: bare pointers to clusters");
55 ATH_MSG_DEBUG("Decoration name: " << m_clusterDecoration.key());
56 using decoration_type = std::vector<const xAOD::UncalibratedMeasurement*>;
58 decoration_type > barePointersToClusters( m_clusterDecoration, ctx );
59
60 ATH_MSG_DEBUG("Retrieving Element Links to Clusters from the Space Points and attaching the bare pointers to the object");
61 for (const xAOD::SpacePoint* sp : *spacePoints) {
62 const link_type& els = elementLinksToClusters(*sp);
63
64 std::vector< const xAOD::UncalibratedMeasurement* > meas;
65 meas.reserve(els.size());
67 meas.push_back(*el);
68 }
69
70 barePointersToClusters(*sp) = std::move(meas);
71 }
72
73 ATH_MSG_DEBUG("Decorations have been attached to space point collection");
74 return StatusCode::SUCCESS;
75 }
76
77}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t sp
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadDecorHandleKey< xAOD::SpacePointContainer > m_linkDecoration
SpacePointReader(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointKey
SG::WriteDecorHandleKey< xAOD::SpacePointContainer > m_clusterDecoration
virtual StatusCode execute(const EventContext &) const override
virtual StatusCode initialize() override
Handle class for reading a decoration on an object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Handle class for adding a decoration to an object.
Primary Vertex Finder.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.