ATLAS Offline Software
Loading...
Searching...
No Matches
FPGAClusterDataVectorSortingAlg.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
6
7
8FPGAClusterDataVectorSortingAlg::FPGAClusterDataVectorSortingAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {
9}
10
11
12
22
23StatusCode 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
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 }
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);
48
49
50 auto sortedxAODStripClusters = std::make_unique<ConstDataVector<xAOD::StripClusterContainer>>(SG::VIEW_ELEMENTS);
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
static Double_t a
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< ConstDataVector< xAOD::StripClusterContainer > > m_sortedxAODStripClusterContainerKeys
SG::ReadHandleKey< xAOD::StripClusterContainer > m_xAODStripClusterContainerKeys
SG::WriteHandleKey< ConstDataVector< xAOD::PixelClusterContainer > > m_sortedxAODPixelClusterContainerKey
FPGAClusterDataVectorSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_xAODPixelClusterContainerKey
virtual StatusCode initialize() override final
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.