ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
MdtROD_Encoder Class Reference

#include <MdtROD_Encoder.h>

Collaboration diagram for MdtROD_Encoder:

Public Member Functions

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

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 }

◆ ~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); }

◆ 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 }

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.

◆ 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:
MdtAmtHit
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition: MdtAmtHit.h:20
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MdtAmtReadOut
Definition: MdtAmtReadOut.h:15
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
MdtCsm
MDT RDOs : Chamber Service Module, container of AmtHits of a single Mdt chamber.
Definition: MdtCsm.h:19
MdtROD_Encoder::m_mdtIdHelper
ServiceHandle< Muon::IMuonIdHelperSvc > m_mdtIdHelper
Definition: MdtROD_Encoder.h:43
MdtCsmReadOut
Definition: MdtCsmReadOut.h:15
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
MdtROD_Encoder::m_vMdtCsm
std::vector< const MdtCsm * > m_vMdtCsm
Definition: MdtROD_Encoder.h:44
MdtHptdcReadOut
Definition: MdtHptdcReadOut.h:15
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
python.PyAthena.v
v
Definition: PyAthena.py:154
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15