ATLAS Offline Software
RpcFlatCableTranslator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
6 #include <format>
7 
8 
9 namespace Muon{
10  std::ostream &operator<<(std::ostream &ostr, const RpcFlatCableTranslator &map) {
11  ostr << "flat-cable: " <<static_cast<unsigned>(map.id()) << ", \n tdcs: ";
12  auto dumpMapping = [&ostr](const RpcFlatCableTranslator::Storage_t &s) {
13  for (size_t p = 0; p < RpcFlatCableTranslator::readStrips; ++p) {
14  const unsigned int ch = s[p];
16  ostr << std::format("{:2d}{:}", ch+1, (p + 1) != RpcFlatCableTranslator::readStrips ? " " : "");
17  }
18  else {
19  ostr << std::format("--{:}", (p + 1) != RpcFlatCableTranslator::readStrips ? " " : "");
20  }
21  }
22  };
23  dumpMapping(map.tdcMap());
24  ostr << "\n strips: ";
25  dumpMapping(map.stripMap());
26  return ostr;
27  }
28 
30  m_id{cardId} {}
31 
33 
36 
38  std::optional<uint8_t> RpcFlatCableTranslator::tdcChannel(uint8_t strip, MsgStream& log) const {
39  const uint8_t mapStrip = (strip - firstStrip) % readStrips;
40  if (m_stripToTdc[mapStrip] == notSet) {
41  if (log.level() <= MSG::VERBOSE) {
42  log<<MSG::VERBOSE<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": The channel "
43  <<static_cast<unsigned>(strip)<<" is unmapped."<<endmsg;
44  }
45  return std::nullopt;
46  }
47  if (log.level() <= MSG::VERBOSE) {
48  log<<MSG::VERBOSE<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": Map channel "
49  <<static_cast<unsigned>(strip)<<" to tdc "<<static_cast<unsigned>(m_stripToTdc[mapStrip] + firstTdc)<<endmsg;
50  }
51  return std::make_optional<uint8_t>(m_stripToTdc[mapStrip] + firstTdc);
52  }
53  std::optional<uint8_t> RpcFlatCableTranslator::stripChannel(uint8_t tdcChannel, MsgStream& log) const {
54  const uint8_t mapTdc = (tdcChannel - firstTdc);
55  if (mapTdc >= readStrips && log.level() <= MSG::WARNING) {
56  log<<MSG::WARNING<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": The parsed tdc "
57  <<static_cast<unsigned>(tdcChannel)<<" is out of range"<<endmsg;
58  return std::nullopt;
59  }
60  if (m_tdcToStrip[mapTdc] == notSet) {
61  if (log.level() <= MSG::VERBOSE){
62  log<<MSG::VERBOSE<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": The parsed tdc "
63  <<static_cast<unsigned>(tdcChannel)<<" is not connected."<<endmsg;
64  }
65  return std::nullopt;
66  }
67  return m_tdcToStrip[mapTdc] + firstStrip;
68  }
69  bool RpcFlatCableTranslator::mapChannels(uint8_t strip, uint8_t tdc, MsgStream& log) {
70  const uint8_t mapStrip = strip - firstStrip;
71  const uint8_t mapTdc = tdc - firstTdc;
72  if (mapStrip >= readStrips || m_stripToTdc[mapStrip] != notSet){
73  log<<MSG::ERROR<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": The strip "<<static_cast<unsigned>(strip)
74  <<" is already mapped to "<<static_cast<unsigned>(m_stripToTdc[mapStrip] + firstTdc)<<std::endl<<(*this)<<endmsg;
75  return false;
76  }
77  if (mapTdc >= readStrips || m_tdcToStrip[mapTdc] != notSet){
78  log<<MSG::ERROR<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": The strip "<<static_cast<unsigned>(strip)
79  <<" is already mapped to "<<static_cast<unsigned>(m_tdcToStrip[mapTdc] + firstStrip)<<std::endl<<(*this)<<endmsg;
80  return false;
81  }
82  m_stripToTdc[mapStrip] = mapTdc;
83  m_tdcToStrip[mapTdc] = mapStrip;
84  ++m_nCh;
85  if (log.level() <= MSG::VERBOSE) {
86  log<<MSG::VERBOSE<<"RpcFlatCableTranslator::"<<__func__<<"() - "<<__LINE__<<": Map strip "<<static_cast<unsigned>(strip)
87  <<" to tdc "<<static_cast<unsigned>(tdc)<<endmsg;
88  }
89  return true;
90  }
91 }
Muon::RpcFlatCableTranslator::readStrips
static constexpr uint8_t readStrips
Number of channels covered by one chip.
Definition: RpcFlatCableTranslator.h:21
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Muon::RpcFlatCableTranslator::m_stripToTdc
Storage_t m_stripToTdc
Definition: RpcFlatCableTranslator.h:57
vtune_athena.format
format
Definition: vtune_athena.py:14
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Muon::RpcFlatCableTranslator::mapChannels
bool mapChannels(uint8_t strip, uint8_t tdc, MsgStream &log)
Connect the strip with a tdc channel.
Definition: RpcFlatCableTranslator.cxx:69
Muon::RpcFlatCableTranslator::notSet
static constexpr uint8_t notSet
Default value indicating that the channel is not set.
Definition: RpcFlatCableTranslator.h:23
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
Muon::RpcFlatCableTranslator::connectedChannels
uint8_t connectedChannels() const
Number of connected channels.
Definition: RpcFlatCableTranslator.cxx:32
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Muon::RpcFlatCableTranslator::firstTdc
static constexpr uint8_t firstTdc
Convention of the lowest tdc number.
Definition: RpcFlatCableTranslator.h:27
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:38
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Muon::RpcFlatCableTranslator::Storage_t
std::array< uint8_t, readStrips > Storage_t
Internal storage array.
Definition: RpcFlatCableTranslator.h:29
Muon::RpcFlatCableTranslator::m_id
uint8_t m_id
Definition: RpcFlatCableTranslator.h:59
Muon::RpcFlatCableTranslator::id
uint8_t id() const
Identifier of the card layout.
Definition: RpcFlatCableTranslator.cxx:37
Muon::RpcFlatCableTranslator::m_tdcToStrip
Storage_t m_tdcToStrip
Definition: RpcFlatCableTranslator.h:58
Muon::RpcFlatCableTranslator::RpcFlatCableTranslator
RpcFlatCableTranslator(const uint8_t cardId)
Standard constructor taking the card ID as input.
Definition: RpcFlatCableTranslator.cxx:29
Muon::operator<<
std::ostream & operator<<(std::ostream &ostr, const Muon::HedgehogBoard &board)
Definition: HedgehogBoard.cxx:11
RpcFlatCableTranslator.h
Muon::RpcFlatCableTranslator::firstStrip
static constexpr uint8_t firstStrip
Convention of the lowest strip number.
Definition: RpcFlatCableTranslator.h:25
AthMessaging.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
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:53
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
Muon::RpcFlatCableTranslator::tdcMap
const Storage_t & tdcMap() const
Returns the underlying tdc mapping storage.
Definition: RpcFlatCableTranslator.cxx:35
Muon::RpcFlatCableTranslator::stripMap
const Storage_t & stripMap() const
Returns underlying strip mapping storage.
Definition: RpcFlatCableTranslator.cxx:34
Muon::RpcFlatCableTranslator::m_nCh
uint8_t m_nCh
Number of channels that are connected to the cable.
Definition: RpcFlatCableTranslator.h:61
Muon::RpcFlatCableTranslator
Definition: RpcFlatCableTranslator.h:18