ATLAS Offline Software
Loading...
Searching...
No Matches
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
9MuonCombinedInDetExtensionAlg::MuonCombinedInDetExtensionAlg(const std::string& name, ISvcLocator* pSvcLocator) :
10 AthReentrantAlgorithm(name, pSvcLocator) {}
11
13 ATH_MSG_VERBOSE(" usePRDs = " << m_usePRDs);
22 ATH_CHECK(m_tagMap.initialize());
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
30StatusCode MuonCombinedInDetExtensionAlg::execute(const EventContext& ctx) const {
32 if (!indetCandidateCollection.isValid()) {
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
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) {
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}
68template <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}
83template <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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_TGC_ContainerName
SG::WriteHandleKey< TrackCollection > m_METracks
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_MM_ContainerName
MuonCombinedInDetExtensionAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< MuonCombined::InDetCandidateToTagMap > m_tagMap
SG::WriteHandleKey< Trk::SegmentCollection > m_segments
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_sTGC_ContainerName
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_CSC_ContainerName
SG::ReadHandleKey< InDetCandidateCollection > m_indetCandidateCollectionName
StatusCode loadPrdContainer(const EventContext &ctx, const SG::ReadHandleKey< ContType > &key, const ContType *&target_ptr) const
SG::WriteHandleKey< TrackCollection > m_combTracks
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_MDT_ContainerName
StatusCode execute(const EventContext &ctx) const override
ToolHandle< MuonCombined::IMuonCombinedInDetExtensionTool > m_muonCombinedInDetExtensionTool
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_RPC_ContainerName
StatusCode record(const EventContext &ctx, const SG::WriteHandleKey< ContType > &key, ContType *&target_ptr) const
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
DataVector< Trk::Segment > SegmentCollection