ATLAS Offline Software
Loading...
Searching...
No Matches
RPC_RawDataProviderToolMT.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include "GaudiKernel/ServiceHandle.h"
9#include "GaudiKernel/ThreadLocalContext.h"
10
12
13Muon::RPC_RawDataProviderToolMT::RPC_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p) :
14 base_class(t, n, p) {
15}
16
19
21 ATH_CHECK(m_idHelperSvc.retrieve());
22
23 // We should only turn off the sector logic when running with cached data a la trigger mode
26 "Cannot write out RpcSectorLogic while running with cached RpcPad containers"
27 " as the RpcSectorLogic is not cached at the same time and the written containers will desync."
28 " Please turn off RpcSectorLogic writing when running with cached bytestream container");
29 return StatusCode::FAILURE;
30 }
31
32 ATH_MSG_INFO("initialize() successful in " << name());
33
34 return StatusCode::SUCCESS;
35}
36
37// the new one
38StatusCode Muon::RPC_RawDataProviderToolMT::convert() const { return this->convert(Gaudi::Hive::currentContext()); }
39
40StatusCode Muon::RPC_RawDataProviderToolMT::convert(const EventContext& ctx) const {
41 SG::ReadCondHandle<RpcCablingCondData> readHandle{m_readKey, ctx};
42 const RpcCablingCondData* readCdo{*readHandle};
43 // CALLGRIND_START_INSTRUMENTATION
45 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
46 std::vector<uint32_t> robIds = readCdo->giveFullListOfRobIds();
47 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
48 // CALLGRIND_STOP_INSTRUMENTATION
49 return convert(vecOfRobf, ctx); // using the old one
50}
51// the old one
52StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs) const {
53 return this->convert(vecRobs, Gaudi::Hive::currentContext());
54}
55
56StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const EventContext& ctx) const {
57 // CALLGRIND_START_INSTRUMENTATION
58 std::vector<IdentifierHash> collections;
59 // CALLGRIND_STOP_INSTRUMENTATION
60 return convert(vecRobs, collections, ctx);
61}
62
63// the new one
64StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds) const {
65 return this->convert(robIds, Gaudi::Hive::currentContext());
66}
67
68StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds, const EventContext& ctx) const {
69 // CALLGRIND_START_INSTRUMENTATION
70 std::vector<IdentifierHash> collections;
71 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
72 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
73 // CALLGRIND_STOP_INSTRUMENTATION
74 return convert(vecOfRobf, collections, ctx);
75}
76
77// the new one
78StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect) const {
79 return this->convert(rdoIdhVect, Gaudi::Hive::currentContext());
80}
81
82StatusCode Muon::RPC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect, const EventContext& ctx) const {
83 SG::ReadCondHandle<RpcCablingCondData> readHandle{m_readKey, ctx};
84 const RpcCablingCondData* readCdo{*readHandle};
85 // CALLGRIND_START_INSTRUMENTATION
86 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecOfRobf;
87 std::vector<uint32_t> robIds;
88 CHECK(readCdo->giveROB_fromRDO(rdoIdhVect, robIds));
89 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
90 // CALLGRIND_STOP_INSTRUMENTATION
91 return convert(vecOfRobf, rdoIdhVect, ctx); // using the old one
92}
93// the old one
94StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>& collections) const {
95 return this->convert(vecRobs, collections, Gaudi::Hive::currentContext());
96}
97
98StatusCode Muon::RPC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>& collections,
99 const EventContext& ctx) const {
100 // CALLGRIND_START_INSTRUMENTATION
101
102 SG::WriteHandle<RpcPadContainer> rdoContainerHandle(m_containerKey, ctx);
103 SG::WriteHandle<RpcSectorLogicContainer> logicHandle(m_sec, ctx);
104
105 // run 3 mode, here we always try to write the containers
106
107 // Split the methods to have one where we use the cache and one where we just setup the container
108 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
109 if (!externalCacheRDO) {
110 ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(m_idHelperSvc->rpcIdHelper().module_hash_max())));
111 ATH_MSG_DEBUG("Created RpcPadContainer");
112 } else {
114 ATH_CHECK(update.isValid());
115 ATH_CHECK(rdoContainerHandle.record(std::make_unique<RpcPadContainer>(update.ptr())));
116 ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
117 }
118 RpcPadContainer* pad = rdoContainerHandle.ptr();
119
120 RpcSectorLogicContainer* logic = nullptr;
122 ATH_MSG_DEBUG("Writing out RpcSectorLogicContainer");
123 ATH_CHECK(logicHandle.record(std::make_unique<RpcSectorLogicContainer>()));
124 logic = logicHandle.ptr();
125 }
126
127 // pass the containers to the convertIntoContainers function in the RPC_RawDataProviderToolCore base class
128 ATH_CHECK(convertIntoContainers(vecRobs, collections, pad, logic, true));
129
130 return StatusCode::SUCCESS;
131}
#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)
#define CHECK(...)
Evaluate an expression and check for errors.
Gaudi::Property< bool > m_WriteOutRpcSectorLogic
Turn on/off RpcSectorConfig writing.
virtual StatusCode convert() const override
the new ones
virtual StatusCode initialize() override
SG::UpdateHandleKey< RpcPad_Cache > m_rdoContainerCacheKey
RPC container cache key.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
RPC_RawDataProviderToolMT(const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode convert(const ROBFragmentList &vecRobs) const override
Decoding method.
StatusCode giveROB_fromRDO(const IdentifierHash rdoHashId, uint32_t &robId) const
const std::vector< uint32_t > & giveFullListOfRobIds() 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.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27