ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonTGC_CnvTools
src
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
5
#include "
TGC_RawDataProviderTool.h
"
6
7
//================ Initialisation =================
8
namespace
Muon
{
9
StatusCode
TGC_RawDataProviderTool::initialize
() {
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
24
ATH_CHECK
(
m_rdoContainerCacheKey
.initialize(
25
!
m_rdoContainerCacheKey
.key().empty()));
26
27
ATH_MSG_INFO
(
"initialize() successful in "
<< name());
28
return
StatusCode::SUCCESS;
29
}
30
31
StatusCode
TGC_RawDataProviderTool::convertIntoContainer
(
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
{
44
SG::UpdateHandle<TgcRdo_Cache>
update(
m_rdoContainerCacheKey
, ctx);
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) {
71
ATH_MSG_INFO
(
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
82
TGC_RawDataProviderTool::ROBFragmentList
83
TGC_RawDataProviderTool::getROBData
(
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()) {
89
ATH_MSG_ERROR
(
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)) {
103
ATH_MSG_WARNING
(
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
122
StatusCode
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
128
StatusCode
TGC_RawDataProviderTool::convert
(
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
size
size_t size() const
Number of registered mappings.
TGC_RawDataProviderTool.h
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition
IdContext.h:26
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition
IdentifiableContainerMT.h:209
Muon::TGC_RawDataProviderTool::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Rob Data Provider handle.
Definition
TGC_RawDataProviderTool.h:70
Muon::TGC_RawDataProviderTool::m_decoder
ToolHandle< ITGC_RodDecoder > m_decoder
Decoder for ROB fragment RDO conversion.
Definition
TGC_RawDataProviderTool.h:58
Muon::TGC_RawDataProviderTool::m_cablingKey
SG::ReadCondHandleKey< Muon::TgcCablingMap > m_cablingKey
Definition
TGC_RawDataProviderTool.h:73
Muon::TGC_RawDataProviderTool::m_rdoContainerKey
SG::WriteHandleKey< TgcRdoContainer > m_rdoContainerKey
RDO container key.
Definition
TGC_RawDataProviderTool.h:61
Muon::TGC_RawDataProviderTool::m_rdoContainerCacheKey
SG::UpdateHandleKey< TgcRdo_Cache > m_rdoContainerCacheKey
Definition
TGC_RawDataProviderTool.h:76
Muon::TGC_RawDataProviderTool::getROBData
ROBFragmentList getROBData(const std::vector< IdentifierHash > &rdoIdhVect, const EventContext &ctx) const
Function to get the ROB data from a vector of IdentifierHash.
Definition
TGC_RawDataProviderTool.cxx:83
Muon::TGC_RawDataProviderTool::convertIntoContainer
StatusCode convertIntoContainer(const ROBFragmentList &vecRobs, const EventContext &ctx) const
Method that converts the ROBFragments into the passed container.
Definition
TGC_RawDataProviderTool.cxx:31
Muon::TGC_RawDataProviderTool::m_maxhashtoUse
unsigned int m_maxhashtoUse
Definition
TGC_RawDataProviderTool.h:65
Muon::TGC_RawDataProviderTool::convert
virtual StatusCode convert(const EventContext &) const override
EventContext ones.
Definition
TGC_RawDataProviderTool.cxx:122
Muon::TGC_RawDataProviderTool::m_hid2re
TGC_Hid2RESrcID m_hid2re
ID converter.
Definition
TGC_RawDataProviderTool.h:68
Muon::TGC_RawDataProviderTool::initialize
virtual StatusCode initialize() override
Standard AlgTool method.
Definition
TGC_RawDataProviderTool.cxx:9
Muon::TGC_RawDataProviderTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
TGC_RawDataProviderTool.h:55
Muon::TgcCablingMap
Definition
TgcCablingMap.h:21
SG::UpdateHandle
Definition
UpdateHandle.h:91
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
TgcRdoContainer
Definition
TgcRdoContainer.h:25
Identifier
Definition
IdentifierFieldParser.cxx:14
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition
TrackSystemController.h:46
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition
RawEvent.h:27
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Generated on
for ATLAS Offline Software by
1.17.0