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

#include <MdtROD_Encoder.h>

Collaboration diagram for MdtROD_Encoder:

Public Member Functions

 MdtROD_Encoder ()
 constructor
 ~MdtROD_Encoder ()=default
 destructor
void add (const MdtCsm *csm)
 initialize the map
void clear ()
 clear the current csm list
void fillROD (std::vector< uint32_t > &v)
 convert all Csm in the current list to a vector of 32bit words

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_mdtIdHelper {"Muon::MuonIdHelperSvc/MuonIdHelperSvc", "MdtRDO_Encoder"}
std::vector< const MdtCsm * > m_vMdtCsm

Detailed Description

Definition at line 15 of file MdtROD_Encoder.h.

Constructor & Destructor Documentation

◆ MdtROD_Encoder()

MdtROD_Encoder::MdtROD_Encoder ( )

constructor

Definition at line 21 of file MdtROD_Encoder.cxx.

21 {
22 if (!m_mdtIdHelper.retrieve().isSuccess()) { throw std::runtime_error("MdtROD_Encoder -- Failed to initialize the IdHelperSvc"); }
23}
ServiceHandle< Muon::IMuonIdHelperSvc > m_mdtIdHelper

◆ ~MdtROD_Encoder()

MdtROD_Encoder::~MdtROD_Encoder ( )
default

destructor

Member Function Documentation

◆ add()

void MdtROD_Encoder::add ( const MdtCsm * csm)

initialize the map

add Mdt Csms to the current list

Definition at line 25 of file MdtROD_Encoder.cxx.

25{ m_vMdtCsm.push_back(csm); }
std::vector< const MdtCsm * > m_vMdtCsm

◆ clear()

void MdtROD_Encoder::clear ( )

clear the current csm list

Definition at line 28 of file MdtROD_Encoder.cxx.

28{ m_vMdtCsm.erase(m_vMdtCsm.begin(), m_vMdtCsm.end()); }

◆ fillROD()

void MdtROD_Encoder::fillROD ( std::vector< uint32_t > & v)

convert all Csm in the current list to a vector of 32bit words

convert all MDT CSMs in the current list to a vector of 32bit words

Definition at line 34 of file MdtROD_Encoder.cxx.

