ATLAS Offline Software
Loading...
Searching...
No Matches
MdtMezzanineCard Class Reference

MdtMezzanineCard - Helper struct to represent the structure of a mezzanine card in a consistent way Each mezzanine card reads out in total 24 tubes of a chamber covering all tube layers of a chamber. More...

#include <MdtMezzanineCard.h>

Collaboration diagram for MdtMezzanineCard:

Classes

struct  OfflineCh
 Helper struct to pipe the result from the tdc -> offline channel translation. More...

Public Types

using MezzCardPtr = std::shared_ptr<const MdtMezzanineCard>
using Mapping = std::array<uint8_t, 24>

Public Member Functions

 MdtMezzanineCard (const Mapping &tdcToTubeMap, uint8_t num_layers, uint8_t mezz_id)
 Standard constructor of the mezzanine card.
uint8_t tdcChannel (uint8_t tubeLay, uint8_t tube, MsgStream &msg) const
 returns the tdc channel number
uint8_t tubeNumber (uint8_t tubeLay, uint8_t tube) const
 returns the tube number
bool checkConsistency (MsgStream &msg) const
 checks whether the tdc mapping is complete.
uint8_t id () const
 returns mezzanine database identifier
uint8_t numTubeLayers () const
 returns the number of layers
uint8_t numTubesPerLayer () const
 returns the number of tubes per layer;
OfflineCh offlineTube (uint8_t tdc, MsgStream &msg) const
const MappingtdcToTubeMap () const
 Returns the underlying TDC -> Tube conversion map.
const MappingtubeToTdcMap () const
 Returns the underlying Tube -> Tdc conversion map.

Static Public Attributes

static constexpr uint8_t NOTSET = 250

Private Attributes

Mapping m_tdcToTubes {make_array<uint8_t, 24>(NOTSET)}
 Mapping of the tdc channels to the mezzanine tube number.
Mapping m_tubesToTdc {make_array<uint8_t, 24>(NOTSET)}
 Mapping of the mezzanine tube number to the tdc channel.
uint8_t m_nlay {0}
 Number of tube layers.
uint8_t m_nTubes {0}
 Number of tubes per layer.
uint8_t m_mezzId {0}
 Mezzanine database identifier.

Detailed Description

MdtMezzanineCard - Helper struct to represent the structure of a mezzanine card in a consistent way Each mezzanine card reads out in total 24 tubes of a chamber covering all tube layers of a chamber.

Given that a chamber has either 3 or 4 layers, 8 or 6 tubes per layer are read out by the cards. The assignment of the tdc channels to the tubes does not follow a distinct pattern:

       Layer 2:   (01) (03) (05) (07) (06) (04) (02) (00)
       Layer 1: (09) (11) (13) (15) (14) (12) (10) (08)
       Layer 0:   (17) (19) (21) (23) (22) (20) (18) (16)

To preserve a continuous memory layout and to ease the translation of online -> offline numbering scheme, the tubes are numbered sequentially Layer 2: (16) (17) (18) (19) (20) (21) (22) (23) Layer 1: (08) (09) (10) (11) (12) (13) (14) (15) Layer 0: (00) (01) (02) (03) (04) (05) (06) (07) The mapping between the two schemes is represented by a 24 long array, where the index is the channel number, tdc in the case of online -> offline, and tube number in the case of online to online.

Definition at line 35 of file MdtMezzanineCard.h.

Member Typedef Documentation

◆ Mapping

using MdtMezzanineCard::Mapping = std::array<uint8_t, 24>

Definition at line 40 of file MdtMezzanineCard.h.

◆ MezzCardPtr

using MdtMezzanineCard::MezzCardPtr = std::shared_ptr<const MdtMezzanineCard>

Definition at line 39 of file MdtMezzanineCard.h.

Constructor & Destructor Documentation

◆ MdtMezzanineCard()

MdtMezzanineCard::MdtMezzanineCard ( const Mapping & tdcToTubeMap,
uint8_t num_layers,
uint8_t mezz_id )

Standard constructor of the mezzanine card.

Parameters
tdcToTubeMaparray mapping the tdc channels to the tube numbers covered by the card
num_layersnumber of tube layers (3 or 4)
mezz_idGlobal identifier number to map the card in the online <-> offline conversion

Should be 6 or 8 tubes per layer

Fill the map from tdc -> tube number

Definition at line 39 of file MdtMezzanineCard.cxx.

