ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetMeasurementUtilities
src
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
"
6
#include "
xAODMeasurementBase/UncalibratedMeasurementContainer.h
"
7
#include "AthLinks/ElementLink.h"
8
#include "
StoreGate/ReadDecorHandle.h
"
9
#include "
StoreGate/WriteDecorHandle.h
"
10
11
namespace
InDet
{
12
13
SpacePointReader::SpacePointReader
(
const
std::string& name,
14
ISvcLocator* pSvcLocator)
15
:
AthReentrantAlgorithm
(name, pSvcLocator)
16
{}
17
18
StatusCode
SpacePointReader::initialize
()
19
{
20
ATH_MSG_DEBUG
(
"Initializing "
<< name() <<
" ... "
);
21
22
m_linkDecoration
=
m_spacePointKey
.key() +
"."
+
m_linkDecoration
.key();
23
m_clusterDecoration
=
m_spacePointKey
.key() +
"."
+
m_clusterDecoration
.key();
24
25
ATH_MSG_DEBUG
(
"Properties:"
);
26
ATH_MSG_DEBUG
(
m_spacePointKey
);
27
ATH_MSG_DEBUG
(
m_linkDecoration
);
28
ATH_MSG_DEBUG
(
m_clusterDecoration
);
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());
42
SG::ReadHandle< xAOD::SpacePointContainer >
spHandle =
SG::makeHandle
(
m_spacePointKey
, ctx );
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> >;
50
SG::ReadDecorHandle
<
xAOD::SpacePointContainer
,
51
link_type
> elementLinksToClusters(
m_linkDecoration
, ctx );
52
if
(not elementLinksToClusters.isAvailable()) {
53
ATH_MSG_DEBUG
(
"Decoration missing: "
<<
m_linkDecoration
.key() <<
". This may indicate file corruption or non standard processing upstream."
);
54
}
55
56
ATH_MSG_DEBUG
(
"Adding decoration to space point collection: bare pointers to clusters"
);
57
ATH_MSG_DEBUG
(
"Decoration name: "
<<
m_clusterDecoration
.key());
58
using
decoration_type = std::vector<const xAOD::UncalibratedMeasurement*>;
59
SG::WriteDecorHandle
<
xAOD::SpacePointContainer
,
60
decoration_type > barePointersToClusters(
m_clusterDecoration
, ctx );
61
62
ATH_MSG_DEBUG
(
"Retrieving Element Links to Clusters from the Space Points and attaching the bare pointers to the object"
);
63
for
(
const
xAOD::SpacePoint
*
sp
: *spacePoints) {
64
const
link_type
els = elementLinksToClusters.isAvailable()
65
? elementLinksToClusters(*
sp
)
66
:
link_type
();
67
68
std::vector< const xAOD::UncalibratedMeasurement* > meas;
69
meas.reserve(els.size());
70
for
(
const
ElementLink< xAOD::UncalibratedMeasurementContainer >
& el : els) {
71
meas.push_back(*el);
72
}
73
74
barePointersToClusters(*
sp
) = std::move(meas);
75
}
76
77
ATH_MSG_DEBUG
(
"Decorations have been attached to space point collection"
);
78
return
StatusCode::SUCCESS;
79
}
80
81
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
sp
static Double_t sp
Definition
LArPhysWaveHECTool.cxx:37
SpacePointReader.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
UncalibratedMeasurementContainer.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ElementLink< xAOD::UncalibratedMeasurementContainer >
InDet::SpacePointReader::m_linkDecoration
SG::ReadDecorHandleKey< xAOD::SpacePointContainer > m_linkDecoration
Definition
SpacePointReader.h:34
InDet::SpacePointReader::SpacePointReader
SpacePointReader(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SpacePointReader.cxx:13
InDet::SpacePointReader::m_spacePointKey
SG::ReadHandleKey< xAOD::SpacePointContainer > m_spacePointKey
Definition
SpacePointReader.h:30
InDet::SpacePointReader::m_clusterDecoration
SG::WriteDecorHandleKey< xAOD::SpacePointContainer > m_clusterDecoration
Definition
SpacePointReader.h:37
InDet::SpacePointReader::execute
virtual StatusCode execute(const EventContext &) const override
Definition
SpacePointReader.cxx:37
InDet::SpacePointReader::initialize
virtual StatusCode initialize() override
Definition
SpacePointReader.cxx:18
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::SpacePointContainer
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
Definition
Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePointContainer.h:14
xAOD::SpacePoint
SpacePoint_v1 SpacePoint
Definition
Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/SpacePoint.h:12
link_type
Generated on
for ATLAS Offline Software by
1.17.0