ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCombinedAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MuonCombinedAlg.h"
6
7MuonCombinedAlg::MuonCombinedAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
8
10 ATH_CHECK(m_muonCombinedTool.retrieve());
13 ATH_CHECK(m_combTagMaps.initialize());
14 ATH_CHECK(m_muidCombinedTracks.initialize());
15 ATH_CHECK(m_muidMETracks.initialize());
16
17 return StatusCode::SUCCESS;
18}
19
20StatusCode MuonCombinedAlg::execute(const EventContext& ctx) const {
22 if (!inDetCandidateCollection.isValid()) {
24 return StatusCode::FAILURE;
25 }
26 if (!inDetCandidateCollection.isPresent()) {
28 return StatusCode::SUCCESS;
29 }
30
32 if (!muonCandidateCollection.isValid()) {
33 ATH_MSG_ERROR("Could not read " << m_muonCandidateCollectionName);
34 return StatusCode::FAILURE;
35 }
36 if (!muonCandidateCollection.isPresent()) {
38 return StatusCode::SUCCESS;
39 }
40
41 std::vector<SG::WriteHandle<MuonCombined::InDetCandidateToTagMap> > tagMaps = m_combTagMaps.makeHandles(ctx);
42 std::vector<MuonCombined::InDetCandidateToTagMap*> maps;
43 for (auto& h : tagMaps) {
44 ATH_CHECK(h.record(std::make_unique<MuonCombined::InDetCandidateToTagMap>()));
45 maps.push_back(h.ptr());
46 }
47
49 ATH_CHECK(muidCombTracks.record(std::make_unique<TrackCollection>()));
50
52 ATH_CHECK(muidMETracks.record(std::make_unique<TrackCollection>()));
53
54 if (inDetCandidateCollection->empty() || muonCandidateCollection->empty()) return StatusCode::SUCCESS;
55
56 // note that STACO does not create new Trk::Tracks so it doesn't need collections here
57 m_muonCombinedTool->combine(*muonCandidateCollection, *inDetCandidateCollection, maps, muidCombTracks.ptr(), muidMETracks.ptr(), ctx);
58
59 return StatusCode::SUCCESS;
60}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
Header file for AthHistogramAlgorithm.
An algorithm that can be simultaneously executed in multiple threads.
ToolHandle< MuonCombined::IMuonCombinedTool > m_muonCombinedTool
SG::ReadHandleKey< MuonCandidateCollection > m_muonCandidateCollectionName
SG::WriteHandleKey< TrackCollection > m_muidMETracks
StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< InDetCandidateCollection > m_indetCandidateCollectionName
SG::WriteHandleKey< TrackCollection > m_muidCombinedTracks
SG::WriteHandleKeyArray< MuonCombined::InDetCandidateToTagMap > m_combTagMaps
StatusCode initialize() override
MuonCombinedAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.