ATLAS Offline Software
Loading...
Searching...
No Matches
TGC_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
7//================ Initialisation =================
8namespace Muon {
10 ATH_CHECK(m_idHelperSvc.retrieve());
11
12 ATH_CHECK(m_decoder.retrieve());
13
14 // Get ROBDataProviderSvc
15 ATH_CHECK(m_robDataProvider.retrieve());
16
17 m_maxhashtoUse = m_idHelperSvc->tgcIdHelper().module_hash_max();
18
19 ATH_CHECK(m_rdoContainerKey.initialize());
20
21 ATH_CHECK(m_cablingKey.initialize());
22 m_hid2re.fillAllRobIds();
23 // Initialise the container cache if available
25 !m_rdoContainerCacheKey.key().empty()));
26
27 ATH_MSG_INFO("initialize() successful in " << name());
28 return StatusCode::SUCCESS;
29}
30
32 const ROBFragmentList& vecRobs, const EventContext& ctx) const {
33
34 SG::WriteHandle rdoContainerHandle(m_rdoContainerKey, ctx);
35
36 // Split the methods to have one where we use the cache and one where we
37 // just setup the container
38 const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
39 if (!externalCacheRDO) {
40 ATH_CHECK(rdoContainerHandle.record(
41 std::make_unique<TgcRdoContainer>(m_maxhashtoUse)));
42 ATH_MSG_DEBUG("Created TGC container");
43 } else {
45 ATH_CHECK(update.isValid());
46 ATH_CHECK(rdoContainerHandle.record(
47 std::make_unique<TgcRdoContainer>(update.ptr())));
48 ATH_MSG_DEBUG("Created container using cache for "
49 << m_rdoContainerCacheKey.key());
50 }
51
52 TgcRdoContainer* rdoContainer = rdoContainerHandle.ptr();
53
54 // this should never happen, but since we dereference the pointer, we should
55 // check
56 if (!rdoContainer) {
57 ATH_MSG_ERROR("TGC RDO Container is null, cannot decode TGC data");
58 return StatusCode::FAILURE;
59 }
61 static thread_local int DecodeErrCount = 0;
62
63 // Update to range based loop
64 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* fragment : vecRobs) {
65 if (m_decoder->fillCollection(*fragment, *rdoContainer, ctx)
66 .isFailure()) {
67 if (DecodeErrCount < 100) {
68 ATH_MSG_INFO("Problem with TGC ByteStream Decoding!");
69 DecodeErrCount++;
70 } else if (100 == DecodeErrCount) {
72 "Too many Problems with TGC Decoding messages. Turning "
73 "message off.");
74 DecodeErrCount++;
75 }
76 }
77 }
78 ATH_MSG_DEBUG("Size of TgcRdoContainer is " << rdoContainer->size());
79 return StatusCode::SUCCESS;
80}
81
82TGC_RawDataProviderTool::ROBFragmentList
84 const std::vector<IdentifierHash>& rdoIdhVect,
85 const EventContext& ctx) const {
86 ROBFragmentList vecOfRobf;
87 const TgcCablingMap* cabling{};
88 if (!SG::get(cabling, m_cablingKey, ctx).isSuccess()) {
90 "Could not get cabling, return empty vector of ROB fragments");
91 return vecOfRobf;
92 }
93
94 IdContext tgcContext = m_idHelperSvc->tgcIdHelper().module_context();
95
96 std::vector<uint32_t> robIds;
97
98 unsigned int size = rdoIdhVect.size();
99 for (unsigned int i = 0; i < size; ++i) {
100 Identifier Id;
101 if (m_idHelperSvc->tgcIdHelper().get_id(rdoIdhVect[i], Id,
102 &tgcContext)) {
104 "Unable to get TGC Identifier from collection hash id ");
105 continue;
106 }
107 const Identifier tgcId = Id;
108 uint32_t rodId = m_hid2re.getRodID(tgcId, cabling);
109 uint32_t robId = m_hid2re.getRobID(rodId);
110 std::vector<uint32_t>::iterator it_robId =
111 std::find(robIds.begin(), robIds.end(), robId);
112 if (it_robId == robIds.end()) {
113 robIds.push_back(robId);
114 }
115 }
116 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
117 ATH_MSG_VERBOSE("Number of ROB fragments " << vecOfRobf.size());
118 return vecOfRobf;
119}
120
121
122StatusCode TGC_RawDataProviderTool::convert(const EventContext& ctx) const {
123 ROBFragmentList vecOfRobf;
124 m_robDataProvider->getROBData(ctx, m_hid2re.allRobIds(), vecOfRobf);
125 return convertIntoContainer(vecOfRobf, ctx);
126}
127
129 const std::vector<IdentifierHash>& rdoIdhVect,
130 const EventContext& ctx) const {
131 ROBFragmentList vecOfRobf =
132 getROBData(rdoIdhVect, ctx);
133
134 return convertIntoContainer(vecOfRobf, ctx);
135}
136
137} // namespace Muon
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
size_t size() const
Duplicate of fullSize for backwards compatability.
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Rob Data Provider handle.
ToolHandle< ITGC_RodDecoder > m_decoder
Decoder for ROB fragment RDO conversion.
SG::ReadCondHandleKey< Muon::TgcCablingMap > m_cablingKey
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
RDO container key.
SG::UpdateHandleKey< TgcRdo_Cache > m_rdoContainerCacheKey
ROBFragmentList getROBData(const std::vector< IdentifierHash > &rdoIdhVect, const EventContext &ctx) const
Function to get the ROB data from a vector of IdentifierHash.
StatusCode convertIntoContainer(const ROBFragmentList &vecRobs, const EventContext &ctx) const
Method that converts the ROBFragments into the passed container.
virtual StatusCode convert(const EventContext &) const override
EventContext ones.
TGC_Hid2RESrcID m_hid2re
ID converter.
virtual StatusCode initialize() override
Standard AlgTool method.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
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.