45 for (unsigned int tdc = 0; tdc < m_tdcToTubes.size(); ++tdc) {
47 if (tube < m_tubesToTdc.size())
48 m_tubesToTdc[tube] = tdc;
49 }
50}
uint8_t m_mezzId
Mezzanine database identifier.
Mapping m_tubesToTdc
Mapping of the mezzanine tube number to the tdc channel.
const Mapping & tdcToTubeMap() const
Returns the underlying TDC -> Tube conversion map.
Mapping m_tdcToTubes
Mapping of the tdc channels to the mezzanine tube number.
uint8_t m_nlay
Number of tube layers.
uint8_t m_nTubes
Number of tubes per layer.
tuple num_layers
retrieve num layers and layer names (from new or ref hv input)

Member Function Documentation

◆ checkConsistency()

bool MdtMezzanineCard::checkConsistency ( MsgStream & msg) const

checks whether the tdc mapping is complete.

I.e. – all channels are uniquely defined – number of layers is 4 or 3

Check that all channels are actually set

Definition at line 52 of file MdtMezzanineCard.cxx.

52 {
53 const bool debug = (log.level() <= MSG::VERBOSE);
54 if (debug) {
55 log << MSG::VERBOSE << " Check consistency of mezzanine card "
56 << static_cast<int>(id()) << "." << endmsg;
57 }
58 if (numTubeLayers() != 3 && numTubeLayers() != 4) {
59 log << MSG::ERROR << "Mezzanine card " << static_cast<int>(id())
60 << " has invalid many tube layers "
61 << static_cast<int>(numTubeLayers()) << endmsg;
62 return false;
63 }
65 std::set<uint8_t> uniqueSet{};
66 std::copy_if(m_tdcToTubes.begin(), m_tdcToTubes.end(),
67 std::inserter(uniqueSet, uniqueSet.end()),
68 [](const uint8_t ch) { return ch != NOTSET; });
69 unsigned int unmapped =
70 std::count_if(m_tdcToTubes.begin(), m_tdcToTubes.end(),
71 [](const uint8_t ch) { return ch == NOTSET; });
72 if ((uniqueSet.size() + unmapped) != m_tdcToTubes.size()) {
73 log << MSG::ERROR
74 << "Mezzanine card has unassigned tdc -> tube channels " << endmsg;
75 log << MSG::ERROR << "Mapped channels " << uniqueSet.size()
76 << " dead channels: " << unmapped << std::endl;
77 log << MSG::ERROR << "Please check " << (*this) << endmsg;
78 return false;
79 }
80 if (unmapped == m_tdcToTubes.size()) {
81 log << MSG::ERROR
82 << "Mezzanine card does not have any associated channel " << endmsg;
83 log << MSG::ERROR << "Please check " << (*this) << endmsg;
84 }
85 uniqueSet.clear();
86 std::copy_if(m_tubesToTdc.begin(), m_tubesToTdc.end(),
87 std::inserter(uniqueSet, uniqueSet.end()),
88 [](const uint8_t ch) { return ch != NOTSET; });
89 unmapped = std::count_if(m_tubesToTdc.begin(), m_tubesToTdc.end(),
90 [](const uint8_t ch) { return ch == NOTSET; });
91 if ((uniqueSet.size() + unmapped) != m_tubesToTdc.size()) {
92 log << MSG::ERROR << " Mezzanine card maps tubes -> tdc inconsitently "
93 << endmsg;
94 log << MSG::ERROR << "Mapped channels " << uniqueSet.size()
95 << " dead channels: " << unmapped << std::endl;
96 log << MSG::ERROR << " Please check " << (*this) << endmsg;
97 return false;
98 }
99 if (debug) {
100 log << MSG::VERBOSE << " All checks passed " << std::endl
101 << (*this) << endmsg;
102 }
103 return true;
104}
#define endmsg
const bool debug
uint8_t id() const
returns mezzanine database identifier
uint8_t numTubeLayers() const
returns the number of layers

◆ id()

uint8_t MdtMezzanineCard::id ( ) const
inline

returns mezzanine database identifier

Definition at line 65 of file MdtMezzanineCard.h.

65{ return m_mezzId; }

◆ numTubeLayers()

uint8_t MdtMezzanineCard::numTubeLayers ( ) const
inline

returns the number of layers

Definition at line 67 of file MdtMezzanineCard.h.

67{ return m_nlay; }

◆ numTubesPerLayer()

uint8_t MdtMezzanineCard::numTubesPerLayer ( ) const
inline

returns the number of tubes per layer;

Definition at line 69 of file MdtMezzanineCard.h.

69{ return m_nTubes; }

◆ offlineTube()

OfflineCh MdtMezzanineCard::offlineTube ( uint8_t tdc,
MsgStream & msg ) const

Do not offset the tube as the tube number needs to be shifted by the first tube of the card

