ATLAS Offline Software
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 
8 FPGAClusterSortingAlg::FPGAClusterSortingAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {
9 }
10 
11 
12 
14 
19 
20  return StatusCode::SUCCESS;
21 }
22 
23 StatusCode 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 }
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
FPGAClusterSortingAlg::initialize
virtual StatusCode initialize() override final
Definition: FPGAClusterSortingAlg.cxx:13
FPGAClusterSortingAlg::m_sortedxAODStripClusterContainerKeys
SG::WriteHandleKey< xAOD::StripClusterContainer > m_sortedxAODStripClusterContainerKeys
Definition: FPGAClusterSortingAlg.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
xAOD::StripCluster
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
Definition: StripCluster.h:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PixelClusterAuxContainer.h
xAOD::PixelCluster
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
Definition: Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/PixelCluster.h:13
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
FPGAClusterSortingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: FPGAClusterSortingAlg.cxx:23
FPGAClusterSortingAlg::m_xAODStripClusterContainerKeys
SG::ReadHandleKey< xAOD::StripClusterContainer > m_xAODStripClusterContainerKeys
Definition: FPGAClusterSortingAlg.h:25
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?
FPGAClusterSortingAlg::m_xAODPixelClusterContainerKey
SG::ReadHandleKey< xAOD::PixelClusterContainer > m_xAODPixelClusterContainerKey
Definition: FPGAClusterSortingAlg.h:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StripClusterAuxContainer.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::PixelCluster_v1
Definition: PixelCluster_v1.h:17
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
FPGAClusterSortingAlg::m_sortedxAODPixelClusterContainerKey
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_sortedxAODPixelClusterContainerKey
Definition: FPGAClusterSortingAlg.h:27
FPGAClusterSortingAlg.h
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.
FPGAClusterSortingAlg::FPGAClusterSortingAlg
FPGAClusterSortingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FPGAClusterSortingAlg.cxx:8