ATLAS Offline Software
MuonMDT_CablingMap.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
9 
10 #include "AthenaKernel/CLASS_DEF.h"
12 #include <set>
13 #include <memory>
14 #include <map>
15 #include <vector>
16 #include <cstdint>
17 /**********************************************
18  *
19  * @brief MDT map data object
20  *
21  **********************************************/
22 
23 class MdtMezzanineType;
24 class MdtIdHelper;
25 class IdentifierHash;
26 class Identifier;
27 
29  public:
31  using MezzanineTypes = std::map<uint8_t, std::unique_ptr<MdtMezzanineType>>;
32  using TdcOffSet = std::set<MdtTdcOffSorter, std::less<>>;
33  using TdcOnlSet = std::vector<MdtTdcOnlSorter>;
34 
40  // larger number of tubes. The csm caches the up to 2 CSM associated
41  // with this object
42  struct MdtOffChModule {
43  TdcOffSet::const_iterator begin() const { return cards.begin(); }
44  TdcOffSet::const_iterator end() const { return cards.end(); }
45  TdcOffSet::const_iterator begin() { return cards.begin(); }
46  TdcOffSet::const_iterator end() { return cards.end(); }
47 
51  std::array<MdtCablingOnData, 2> csm{};
52  };
53 
54  using OffToOnlMap = std::map<MdtCablingOffData, MdtOffChModule>;
62  struct MdtTdcModule {
63  TdcOnlSet::const_iterator begin() const { return all_modules.begin(); }
64  TdcOnlSet::const_iterator end() const { return all_modules.end(); }
65  TdcOnlSet::const_iterator begin() { return all_modules.begin(); }
66  TdcOnlSet::const_iterator end() { return all_modules.end(); }
67 
69 
71  };
72  using OnlToOffMap = std::map<MdtCablingOnData, MdtTdcModule>;
73 
75  /* mapping from hashid to ROB identifier as Subdetector+Rodid */
76  using ChamberToROBMap = std::map<IdentifierHash, uint32_t>;
77  using ROBToChamberMap = std::map<uint32_t, std::vector<IdentifierHash>>;
78  using ListOfROB = std::vector<uint32_t>;
82 
84  bool addMezzanineLine(const int type, const int layer, const int sequence,
85  MsgStream& log);
86 
88  bool addMezanineLayout(std::unique_ptr<MdtMezzanineCard> card,
89  MsgStream& log);
90 
91  enum class DataSource { JSON, LegacyCOOL };
96  MsgStream& log);
97 
99  bool getOfflineId(CablingData& cabling_data, MsgStream& log) const;
100 
102  bool getOnlineId(CablingData& cabling_data, MsgStream& log) const;
106  bool convert(const CablingData& cabling_data, Identifier& id,
107  bool check_valid = true) const;
110  bool convert(const Identifier& id, CablingData& cabling_data) const;
111 
113  uint32_t getROBId(const IdentifierHash& stationCode, MsgStream& log) const;
116  ListOfROB getROBId(const std::vector<IdentifierHash>& mdtHashVector,
117  MsgStream& log) const;
118 
120  std::vector<IdentifierHash> getMultiLayerHashVec(
121  const std::vector<uint32_t>& ROBId_list, MsgStream& log) const;
122 
124  const std::vector<IdentifierHash>& getMultiLayerHashVec(
125  const uint32_t ROBI, MsgStream& log) const;
126 
128  const ListOfROB& getAllROBId() const;
129 
131  const OnlToOffMap& getOnlineConvMap() const;
133  const OffToOnlMap& getOfflineConvMap() const;
134 
135  bool finalize_init(MsgStream& log);
136 
139  bool getStationCode(const CablingData& map_data, IdentifierHash& mdtHashId,
140  MsgStream& log) const;
143  bool getMultiLayerCode(const CablingData& map_data, Identifier& multiLayer,
144  IdentifierHash& mdtHashId, MsgStream& log) const;
145 
148  unsigned int csmNumOnChamber(const CablingData& map_data,
149  MsgStream& log) const;
152  bool has2CsmML() const;
155  MezzCardPtr getHedgeHogMapping(uint8_t mezzCardId) const;
156 
157  private:
159  bool addChamberToROBMap(const CablingData& cabling_data, MsgStream& log);
160 
162  const MdtIdHelper* m_mdtIdHelper{nullptr};
163 
167 
170  std::vector<std::unique_ptr<MdtTdcMap>> m_tdcs{};
171 
174 
177 
183  bool m_2CSM_cham{false};
184 
186  using MezzCardList = std::vector<MezzCardPtr>;
191 };
192 
193 CLASS_DEF(MuonMDT_CablingMap, 51038731, 1)
194 #include "AthenaKernel/CondCont.h"
196 
197 #endif
MuonMDT_CablingMap::m_ROBToMultiLayer
ROBToChamberMap m_ROBToMultiLayer
map returning a detector element hashes associated with a given ROD
Definition: MuonMDT_CablingMap.h:173
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:412
MuonMDT_CablingMap::MuonMDT_CablingMap
MuonMDT_CablingMap()
Definition: MuonMDT_CablingMap.cxx:24
MuonMDT_CablingMap::MdtOffChModule::cards
TdcOffSet cards
Mezzanine cards mounted on the chamber.
Definition: MuonMDT_CablingMap.h:49
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:511
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:605
MuonMDT_CablingMap::MdtTdcModule::end
TdcOnlSet::const_iterator end()
Definition: MuonMDT_CablingMap.h:66
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
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:355
MuonMDT_CablingMap::MdtOffChModule::begin
TdcOffSet::const_iterator begin()
Definition: MuonMDT_CablingMap.h:45
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:78
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:76
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
MuonMDT_CablingMap::m_toOfflineConv
OnlToOffMap m_toOfflineConv
Definition: MuonMDT_CablingMap.h:169
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:46
MuonMDT_CablingMap::m_mezzCards
MezzCardList m_mezzCards
Definition: MuonMDT_CablingMap.h:187
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:31
MuonMDT_CablingMap::MdtTdcModule
The online -> offline conversion needs to treat two cases tdcId && channelId == 0xFF: ** Decode the s...
Definition: MuonMDT_CablingMap.h:62
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:400
MuonMDT_CablingMap::MezzCardPtr
MdtMezzanineCard::MezzCardPtr MezzCardPtr
Definition: MuonMDT_CablingMap.h:154
MuonMDT_CablingMap::OffToOnlMap
std::map< MdtCablingOffData, MdtOffChModule > OffToOnlMap
Definition: MuonMDT_CablingMap.h:54
MuonMDT_CablingMap::m_tdcs
std::vector< std::unique_ptr< MdtTdcMap > > m_tdcs
Definition: MuonMDT_CablingMap.h:170
MuonMDT_CablingMap::getHedgeHogMapping
MezzCardPtr getHedgeHogMapping(uint8_t mezzCardId) const
Definition: MuonMDT_CablingMap.cxx:176
MuonMDT_CablingMap
Definition: MuonMDT_CablingMap.h:28
MuonMDT_CablingMap::m_chamberToROB
ChamberToROBMap m_chamberToROB
map returning the RODid for a given chamber ID
Definition: MuonMDT_CablingMap.h:179
MuonMDT_CablingMap::MdtTdcModule::all_modules
TdcOnlSet all_modules
Definition: MuonMDT_CablingMap.h:68
MdtMezzanineCard::MezzCardPtr
std::shared_ptr< const MdtMezzanineCard > MezzCardPtr
Definition: MdtMezzanineCard.h:38
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:51
jobOptions.card
card
Definition: jobOptions.GenevaPy8_Zmumu.py:11
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:44
MdtCablingData
Definition: MdtCablingData.h:82
MuonMDT_CablingMap::m_toOnlineConv
OffToOnlMap m_toOnlineConv
Definition: MuonMDT_CablingMap.h:168
MuonMDT_CablingMap::finalize_init
bool finalize_init(MsgStream &log)
Definition: MuonMDT_CablingMap.cxx:533
MuonMDT_CablingMap::OnlToOffMap
std::map< MdtCablingOnData, MdtTdcModule > OnlToOffMap
Definition: MuonMDT_CablingMap.h:72
MuonMDT_CablingMap::MdtOffChModule::begin
TdcOffSet::const_iterator begin() const
Definition: MuonMDT_CablingMap.h:43
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:183
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:315
MuonMDT_CablingMap::MezzCardList
std::vector< MezzCardPtr > MezzCardList
List of mezzanine cards.
Definition: MuonMDT_CablingMap.h:186
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:465
MuonMDT_CablingMap::MdtTdcModule::begin
TdcOnlSet::const_iterator begin()
Definition: MuonMDT_CablingMap.h:65
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:429
MuonMDT_CablingMap::getOfflineConvMap
const OffToOnlMap & getOfflineConvMap() const
Returns hte map to convert the offline -> online identifiers.
Definition: MuonMDT_CablingMap.cxx:350
MuonMDT_CablingMap::DataSource::LegacyCOOL
@ LegacyCOOL
MuonMDT_CablingMap::getAllROBId
const ListOfROB & getAllROBId() const
return the ROD id of a given chamber
Definition: MuonMDT_CablingMap.cxx:529
MuonMDT_CablingMap::TdcOnlSet
std::vector< MdtTdcOnlSorter > TdcOnlSet
Definition: MuonMDT_CablingMap.h:33
MuonMDT_CablingMap::MdtTdcModule::zero_module
MdtTdcOnlSorter zero_module
Definition: MuonMDT_CablingMap.h:70
MuonMDT_CablingMap::m_multilayerToROB
ChamberToROBMap m_multilayerToROB
map raturning the RODid for a given multi layer ID
Definition: MuonMDT_CablingMap.h:181
MuonMDT_CablingMap::MdtOffChModule
Helper struct to group the Mezzanine cards mounted on each multilayer The object provides the followi...
Definition: MuonMDT_CablingMap.h:42
MuonMDT_CablingMap::getOnlineConvMap
const OnlToOffMap & getOnlineConvMap() const
Returns the map to convert the online -> offline identifiers.
Definition: MuonMDT_CablingMap.cxx:346
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:586
MuonMDT_CablingMap::ROBToChamberMap
std::map< uint32_t, std::vector< IdentifierHash > > ROBToChamberMap
Definition: MuonMDT_CablingMap.h:77
MuonMDT_CablingMap::MdtTdcModule::end
TdcOnlSet::const_iterator end() const
Definition: MuonMDT_CablingMap.h:64
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:91
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonMDT_CablingMap::MdtTdcModule::begin
TdcOnlSet::const_iterator begin() const
Definition: MuonMDT_CablingMap.h:63
MuonMDT_CablingMap::getOfflineId
bool getOfflineId(CablingData &cabling_data, MsgStream &log) const
return the offline id given the online id
Definition: MuonMDT_CablingMap.cxx:250
copySelective.source
string source
Definition: copySelective.py:32
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
MuonMDT_CablingMap::MdtOffChModule::end
TdcOffSet::const_iterator end()
Definition: MuonMDT_CablingMap.h:46
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:162
MuonMDT_CablingMap::m_listOfROB
ListOfROB m_listOfROB
full list of ROBs
Definition: MuonMDT_CablingMap.h:176
MuonMDT_CablingMap::TdcOffSet
std::set< MdtTdcOffSorter, std::less<> > TdcOffSet
Definition: MuonMDT_CablingMap.h:32
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:426
MezzCardPtr
MuonMDT_CablingMap::MezzCardPtr MezzCardPtr
Definition: MuonMDT_CablingMap.cxx:22
MuonMDT_CablingMap::CablingData
MdtCablingData CablingData
Definition: MuonMDT_CablingMap.h:79
Identifier
Definition: IdentifierFieldParser.cxx:14