ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::RpcCablingMap Class Reference

#include <RpcCablingMap.h>

Collaboration diagram for Muon::RpcCablingMap:

Classes

struct  CoolDBEntry
 Helper struct to ship all information from the Database. More...
struct  GasGapToTdcAssociation
 Helper struct to associate all strips in an eta/phi gasGap to the corresponding Tdc. More...
struct  TdcToGasGapAssociation
 Helper struct to associate all Tdcs to their corresponding strips in the gasGap. More...

Public Types

using ChamberToROBMap = std::unordered_map<IdentifierHash, uint32_t>
 typedef to implement the csm mapping to ROB
using ROBToChamberMap = std::unordered_map<uint32_t, std::vector<IdentifierHash>>
using ListOfROB = std::vector<uint32_t>
using FlatCablePtr = GeoModel::TransientConstSharedPtr<Muon::RpcFlatCableTranslator>

Public Member Functions

 RpcCablingMap (const IMuonIdHelperSvc *idHelperSvc)
 Constructor taking the IdHelperSvc.
 ~RpcCablingMap ()
bool getOfflineId (RpcCablingData &cabling_data, MsgStream &log) const
 return the offline id given the online id
bool getOnlineId (RpcCablingData &cabling_data, MsgStream &log) const
 return the online id given the offline id
bool convert (const RpcCablingData &translationCache, Identifier &id, bool checkValid=true) const
 Converts the translation cache back to an Identifier.
bool convert (const Identifier &id, RpcCablingData &translationCache, bool setSideBit) const
 Copies the Identifier field onto the translationCache.
bool insertChannels (CoolDBEntry &&dbEntry, MsgStream &log)
 Inserts a new dbEntry into the map.
std::set< FlatCablePtrflatCables () const
 Returns the list of all Rpc flat cable cards.
