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,
49 const EventContext& ctx) const {
50 for (auto itFrag = vecRobs.begin(); itFrag != vecRobs.end(); itFrag++) {
51 // convert only if data payload is delivered
52 if ((**itFrag).rod_ndata() != 0) {
53 std::vector<IdentifierHash> coll = to_be_converted(**itFrag, collections);
54
55 if (m_decoder->fillCollections(ctx, **itFrag, *pad, coll, logic, decodeSL).isFailure()) {
56 // store the error conditions into the StatusCode and continue
57 }
58 } else {
59 if (msgLvl(MSG::DEBUG)) {
60 uint32_t sourceId = (**itFrag).source_id();
61 msg(MSG::DEBUG) << " ROB " << MSG::hex << sourceId << " is delivered with an empty payload" << MSG::dec << endmsg;
62 }
63 // store the error condition into the StatusCode and continue
64 }
65 }
66
67 ATH_MSG_DEBUG("After processing, number of collections in container : " << pad->numberOfCollections());
68
69 // in presence of errors return FAILURE
70 return StatusCode::SUCCESS;
71}
72
73std::vector<IdentifierHash> RPC_RawDataProviderTool::to_be_converted(const ROBFragment& robFrag,
74 const std::vector<IdentifierHash>& coll) const {
76 const RpcCablingCondData* readCdo{*readHandle};
77
78 std::vector<IdentifierHash> to_return;
79 if (coll.empty()) {
80 // get SubdetectorId and ModuleId
81 uint32_t source_id = robFrag.rod_source_id();
82 SourceIdentifier sid(source_id);
83 to_return = (readCdo->rod2hash(sid.subdetector_id(), sid.module_id()));
84 } else {
85 uint32_t source_id = robFrag.rod_source_id();
86 std::vector<IdentifierHash>::const_iterator it = coll.begin();
87 to_return.reserve(coll.size());
88 for (; it != coll.end(); ++it) {
89 if (source_id == readCdo->hash2source(*it)) to_return.emplace_back(*it);
90 }
91 }
92
93 return to_return;
94}
95
96StatusCode RPC_RawDataProviderTool::convert(const EventContext& ctx) const {
97 const RpcCablingCondData* readCdo{nullptr};
98 ATH_CHECK(SG::get(readCdo, m_readKey, ctx));
99 return convert(readCdo->giveFullListOfRobIds(), ctx);
100}
101
102StatusCode RPC_RawDataProviderTool::convert(const std::vector<uint32_t>& robIds,
103 const EventContext& ctx) const {
104 std::vector<IdentifierHash> collections;
105 ROBFragmentList vecOfRobf;
106 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
107 return convertIntoContainer(vecOfRobf, collections, ctx);
108}
109
110StatusCode RPC_RawDataProviderTool::convert(const std::vector<IdentifierHash>& rdoIdhVect,
111 const EventContext& ctx) const {
112 const RpcCablingCondData* readCdo{nullptr};
113 ATH_CHECK(SG::get(readCdo, m_readKey, ctx));
114 ROBFragmentList vecOfRobf;
115 std::vector<uint32_t> robIds;
116 ATH_CHECK(readCdo->giveROB_fromRDO(rdoIdhVect, robIds));
117 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
118 return convertIntoContainer(vecOfRobf, rdoIdhVect, ctx);
119}
120
121StatusCode RPC_RawDataProviderTool::convertIntoContainer(const ROBFragmentList& vecRobs,
122 const std::vector<IdentifierHash>& collections,
123 const EventContext& ctx) const {
124 SG::WriteHandle<RpcPadContainer> rdoContainerHandle(m_containerKey, ctx);
126
127 // run 3 mode, here we always try to write the containers
128
129 // Split the methods to have one where we use the cache and one where we just setup the container
130 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
131 if (!externalCacheRDO) {
132 ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(m_idHelperSvc->rpcIdHelper().module_hash_max())));
133 ATH_MSG_DEBUG("Created RpcPadContainer");
134 } else {
136 ATH_CHECK(update.isValid());
137 ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(update.ptr())));
138 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
139 }
140 RpcPadContainer* pad = rdoContainerHandle.ptr();
141
142 RpcSectorLogicContainer* logic = nullptr;
144 ATH_MSG_DEBUG("Writing out RpcSectorLogicContainer");
145 ATH_CHECK(logicHandle.record(std::make_unique<RpcSectorLogicContainer>()));
146 logic = logicHandle.ptr();
147 }
148
149 // pass the containers to the convertIntoContainers function
150 ATH_CHECK(convertIntoContainers(vecRobs, collections, pad, logic, true, ctx));
151
152 return StatusCode::SUCCESS;
153}
154}
#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
virtual StatusCode convert(const EventContext &) const override
Decoding method - IMuonRawDataProviderTool interface (EventContext-based).
ToolHandle< IRpcROD_Decoder > m_decoder
SG::UpdateHandleKey< RpcPad_Cache > m_rdoContainerCacheKey
RPC container cache key.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode initialize() override
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
StatusCode convertIntoContainers(const ROBFragmentList &vecRobs, const std::vector< IdentifierHash > &collections, RpcPadContainer *pad, RpcSectorLogicContainer *logic, const bool &decodeSL, 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