ATLAS Offline Software
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 
7 MuonCombinedAlg::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 
20 StatusCode MuonCombinedAlg::execute(const EventContext& ctx) const {
22  if (!inDetCandidateCollection.isValid()) {
23  ATH_MSG_ERROR("Could not read " << m_indetCandidateCollectionName);
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 }
MuonCombinedAlg::MuonCombinedAlg
MuonCombinedAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonCombinedAlg.cxx:7
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonCombinedAlg::initialize
StatusCode initialize() override
Definition: MuonCombinedAlg.cxx:9
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MuonCombinedAlg::m_muidCombinedTracks
SG::WriteHandleKey< TrackCollection > m_muidCombinedTracks
Definition: MuonCombinedAlg.h:40
MuonCombinedAlg::m_muonCombinedTool
ToolHandle< MuonCombined::IMuonCombinedTool > m_muonCombinedTool
Definition: MuonCombinedAlg.h:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
MuonCombinedAlg::m_muonCandidateCollectionName
SG::ReadHandleKey< MuonCandidateCollection > m_muonCandidateCollectionName
Definition: MuonCombinedAlg.h:36
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonCombinedAlg.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonCombinedAlg::m_indetCandidateCollectionName
SG::ReadHandleKey< InDetCandidateCollection > m_indetCandidateCollectionName
Definition: MuonCombinedAlg.h:34
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MuonCombinedAlg::m_muidMETracks
SG::WriteHandleKey< TrackCollection > m_muidMETracks
Definition: MuonCombinedAlg.h:42
h
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
MuonCombinedAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: MuonCombinedAlg.cxx:20
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:397
MuonCombinedAlg::m_combTagMaps
SG::WriteHandleKeyArray< MuonCombined::InDetCandidateToTagMap > m_combTagMaps
Definition: MuonCombinedAlg.h:38
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.