ATLAS Offline Software
Loading...
Searching...
No Matches
RPC_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
8#include "GaudiKernel/ServiceHandle.h"
10#include "eformat/SourceIdentifier.h"
11
12using eformat::helper::SourceIdentifier;
14
15namespace Muon{
17 // retrieve ROD decoder
18 ATH_CHECK(m_decoder.retrieve());
19
20 ATH_CHECK(m_containerKey.initialize());
21 ATH_CHECK(m_sec.initialize());
22
23 // get ROB data provider service
24 ATH_CHECK(m_robDataProvider.retrieve());
25
26 ATH_CHECK(m_readKey.initialize());
27
28 // Additional initialization from MT class
30 ATH_CHECK(m_idHelperSvc.retrieve());
31
32 // We should only turn off the sector logic when running with cached data a la trigger mode
35 "Cannot write out RpcSectorLogic while running with cached RpcPad containers"
36 " as the RpcSectorLogic is not cached at the same time and the written containers will desync."
37 " Please turn off RpcSectorLogic writing when running with cached bytestream container");
38 return StatusCode::FAILURE;
39 }
40
41 ATH_MSG_INFO("initialize() successful in " << name());
42
43 return StatusCode::SUCCESS;
44}
45
47 const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>& collections,
48 RpcPadContainer* pad, RpcSectorLogicContainer* logic, const bool& decodeSL) const {
49 for (auto itFrag = vecRobs.begin(); itFrag != vecRobs.end(); itFrag++) {
50 // convert only if data payload is delivered
51 if ((**itFrag).rod_ndata() != 0) {
52 std::vector<IdentifierHash> coll = to_be_converted(**itFrag, collections);
53
54 if (m_decoder->fillCollections(**itFrag, *pad, coll, logic, decodeSL).isFailure()) {
55 // store the error conditions into the StatusCode and continue
56 }
57 } else {
58 if (msgLvl(MSG::DEBUG)) {
59 uint32_t sourceId = (**itFrag).source_id();
60 msg(MSG::DEBUG) << " ROB " << MSG::hex << sourceId << " is delivered with an empty payload" << MSG::dec << endmsg;
61 }
62 // store the error condition into the StatusCode and continue
63 }
64 }
65
66 ATH_MSG_DEBUG("After processing, number of collections in container : " << pad->numberOfCollections());
67
68 // in presence of errors return FAILURE
69 return StatusCode::SUCCESS;
70}
71
72std::vector<IdentifierHash> RPC_RawDataProviderTool::to_be_converted(const ROBFragment& robFrag,
73 const std::vector<IdentifierHash>& coll) const {
75 const RpcCablingCondData* readCdo{*readHandle};
76
77 std::vector<IdentifierHash> to_return;
78 if (coll.empty()) {
79 // get SubdetectorId and ModuleId
80 uint32_t source_id = robFrag.rod_source_id();
81 SourceIdentifier sid(source_id);
82 to_return = (readCdo->rod2hash(sid.subdetector_id(), sid.module_id()));
83 } else {
84 uint32_t source_id = robFrag.rod_source_id();
85 std::vector<IdentifierHash>::const_iterator it = coll.begin();
86 to_return.reserve(coll.size());
87 for (; it != coll.end(); ++it) {
88 if (source_id == readCdo->hash2source(*it)) to_return.emplace_back(*it);
89 }
90 }
91
92 return to_return;
93}
94
95StatusCode RPC_RawDataProviderTool::convert(const EventContext& ctx) const {
96 const RpcCablingCondData* readCdo{nullptr};
97 ATH_CHECK(SG::get(readCdo, m_readKey, ctx));
98 return convert(readCdo->giveFullListOfRobIds(), ctx);
99}
100
101StatusCode RPC_RawDataProviderTool::convert(const std::vector<uint32_t>& robIds,
102 const EventContext& ctx) const {
103 std::vector<IdentifierHash> collections;
104 ROBFragmentList vecOfRobf;
105 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
106 return convertIntoContainer(vecOfRobf, collections, ctx);
107}
108
109StatusCode RPC_RawDataProviderTool::convert(const std::vector<IdentifierHash>& rdoIdhVect,
110 const EventContext& ctx) const {
111 const RpcCablingCondData* readCdo{nullptr};
112 ATH_CHECK(SG::get(readCdo, m_readKey, ctx));
113 ROBFragmentList vecOfRobf;
114 std::vector<uint32_t> robIds;
115 ATH_CHECK(readCdo->giveROB_fromRDO(rdoIdhVect, robIds));
116 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
117 return convertIntoContainer(vecOfRobf, rdoIdhVect, ctx);
118}
119
120StatusCode RPC_RawDataProviderTool::convertIntoContainer(const ROBFragmentList& vecRobs,
121 const std::vector<IdentifierHash>& collections,
122 const EventContext& ctx) const {
123 SG::WriteHandle<RpcPadContainer> rdoContainerHandle(m_containerKey, ctx);
125
126 // run 3 mode, here we always try to write the containers
127
128 // Split the methods to have one where we use the cache and one where we just setup the container
129 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
130 if (!externalCacheRDO) {
131 ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(m_idHelperSvc->rpcIdHelper().module_hash_max())));
132 ATH_MSG_DEBUG("Created RpcPadContainer");
133 } else {
135 ATH_CHECK(update.isValid());
136 ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(update.ptr())));
137 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
138 }
139 RpcPadContainer* pad = rdoContainerHandle.ptr();
140
141 RpcSectorLogicContainer* logic = nullptr;
143 ATH_MSG_DEBUG("Writing out RpcSectorLogicContainer");
144 ATH_CHECK(logicHandle.record(std::make_unique<RpcSectorLogicContainer>()));
145 logic = logicHandle.ptr();
146 }
147
148 // pass the containers to the convertIntoContainers function
149 ATH_CHECK(convertIntoContainers(vecRobs, collections, pad, logic, true));
150
151 return StatusCode::SUCCESS;
152}
153}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
virtual size_t numberOfCollections() const override final
return number of collections
SG::WriteHandleKey< RpcPadContainer > m_containerKey
SG::WriteHandleKey< RpcSectorLogicContainer > m_sec
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode convertIntoContainers(const ROBFragmentList &vecRobs, const std::vector< IdentifierHash > &collections, RpcPadContainer *pad, RpcSectorLogicContainer *logic, const bool &decodeSL) const
ToolHandle< IRpcROD_Decoder > m_decoder
SG::UpdateHandleKey< RpcPad_Cache > m_rdoContainerCacheKey
RPC container cache key.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode initialize() override
virtual StatusCode convert() const
Decoding method - IMuonRawDataProviderTool interface (EventContext-based)
std::vector< IdentifierHash > to_be_converted(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, const std::vector< IdentifierHash > &coll) const
StatusCode convertIntoContainer(const ROBFragmentList &vecRobs, const std::vector< IdentifierHash > &collections, const EventContext &ctx) const
Gaudi::Property< bool > m_WriteOutRpcSectorLogic
Turn on/off RpcSectorConfig writing.
SG::ReadCondHandleKey< RpcCablingCondData > m_readKey
StatusCode giveROB_fromRDO(const IdentifierHash rdoHashId, uint32_t &robId) const
const std::vector< uint32_t > & giveFullListOfRobIds() const
std::vector< IdentifierHash > rod2hash(uint16_t subsystem, uint16_t rod) const
uint32_t hash2source(unsigned int h) const
Use IdentifiableContainer with RpcPad.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
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.
MsgStream & msg
Definition testRead.cxx:32