bool finalize (MsgStream &log)
 Performs consistency checks for the cabling data (I.e.
uint32_t getROBId (const IdentifierHash &stationCode, MsgStream &log) const
 return the ROD id of a given chamber, given the hash id
ListOfROB getROBId (const std::vector< IdentifierHash > &rpcHashVector, MsgStream &log) const
 get the robs corresponding to a vector of hashIds, copied from Svc before the readCdo migration
const std::vector< IdentifierHash > & getChamberHashVec (const uint32_t ROBI, MsgStream &log) const
 return a HashId list for a given ROD
std::vector< IdentifierHashgetChamberHashVec (const ListOfROB &ROBs, MsgStream &log) const
const ListOfROBgetAllROBId () const
 return the full list of ROD id

Private Types

using AllTdcsPerGasGap = std::vector<GasGapToTdcAssociation>
using AllGasGapsPerTdc = std::vector<TdcToGasGapAssociation>
using OfflToOnlMap = std::map<RpcCablingOfflineID, AllTdcsPerGasGap>
using OnlToOfflMap = std::map<RpcCablingOnlineID, AllGasGapsPerTdc>

Private Attributes

const RpcIdHelperm_rpcIdHelper
 Pointer to the RpcIdHelper.
OnlToOfflMap m_onToOffline {}
 Map storing the connection from online -> offline channels.
OfflToOnlMap m_offToOnline {}
 Map to cache the offline -> online conversions *‍/.
ChamberToROBMap m_chambROBs {}
ROBToChamberMap m_ROBHashes {}
ListOfROB m_listOfROB {}
 full list of ROBs

Detailed Description

Definition at line 27 of file RpcCablingMap.h.

Member Typedef Documentation

◆ AllGasGapsPerTdc

Definition at line 116 of file RpcCablingMap.h.

◆ AllTdcsPerGasGap

Definition at line 115 of file RpcCablingMap.h.

◆ ChamberToROBMap

using Muon::RpcCablingMap::ChamberToROBMap = std::unordered_map<IdentifierHash, uint32_t>

typedef to implement the csm mapping to ROB

Definition at line 31 of file RpcCablingMap.h.

◆ FlatCablePtr

◆ ListOfROB

using Muon::RpcCablingMap::ListOfROB = std::vector<uint32_t>

Definition at line 33 of file RpcCablingMap.h.

◆ OfflToOnlMap

Definition at line 117 of file RpcCablingMap.h.

◆ OnlToOfflMap

Definition at line 118 of file RpcCablingMap.h.

◆ ROBToChamberMap

using Muon::RpcCablingMap::ROBToChamberMap = std::unordered_map<uint32_t, std::vector<IdentifierHash>>

Definition at line 32 of file RpcCablingMap.h.

Constructor & Destructor Documentation

◆ RpcCablingMap()

Muon::RpcCablingMap::RpcCablingMap ( const IMuonIdHelperSvc * idHelperSvc)

Constructor taking the IdHelperSvc.

Definition at line 14 of file RpcCablingMap.cxx.

14 :
15 m_rpcIdHelper{idHelperSvc->rpcIdHelper()}{}
const RpcIdHelper & m_rpcIdHelper
Pointer to the RpcIdHelper.

◆ ~RpcCablingMap()

Muon::RpcCablingMap::~RpcCablingMap ( )
default

Member Function Documentation

◆ convert() [1/2]

bool Muon::RpcCablingMap::convert ( const Identifier & id,
RpcCablingData & translationCache,
bool setSideBit ) const

Copies the Identifier field onto the translationCache.

Parameters
idIdentifier of the offline channel to copy
setSideBitIndicate that the chip is located at the HV side of the chamber (BIL-RPC)

Definition at line 33 of file RpcCablingMap.cxx.

33 {
34 if (!m_rpcIdHelper.is_rpc(channelId)) {
35 return false;
36 }
37 translator.stationIndex = m_rpcIdHelper.stationName(channelId);
38 translator.eta = m_rpcIdHelper.stationEta(channelId);
39 translator.phi = m_rpcIdHelper.stationPhi(channelId);
40 translator.doubletR = m_rpcIdHelper.doubletR(channelId);
41 translator.doubletPhi = m_rpcIdHelper.doubletPhi(channelId);
42 translator.doubletZ = m_rpcIdHelper.doubletZ(channelId);
43 translator.gasGap = m_rpcIdHelper.gasGap(channelId);
44 translator.setMeasPhiAndSide(m_rpcIdHelper.measuresPhi(channelId), setSideBit);
45 translator.strip = m_rpcIdHelper.strip(channelId);
46 return true;
47 }

◆ convert() [2/2]

bool Muon::RpcCablingMap::convert ( const RpcCablingData & translationCache,
Identifier & id,
bool checkValid = true ) const

Converts the translation cache back to an Identifier.

Parameters
translationCacheReference to the translation cache to take the Identifier fields from
idReference to the target Identifier to modify
checkValidChecks whether the resuling Identifier is valid within the boundaries of the associated fields. May trigger the function to return false, but is also tremendously slow!!!

Definition at line 19 of file RpcCablingMap.cxx.

19 {
20 bool valid{!check_valid};
21 id = check_valid
22 ? m_rpcIdHelper.channelID(translator.stationIndex, translator.eta, translator.phi,
23 translator.doubletR, translator.doubletZ,
24 translator.doubletPhi, translator.gasGap,
25 translator.measuresPhi(), translator.strip, valid)
26 : m_rpcIdHelper.channelID(translator.stationIndex, translator.eta, translator.phi,
27 translator.doubletR, translator.doubletZ,
28 translator.doubletPhi, translator.gasGap,
29 translator.measuresPhi(), translator.strip);
30 return valid;
31 }
list valid
Definition calibdata.py:44

◆ finalize()

bool Muon::RpcCablingMap::finalize ( MsgStream & log)

Performs consistency checks for the cabling data (I.e.

looking for 0 strips and overlaps)

Generate the ROB maps

Definition at line 164 of file RpcCablingMap.cxx.

164 {
165 if (m_offToOnline.empty()) {
166 log << MSG::ERROR <<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__
167 <<": finalize() -- No data has been loaded " << endmsg;
168 return false;
169 }
171 RpcCablingData RobOffId{};
172 RobOffId.strip = 1;
173 for (const auto& [card, chambers] : m_onToOffline) {
174 for (const TdcToGasGapAssociation& chamber : chambers) {
175 static_cast<RpcCablingOfflineID&>(RobOffId) = chamber.gasGapID;
176 Identifier chId{0};
177 if (!convert(RobOffId, chId, true)) {
178 log << MSG::ERROR<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__
179 << ": Could not construct an offline identifier from " << chamber.gasGapID << endmsg;
180 return false;
181 }
182 IdentifierHash hash{0};
183 if (m_rpcIdHelper.get_module_hash(chId, hash)) {
184 log << MSG::ERROR <<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__
185 << ": Failed to generate a hash for " << chamber.gasGapID << endmsg;
186 return false;
187 }
188 uint32_t hardId = (card.subDetector << 16) | card.boardSector;
189 m_chambROBs[hash] = hardId;
190 std::vector<IdentifierHash>& robHashes = m_ROBHashes[hardId];
191 if (std::ranges::find(robHashes, hash) == robHashes.end()){
192 robHashes.push_back(hash);
193 }
194 }
195 }
196 return true;
197 }
#define endmsg
OnlToOfflMap m_onToOffline
Map storing the connection from online -> offline channels.
OfflToOnlMap m_offToOnline
Map to cache the offline -> online conversions *‍/.
bool convert(const RpcCablingData &translationCache, Identifier &id, bool checkValid=true) const
Converts the translation cache back to an Identifier.
ROBToChamberMap m_ROBHashes
ChamberToROBMap m_chambROBs
setEventNumber uint32_t
Helper struct to associate all Tdcs to their corresponding strips in the gasGap.

◆ flatCables()

std::set< RpcCablingMap::FlatCablePtr > Muon::RpcCablingMap::flatCables ( ) const

Returns the list of all Rpc flat cable cards.

Definition at line 242 of file RpcCablingMap.cxx.

242 {
243 std::set<FlatCablePtr> cables{};
244 for (const auto &[offId, gapToTdcs] : m_offToOnline) {
245 for (const GasGapToTdcAssociation& assoc : gapToTdcs){
246 cables.insert(assoc.flatCable);
247 }
248 }
249 return cables;
250 }
Helper struct to associate all strips in an eta/phi gasGap to the corresponding Tdc.

◆ getAllROBId()

const RpcCablingMap::ListOfROB & Muon::RpcCablingMap::getAllROBId ( ) const

return the full list of ROD id

Definition at line 239 of file RpcCablingMap.cxx.

239 {
240 return m_listOfROB;
241 }
ListOfROB m_listOfROB
full list of ROBs

◆ getChamberHashVec() [1/2]

std::vector< IdentifierHash > Muon::RpcCablingMap::getChamberHashVec ( const ListOfROB & ROBs,
MsgStream & log ) const

Definition at line 228 of file RpcCablingMap.cxx.

228 {
229 std::unordered_set<IdentifierHash> hashSet{};
230 for (const uint32_t rob : ROBs) {
231 const std::vector<IdentifierHash>& hashFromROB = getChamberHashVec(rob, log);
232 hashSet.insert(hashFromROB.begin(), hashFromROB.end());
233 }
234 std::vector<IdentifierHash> hashVec{};
235 hashVec.insert(hashVec.end(), hashSet.begin(), hashSet.end());
236 return hashVec;
237 }
const std::vector< IdentifierHash > & getChamberHashVec(const uint32_t ROBI, MsgStream &log) const
return a HashId list for a given ROD

◆ getChamberHashVec() [2/2]

const std::vector< IdentifierHash > & Muon::RpcCablingMap::getChamberHashVec ( const uint32_t ROBI,
MsgStream & log ) const

return a HashId list for a given ROD

Definition at line 217 of file RpcCablingMap.cxx.

217 {
218 ROBToChamberMap::const_iterator itr = m_ROBHashes.find(ROBI);
219 if (itr != m_ROBHashes.end()){
220 return itr->second;
221 }
222 if (log.level() <= MSG::WARNING) {
223 log << MSG::WARNING << "ROB ID " << ROBI << " not found ! " << endmsg;
224 }
225 static const std::vector<IdentifierHash> dummy;
226 return dummy;
227 }

◆ getOfflineId()

bool Muon::RpcCablingMap::getOfflineId ( RpcCablingData & cabling_data,
MsgStream & log ) const

return the offline id given the online id

The channel is not connected to this slot

Assign the chamber

Definition at line 93 of file RpcCablingMap.cxx.

93 {
94 OnlToOfflMap::const_iterator itr = m_onToOffline.find(translatorCache);
95 if (itr == m_onToOffline.end()) {
96 log << MSG::DEBUG <<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": The tdc chip "
97 << static_cast<const RpcCablingOnlineID&>(translatorCache) << " is unknown " << endmsg;
98 return false;
99 }
100 for (const TdcToGasGapAssociation& connectChamb: itr->second) {
101 const std::optional<uint8_t> stripCh = connectChamb.flatCable->stripChannel(translatorCache.channelId, log);
103 if (!stripCh) {
104 continue;
105 }
107 static_cast<RpcCablingOfflineID&>(translatorCache) = connectChamb.gasGapID;
108 translatorCache.strip = (*stripCh) + connectChamb.firstStrip;
109 if (log.level() <= MSG::DEBUG) {
110 log <<MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": -- Card "
111 <<connectChamb.gasGapID<<", strip: "<<static_cast<int>(translatorCache.strip)<<endmsg;
112 }
113 return true;
114 }
115 log << MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": No tdc channel could be found for the object "
116 << static_cast<const RpcCablingOnlineID&>(translatorCache)
117 << " tdc: " << static_cast<int>(translatorCache.channelId) << endmsg;
118
119 return false;
120 }

◆ getOnlineId()

bool Muon::RpcCablingMap::getOnlineId ( RpcCablingData & cabling_data,
MsgStream & log ) const

return the online id given the offline id

get the online id from the offline id

Assign the TDC / tdcSector / subDetector ID

Definition at line 50 of file RpcCablingMap.cxx.

50 {
51 if (log.level()<= MSG::DEBUG) {
52 log<<MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": test "<<translatorCache<<endmsg;
53 }
54 const RpcCablingOfflineID& offId{translatorCache};
55 OfflToOnlMap::const_iterator itr = m_offToOnline.find(offId);
56 if (itr == m_offToOnline.end()) {
57 log << MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": The offline identifier "
58 << offId << " is unknown " << endmsg;
59 return false;
60 }
61 const AllTdcsPerGasGap& tdcs{itr->second};
63 if (log.level() <= MSG::DEBUG) {
64 log<<MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": Chamber "<<offId<<" has "
65 <<tdcs.size()<<" cards "<<endmsg;
66 }
67
68 const AllTdcsPerGasGap::const_iterator onlineCardItr =
69 std::ranges::find_if(tdcs, [&translatorCache](const GasGapToTdcAssociation& tdc){
70 return tdc.firstStrip + RpcFlatCableTranslator::readStrips > translatorCache.strip
71 && tdc.firstStrip <= translatorCache.strip;
72 });
73 if (onlineCardItr != itr->second.end()) {
74 const GasGapToTdcAssociation& onlineCard = (*onlineCardItr);
76 std::optional<uint8_t> tdcChannel = onlineCard.flatCable->tdcChannel(translatorCache.strip, log);
77 if (tdcChannel) {
78 static_cast<RpcCablingOnlineID&>(translatorCache) = onlineCard.tdcID;
79 translatorCache.channelId = (*tdcChannel);
80 if (log.level() <= MSG::DEBUG) {
81 log <<MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": Mapped to card "
82 <<onlineCard.tdcID<<", channel: "<<static_cast<int>(translatorCache.channelId)<<endmsg;
83 }
84 return true;
85 } else if (log.level() <= MSG::DEBUG) {
86 log <<MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<":\n"<<(*onlineCard.flatCable)<<endmsg;
87 }
88 }
89 log << MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": No tdc channel could be found for the object "
90 << static_cast<const RpcCablingOfflineID&>(translatorCache)<< " strip: " << static_cast<int>(translatorCache.strip) << endmsg;
91 return false;
92 }
std::vector< GasGapToTdcAssociation > AllTdcsPerGasGap
std::optional< uint8_t > tdcChannel(uint8_t strip, MsgStream &log) const
Returns the connected tdc channel connected to a strip.
static constexpr uint8_t readStrips
Number of channels covered by one chip.
FlatCablePtr flatCable
Pointer to the flat cable card.

◆ getROBId() [1/2]

uint32_t Muon::RpcCablingMap::getROBId ( const IdentifierHash & stationCode,
MsgStream & log ) const

return the ROD id of a given chamber, given the hash id

Definition at line 198 of file RpcCablingMap.cxx.

198 {
199 ChamberToROBMap::const_iterator it = m_chambROBs.find(stationCode);
200 if (it != m_chambROBs.end()) {
201 return it->second;
202 }
203 if (log.level() <= MSG::WARNING) {
204 log << MSG::WARNING << "Station code " << stationCode << " not found !! "<< endmsg;
205 }
206 return 0;
207 }

◆ getROBId() [2/2]

RpcCablingMap::ListOfROB Muon::RpcCablingMap::getROBId ( const std::vector< IdentifierHash > & rpcHashVector,
MsgStream & log ) const

get the robs corresponding to a vector of hashIds, copied from Svc before the readCdo migration

Definition at line 209 of file RpcCablingMap.cxx.

209 {
210 ListOfROB toRet{};
211 toRet.reserve(rpcHashVector.size());
212 for (const IdentifierHash& hash : rpcHashVector) {
213 toRet.push_back(getROBId(hash, log));
214 }
215 return toRet;
216 }
std::vector< uint32_t > ListOfROB
uint32_t getROBId(const IdentifierHash &stationCode, MsgStream &log) const
return the ROD id of a given chamber, given the hash id

◆ insertChannels()

bool Muon::RpcCablingMap::insertChannels ( CoolDBEntry && dbEntry,
MsgStream & log )

Inserts a new dbEntry into the map.

Parameters
dbEntryReference to all the DB information to insert
logRefernce to the MsgStream of the executing algorithm to report failures & debugs

Definition at line 122 of file RpcCablingMap.cxx.

122 {
123 RpcCablingOfflineID offCh{entry};
124 RpcCablingOnlineID onlCh{entry};
125 GasGapToTdcAssociation offToOnl{};
126 offToOnl.tdcID = onlCh;
127 offToOnl.flatCable = entry.flatCable;
128 offToOnl.firstStrip = entry.firstStrip;
129
130 m_offToOnline[offCh].emplace_back(std::move(offToOnl));
131 std::ranges::sort(m_offToOnline[offCh],
133 return a.firstStrip < b.firstStrip;
134 });
135
136 TdcToGasGapAssociation onlToOff{};
137 onlToOff.gasGapID = offCh;
138 onlToOff.firstStrip = entry.firstStrip - RpcFlatCableTranslator::firstStrip;
139 onlToOff.flatCable = entry.flatCable;
140 m_onToOffline[onlCh].push_back(std::move(onlToOff));
141 std::ranges::sort(m_onToOffline[onlCh],
143 return a.firstStrip < b.firstStrip;
144 });
145
146 if (log.level()<= MSG::DEBUG) {
147 log<<MSG::DEBUG<<"RpcCablingMap::"<<__func__<<"() - "<<__LINE__<<": Add new cabling channel "
148 <<offCh<<std::format("firstStrip: {:2d}", entry.firstStrip)<<" - "<<onlCh
149 <<std::format("flatCable: {:2d}", entry.flatCable->id())<<endmsg;
150 }
151
152 int sub = entry.subDetector;
153 int rod = entry.boardSector;
154
155 int32_t hardId = (sub << 16) | rod;
156
157 const bool robInitialized = std::find(m_listOfROB.begin(), m_listOfROB.end(), hardId) != m_listOfROB.end();
158 if (!robInitialized) {
159 m_listOfROB.push_back(hardId);
160 }
161
162 return true;
163 }
static Double_t a
static constexpr uint8_t firstStrip
Convention of the lowest strip number.
RpcCablingOnlineID tdcID
Associated tdc chip.
RpcCablingOfflineID gasGapID
Associated tdc chip.

Member Data Documentation

◆ m_chambROBs

ChamberToROBMap Muon::RpcCablingMap::m_chambROBs {}
private

Definition at line 125 of file RpcCablingMap.h.

125{};

◆ m_listOfROB

ListOfROB Muon::RpcCablingMap::m_listOfROB {}
private

full list of ROBs

Definition at line 129 of file RpcCablingMap.h.

129{};

◆ m_offToOnline

OfflToOnlMap Muon::RpcCablingMap::m_offToOnline {}
private

Map to cache the offline -> online conversions *‍/.

Definition at line 123 of file RpcCablingMap.h.

123{};

◆ m_onToOffline

OnlToOfflMap Muon::RpcCablingMap::m_onToOffline {}
private

Map storing the connection from online -> offline channels.

Definition at line 121 of file RpcCablingMap.h.

121{};

◆ m_ROBHashes

ROBToChamberMap Muon::RpcCablingMap::m_ROBHashes {}
private

Definition at line 126 of file RpcCablingMap.h.

126{};

◆ m_rpcIdHelper

const RpcIdHelper& Muon::RpcCablingMap::m_rpcIdHelper
private

Pointer to the RpcIdHelper.

Definition at line 114 of file RpcCablingMap.h.


The documentation for this class was generated from the following files: