ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSegmentMergingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6
8
11
13 if (m_inKeys.empty()){
14 ATH_MSG_FATAL("No containers to merge");
15 return StatusCode::FAILURE;
16 }
17 ATH_CHECK(m_inKeys.initialize());
18 ATH_CHECK(m_writeKey.initialize());
19 return StatusCode::SUCCESS;
20}
21StatusCode MuonSegmentMergingAlg::execute(const EventContext& ctx) const {
22
23 SG::WriteHandle writeHandle{m_writeKey, ctx};
24
26 auto outCopyCont = std::make_unique<Trk::SegmentCollection>();
27
28 for (const auto& key : m_inKeys) {
29 const Trk::SegmentCollection* inColl{nullptr};
30 ATH_CHECK(SG::get(inColl, key, ctx));
31 if (!m_hardCopy) {
32 outViewCont.insert(outViewCont.end(), inColl->begin(), inColl->end());
33 } else {
34 for (const Trk::Segment* trkSeg : *inColl) {
35 const auto* seg = static_cast<const Muon::MuonSegment*>(trkSeg);
36 outCopyCont->push_back(std::make_unique<Muon::MuonSegment>(*seg));
37 }
38 }
39 }
40 if (m_hardCopy) {
41 ATH_CHECK(writeHandle.record(std::move(outCopyCont)));
42 } else {
43 ATH_CHECK(writeHandle.record(std::make_unique<Trk::SegmentCollection>(*outViewCont.asDataVector())));
44 }
45 return StatusCode::SUCCESS;
46}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x,...)
DataVector adapter that acts like it holds const pointers.
DataVector adapter that acts like it holds const pointers.
iterator end() noexcept
Return an iterator pointing past the end of the collection.
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual StatusCode execute(const EventContext &ctx) const final
SG::WriteHandleKey< Trk::SegmentCollection > m_writeKey
SG::ReadHandleKeyArray< Trk::SegmentCollection > m_inKeys
Gaudi::Property< bool > m_hardCopy
virtual StatusCode initialize() override final
This is the common class for 3D segments used in the muon spectrometer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Base class for all TrackSegment implementations, extends the common MeasurementBase.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
DataVector< Trk::Segment > SegmentCollection