ATLAS Offline Software
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 
11 namespace InDet {
12 
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 }
InDet::SpacePointReader::initialize
virtual StatusCode initialize() override
Definition: SpacePointReader.cxx:18
InDet::SpacePointReader::m_spacePointKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointKey
Definition: SpacePointReader.h:30
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SpacePointReader.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::SpacePointReader::m_linkDecoration
SG::ReadDecorHandleKey< xAOD::SpacePointContainer > m_linkDecoration
Definition: SpacePointReader.h:34
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
InDet::SpacePointReader::SpacePointReader
SpacePointReader(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SpacePointReader.cxx:13
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
InDet::SpacePointReader::execute
virtual StatusCode execute(const EventContext &) const override
Definition: SpacePointReader.cxx:37
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
UncalibratedMeasurementContainer.h
WriteDecorHandle.h
Handle class for adding a decoration to an object.
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDet::SpacePointReader::m_clusterDecoration
SG::WriteDecorHandleKey< xAOD::SpacePointContainer > m_clusterDecoration
Definition: SpacePointReader.h:37
xAOD::SpacePointContainer
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
Definition: Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePointContainer.h:14
ReadDecorHandle.h
Handle class for reading a decoration on an object.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.