ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::nsw::NSWElink Class Reference

#include <NSWElink.h>

Collaboration diagram for Muon::nsw::NSWElink:

Public Member Functions

 NSWElink (const uint32_t *bs, uint32_t remaining)
virtual ~NSWElink ()
 NSWElink (const NSWElink &)=delete
NSWElinkoperator= (const NSWElink &)=delete
const std::vector< Muon::nsw::VMMChannel * > & get_channels () const
unsigned int nwords () const
unsigned int nhits () const
unsigned int status () const
uint32_t elinkWord () const
const Muon::nsw::NSWResourceIdelinkId () const
Muon::nsw::NSWResourceIdelinkId ()
bool isNull () const
bool noTdc () const
uint16_t l1Id () const
uint16_t rocId () const
uint16_t bcId () const
uint16_t orbit () const
bool tout () const
bool extended () const
uint8_t checksum () const
uint16_t nhitsTrail () const
uint16_t l0Id () const
uint16_t flagMiss () const

Private Member Functions

unsigned int test_checksum (const uint8_t *buffer, unsigned int buflen)

Private Attributes

unsigned int m_wordCount
unsigned int m_nhits
unsigned int m_running_checksum
unsigned int m_packet_status
bool m_isNull
bool m_noTdc
bool m_tout
bool m_extended
uint8_t m_checksum
uint16_t m_l1Id
uint16_t m_rocId
uint16_t m_bcId
uint16_t m_orbit
uint16_t m_nhitsTrail
uint16_t m_l0Id
uint16_t m_flagMiss
uint32_t m_elinkWord
Muon::nsw::NSWResourceIdm_elinkId
std::vector< Muon::nsw::VMMChannel * > m_channels

Static Private Attributes

static const unsigned int s_null_packet_length = 10

Detailed Description

Definition at line 20 of file NSWElink.h.

Constructor & Destructor Documentation

◆ NSWElink() [1/2]

Muon::nsw::NSWElink::NSWElink ( const uint32_t * bs,
uint32_t remaining )

Definition at line 19 of file NSWElink.cxx.

20 : m_wordCount (0)
21{
22 m_rocId = 0; // Fix coverity warning
23
24 // Felix header (2 words)
25 // Packet length includes Felix header
26
27 uint32_t word = bs[m_wordCount++];
30
31 if (m_packet_status != 0)
32 {
33 std::ostringstream s;
34 s << "Packet status in FELIX header 0x" << std::hex << m_packet_status << std::dec;
35 Muon::nsw::MuonNSWCommonDecoder::NSWElinkFelixHeaderException e (ERS_HERE, s.str ());
36 throw e;
37 }
38
39 if (remaining * sizeof (uint32_t) < packet_nbytes)
40 {
41 std::ostringstream s;
42 s << "Packet length in FELIX header " << packet_nbytes << " is larger than available data";
43 Muon::nsw::MuonNSWCommonDecoder::NSWElinkFelixHeaderException e (ERS_HERE, s.str ());
44 throw e;
45 }
46
48 m_elinkId = new Muon::nsw::NSWResourceId (m_elinkWord);
49
50 // Decode sROC header
51
52 word = bs[m_wordCount++];
53
54 ERS_DEBUG (2, "==============================================================");
55 ERS_DEBUG (2, "FELIX HEADER: LENGTH (BYTES) = " << packet_nbytes <<
56 " | STATUS = " << m_packet_status << " | RESOURCE ID = 0x" << std::hex << m_elinkWord << std::dec);
57
59 {
62
63 ERS_DEBUG (2, "ROC HEADER: | NULL = " << m_isNull <<
64 " | ROCID = " << m_rocId << " | L1ID = " << m_l1Id);
65
66 // It may happen that the packet is flagged as a null packet but there are additional bytes
67
68 if (packet_nbytes != s_null_packet_length)
69 {
70 std::ostringstream s;
71 s << "Additional data detected in packet flagged as null " << packet_nbytes;
72 Muon::nsw::MuonNSWCommonDecoder::NSWElinkROCHeaderException e (ERS_HERE, s.str ());
73
74 // Additional words are ignored
75
76 m_wordCount = packet_nbytes / sizeof (uint32_t);
77 }
78 }
79 else
80 {
81 // It may happen that the null packet flag is wrong (or the size is wrong)
82 // In that case, throw an exception
83
84 if (packet_nbytes == s_null_packet_length)
85 {
86 std::ostringstream s;
87 s << "Packet length in FELIX header " << packet_nbytes << " and null event flag in packet are inconsistent";
88 Muon::nsw::MuonNSWCommonDecoder::NSWElinkROCHeaderException e (ERS_HERE, s.str ());
89 throw e;
90 }
91
92 // Calculate packet checksum
93
94 const uint8_t *p = reinterpret_cast <const uint8_t *> (bs + 2);
95 m_running_checksum = this->test_checksum (p, (packet_nbytes - 2 * sizeof (uint32_t)));
96
97 // m_noTDC will only affect data size, hit words should be re-aligned to uint32_t
98
103
104 // Set hit bytes to correspond to the length in Flx header
105 // Everything should be re-aligned in the swROD, though
106
107 // const unsigned int hit_size = m_noTdc ? 3 : 4; // set hit bytes to correspond to the length in Flx header
108
109 // Hit size should always be 4, since (at least for run 3) the detector is always configured to get the TDC info
110 // Please keep the previous commented out line. Having noTdc = true is a legal condition, in principle,
111 // but given the actual configuration of the detector, that should never happen and a crash is provoked when it does if
112 // it is taken into account. I (EP) added a warning exception to report that condition.
113
114 static const unsigned int hit_size = 4;
115
116 if (m_noTdc)
117 {
118 std::ostringstream s;
119 s << "Hit size is not compatible with flags in ROC header, elink ID = " << m_elinkWord << " L1 ID = " << m_l1Id;
120 Muon::nsw::MuonNSWCommonDecoder::NSWElinkROCHeaderException e (ERS_HERE, s.str ());
121 ers::warning (e);
122 }
123
124 // Two 32-bits words for Felix header, 1 word for ROC header, 1 word for the ROC trailer
125
126 m_nhits = (packet_nbytes - 4 * sizeof (uint32_t)) / hit_size;
127 if (packet_nbytes % 4) ++m_nhits;
128
129 ERS_DEBUG (2, "ROC HEADER: T = " << m_noTdc << " | NULL = " << m_isNull <<
130 " | ORBIT = " << m_orbit << " | BCID = " << m_bcId << " | L1ID = " << m_l1Id);
131
132 // Hit Data
133
134 for (unsigned int i=0; i < m_nhits; ++i)
135 {
136 Muon::nsw::VMMChannel *c = new Muon::nsw::VMMChannel (bs[m_wordCount++], this);
137 m_channels.push_back(c);
138 }
139
140 // ROC Trailer (1 word)
141
142 word = bs[m_wordCount++];
143
150
151 ERS_DEBUG (2, "ROC TRAILER: EXTENDED = " << m_extended << " | TIMEOUT = " << m_tout << std::hex <<
152 " | FLAGMISS = 0x" << m_flagMiss << std::dec << " | L0ID = " << m_l0Id << " | NHITS = " << m_nhits <<
153 " | CHECKSUM = 0x" << std::hex << static_cast <unsigned int> (m_checksum) << std::dec);
154 ERS_DEBUG (2, "PACKET CHECKSUM = " << m_running_checksum);
155 }
156}
uint32_t get_bits(uint32_t word, uint32_t mask, uint8_t position)
setEventNumber uint32_t

