ATLAS Offline Software
MuonLayerHoughAlg.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 "MuonLayerHoughAlg.h"
6 
14 
15 MuonLayerHoughAlg::MuonLayerHoughAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
16 
18  if (m_layerTool.empty()) {
19  ATH_MSG_ERROR("MuonLayerScanTool property is empty");
20  return StatusCode::FAILURE;
21  }
22  ATH_CHECK(m_layerTool.retrieve());
23  ATH_CHECK(m_printer.retrieve());
24  ATH_CHECK(m_keyRpc.initialize());
25  ATH_CHECK(m_keyMdt.initialize());
26  ATH_CHECK(m_keyTgc.initialize());
27  ATH_CHECK(m_keyCsc.initialize(!m_keyCsc.empty()));
28  ATH_CHECK(m_keysTgc.initialize(!m_keysTgc.empty()));
29  ATH_CHECK(m_keyMM.initialize(!m_keyMM.empty()));
30  ATH_CHECK(m_combis.initialize());
32 
33  return StatusCode::SUCCESS;
34 }
35 
36 StatusCode MuonLayerHoughAlg::execute(const EventContext& ctx) const {
37  const Muon::RpcPrepDataContainer* rpcPrds = GetObject(m_keyRpc, ctx);
38  const Muon::MdtPrepDataContainer* mdtPrds = GetObject(m_keyMdt, ctx);
39  const Muon::TgcPrepDataContainer* tgcPrds = GetObject(m_keyTgc, ctx);
40  const Muon::CscPrepDataContainer* cscPrds = m_keyCsc.empty() ? nullptr : GetObject(m_keyCsc, ctx);
41  const Muon::sTgcPrepDataContainer* stgcPrds = m_keysTgc.empty() ? nullptr : GetObject(m_keysTgc, ctx);
42  const Muon::MMPrepDataContainer* mmPrds = m_keyMM.empty() ? nullptr : GetObject(m_keyMM, ctx);
43  ATH_MSG_VERBOSE("calling layer tool ");
44  auto [combis, houghDataPerSectorVec] = m_layerTool->find(mdtPrds, cscPrds, tgcPrds, rpcPrds, stgcPrds, mmPrds, ctx);
46  if (combis) {
47  if (Handle.record(std::move(combis)).isFailure()) {
48  ATH_MSG_WARNING("Failed to record MuonPatternCombinationCollection at MuonLayerHoughCombis");
49  } else {
50  ATH_MSG_DEBUG("Recorded MuonPatternCombinationCollection at MuonLayerHoughCombis: size " << Handle->size());
52  ATH_MSG_INFO("Number of MuonPatternCombinations " << Handle->size() << std::endl << m_printer->print(*Handle));
53  }
54  }
55  } else {
56  ATH_MSG_VERBOSE("CombinationCollection " << m_combis << " is empty, recording");
57  ATH_CHECK(Handle.record(std::make_unique<MuonPatternCombinationCollection>()));
58  }
59 
60  // write hough data to SG
62  if (houghDataPerSectorVec) {
63  ATH_CHECK(handle.record(std::move(houghDataPerSectorVec)));
64  } else {
65  ATH_MSG_VERBOSE("HoughDataPerSectorVec " << m_houghDataPerSectorVecKey << " is empty, recording");
66  ATH_CHECK(handle.record(std::make_unique<Muon::HoughDataPerSectorVec>()));
67  }
68  return StatusCode::SUCCESS;
69 } // execute
MuonLayerHoughAlg::m_keyCsc
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_keyCsc
Definition: MuonLayerHoughAlg.h:28
Muon::MuonPrepDataContainer
Template for Muon PRD containers (which are basically collections of MuonPrepDataCollections).
Definition: MuonPrepDataContainer.h:42
MuonLayerHoughAlg::m_keysTgc
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_keysTgc
Definition: MuonLayerHoughAlg.h:30
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MuonLayerHoughAlg::m_keyMM
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_keyMM
Definition: MuonLayerHoughAlg.h:31
MuonLayerHoughAlg::m_keyRpc
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_keyRpc
Definition: MuonLayerHoughAlg.h:27
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
MuonLayerHoughAlg::m_printer
ToolHandle< Muon::MuonEDMPrinterTool > m_printer
Definition: MuonLayerHoughAlg.h:36
MuonLayerHoughAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonLayerHoughAlg.cxx:36
MuonLayerHoughAlg::GetObject
const T * GetObject(const SG::ReadHandleKey< T > &key, const EventContext &ctx) const
Definition: MuonLayerHoughAlg.h:41
MuonPrepDataContainer.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RpcPrepDataCollection.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CscPrepDataCollection.h
MdtPrepDataCollection.h
MMPrepDataCollection.h
MuonLayerHoughAlg::initialize
virtual StatusCode initialize() override
Definition: MuonLayerHoughAlg.cxx:17
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonLayerHoughAlg::m_keyMdt
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_keyMdt
Definition: MuonLayerHoughAlg.h:29
MuonLayerHoughAlg.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonLayerHoughAlg::m_houghDataPerSectorVecKey
SG::WriteHandleKey< Muon::HoughDataPerSectorVec > m_houghDataPerSectorVecKey
Definition: MuonLayerHoughAlg.h:34
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
MuonLayerHoughAlg::m_printSummary
Gaudi::Property< bool > m_printSummary
Definition: MuonLayerHoughAlg.h:38
MuonLayerHoughAlg::m_keyTgc
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_keyTgc
Definition: MuonLayerHoughAlg.h:26
MuonLayerHoughAlg::m_layerTool
ToolHandle< Muon::IMuonHoughPatternFinderTool > m_layerTool
Definition: MuonLayerHoughAlg.h:37
TgcPrepDataCollection.h
MuonLayerHoughAlg::MuonLayerHoughAlg
MuonLayerHoughAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonLayerHoughAlg.cxx:15
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
sTgcPrepDataCollection.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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
DEBUG
#define DEBUG
Definition: page_access.h:11
MuonLayerHoughAlg::m_combis
SG::WriteHandleKey< MuonPatternCombinationCollection > m_combis
Definition: MuonLayerHoughAlg.h:33
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.