ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
xAOD
xAODMuonCnv
src
MuonSegmentCnvAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonSegmentCnvAlg.h
"
6
7
#include "
xAODMuon/MuonSegmentAuxContainer.h
"
8
#include "
xAODMuon/MuonSegmentContainer.h
"
9
#include "
TrkSegment/SegmentCollection.h
"
10
#include "
TrkSegment/Segment.h
"
11
#include "
MuonSegment/MuonSegment.h
"
12
#include "AthLinks/ElementLink.h"
13
14
namespace
xAODMaker
{
15
16
MuonSegmentCnvAlg::MuonSegmentCnvAlg
(
const
std::string& name, ISvcLocator* svcLoc) :
17
AthReentrantAlgorithm
(name, svcLoc) {
18
}
19
20
StatusCode
MuonSegmentCnvAlg::initialize
() {
21
22
ATH_MSG_DEBUG
(
"SegmentContainerName = "
<<
m_muonSegmentLocation
.key() <<
" xAODContainerName = "
<<
m_xaodContainerName
.key() );
23
ATH_CHECK
(
m_muonSegmentConverterTool
.retrieve());
24
ATH_CHECK
(
m_muonSegmentLocation
.initialize());
25
ATH_CHECK
(
m_xaodContainerName
.initialize());
26
27
// Return gracefully:
28
return
StatusCode::SUCCESS;
29
}
30
31
StatusCode
MuonSegmentCnvAlg::execute
(
const
EventContext& ctx )
const
{
32
33
// Retrieve the AOD particles:
34
const
Trk::SegmentCollection
* segments =
nullptr
;
35
SG::ReadHandle<Trk::SegmentCollection>
h_segments(
m_muonSegmentLocation
, ctx);
36
if
(h_segments.
isValid
()) {
37
segments = h_segments.
cptr
();
38
}
39
else
{
40
ATH_MSG_FATAL
(
"Unable to retrieve "
<<
m_muonSegmentLocation
.key() );
41
return
StatusCode::FAILURE;
42
}
43
44
// If there's no input, we're done already:
45
if
( ! segments )
return
StatusCode::SUCCESS;
46
47
// Create the xAOD container and its auxiliary store:
48
SG::WriteHandle<xAOD::MuonSegmentContainer>
xaod (
m_xaodContainerName
, ctx);
49
ATH_CHECK
(xaod.
record
(std::make_unique<xAOD::MuonSegmentContainer>(),
50
std::make_unique<xAOD::MuonSegmentAuxContainer>()));
51
52
unsigned
int
index
= 0;
53
for
(
auto
it = segments->
begin
();it!=segments->
end
();++it,++
index
){
54
const
Muon::MuonSegment
* muonSegment =
dynamic_cast<
const
Muon::MuonSegment
*
>
(&(**it));
55
if
( !muonSegment )
continue
;
56
ElementLink< ::Trk::SegmentCollection >
link(*segments,
index
);
57
m_muonSegmentConverterTool
->convert(link,xaod.
ptr
());
58
}
59
ATH_MSG_DEBUG
(
"Recorded MuonSegments with key: "
<<
m_xaodContainerName
.key() <<
" size "
<< xaod->size()
60
<<
" from input: "
<<
m_muonSegmentLocation
.key() <<
" size "
<<segments->
size
());
61
62
return
StatusCode::SUCCESS;
63
}
64
}
// namespace xAODMaker
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:34
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MuonSegmentAuxContainer.h
MuonSegmentCnvAlg.h
MuonSegmentContainer.h
MuonSegment.h
SegmentCollection.h
Segment.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
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.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
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::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
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.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
xAODMaker::MuonSegmentCnvAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition
MuonSegmentCnvAlg.cxx:31
xAODMaker::MuonSegmentCnvAlg::m_muonSegmentConverterTool
ToolHandle< xAODMaker::IMuonSegmentConverterTool > m_muonSegmentConverterTool
Definition
MuonSegmentCnvAlg.h:42
xAODMaker::MuonSegmentCnvAlg::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition
MuonSegmentCnvAlg.cxx:20
xAODMaker::MuonSegmentCnvAlg::MuonSegmentCnvAlg
MuonSegmentCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
Definition
MuonSegmentCnvAlg.cxx:16
xAODMaker::MuonSegmentCnvAlg::m_xaodContainerName
SG::WriteHandleKey< xAOD::MuonSegmentContainer > m_xaodContainerName
Definition
MuonSegmentCnvAlg.h:40
xAODMaker::MuonSegmentCnvAlg::m_muonSegmentLocation
SG::ReadHandleKey< Trk::SegmentCollection > m_muonSegmentLocation
Definition
MuonSegmentCnvAlg.h:39
Trk::SegmentCollection
DataVector< Trk::Segment > SegmentCollection
Definition
SegmentCollection.h:13
index
Definition
index.py:1
xAODMaker
Definition
StoreGateSvc.h:70
Generated on
for ATLAS Offline Software by
1.17.0