ATLAS Offline Software
Loading...
Searching...
No Matches
FPGAClusterSortingAlg.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
6
7
8FPGAClusterSortingAlg::FPGAClusterSortingAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {
9}
10
11
12
22
23StatusCode FPGAClusterSortingAlg::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 std::unique_ptr<xAOD::PixelClusterContainer> sortedxAODPixelClusters = std::make_unique<xAOD::PixelClusterContainer>();
47 std::unique_ptr<xAOD::PixelClusterAuxContainer> sortedxAODPixelClustersAux = std::make_unique<xAOD::PixelClusterAuxContainer>();
48 sortedxAODPixelClusters->setStore (sortedxAODPixelClustersAux.get());
49
51
52
53 std::unique_ptr<xAOD::StripClusterContainer> sortedxAODStripClusters = std::make_unique<xAOD::StripClusterContainer>();
54 std::unique_ptr<xAOD::StripClusterAuxContainer> sortedxAODStripClustersAux = std::make_unique<xAOD::StripClusterAuxContainer>();
55 sortedxAODStripClusters->setStore (sortedxAODStripClustersAux.get());
57
58
59 // Copy pixel clusters into a vector for sorting
60 std::vector<const xAOD::PixelCluster*> pixelClustersVec;
61 pixelClustersVec.reserve(xAODPixelClusters->size());
62 for (const xAOD::PixelCluster* cl : *xAODPixelClusters) {
63 pixelClustersVec.push_back(cl);
64 }
65
66 // Sort by identifierHash
67 std::sort(pixelClustersVec.begin(), pixelClustersVec.end(),
68 [](const xAOD::PixelCluster* a, const xAOD::PixelCluster* b) {
69 return a->identifierHash() < b->identifierHash();
70 });
71
72 // Copy sorted clusters to output container
73 for (const xAOD::PixelCluster* cl : pixelClustersVec) {
75 sortedxAODPixelClusters->push_back(newCl);
76 *newCl = *cl;
77 }
78
79 // Copy strip clusters into a vector for sorting
80 std::vector<const xAOD::StripCluster*> stripClustersVec;
81 stripClustersVec.reserve(xAODStripClusters->size());
82 for (const xAOD::StripCluster* cl : *xAODStripClusters) {
83 stripClustersVec.push_back(cl);
84 }
85
86 // Sort by identifierHash
87 std::sort(stripClustersVec.begin(), stripClustersVec.end(),
88 [](const xAOD::StripCluster* a, const xAOD::StripCluster* b) {
89 return a->identifierHash() < b->identifierHash();
90 });
91
92 // Copy sorted clusters to output container
93 for (const xAOD::StripCluster* cl : stripClustersVec) {
95 sortedxAODStripClusters->push_back(newCl);
96 *newCl = *cl;
97 }
98
99
100 ATH_CHECK(sortedxAODPixelClustersHandle.record(std::move(sortedxAODPixelClusters), std::move(sortedxAODPixelClustersAux)).isSuccess());
101 ATH_CHECK(sortedxAODStripClustersHandle.record(std::move(sortedxAODStripClusters), std::move(sortedxAODStripClustersAux)).isSuccess());
102
103
104
105
106 return StatusCode::SUCCESS;
107}
#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.
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_xAODPixelClusterContainerKey
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_sortedxAODPixelClusterContainerKey
FPGAClusterSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::StripClusterContainer > m_xAODStripClusterContainerKeys
SG::WriteHandleKey< xAOD::StripClusterContainer > m_sortedxAODStripClusterContainerKeys
virtual StatusCode initialize() override final
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
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.