◆ ~NSWElink()

Muon::nsw::NSWElink::~NSWElink ( )
virtual

Definition at line 158 of file NSWElink.cxx.

159{
160 for (auto i = m_channels.begin (); i != m_channels.end (); ++i)
161 delete *i;
162
163 delete m_elinkId;
164}

◆ NSWElink() [2/2]

Muon::nsw::NSWElink::NSWElink ( const NSWElink & )
delete

Member Function Documentation

◆ bcId()

uint16_t Muon::nsw::NSWElink::bcId ( ) const
inline

Definition at line 47 of file NSWElink.h.

47{return m_bcId;};

◆ checksum()

uint8_t Muon::nsw::NSWElink::checksum ( ) const
inline

Definition at line 54 of file NSWElink.h.

54{return m_checksum;};

◆ elinkId() [1/2]

Muon::nsw::NSWResourceId * Muon::nsw::NSWElink::elinkId ( )
inline

Definition at line 39 of file NSWElink.h.

39{return m_elinkId;};

◆ elinkId() [2/2]

const Muon::nsw::NSWResourceId * Muon::nsw::NSWElink::elinkId ( ) const
inline

Definition at line 38 of file NSWElink.h.

38{return m_elinkId;};

◆ elinkWord()

uint32_t Muon::nsw::NSWElink::elinkWord ( ) const
inline

Definition at line 37 of file NSWElink.h.

37{return m_elinkWord;};

◆ extended()

bool Muon::nsw::NSWElink::extended ( ) const
inline

Definition at line 52 of file NSWElink.h.

52{return m_extended;};

◆ flagMiss()

uint16_t Muon::nsw::NSWElink::flagMiss ( ) const
inline

Definition at line 58 of file NSWElink.h.

58{return m_flagMiss;};

◆ get_channels()

const std::vector< Muon::nsw::VMMChannel * > & Muon::nsw::NSWElink::get_channels ( ) const
inline

Definition at line 30 of file NSWElink.h.

30{return m_channels;};

◆ isNull()

bool Muon::nsw::NSWElink::isNull ( ) const
inline

Definition at line 42 of file NSWElink.h.

42{return m_isNull;};

◆ l0Id()

uint16_t Muon::nsw::NSWElink::l0Id ( ) const
inline

Definition at line 57 of file NSWElink.h.

57{return m_l0Id;};

◆ l1Id()

uint16_t Muon::nsw::NSWElink::l1Id ( ) const
inline

Definition at line 45 of file NSWElink.h.

45{return m_l1Id;};

◆ nhits()