34 {
35 MdtAmtReadOut amtReadOut{};
36 MdtHptdcReadOut hptdcReadOut{};
37 MdtCsmReadOut csmReadOut{};
38
39 uint32_t mrod_wcnt{0};
40
41 using hit_vector = std::vector<const MdtAmtHit*>;
42 using tdc_map = std::map<uint16_t, hit_vector>;
43 using masked_map = std::map<uint16_t, uint32_t>;
44
45 tdc_map tdcMap;
46 masked_map maskedMap;
47
48 // Insert the Beginning of Block Word (Lvl1ID not set yet)
49 uint32_t lvl1Id = 0;
50 v.push_back(csmReadOut.makeBOB(lvl1Id));
51
52 // make the body of the ROD
53 // Loop on the CSMs
54 for (const MdtCsm* csm : m_vMdtCsm) {
55 const bool isHPTDC = m_mdtIdHelper->hasHPTDC(csm->identify());
56
57 uint16_t ctwc = 0; // Trailer word count initialized
58
59 v.push_back(csmReadOut.makeLWC(0)); // Link Word Count
60 v.push_back(csmReadOut.makeBOL(csm->MrodId(), csm->CsmId())); // Beginning of link
61
62 v.push_back(csmReadOut.makeTLP(0));
63 ++ctwc; // Trailer word count starts from TLP
64
65 // Group the hits of this CSM according to the TDC number
66 tdcMap.clear();
67 maskedMap.clear();
68 for (const MdtAmtHit* amt : *csm) {
69 uint16_t tdcNum = amt->tdcId();
70
71 if (!amt->isMasked()) {
72 tdcMap[tdcNum].push_back(amt);
73 } else {
74 maskedMap[tdcNum] = maskedMap[tdcNum] | (int)pow(2, amt->channelId());
75 }
76 }
77
78 // Loop on the TDCs and build the corresponding MROD blocks
79 uint16_t jt = 0;
80 tdc_map::const_iterator it_tdc = tdcMap.begin();
81 for (; it_tdc != tdcMap.end(); ++it_tdc) {
82 // Beginning of TDC header word
83 // Need to fix event counter and bcid
84 v.push_back((isHPTDC ? hptdcReadOut.makeBOT((*it_tdc).first, 0, 0) : amtReadOut.makeBOT((*it_tdc).first, 0, 0)));
85 ++ctwc;
86
87 uint32_t maskedFlags = maskedMap[(*it_tdc).first];
88 uint16_t wcnt = 0; // TDC word count
89
90 // Masked channels flags
91 if (maskedFlags != 0) {
92 v.push_back((isHPTDC ? 0 : amtReadOut.makeTMC(jt, maskedFlags)));
93 ++ctwc;
94 ++wcnt;
95 }
96
97 // Loop on the hits for this TDC
98 hit_vector::const_iterator it_amtvec = (*it_tdc).second.begin();
99 for (; it_amtvec != (*it_tdc).second.end(); ++it_amtvec) {
100 uint16_t chan = (*it_amtvec)->channelId();
101
102 uint16_t coarse = (*it_amtvec)->coarse();
103 uint16_t fine = (*it_amtvec)->fine();
104 uint16_t width = (*it_amtvec)->width();
105 uint16_t tdcId = (*it_amtvec)->tdcId();
106
107 // Add a "Single Measurement" word
108 // v.push_back( isHPTDC ? hptdcReadOut.makeTSM(tdcId, chan, leading, coarse, fine)
109 // : amtReadOut.makeTSM(jt, chan, leading, errflag, coarse, fine) );
110
111 // Add a combined measurement data word
112 v.push_back(
113 (isHPTDC ? hptdcReadOut.makeTCM(tdcId, chan, width, coarse, fine) : amtReadOut.makeTCM(jt, chan, width, coarse, fine)));
114
115 ++ctwc; // CSM word count
116 ++wcnt; // TDC word count
117 }
118
119 uint16_t jt{0}, tdcId{0}, ecnt{0}; // Event counter
120 // End of TDC trailer
121 v.push_back((isHPTDC ? hptdcReadOut.makeEOT(tdcId, ecnt, wcnt + 2) : amtReadOut.makeEOT(jt, ecnt, wcnt + 2)));
122 ++ctwc;
123 }
124
125 // Last word of each csm: TWC trailer word count
126 uint16_t ecnt = 0;
127 v.push_back(csmReadOut.makeTWC(ecnt, ctwc));
128
129 // Update the MROD word count
130 mrod_wcnt += ctwc;
131 mrod_wcnt += 2;
132 }
133
134 // Close the MROD: MROD word count in EOB
135 v.push_back(csmReadOut.makeEOB(mrod_wcnt));
136}
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current MdtCsm
const double width
constexpr int pow(int base, int exp) noexcept
uint32_t makeTMC(uint16_t jt, uint32_t masked)
uint32_t makeEOT(uint16_t jt, uint16_t ecnt, uint16_t wcnt)
uint32_t makeTCM(uint16_t jt, uint16_t channel, uint16_t width, uint16_t coarse, uint16_t fine)
uint32_t makeBOT(uint16_t tdcId, uint16_t ecnt, uint16_t bcid)
uint32_t makeEOB(uint32_t wcnt)
uint32_t makeBOB(uint32_t lvl1Id)
uint32_t makeTLP(uint32_t flags)
uint32_t makeLWC(uint32_t clwc)
uint32_t makeBOL(uint16_t mrodId, uint16_t csmId)
uint32_t makeTWC(uint16_t ecnt, uint16_t ctwc)
uint32_t makeBOT(uint16_t tdcId, uint16_t ecnt, uint16_t bcid)
uint32_t makeEOT(uint16_t tdcId, uint16_t ecnt, uint16_t wcnt)
uint32_t makeTCM(uint16_t tdcId, uint16_t channel, uint16_t width, uint16_t coarse, uint16_t fine)
setWord1 uint16_t
setEventNumber uint32_t

Member Data Documentation

◆ m_mdtIdHelper

ServiceHandle<Muon::IMuonIdHelperSvc> MdtROD_Encoder::m_mdtIdHelper {"Muon::MuonIdHelperSvc/MuonIdHelperSvc", "MdtRDO_Encoder"}
private

Definition at line 43 of file MdtROD_Encoder.h.

43{"Muon::MuonIdHelperSvc/MuonIdHelperSvc", "MdtRDO_Encoder"};

◆ m_vMdtCsm

std::vector<const MdtCsm*> MdtROD_Encoder::m_vMdtCsm
private

Definition at line 44 of file MdtROD_Encoder.h.


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