ATLAS Offline Software
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 
8 FPGAClusterDataVectorSortingAlg::FPGAClusterDataVectorSortingAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {
9 }
10 
11 
12 
14 
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 
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 }
FPGAClusterDataVectorSortingAlg.h
FPGAClusterDataVectorSortingAlg::m_xAODStripClusterContainerKeys
SG::ReadHandleKey< xAOD::StripClusterContainer > m_xAODStripClusterContainerKeys
Definition: FPGAClusterDataVectorSortingAlg.h:25
FPGAClusterDataVectorSortingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: FPGAClusterDataVectorSortingAlg.cxx:23
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
FPGAClusterDataVectorSortingAlg::m_sortedxAODStripClusterContainerKeys
SG::WriteHandleKey< ConstDataVector< xAOD::StripClusterContainer > > m_sortedxAODStripClusterContainerKeys
Definition: FPGAClusterDataVectorSortingAlg.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PixelClusterAuxContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::StripCluster_v1
Definition: StripCluster_v1.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
FPGAClusterDataVectorSortingAlg::m_xAODPixelClusterContainerKey
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_xAODPixelClusterContainerKey
Definition: FPGAClusterDataVectorSortingAlg.h:24
StripClusterAuxContainer.h
FPGAClusterDataVectorSortingAlg::m_sortedxAODPixelClusterContainerKey
SG::WriteHandleKey< ConstDataVector< xAOD::PixelClusterContainer > > m_sortedxAODPixelClusterContainerKey
Definition: FPGAClusterDataVectorSortingAlg.h:27
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
FPGAClusterDataVectorSortingAlg::initialize
virtual StatusCode initialize() override final
Definition: FPGAClusterDataVectorSortingAlg.cxx:13
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
FPGAClusterDataVectorSortingAlg::FPGAClusterDataVectorSortingAlg
FPGAClusterDataVectorSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FPGAClusterDataVectorSortingAlg.cxx:8