ATLAS Offline Software
MuonSegmentTagAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuonSegmentTagAlg.h"
6 
8 
9 MuonSegmentTagAlg::MuonSegmentTagAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
10 
12  ATH_CHECK(m_muonSegmentTagTool.retrieve());
16 
17  return StatusCode::SUCCESS;
18 }
19 
20 StatusCode MuonSegmentTagAlg::execute(const EventContext& ctx) const {
22  if (!indetCandidateCollection.isValid()) {
23  ATH_MSG_ERROR("Could not read " << m_indetCandidateCollectionName);
24  return StatusCode::FAILURE;
25  }
27  if (!segments.isValid()) {
28  ATH_MSG_FATAL("Unable to retrieve " << m_muonSegmentCollectionName);
29  return StatusCode::FAILURE;
30  }
31  // Convert the segments to a MuonSegment pointers
32  std::vector<const Muon::MuonSegment*> segmentVec{};
33  segmentVec.reserve(segments->size());
34  for (const Trk::Segment* trk_seg : *segments) {
35  const Muon::MuonSegment* muon_seg = dynamic_cast<const Muon::MuonSegment*>(trk_seg);
37  if (!muon_seg) {
38  ATH_MSG_WARNING("Failed to convert the Muon segment");
39  continue;
40  }
41  segmentVec.push_back(muon_seg);
42  }
43  std::unique_ptr<MuonCombined::InDetCandidateToTagMap> tagMap = std::make_unique<MuonCombined::InDetCandidateToTagMap>();
44 
45  m_muonSegmentTagTool->tag(ctx, *indetCandidateCollection, segmentVec, tagMap.get());
46 
48  ATH_CHECK(writeHandle.record(std::move(tagMap)));
49 
50  return StatusCode::SUCCESS;
51 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonSegmentTagAlg::m_muonSegmentTagTool
ToolHandle< MuonCombined::IMuonSegmentTagTool > m_muonSegmentTagTool
Definition: MuonSegmentTagAlg.h:28
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonSegmentTagAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MuonSegmentTagAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonSegmentTagAlg.cxx:20
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonSegmentTagAlg::MuonSegmentTagAlg
MuonSegmentTagAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonSegmentTagAlg.cxx:9
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::Segment
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:56
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonSegmentTagAlg::m_muonSegmentCollectionName
SG::ReadHandleKey< Trk::SegmentCollection > m_muonSegmentCollectionName
Definition: MuonSegmentTagAlg.h:32
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?
MuonSegmentTagAlg::initialize
virtual StatusCode initialize() override
Definition: MuonSegmentTagAlg.cxx:11
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonSegmentTagAlg::m_indetCandidateCollectionName
SG::ReadHandleKey< InDetCandidateCollection > m_indetCandidateCollectionName
Definition: MuonSegmentTagAlg.h:30
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MuonSegmentTagAlg::m_tagMap
SG::WriteHandleKey< MuonCombined::InDetCandidateToTagMap > m_tagMap
Definition: MuonSegmentTagAlg.h:34
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonSegment.h
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.