ATLAS Offline Software
Loading...
Searching...
No Matches
MDT_RawDataProviderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
11
13 ATH_MSG_VERBOSE("Starting init");
14
15 ATH_MSG_VERBOSE("Getting m_robDataProvider");
16
17 // Get ROBDataProviderSvc
18 ATH_CHECK(m_robDataProvider.retrieve());
19 ATH_CHECK(m_idHelperSvc.retrieve());
20
21 ATH_MSG_VERBOSE("Getting m_decoder");
22
23 // Retrieve decoder
24 ATH_CHECK(m_decoder.retrieve());
25 m_maxhashtoUse = m_idHelperSvc->mdtIdHelper().stationNameIndex("BME") != -1 ? m_idHelperSvc->mdtIdHelper().detectorElement_hash_max()
26 : m_idHelperSvc->mdtIdHelper().module_hash_max();
27
28 ATH_CHECK(m_rdoContainerKey.initialize());
29 ATH_CHECK(m_readKey.initialize());
31
32 ATH_MSG_DEBUG("initialize() successful in " << name());
33 return StatusCode::SUCCESS;
34}
35
36StatusCode Muon::MDT_RawDataProviderTool::convertIntoContainer(const ROBFragmentList & vecRobs,
37 const EventContext& ctx) const {
38
39 ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
40
41 SG::WriteHandle rdoContainerHandle(m_rdoContainerKey, ctx);
42
43 MdtCsmContainer* rdoContainer = nullptr;
44
45 // here we have two paths. The first one we do not use an external cache, so just create
46 // the MDT CSM container and record it. For the second path, we create the container
47 // by passing in the container cache key so that the container is linked with the event
48 // wide cache.
49 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
50 if (!externalCacheRDO) {
51 // without the cache we just record the container
52 ATH_CHECK(rdoContainerHandle.record(std::make_unique<MdtCsmContainer>(m_maxhashtoUse)));
53 ATH_MSG_DEBUG("Created container");
54 rdoContainer = rdoContainerHandle.ptr();
55 } else {
56 // use the cache to get the container
58 ATH_CHECK(update.isValid());
59 ATH_CHECK(rdoContainerHandle.record(std::make_unique<MdtCsmContainer>(update.ptr())));
60 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
61 rdoContainer = rdoContainerHandle.ptr();
62 }
63
64 // this should never happen, but since we dereference the pointer we should check it first
65 if (!rdoContainer) {
66 ATH_MSG_ERROR("MdtCsmContainer is null, cannot convert MDT raw data");
67 return StatusCode::FAILURE;
68 }
69
70
71 ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
72
73 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* frag : vecRobs) {
74 // convert only if data payload is delivered
75 if (frag->rod_ndata() != 0) {
76 m_decoder->fillCollections(*frag, *rdoContainer).ignore();
77 } else {
78 ATH_MSG_DEBUG(" ROB " << MSG::hex << frag->source_id() << " is delivered with an empty payload" );
79 // store the error condition into the StatusCode and continue
80 }
81 }
82 // in presence of errors return FAILURE
83 ATH_MSG_DEBUG("After processing numColls=" << rdoContainer->numberOfCollections());
84 return StatusCode::SUCCESS;
85}
86
88 const EventContext& ctx) const // call decoding function using list of all detector ROBId's
89{
90
91 const MuonMDT_CablingMap* readCdo{};
92 ATH_CHECK(SG::get(readCdo, m_readKey, ctx));
93 return convert(readCdo->getAllROBId(), ctx);
94}
95
96StatusCode Muon::MDT_RawDataProviderTool::convert(const std::vector<IdentifierHash>& HashVec, const EventContext& ctx) const {
97 const MuonMDT_CablingMap* readCdo{};
98 ATH_CHECK(SG::get(readCdo, m_readKey, ctx));
99 return convert(readCdo->getROBId(HashVec, msgStream()), ctx);
100}
101
102StatusCode Muon::MDT_RawDataProviderTool::convert(const std::vector<uint32_t>& robIds,
103 const EventContext& ctx) const {
104 ROBFragmentList vecOfRobf;
105 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
106 return convertIntoContainer(vecOfRobf, ctx); // using the old one
107}
108
109
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
virtual size_t numberOfCollections() const override final
return number of collections
This container provides acces to the MDT RDOs.
const ListOfROB & getAllROBId() const
return the ROD id of a given chamber
uint32_t getROBId(const IdentifierHash &stationCode, MsgStream &log) const
return the ROD id of a given chamber, given the hash id
ToolHandle< MdtROD_Decoder > m_decoder
virtual StatusCode initialize() override
standard Athena-Algorithm method
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode convertIntoContainer(const ROBFragmentList &vecRobs, const EventContext &ctx) const
Convert method.
virtual StatusCode convert(const EventContext &ctx) const override
SG::WriteHandleKey< MdtCsmContainer > m_rdoContainerKey
virtual StatusCode convert() const
IMuonRawDataProviderTool interface - EventContext-based methods.
SG::UpdateHandleKey< MdtCsm_Cache > m_rdoContainerCacheKey
This is the key for the cache for the CSM containers, can be empty.
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_readKey
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.