ATLAS Offline Software
MuonCombinedInDetExtensionAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 MuonCombinedInDetExtensionAlg::MuonCombinedInDetExtensionAlg(const std::string& name, ISvcLocator* pSvcLocator) :
10  AthReentrantAlgorithm(name, pSvcLocator) {}
11 
13  ATH_MSG_VERBOSE(" usePRDs = " << m_usePRDs);
23  ATH_CHECK(m_combTracks.initialize(!m_combTracks.key().empty()));
24  ATH_CHECK(m_METracks.initialize(!m_METracks.key().empty()));
25  ATH_CHECK(m_segments.initialize(!m_segments.key().empty()));
26 
27  return StatusCode::SUCCESS;
28 }
29 
30 StatusCode MuonCombinedInDetExtensionAlg::execute(const EventContext& ctx) const {
32  if (!indetCandidateCollection.isValid()) {
33  ATH_MSG_ERROR("Could not read " << m_indetCandidateCollectionName);
34  return StatusCode::FAILURE;
35  }
36  ATH_MSG_VERBOSE("Loaded InDetCandidateCollection " << m_indetCandidateCollectionName << " with " << indetCandidateCollection->size()
37  << " elements.");
38  if (msgLvl(MSG::VERBOSE)) {
39  for (const MuonCombined::InDetCandidate* candidate : *indetCandidateCollection){
40  ATH_MSG_VERBOSE(candidate->toString());
41  }
42  }
43 
44 
45  MuonCombined::InDetCandidateToTagMap* tagMap{nullptr};
46  TrackCollection* combTracks{nullptr}, *meTracks{nullptr};
47  Trk::SegmentCollection* segments{nullptr};
48  ATH_CHECK(record(ctx, m_tagMap, tagMap));
49  ATH_CHECK(record(ctx,m_combTracks, combTracks ));
50  ATH_CHECK(record(ctx,m_METracks, meTracks ));
51  ATH_CHECK(record(ctx,m_segments, segments ));
52 
53  if (m_usePRDs) {
55  ATH_CHECK(loadPrdContainer(ctx, m_MDT_ContainerName, prdData.mdtPrds));
56  ATH_CHECK(loadPrdContainer(ctx, m_CSC_ContainerName, prdData.cscPrds));
57  ATH_CHECK(loadPrdContainer(ctx, m_sTGC_ContainerName, prdData.stgcPrds));
58  ATH_CHECK(loadPrdContainer(ctx, m_MM_ContainerName, prdData.mmPrds));
59  ATH_CHECK(loadPrdContainer(ctx, m_RPC_ContainerName, prdData.rpcPrds));
60  ATH_CHECK(loadPrdContainer(ctx, m_TGC_ContainerName, prdData.tgcPrds));
61  m_muonCombinedInDetExtensionTool->extendWithPRDs(*indetCandidateCollection, tagMap, prdData, combTracks, meTracks, segments, ctx);
62 
63  } else {
64  m_muonCombinedInDetExtensionTool->extend(*indetCandidateCollection, tagMap, combTracks, meTracks, segments, ctx);
65  }
66  return StatusCode::SUCCESS;
67 }
68 template <class ContType> StatusCode MuonCombinedInDetExtensionAlg::loadPrdContainer(const EventContext& ctx , const SG::ReadHandleKey<ContType>& key, const ContType* & target_ptr) const{
69  if (key.empty()) {
70  ATH_MSG_DEBUG("loadPrdContainer() -- No key given assume it's intended");
71  target_ptr = nullptr;
72  return StatusCode::SUCCESS;
73  }
74  SG::ReadHandle<ContType> readHandle{key,ctx};
75  if (!readHandle.isValid()) {
76  ATH_MSG_FATAL("Failed to load "<<key.fullKey());
77  return StatusCode::FAILURE;
78  }
79  ATH_MSG_VERBOSE("Loaded successfully "<<key.fullKey());
80  target_ptr = readHandle.cptr();
81  return StatusCode::SUCCESS;
82 }
83 template <class ContType> StatusCode MuonCombinedInDetExtensionAlg::record(const EventContext& ctx, const SG::WriteHandleKey<ContType>& key, ContType* & target_ptr) const {
84  if (key.empty()) {
85  ATH_MSG_VERBOSE("record() -- No key was given... Assume it's intended ");
86  target_ptr = nullptr;
87  return StatusCode::SUCCESS;
88  }
89  SG::WriteHandle<ContType> writeHandle{key, ctx};
90  ATH_CHECK(writeHandle.record(std::make_unique<ContType>()));
91  target_ptr = writeHandle.ptr();
92  ATH_MSG_VERBOSE("record() -- Successfully written "<<key.fullKey());
93  return StatusCode::SUCCESS;
94 }
95 
MuonCombinedInDetExtensionAlg::m_TGC_ContainerName
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_TGC_ContainerName
Definition: MuonCombinedInDetExtensionAlg.h:66
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonCombinedInDetExtensionAlg::m_indetCandidateCollectionName
SG::ReadHandleKey< InDetCandidateCollection > m_indetCandidateCollectionName
Definition: MuonCombinedInDetExtensionAlg.h:42
MuonCombined::InDetCandidateToTagMap
Definition: InDetCandidateToTagMap.h:15
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonCombinedInDetExtensionAlg::m_combTracks
SG::WriteHandleKey< TrackCollection > m_combTracks
Definition: MuonCombinedInDetExtensionAlg.h:90
MuonCombinedInDetExtensionAlg::m_usePRDs
Gaudi::Property< bool > m_usePRDs
Definition: MuonCombinedInDetExtensionAlg.h:109
MuonCombinedInDetExtensionAlg::initialize
StatusCode initialize() override
Definition: MuonCombinedInDetExtensionAlg.cxx:12
MuonCombinedInDetExtensionAlg::m_tagMap
SG::WriteHandleKey< MuonCombined::InDetCandidateToTagMap > m_tagMap
Definition: MuonCombinedInDetExtensionAlg.h:84
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
MuonCombined::InDetCandidate
Definition: InDetCandidate.h:18
MuonCombinedInDetExtensionAlg::m_segments
SG::WriteHandleKey< Trk::SegmentCollection > m_segments
Definition: MuonCombinedInDetExtensionAlg.h:102
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
MuonCombinedInDetExtensionAlg::MuonCombinedInDetExtensionAlg
MuonCombinedInDetExtensionAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonCombinedInDetExtensionAlg.cxx:9
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
MuonCombinedInDetExtensionAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: MuonCombinedInDetExtensionAlg.cxx:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonCombinedInDetExtensionAlg::m_hasSTGC
Gaudi::Property< bool > m_hasSTGC
Definition: MuonCombinedInDetExtensionAlg.h:111
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonCombinedInDetExtensionAlg::m_sTGC_ContainerName
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_sTGC_ContainerName
Definition: MuonCombinedInDetExtensionAlg.h:72
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
MuonCombinedInDetExtensionAlg::m_CSC_ContainerName
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_CSC_ContainerName
Definition: MuonCombinedInDetExtensionAlg.h:54
DataVector< Trk::Track >
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
MuonCandidateCollection.h
MuonCombinedInDetExtensionAlg::m_MDT_ContainerName
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_MDT_ContainerName
Definition: MuonCombinedInDetExtensionAlg.h:48
MuonCombinedInDetExtensionAlg::m_muonCombinedInDetExtensionTool
ToolHandle< MuonCombined::IMuonCombinedInDetExtensionTool > m_muonCombinedInDetExtensionTool
Definition: MuonCombinedInDetExtensionAlg.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonCombinedInDetExtensionAlg::loadPrdContainer
StatusCode loadPrdContainer(const EventContext &ctx, const SG::ReadHandleKey< ContType > &key, const ContType *&target_ptr) const
Definition: MuonCombinedInDetExtensionAlg.cxx:68
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MuonCombinedInDetExtensionAlg::record
StatusCode record(const EventContext &ctx, const SG::WriteHandleKey< ContType > &key, ContType *&target_ptr) const
Definition: MuonCombinedInDetExtensionAlg.cxx:83
MuonCombinedInDetExtensionAlg::m_hasMM
Gaudi::Property< bool > m_hasMM
Definition: MuonCombinedInDetExtensionAlg.h:112
MuonCombinedInDetExtensionAlg::m_RPC_ContainerName
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_RPC_ContainerName
Definition: MuonCombinedInDetExtensionAlg.h:60
MuonCombinedInDetExtensionAlg::m_hasCSC
Gaudi::Property< bool > m_hasCSC
Definition: MuonCombinedInDetExtensionAlg.h:110
MuonCombinedInDetExtensionAlg.h
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
MuonCombined::IMuonCombinedInDetExtensionTool::MuonPrdData
Definition: IMuonCombinedInDetExtensionTool.h:27
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MuonCombinedInDetExtensionAlg::m_METracks
SG::WriteHandleKey< TrackCollection > m_METracks
Definition: MuonCombinedInDetExtensionAlg.h:96
MuonCombinedInDetExtensionAlg::m_MM_ContainerName
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_MM_ContainerName
Definition: MuonCombinedInDetExtensionAlg.h:78
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37