ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCablings
MuonCablingData
src
RpcFlatCableTranslator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include <
MuonCablingData/RpcFlatCableTranslator.h
>
5
#include <
AthenaBaseComps/AthMessaging.h
>
6
#include <iostream>
7
#include <format>
8
9
10
namespace
Muon
{
11
std::ostream &
operator<<
(std::ostream &ostr,
const
RpcFlatCableTranslator
&
map
) {
12
ostr <<
"flat-cable: "
<<
static_cast<
unsigned
>
(
map
.id()) <<
", \n tdcs: "
;
13
auto
dumpMapping = [&ostr](
const
RpcFlatCableTranslator::Storage_t
&s) {
14
for
(
size_t
p = 0; p <
RpcFlatCableTranslator::readStrips
; ++p) {
15
const
unsigned
int
ch = s[p];
16
if
(ch !=
RpcFlatCableTranslator::notSet
) {
17
ostr << std::format(
"{:2d}{:}"
, ch+1, (p + 1) !=
RpcFlatCableTranslator::readStrips
?
" "
:
""
);
18
}
19
else
{
20
ostr << std::format(
"--{:}"
, (p + 1) !=
RpcFlatCableTranslator::readStrips
?
" "
:
""
);
21
}
22
}
23
};
24
dumpMapping(
map
.tdcMap());
25
ostr <<
"\n strips: "
;
26
dumpMapping(
map
.stripMap());
27
return
ostr;
28
}
29
30
RpcFlatCableTranslator::RpcFlatCableTranslator
(
const
uint8_t cardId):
31
m_id
{cardId} {}
32
33
uint8_t
RpcFlatCableTranslator::connectedChannels
()
const
{
return
m_nCh
; }
34
35
const
RpcFlatCableTranslator::Storage_t
&
RpcFlatCableTranslator::stripMap
()
const
{
return
m_stripToTdc
; }
36
const
RpcFlatCableTranslator::Storage_t
&
RpcFlatCableTranslator::tdcMap
()
const
{
return
m_tdcToStrip
; }
37
38
uint8_t
RpcFlatCableTranslator::id
()
const
{
return
m_id
; }
39
std::optional<uint8_t>
RpcFlatCableTranslator::tdcChannel
(uint8_t
strip
, MsgStream& log)
const
{
40
const
uint8_t mapStrip = (
strip
-
firstStrip
) %
readStrips
;
41
if
(
m_stripToTdc
[mapStrip] ==
notSet
) {
42
if
(log.level() <= MSG::VERBOSE) {
43
log<<MSG::VERBOSE<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": The channel "
44
<<
static_cast<
unsigned
>
(
strip
)<<
" is unmapped."
<<
endmsg
;
45
}
46
return
std::nullopt;
47
}
48
if
(log.level() <= MSG::VERBOSE) {
49
log<<MSG::VERBOSE<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": Map channel "
50
<<
static_cast<
unsigned
>
(
strip
)<<
" to tdc "
<<
static_cast<
unsigned
>
(
m_stripToTdc
[mapStrip] +
firstTdc
)<<
endmsg
;
51
}
52
return
std::make_optional<uint8_t>(
m_stripToTdc
[mapStrip] +
firstTdc
);
53
}
54
std::optional<uint8_t>
RpcFlatCableTranslator::stripChannel
(uint8_t
tdcChannel
, MsgStream& log)
const
{
55
const
uint8_t mapTdc = (
tdcChannel
-
firstTdc
);
56
if
(mapTdc >=
readStrips
) {
57
if
( log.level() <= MSG::WARNING){
58
log<<MSG::WARNING<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": The parsed tdc "
59
<<
static_cast<
unsigned
>
(
tdcChannel
)<<
" is out of range"
<<
endmsg
;
60
}
61
return
std::nullopt;
//don't proceed out-of-bounds array access is possible
62
}
63
//mapTdc used as index into array here
64
if
(
m_tdcToStrip
[mapTdc] ==
notSet
) {
65
if
(log.level() <= MSG::VERBOSE){
66
log<<MSG::VERBOSE<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": The parsed tdc "
67
<<
static_cast<
unsigned
>
(
tdcChannel
)<<
" is not connected."
<<
endmsg
;
68
}
69
return
std::nullopt;
70
}
71
return
m_tdcToStrip
[mapTdc] +
firstStrip
;
72
}
73
bool
RpcFlatCableTranslator::mapChannels
(uint8_t
strip
, uint8_t tdc, MsgStream& log) {
74
const
uint8_t mapStrip =
strip
-
firstStrip
;
75
const
uint8_t mapTdc = tdc -
firstTdc
;
76
if
(mapStrip >=
readStrips
or mapTdc>=
readStrips
){
77
log<<MSG::ERROR<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": The mapStrip "
<<mapStrip
78
<<
"or mapTdc "
<<mapTdc<<
" is out of range 0-31."
<<
endmsg
;
79
return
false
;
80
}
81
if
(
m_stripToTdc
[mapStrip] !=
notSet
){
82
log<<MSG::ERROR<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": The strip "
<<
static_cast<
unsigned
>
(
strip
)
83
<<
" is already mapped to "
<<
static_cast<
unsigned
>
(
m_stripToTdc
[mapStrip] +
firstTdc
)<<std::endl<<(*this)<<
endmsg
;
84
return
false
;
85
}
86
if
(
m_tdcToStrip
[mapTdc] !=
notSet
){
87
log<<MSG::ERROR<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": The strip "
<<
static_cast<
unsigned
>
(
strip
)
88
<<
" is already mapped to "
<<
static_cast<
unsigned
>
(
m_tdcToStrip
[mapTdc] +
firstStrip
)<<std::endl<<(*this)<<
endmsg
;
89
return
false
;
90
}
91
m_stripToTdc
[mapStrip] = mapTdc;
92
m_tdcToStrip
[mapTdc] = mapStrip;
93
++
m_nCh
;
94
if
(log.level() <= MSG::VERBOSE) {
95
log<<MSG::VERBOSE<<
"RpcFlatCableTranslator::"
<<__func__<<
"() - "
<<__LINE__<<
": Map strip "
<<
static_cast<
unsigned
>
(
strip
)
96
<<
" to tdc "
<<
static_cast<
unsigned
>
(tdc)<<
endmsg
;
97
}
98
return
true
;
99
}
100
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
AthMessaging.h
SiliconTech::strip
@ strip
Definition
FPGATrackSimTypes.h:25
RpcFlatCableTranslator.h
Muon::RpcFlatCableTranslator
Definition
RpcFlatCableTranslator.h:19
Muon::RpcFlatCableTranslator::Storage_t
std::array< uint8_t, readStrips > Storage_t
Internal storage array.
Definition
RpcFlatCableTranslator.h:30
Muon::RpcFlatCableTranslator::stripMap
const Storage_t & stripMap() const
Returns underlying strip mapping storage.
Definition
RpcFlatCableTranslator.cxx:35
Muon::RpcFlatCableTranslator::firstStrip
static constexpr uint8_t firstStrip
Convention of the lowest strip number.
Definition
RpcFlatCableTranslator.h:26
Muon::RpcFlatCableTranslator::RpcFlatCableTranslator
RpcFlatCableTranslator(const uint8_t cardId)
Standard constructor taking the card ID as input.
Definition
RpcFlatCableTranslator.cxx:30
Muon::RpcFlatCableTranslator::mapChannels
bool mapChannels(uint8_t strip, uint8_t tdc, MsgStream &log)
Connect the strip with a tdc channel.
Definition
RpcFlatCableTranslator.cxx:73
Muon::RpcFlatCableTranslator::m_id
uint8_t m_id
Definition
RpcFlatCableTranslator.h:60
Muon::RpcFlatCableTranslator::id
uint8_t id() const
Identifier of the card layout.
Definition
RpcFlatCableTranslator.cxx:38
Muon::RpcFlatCableTranslator::tdcChannel
std::optional< uint8_t > tdcChannel(uint8_t strip, MsgStream &log) const
Returns the connected tdc channel connected to a strip.
Definition
RpcFlatCableTranslator.cxx:39
Muon::RpcFlatCableTranslator::connectedChannels
uint8_t connectedChannels() const
Number of connected channels.
Definition
RpcFlatCableTranslator.cxx:33
Muon::RpcFlatCableTranslator::m_nCh
uint8_t m_nCh
Number of channels that are connected to the cable.
Definition
RpcFlatCableTranslator.h:62
Muon::RpcFlatCableTranslator::readStrips
static constexpr uint8_t readStrips
Number of channels covered by one chip.
Definition
RpcFlatCableTranslator.h:22
Muon::RpcFlatCableTranslator::firstTdc
static constexpr uint8_t firstTdc
Convention of the lowest tdc number.
Definition
RpcFlatCableTranslator.h:28
Muon::RpcFlatCableTranslator::tdcMap
const Storage_t & tdcMap() const
Returns the underlying tdc mapping storage.
Definition
RpcFlatCableTranslator.cxx:36
Muon::RpcFlatCableTranslator::notSet
static constexpr uint8_t notSet
Default value indicating that the channel is not set.
Definition
RpcFlatCableTranslator.h:24
Muon::RpcFlatCableTranslator::m_stripToTdc
Storage_t m_stripToTdc
Definition
RpcFlatCableTranslator.h:58
Muon::RpcFlatCableTranslator::stripChannel
std::optional< uint8_t > stripChannel(uint8_t tdcChannel, MsgStream &log) const
Returns the strip channel connected to a strip.
Definition
RpcFlatCableTranslator.cxx:54
Muon::RpcFlatCableTranslator::m_tdcToStrip
Storage_t m_tdcToStrip
Definition
RpcFlatCableTranslator.h:59
map
STL class.
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition
TrackSystemController.h:46
Muon::operator<<
std::ostream & operator<<(std::ostream &ostr, const Muon::HedgehogBoard &board)
Definition
HedgehogBoard.cxx:11
Generated on
for ATLAS Offline Software by
1.17.0