ATLAS Offline Software
MuonLayerHoughAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuonLayerHoughAlg.h"
6 
7 #include "StoreGate/ReadHandle.h"
15 
16 MuonLayerHoughAlg::MuonLayerHoughAlg(const std::string& name, ISvcLocator* pSvcLocator) :
17  AthReentrantAlgorithm(name, pSvcLocator) {}
18 
19 
20 template <class T> StatusCode MuonLayerHoughAlg::retrieveContainer(const EventContext& ctx,
22  const T*& contPtr) const {
23  if (key.empty()) {
24  ATH_MSG_DEBUG("No key of type "<<typeid(T).name()<<" has been set. Set to nullptr");
25  contPtr = nullptr;
26  return StatusCode::SUCCESS;
27  }
28  SG::ReadHandle<T> handle(key, ctx);
29  ATH_CHECK(handle.isValid());
30  contPtr = handle.cptr();
31  return StatusCode::SUCCESS;
32 }
33 
35  if (m_layerTool.empty()) {
36  ATH_MSG_ERROR("MuonLayerScanTool property is empty");
37  return StatusCode::FAILURE;
38  }
39  ATH_CHECK(m_layerTool.retrieve());
40  ATH_CHECK(m_printer.retrieve());
41  ATH_CHECK(m_keyRpc.initialize(!m_keyRpc.empty()));
42  ATH_CHECK(m_keyMdt.initialize(!m_keyMdt.empty()));
43  ATH_CHECK(m_keyTgc.initialize(!m_keyTgc.empty()));
44  ATH_CHECK(m_keyCsc.initialize(!m_keyCsc.empty()));
45  ATH_CHECK(m_keysTgc.initialize(!m_keysTgc.empty()));
46  ATH_CHECK(m_keyMM.initialize(!m_keyMM.empty()));
47  ATH_CHECK(m_combis.initialize());
49 
50  return StatusCode::SUCCESS;
51 }
52 
53 StatusCode MuonLayerHoughAlg::execute(const EventContext& ctx) const {
54  const Muon::RpcPrepDataContainer* rpcPrds{nullptr};
55  const Muon::MdtPrepDataContainer* mdtPrds{nullptr};
56  const Muon::TgcPrepDataContainer* tgcPrds{nullptr};
57  const Muon::CscPrepDataContainer* cscPrds{nullptr};
58  const Muon::sTgcPrepDataContainer* stgcPrds{nullptr};
59  const Muon::MMPrepDataContainer* mmPrds{nullptr};
60  ATH_CHECK(retrieveContainer(ctx, m_keyMdt, mdtPrds));
61  ATH_CHECK(retrieveContainer(ctx, m_keyRpc, rpcPrds));
62  ATH_CHECK(retrieveContainer(ctx, m_keyTgc, tgcPrds));
63  ATH_CHECK(retrieveContainer(ctx, m_keyCsc, cscPrds));
64  ATH_CHECK(retrieveContainer(ctx, m_keysTgc, stgcPrds));
65  ATH_CHECK(retrieveContainer(ctx, m_keyMM, mmPrds));
66 
67 
68 
69  ATH_MSG_VERBOSE("calling layer tool ");
70  auto [combis, houghDataPerSectorVec] = m_layerTool->find(mdtPrds, cscPrds, tgcPrds, rpcPrds, stgcPrds, mmPrds, ctx);
72  if (combis) {
73  if (Handle.record(std::move(combis)).isFailure()) {
74  ATH_MSG_WARNING("Failed to record MuonPatternCombinationCollection at MuonLayerHoughCombis");
75  } else {
76  ATH_MSG_DEBUG("Recorded MuonPatternCombinationCollection at MuonLayerHoughCombis: size " << Handle->size());
78  ATH_MSG_INFO("Number of MuonPatternCombinations " << Handle->size() << std::endl << m_printer->print(*Handle));
79  }
80  }
81  } else {
82  ATH_MSG_VERBOSE("CombinationCollection " << m_combis << " is empty, recording");
83  ATH_CHECK(Handle.record(std::make_unique<MuonPatternCombinationCollection>()));
84  }
85 
86  // write hough data to SG
88  if (houghDataPerSectorVec) {
89  ATH_CHECK(handle.record(std::move(houghDataPerSectorVec)));
90  } else {
91  ATH_MSG_VERBOSE("HoughDataPerSectorVec " << m_houghDataPerSectorVecKey << " is empty, recording");
92  ATH_CHECK(handle.record(std::make_unique<Muon::HoughDataPerSectorVec>()));
93  }
94  return StatusCode::SUCCESS;
95 } // execute
MuonLayerHoughAlg::m_keyCsc
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_keyCsc
Definition: MuonLayerHoughAlg.h:30
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:32
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
MuonLayerHoughAlg::m_keyMM
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_keyMM
Definition: MuonLayerHoughAlg.h:33
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonLayerHoughAlg::m_keyRpc
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_keyRpc
Definition: MuonLayerHoughAlg.h:29
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
MuonLayerHoughAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonLayerHoughAlg.cxx:53
MuonPrepDataContainer.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
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:34
MuonLayerHoughAlg::m_printer
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
Definition: MuonLayerHoughAlg.h:38
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonLayerHoughAlg::m_keyMdt
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_keyMdt
Definition: MuonLayerHoughAlg.h:31
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:36
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::retrieveContainer
StatusCode retrieveContainer(const EventContext &ctx, const SG::ReadHandleKey< T > &key, const T *&contPtr) const
Definition: MuonLayerHoughAlg.cxx:20
MuonLayerHoughAlg::m_printSummary
Gaudi::Property< bool > m_printSummary
Definition: MuonLayerHoughAlg.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
MuonLayerHoughAlg::m_keyTgc
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_keyTgc
Definition: MuonLayerHoughAlg.h:28
MuonLayerHoughAlg::m_layerTool
ToolHandle< Muon::IMuonHoughPatternFinderTool > m_layerTool
Definition: MuonLayerHoughAlg.h:39
TgcPrepDataCollection.h
MuonLayerHoughAlg::MuonLayerHoughAlg
MuonLayerHoughAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonLayerHoughAlg.cxx:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:35
ReadHandle.h
Handle class for reading from StoreGate.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37