ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
EFTracking
EFTrackingFPGAIntegration
FPGAClusterSorting
src
FPGAClusterDataVectorSortingAlg.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
#include "
FPGAClusterSorting/FPGAClusterDataVectorSortingAlg.h
"
4
#include "
xAODInDetMeasurement/PixelClusterAuxContainer.h
"
5
#include "
xAODInDetMeasurement/StripClusterAuxContainer.h
"
6
7
8
FPGAClusterDataVectorSortingAlg::FPGAClusterDataVectorSortingAlg
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm
(name, pSvcLocator) {
9
}
10
11
12
13
StatusCode
FPGAClusterDataVectorSortingAlg::initialize
() {
14
15
ATH_CHECK
(
m_xAODPixelClusterContainerKey
.initialize());
16
ATH_CHECK
(
m_xAODStripClusterContainerKeys
.initialize());
17
ATH_CHECK
(
m_sortedxAODPixelClusterContainerKey
.initialize());
18
ATH_CHECK
(
m_sortedxAODStripClusterContainerKeys
.initialize());
19
20
return
StatusCode::SUCCESS;
21
}
22
23
StatusCode
FPGAClusterDataVectorSortingAlg::execute
(
const
EventContext& ctx)
const
{
24
25
if
(
m_xAODPixelClusterContainerKey
.key().empty()) {
26
ATH_MSG_ERROR
(
"No input xAOD Pixel Cluster container key provided"
);
27
return
StatusCode::FAILURE;
28
}
29
if
(
m_xAODStripClusterContainerKeys
.key().empty()) {
30
ATH_MSG_ERROR
(
"No input xAOD Strip Cluster container key provided"
);
31
return
StatusCode::FAILURE;
32
}
33
34
SG::ReadHandle<xAOD::PixelClusterContainer>
xAODPixelClusters(
m_xAODPixelClusterContainerKey
, ctx);
35
if
(!xAODPixelClusters.
isValid
()) {
36
ATH_MSG_ERROR
(
"Failed to retrieve xAOD Pixel Cluster container with key "
<<
m_xAODPixelClusterContainerKey
.key());
37
return
StatusCode::FAILURE;
38
}
39
SG::ReadHandle<xAOD::StripClusterContainer>
xAODStripClusters(
m_xAODStripClusterContainerKeys
, ctx);
40
if
(!xAODStripClusters.
isValid
()) {
41
ATH_MSG_ERROR
(
"Failed to retrieve xAOD Strip Cluster container with key "
<<
m_xAODStripClusterContainerKeys
.key());
42
return
StatusCode::FAILURE;
43
}
44
45
46
auto
sortedxAODPixelClusters = std::make_unique<ConstDataVector<xAOD::PixelClusterContainer>>(
SG::VIEW_ELEMENTS
);
47
SG::WriteHandle<ConstDataVector<xAOD::PixelClusterContainer>
> sortedxAODPixelClustersHandle(
m_sortedxAODPixelClusterContainerKey
, ctx);
48
49
50
auto
sortedxAODStripClusters = std::make_unique<ConstDataVector<xAOD::StripClusterContainer>>(
SG::VIEW_ELEMENTS
);
51
SG::WriteHandle<ConstDataVector<xAOD::StripClusterContainer>
> sortedxAODStripClustersHandle(
m_sortedxAODStripClusterContainerKeys
, ctx);
52
53
54
// Copy pixel clusters into a vector for sorting
55
std::vector<const xAOD::PixelCluster*> pixelClustersVec;
56
pixelClustersVec.reserve(xAODPixelClusters->size());
57
for
(
const
xAOD::PixelCluster
* cl : *xAODPixelClusters) {
58
pixelClustersVec.push_back(cl);
59
}
60
61
// Sort by identifierHash
62
std::sort
(pixelClustersVec.begin(), pixelClustersVec.end(),
63
[](
const
xAOD::PixelCluster
*
a
,
const
xAOD::PixelCluster
* b) {
64
return a->identifierHash() < b->identifierHash();
65
});
66
67
// Copy sorted clusters to output container
68
for
(
const
xAOD::PixelCluster
* cl : pixelClustersVec) {
69
sortedxAODPixelClusters->push_back(cl);
70
}
71
72
// Copy strip clusters into a vector for sorting
73
std::vector<const xAOD::StripCluster*> stripClustersVec;
74
stripClustersVec.reserve(xAODStripClusters->size());
75
for
(
const
xAOD::StripCluster
* cl : *xAODStripClusters) {
76
stripClustersVec.push_back(cl);
77
}
78
79
// Sort by identifierHash
80
std::sort
(stripClustersVec.begin(), stripClustersVec.end(),
81
[](
const
xAOD::StripCluster
*
a
,
const
xAOD::StripCluster
* b) {
82
return a->identifierHash() < b->identifierHash();
83
});
84
85
// Copy sorted clusters to output container
86
for
(
const
xAOD::StripCluster
* cl : stripClustersVec) {
87
sortedxAODStripClusters->push_back(cl);
88
}
89
90
ATH_CHECK
(sortedxAODPixelClustersHandle.record(std::move(sortedxAODPixelClusters)));
91
ATH_CHECK
(sortedxAODStripClustersHandle.record(std::move(sortedxAODStripClusters)));
92
93
94
95
96
return
StatusCode::SUCCESS;
97
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
FPGAClusterDataVectorSortingAlg.h
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
PixelClusterAuxContainer.h
StripClusterAuxContainer.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
FPGAClusterDataVectorSortingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
FPGAClusterDataVectorSortingAlg.cxx:23
FPGAClusterDataVectorSortingAlg::m_sortedxAODStripClusterContainerKeys
SG::WriteHandleKey< ConstDataVector< xAOD::StripClusterContainer > > m_sortedxAODStripClusterContainerKeys
Definition
FPGAClusterDataVectorSortingAlg.h:28
FPGAClusterDataVectorSortingAlg::m_xAODStripClusterContainerKeys
SG::ReadHandleKey< xAOD::StripClusterContainer > m_xAODStripClusterContainerKeys
Definition
FPGAClusterDataVectorSortingAlg.h:25
FPGAClusterDataVectorSortingAlg::m_sortedxAODPixelClusterContainerKey
SG::WriteHandleKey< ConstDataVector< xAOD::PixelClusterContainer > > m_sortedxAODPixelClusterContainerKey
Definition
FPGAClusterDataVectorSortingAlg.h:27
FPGAClusterDataVectorSortingAlg::FPGAClusterDataVectorSortingAlg
FPGAClusterDataVectorSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
FPGAClusterDataVectorSortingAlg.cxx:8
FPGAClusterDataVectorSortingAlg::m_xAODPixelClusterContainerKey
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_xAODPixelClusterContainerKey
Definition
FPGAClusterDataVectorSortingAlg.h:24
FPGAClusterDataVectorSortingAlg::initialize
virtual StatusCode initialize() override final
Definition
FPGAClusterDataVectorSortingAlg.cxx:13
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
xAOD::StripCluster
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
Definition
StripCluster.h:13
xAOD::PixelCluster
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Definition
Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/PixelCluster.h:13
Generated on
for ATLAS Offline Software by
1.17.0