Definition at line 126 of file MdtMezzanineCard.cxx.

126 {
127 if (tdc >= m_tdcToTubes.size()) {
128 msg << MSG::WARNING << " Tdc channel is out of range "
129 << static_cast<int>(tdc) << endmsg;
130 return {};
131 }
132 uint8_t globTubeNum = m_tdcToTubes[tdc];
133 uint8_t tube = globTubeNum % numTubesPerLayer();
134 uint8_t lay = (globTubeNum - tube) / numTubesPerLayer();
135 OfflineCh ret{};
138 ret.tube = tube;
139 ret.layer = lay + 1;
140 ret.isValid = globTubeNum != NOTSET;
141 return ret;
142}
static constexpr uint8_t NOTSET
uint8_t numTubesPerLayer() const
returns the number of tubes per layer;
Helper struct to pipe the result from the tdc -> offline channel translation.
MsgStream & msg
Definition testRead.cxx:32

◆ tdcChannel()

uint8_t MdtMezzanineCard::tdcChannel ( uint8_t tubeLay,
uint8_t tube,
MsgStream & msg ) const

returns the tdc channel number

Parameters
tubeLaytube layer (1-4)
tubeglobal number of the tube in a layer (1-120)

Definition at line 106 of file MdtMezzanineCard.cxx.

107 {
108 if (tubeLay > numTubeLayers()) {
109 msg << MSG::WARNING << "MdtMezzanineCard::tdcChannel() -- Tube layer "
110 << static_cast<int>(tubeLay) << " is out of range. Max allowed "
111 << static_cast<int>(numTubeLayers()) << endmsg;
112 return NOTSET;
113 }
114 uint8_t globTubeNum = tubeNumber(tubeLay, tube);
115 if (msg.level() <= MSG::VERBOSE) {
116 msg << "MdtMezzanineCard::tdcChannel() -- Resolved layer "
117 << static_cast<int>(tubeLay) << " & tube " << static_cast<int>(tube)
118 << " to " << static_cast<int>(globTubeNum) << endmsg;
119 }
120 return m_tubesToTdc[globTubeNum];
121}
uint8_t tubeNumber(uint8_t tubeLay, uint8_t tube) const
returns the tube number

◆ tdcToTubeMap()

const Mapping & MdtMezzanineCard::tdcToTubeMap ( ) const
inline

Returns the underlying TDC -> Tube conversion map.

Definition at line 81 of file MdtMezzanineCard.h.

81{ return m_tdcToTubes; }

◆ tubeNumber()

uint8_t MdtMezzanineCard::tubeNumber ( uint8_t tubeLay,
uint8_t tube ) const

returns the tube number

Parameters
tubeLaytube layer (1-4)
tubeglobal number of the tube in a layer (1-120)

Definition at line 122 of file MdtMezzanineCard.cxx.

122 {
123 return ((tube - 1) % numTubesPerLayer()) +
124 (numTubesPerLayer() * (tubeLay - 1));
125}

◆ tubeToTdcMap()

const Mapping & MdtMezzanineCard::tubeToTdcMap ( ) const
inline

Returns the underlying Tube -> Tdc conversion map.

Definition at line 83 of file MdtMezzanineCard.h.

83{ return m_tubesToTdc; }

Member Data Documentation

◆ m_mezzId

uint8_t MdtMezzanineCard::m_mezzId {0}
private

Mezzanine database identifier.

Definition at line 95 of file MdtMezzanineCard.h.

95{0};

◆ m_nlay

uint8_t MdtMezzanineCard::m_nlay {0}
private

Number of tube layers.

Definition at line 91 of file MdtMezzanineCard.h.

91{0};

◆ m_nTubes

uint8_t MdtMezzanineCard::m_nTubes {0}
private

Number of tubes per layer.

Definition at line 93 of file MdtMezzanineCard.h.

93{0};

◆ m_tdcToTubes

Mapping MdtMezzanineCard::m_tdcToTubes {make_array<uint8_t, 24>(NOTSET)}
private

Mapping of the tdc channels to the mezzanine tube number.

Definition at line 87 of file MdtMezzanineCard.h.

constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
Definition ArrayHelper.h:10

◆ m_tubesToTdc

Mapping MdtMezzanineCard::m_tubesToTdc {make_array<uint8_t, 24>(NOTSET)}
private

Mapping of the mezzanine tube number to the tdc channel.

Definition at line 89 of file MdtMezzanineCard.h.

◆ NOTSET

uint8_t MdtMezzanineCard::NOTSET = 250
staticconstexpr

Definition at line 37 of file MdtMezzanineCard.h.


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