unsigned int Muon::nsw::NSWElink::nhits ( ) const
inline

Definition at line 33 of file NSWElink.h.

33{return m_nhits;};

◆ nhitsTrail()

uint16_t Muon::nsw::NSWElink::nhitsTrail ( ) const
inline

Definition at line 56 of file NSWElink.h.

56{return m_nhitsTrail;};

◆ noTdc()

bool Muon::nsw::NSWElink::noTdc ( ) const
inline

Definition at line 43 of file NSWElink.h.

43{return m_noTdc;};

◆ nwords()

unsigned int Muon::nsw::NSWElink::nwords ( ) const
inline

Definition at line 32 of file NSWElink.h.

32{return m_wordCount;};

◆ operator=()

NSWElink & Muon::nsw::NSWElink::operator= ( const NSWElink & )
delete

◆ orbit()

uint16_t Muon::nsw::NSWElink::orbit ( ) const
inline

Definition at line 48 of file NSWElink.h.

48{return m_orbit;};

◆ rocId()

uint16_t Muon::nsw::NSWElink::rocId ( ) const
inline

Definition at line 46 of file NSWElink.h.

46{return m_rocId;};

◆ status()

unsigned int Muon::nsw::NSWElink::status ( ) const
inline

Definition at line 34 of file NSWElink.h.

34{return m_packet_status;};

◆ test_checksum()

unsigned int Muon::nsw::NSWElink::test_checksum ( const uint8_t * buffer,
unsigned int buflen )
inlineprivate

Definition at line 93 of file NSWElink.h.

94{
95 const uint8_t *p = buffer;
96 unsigned int running_checksum = 0;
97
98 for (unsigned int i = 0; i < buflen; ++i, ++p)
99 running_checksum += *p;
100
101 running_checksum = (running_checksum & 0xff) + (running_checksum >> 8); // add carry bits
102 running_checksum = (running_checksum & 0xff) + (running_checksum >> 8); // do it twice
103 running_checksum = (~running_checksum) & 0xff;
104
105 return running_checksum;
106}

◆ tout()

bool Muon::nsw::NSWElink::tout ( ) const
inline

Definition at line 51 of file NSWElink.h.

51{return m_tout;};

Member Data Documentation

◆ m_bcId

uint16_t Muon::nsw::NSWElink::m_bcId
private

Definition at line 78 of file NSWElink.h.

◆ m_channels

std::vector<Muon::nsw::VMMChannel *> Muon::nsw::NSWElink::m_channels
private

Definition at line 86 of file NSWElink.h.

◆ m_checksum

uint8_t Muon::nsw::NSWElink::m_checksum
private

Definition at line 74 of file NSWElink.h.

◆ m_elinkId

Muon::nsw::NSWResourceId* Muon::nsw::NSWElink::m_elinkId
private

Definition at line 85 of file NSWElink.h.

◆ m_elinkWord

uint32_t Muon::nsw::NSWElink::m_elinkWord
private

Definition at line 84 of file NSWElink.h.

◆ m_extended

bool Muon::nsw::NSWElink::m_extended
private

Definition at line 72 of file NSWElink.h.

◆ m_flagMiss

uint16_t Muon::nsw::NSWElink::m_flagMiss
private

Definition at line 82 of file NSWElink.h.

◆ m_isNull

bool Muon::nsw::NSWElink::m_isNull
private

Definition at line 69 of file NSWElink.h.

◆ m_l0Id

uint16_t Muon::nsw::NSWElink::m_l0Id
private

Definition at line 81 of file NSWElink.h.

◆ m_l1Id

uint16_t Muon::nsw::NSWElink::m_l1Id
private

Definition at line 76 of file NSWElink.h.

◆ m_nhits

unsigned int Muon::nsw::NSWElink::m_nhits
private

Definition at line 65 of file NSWElink.h.

◆ m_nhitsTrail

uint16_t Muon::nsw::NSWElink::m_nhitsTrail
private

Definition at line 80 of file NSWElink.h.

◆ m_noTdc

bool Muon::nsw::NSWElink::m_noTdc
private

Definition at line 70 of file NSWElink.h.

◆ m_orbit

uint16_t Muon::nsw::NSWElink::m_orbit
private

Definition at line 79 of file NSWElink.h.

◆ m_packet_status

unsigned int Muon::nsw::NSWElink::m_packet_status
private

Definition at line 67 of file NSWElink.h.

◆ m_rocId

uint16_t Muon::nsw::NSWElink::m_rocId
private

Definition at line 77 of file NSWElink.h.

◆ m_running_checksum

unsigned int Muon::nsw::NSWElink::m_running_checksum
private

Definition at line 66 of file NSWElink.h.

◆ m_tout

bool Muon::nsw::NSWElink::m_tout
private

Definition at line 71 of file NSWElink.h.

◆ m_wordCount

unsigned int Muon::nsw::NSWElink::m_wordCount
private

Definition at line 64 of file NSWElink.h.

◆ s_null_packet_length

const unsigned int Muon::nsw::NSWElink::s_null_packet_length = 10
staticprivate

Definition at line 88 of file NSWElink.h.


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