ATLAS Offline Software
MuonMDT_CablingMap.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONMDT_CABLING_MUONMDT_CABLINGMAP_H
6 #define MUONMDT_CABLING_MUONMDT_CABLINGMAP_H
7 
8 #include <set>
9 
10 #include "AthenaKernel/CLASS_DEF.h"
11 #include "Identifier/Identifier.h"
13 
14 /**********************************************
15  *
16  * @brief MDT map data object
17  *
18  **********************************************/
19 
20 class MdtMezzanineType;
21 class MdtIdHelper;
22 class IdentifierHash;
23 
25  public:
27  using MezzanineTypes = std::map<uint8_t, std::unique_ptr<MdtMezzanineType>>;
28  using TdcOffSet = std::set<MdtTdcOffSorter, std::less<>>;
29  using TdcOnlSet = std::vector<MdtTdcOnlSorter>;
30 
36  // larger number of tubes. The csm caches the up to 2 CSM associated
37  // with this object
38  struct MdtOffChModule {
39  TdcOffSet::const_iterator begin() const { return cards.begin(); }
40  TdcOffSet::const_iterator end() const { return cards.end(); }
41  TdcOffSet::const_iterator begin() { return cards.begin(); }
42  TdcOffSet::const_iterator end() { return cards.end(); }
43 
47  std::array<MdtCablingOnData, 2> csm{};
48  };
49 
50  using OffToOnlMap = std::map<MdtCablingOffData, MdtOffChModule>;
58  struct MdtTdcModule {
59  TdcOnlSet::const_iterator begin() const { return all_modules.begin(); }
60  TdcOnlSet::const_iterator end() const { return all_modules.end(); }
61  TdcOnlSet::const_iterator begin() { return all_modules.begin(); }
62  TdcOnlSet::const_iterator end() { return all_modules.end(); }
63 
65 
67  };
68  using OnlToOffMap = std::map<MdtCablingOnData, MdtTdcModule>;
69 
71  /* mapping from hashid to ROB identifier as Subdetector+Rodid */
72  using ChamberToROBMap = std::map<IdentifierHash, uint32_t>;
73  using ROBToChamberMap = std::map<uint32_t, std::vector<IdentifierHash>>;
74  using ListOfROB = std::vector<uint32_t>;
78 
80  bool addMezzanineLine(const int type, const int layer, const int sequence,
81  MsgStream& log);
82 
84  bool addMezanineLayout(std::unique_ptr<MdtMezzanineCard> card,
85  MsgStream& log);
86 
87  enum class DataSource { JSON, LegacyCOOL };
92  MsgStream& log);
93 
95  bool getOfflineId(CablingData& cabling_data, MsgStream& log) const;
96 
98  bool getOnlineId(CablingData& cabling_data, MsgStream& log) const;
102  bool convert(const CablingData& cabling_data, Identifier& id,
103  bool check_valid = true) const;
106  bool convert(const Identifier& id, CablingData& cabling_data) const;
107 
109  uint32_t getROBId(const IdentifierHash& stationCode, MsgStream& log) const;
112  ListOfROB getROBId(const std::vector<IdentifierHash>& mdtHashVector,
113  MsgStream& log) const;
114 
116  std::vector<IdentifierHash> getMultiLayerHashVec(
117  const std::vector<uint32_t>& ROBId_list, MsgStream& log) const;
118 
120  const std::vector<IdentifierHash>& getMultiLayerHashVec(
121  const uint32_t ROBI, MsgStream& log) const;
122 
124  const ListOfROB& getAllROBId() const;
125 
127  const OnlToOffMap& getOnlineConvMap() const;
129  const OffToOnlMap& getOfflineConvMap() const;
130 
131  bool finalize_init(MsgStream& log);
132 
135  bool getStationCode(const CablingData& map_data, IdentifierHash& mdtHashId,
136  MsgStream& log) const;
139  bool getMultiLayerCode(const CablingData& map_data, Identifier& multiLayer,
140  IdentifierHash& mdtHashId, MsgStream& log) const;
141 
144  unsigned int csmNumOnChamber(const CablingData& map_data,
145  MsgStream& log) const;
148  bool has2CsmML() const;
151  MezzCardPtr getHedgeHogMapping(uint8_t mezzCardId) const;
152 
153  private:
155  bool addChamberToROBMap(const CablingData& cabling_data, MsgStream& log);
156 
158  const MdtIdHelper* m_mdtIdHelper{nullptr};
159 
163 
166  std::vector<std::unique_ptr<MdtTdcMap>> m_tdcs{};
167 
170 
173 
179  bool m_2CSM_cham{false};
180 
182  using MezzCardList = std::vector<MezzCardPtr>;
187 };
188 
189 CLASS_DEF(MuonMDT_CablingMap, 51038731, 1)
190 #include "AthenaKernel/CondCont.h"
192 
193 #endif
MuonMDT_CablingMap::m_ROBToMultiLayer
ROBToChamberMap m_ROBToMultiLayer
map returning a detector element hashes associated with a given ROD
Definition: MuonMDT_CablingMap.h:169
MuonMDT_CablingMap::getStationCode
bool getStationCode(const CablingData &map_data, IdentifierHash &mdtHashId, MsgStream &log) const
Transforms the identifier to an IdentifierHash corresponding to the module.
Definition: MuonMDT_CablingMap.cxx:402
MuonMDT_CablingMap::MuonMDT_CablingMap
MuonMDT_CablingMap()
Definition: MuonMDT_CablingMap.cxx:23
MuonMDT_CablingMap::MdtOffChModule::cards
TdcOffSet cards
Mezzanine cards mounted on the chamber.
Definition: MuonMDT_CablingMap.h:45
MuonMDT_CablingMap::getMultiLayerHashVec
std::vector< IdentifierHash > getMultiLayerHashVec(const std::vector< uint32_t > &ROBId_list, MsgStream &log) const
return a vector of HashId lists for a given list of ROD's
Definition: MuonMDT_CablingMap.cxx:501
MuonMDT_CablingMap::legacyHedgehogCard
MezzCardPtr legacyHedgehogCard(CablingData &cabling, MsgStream &msg) const
In the legacy data format several transformations on the hedgehog layout were applied during the fina...
Definition: MuonMDT_CablingMap.cxx:595
MuonMDT_CablingMap::MdtTdcModule::end
TdcOnlSet::const_iterator end()
Definition: MuonMDT_CablingMap.h:62
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
MuonMDT_CablingMap::addChamberToROBMap
bool addChamberToROBMap(const CablingData &cabling_data, MsgStream &log)
private function to add a chamber to the ROD map
Definition: MuonMDT_CablingMap.cxx:344
MuonMDT_CablingMap::MdtOffChModule::begin
TdcOffSet::const_iterator begin()
Definition: MuonMDT_CablingMap.h:41
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
MuonMDT_CablingMap::addMezzanine
bool addMezzanine(CablingData cabling_data, DataSource source, MsgStream &log)
Add a new fully configured mezzanine card.
Definition: MuonMDT_CablingMap.cxx:184
MuonMDT_CablingMap::ListOfROB
std::vector< uint32_t > ListOfROB
Definition: MuonMDT_CablingMap.h:74
MuonMDT_CablingMap::DataSource::JSON
@ JSON
MuonMDT_CablingMap::ChamberToROBMap
std::map< IdentifierHash, uint32_t > ChamberToROBMap
typedef to implement the csm mapping to ROB
Definition: MuonMDT_CablingMap.h:72
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
MuonMDT_CablingMap::m_toOfflineConv
OnlToOffMap m_toOfflineConv
Definition: MuonMDT_CablingMap.h:165
MuonMDT_CablingMap::convert
bool convert(const CablingData &cabling_data, Identifier &id, bool check_valid=true) const
converts the cabling data into an identifier.
Definition: MuonMDT_CablingMap.cxx:42
createCablingJSON.cabling_data
dictionary cabling_data
Definition: createCablingJSON.py:18
MuonMDT_CablingMap::m_mezzCards
MezzCardList m_mezzCards
Definition: MuonMDT_CablingMap.h:183
MdtTdcOnlSorter
Helper struct to search through the std::set if a conversion from online -> offline is needed.
Definition: MdtTdcMap.h:100
MuonMDT_CablingMap::operator=
MuonMDT_CablingMap & operator=(const MuonMDT_CablingMap &right)=delete
assignment and copy constructor operator (hidden)
MuonMDT_CablingMap::MezzanineTypes
std::map< uint8_t, std::unique_ptr< MdtMezzanineType > > MezzanineTypes
typedef to implement the list of mezzanine types
Definition: MuonMDT_CablingMap.h:27
MuonMDT_CablingMap::MdtTdcModule
The online -> offline conversion needs to treat two cases tdcId && channelId == 0xFF: ** Decode the s...
Definition: MuonMDT_CablingMap.h:58
MuonMDT_CablingMap::csmNumOnChamber
unsigned int csmNumOnChamber(const CablingData &map_data, MsgStream &log) const
Returns whether the channel belongs to the first or second mounted CSM card.
Definition: MuonMDT_CablingMap.cxx:390
MuonMDT_CablingMap::MezzCardPtr
MdtMezzanineCard::MezzCardPtr MezzCardPtr
Definition: MuonMDT_CablingMap.h:150
MuonMDT_CablingMap::OffToOnlMap
std::map< MdtCablingOffData, MdtOffChModule > OffToOnlMap
Definition: MuonMDT_CablingMap.h:50
MuonMDT_CablingMap::m_tdcs
std::vector< std::unique_ptr< MdtTdcMap > > m_tdcs
Definition: MuonMDT_CablingMap.h:166
MuonMDT_CablingMap::getHedgeHogMapping
MezzCardPtr getHedgeHogMapping(uint8_t mezzCardId) const
Definition: MuonMDT_CablingMap.cxx:176
MuonMDT_CablingMap
Definition: MuonMDT_CablingMap.h:24
MuonMDT_CablingMap::m_chamberToROB
ChamberToROBMap m_chamberToROB
map returning the RODid for a given chamber ID
Definition: MuonMDT_CablingMap.h:175
MuonMDT_CablingMap::MdtTdcModule::all_modules
TdcOnlSet all_modules
Definition: MuonMDT_CablingMap.h:64
MdtMezzanineCard::MezzCardPtr
std::shared_ptr< const MdtMezzanineCard > MezzCardPtr
Definition: MdtMezzanineCard.h:38
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MuonMDT_CablingMap::MdtOffChModule::csm
std::array< MdtCablingOnData, 2 > csm
The up to 2 CSMs to which the cards are connected.
Definition: MuonMDT_CablingMap.h:47
MdtIdHelper
Definition: MdtIdHelper.h:61
MuonMDT_CablingMap::MuonMDT_CablingMap
MuonMDT_CablingMap(const MuonMDT_CablingMap &)=delete
MdtTdcMap.h
MuonMDT_CablingMap::MdtOffChModule::end
TdcOffSet::const_iterator end() const
Definition: MuonMDT_CablingMap.h:40
MdtCablingData
Definition: MdtCablingData.h:82
MuonMDT_CablingMap::m_toOnlineConv
OffToOnlMap m_toOnlineConv
Definition: MuonMDT_CablingMap.h:164
MuonMDT_CablingMap::finalize_init
bool finalize_init(MsgStream &log)
Definition: MuonMDT_CablingMap.cxx:523
MuonMDT_CablingMap::OnlToOffMap
std::map< MdtCablingOnData, MdtTdcModule > OnlToOffMap
Definition: MuonMDT_CablingMap.h:68
MuonMDT_CablingMap::MdtOffChModule::begin
TdcOffSet::const_iterator begin() const
Definition: MuonMDT_CablingMap.h:39
MuonMDT_CablingMap::m_2CSM_cham
bool m_2CSM_cham
Switch to check whether the layout has chambers with 2 CSM chips.
Definition: MuonMDT_CablingMap.h:179
MuonMDT_CablingMap::~MuonMDT_CablingMap
~MuonMDT_CablingMap()
MuonMDT_CablingMap::getOnlineId
bool getOnlineId(CablingData &cabling_data, MsgStream &log) const
return the online id given the offline id
Definition: MuonMDT_CablingMap.cxx:304
MuonMDT_CablingMap::MezzCardList
std::vector< MezzCardPtr > MezzCardList
List of mezzanine cards.
Definition: MuonMDT_CablingMap.h:182
MuonMDT_CablingMap::getROBId
uint32_t getROBId(const IdentifierHash &stationCode, MsgStream &log) const
return the ROD id of a given chamber, given the hash id
Definition: MuonMDT_CablingMap.cxx:455
MuonMDT_CablingMap::MdtTdcModule::begin
TdcOnlSet::const_iterator begin()
Definition: MuonMDT_CablingMap.h:61
MuonMDT_CablingMap::getMultiLayerCode
bool getMultiLayerCode(const CablingData &map_data, Identifier &multiLayer, IdentifierHash &mdtHashId, MsgStream &log) const
Transforms the identifier to an IdentifierHash corresponding to the multilayer In this case,...
Definition: MuonMDT_CablingMap.cxx:419
MuonMDT_CablingMap::getOfflineConvMap
const OffToOnlMap & getOfflineConvMap() const
Returns hte map to convert the offline -> online identifiers.
Definition: MuonMDT_CablingMap.cxx:339
MuonMDT_CablingMap::DataSource::LegacyCOOL
@ LegacyCOOL
MuonMDT_CablingMap::getAllROBId
const ListOfROB & getAllROBId() const
return the ROD id of a given chamber
Definition: MuonMDT_CablingMap.cxx:519
MuonMDT_CablingMap::TdcOnlSet
std::vector< MdtTdcOnlSorter > TdcOnlSet
Definition: MuonMDT_CablingMap.h:29
MuonMDT_CablingMap::MdtTdcModule::zero_module
MdtTdcOnlSorter zero_module
Definition: MuonMDT_CablingMap.h:66
MuonMDT_CablingMap::m_multilayerToROB
ChamberToROBMap m_multilayerToROB
map raturning the RODid for a given multi layer ID
Definition: MuonMDT_CablingMap.h:177
MuonMDT_CablingMap::MdtOffChModule
Helper struct to group the Mezzanine cards mounted on each multilayer The object provides the followi...
Definition: MuonMDT_CablingMap.h:38
MuonMDT_CablingMap::getOnlineConvMap
const OnlToOffMap & getOnlineConvMap() const
Returns the map to convert the online -> offline identifiers.
Definition: MuonMDT_CablingMap.cxx:335
CondCont< MuonMDT_CablingMap >
MuonMDT_CablingMap::addMezanineLayout
bool addMezanineLayout(std::unique_ptr< MdtMezzanineCard > card, MsgStream &log)
Adds a new mezzanine card mapping.
Definition: MuonMDT_CablingMap.cxx:576
MuonMDT_CablingMap::ROBToChamberMap
std::map< uint32_t, std::vector< IdentifierHash > > ROBToChamberMap
Definition: MuonMDT_CablingMap.h:73
MuonMDT_CablingMap::MdtTdcModule::end
TdcOnlSet::const_iterator end() const
Definition: MuonMDT_CablingMap.h:60
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
MuonMDT_CablingMap::DataSource
DataSource
Definition: MuonMDT_CablingMap.h:87
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonMDT_CablingMap::MdtTdcModule::begin
TdcOnlSet::const_iterator begin() const
Definition: MuonMDT_CablingMap.h:59
MuonMDT_CablingMap::getOfflineId
bool getOfflineId(CablingData &cabling_data, MsgStream &log) const
return the offline id given the online id
Definition: MuonMDT_CablingMap.cxx:239
IdentifierHash
Definition: IdentifierHash.h:38
MuonMDT_CablingMap::MdtOffChModule::end
TdcOffSet::const_iterator end()
Definition: MuonMDT_CablingMap.h:42
sTgcDigitEffiDump.multiLayer
int multiLayer
Definition: sTgcDigitEffiDump.py:36
CLASS_DEF.h
macros to associate a CLID to a type
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
MuonMDT_CablingMap::m_mdtIdHelper
const MdtIdHelper * m_mdtIdHelper
Pointer to the MdtIdHelper.
Definition: MuonMDT_CablingMap.h:158
MuonMDT_CablingMap::m_listOfROB
ListOfROB m_listOfROB
full list of ROBs
Definition: MuonMDT_CablingMap.h:172
MuonMDT_CablingMap::TdcOffSet
std::set< MdtTdcOffSorter, std::less<> > TdcOffSet
Definition: MuonMDT_CablingMap.h:28
MuonMDT_CablingMap::addMezzanineLine
bool addMezzanineLine(const int type, const int layer, const int sequence, MsgStream &log)
Add a new line describing a mezzanine type.
Definition: MuonMDT_CablingMap.cxx:69
MuonMDT_CablingMap::has2CsmML
bool has2CsmML() const
Returns if the cabling map has found multilayers connected to 2 CSM cards.
Definition: MuonMDT_CablingMap.cxx:416
MezzCardPtr
MuonMDT_CablingMap::MezzCardPtr MezzCardPtr
Definition: MuonMDT_CablingMap.cxx:21
MuonMDT_CablingMap::CablingData
MdtCablingData CablingData
Definition: MuonMDT_CablingMap.h:75