ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonReconstruction
MuonSegmentCombiners
MuonSegmentCombinerTools
MooSegmentCombinationFinder
src
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
7
#include "
MuonSegmentMergingAlg.h
"
8
9
#include "
AthContainers/ConstDataVector.h
"
10
#include "
MuonSegment/MuonSegment.h
"
11
12
StatusCode
MuonSegmentMergingAlg::initialize
() {
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
}
21
StatusCode
MuonSegmentMergingAlg::execute
(
const
EventContext& ctx)
const
{
22
23
SG::WriteHandle
writeHandle{
m_writeKey
, ctx};
24
25
ConstDataVector<Trk::SegmentCollection>
outViewCont{
SG::VIEW_ELEMENTS
};
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
MuonSegmentMergingAlg.h
MuonSegment.h
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::end
iterator end() noexcept
Return an iterator pointing past the end of the collection.
ConstDataVector::insert
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
MuonSegmentMergingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const final
Definition
MuonSegmentMergingAlg.cxx:21
MuonSegmentMergingAlg::m_writeKey
SG::WriteHandleKey< Trk::SegmentCollection > m_writeKey
Definition
MuonSegmentMergingAlg.h:22
MuonSegmentMergingAlg::m_inKeys
SG::ReadHandleKeyArray< Trk::SegmentCollection > m_inKeys
Definition
MuonSegmentMergingAlg.h:20
MuonSegmentMergingAlg::m_hardCopy
Gaudi::Property< bool > m_hardCopy
Definition
MuonSegmentMergingAlg.h:24
MuonSegmentMergingAlg::initialize
virtual StatusCode initialize() override final
Definition
MuonSegmentMergingAlg.cxx:12
Muon::MuonSegment
This is the common class for 3D segments used in the muon spectrometer.
Definition
MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Trk::Segment
Base class for all TrackSegment implementations, extends the common MeasurementBase.
Definition
Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:281
Trk::SegmentCollection
DataVector< Trk::Segment > SegmentCollection
Definition
SegmentCollection.h:13
Generated on
for ATLAS Offline Software by
1.17.0