ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
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 
47  m_elinkWord = bs[m_wordCount++];
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;
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";
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;
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  {
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 }

◆ ~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:
Muon::nsw::bitMaskSRocORBIT
@ bitMaskSRocORBIT
Definition: NSWDecodeBitmaps.h:57
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Muon::nsw::bitMaskSRocNULL
@ bitMaskSRocNULL
Definition: NSWDecodeBitmaps.h:58
Muon::nsw::bitPosTrailTO
@ bitPosTrailTO
Definition: NSWDecodeBitmaps.h:109
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Muon::nsw::bitMaskFlxLENGTH
@ bitMaskFlxLENGTH
Definition: NSWDecodeBitmaps.h:48
Muon::nsw::bitPosFlxLENGTH
@ bitPosFlxLENGTH
Definition: NSWDecodeBitmaps.h:82
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Muon::nsw::bitMaskSRocNullL1ID
@ bitMaskSRocNullL1ID
Definition: NSWDecodeBitmaps.h:53
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Muon::nsw::bitMaskTrailL0ID
@ bitMaskTrailL0ID
Definition: NSWDecodeBitmaps.h:73
Muon::nsw::bitMaskSRocL1ID
@ bitMaskSRocL1ID
Definition: NSWDecodeBitmaps.h:55
Muon::nsw::bitMaskSRocBCID
@ bitMaskSRocBCID
Definition: NSWDecodeBitmaps.h:56
Muon::nsw::bitPosSRocL1ID
@ bitPosSRocL1ID
Definition: NSWDecodeBitmaps.h:89
Muon::nsw::bitPosTrailLENGTH
@ bitPosTrailLENGTH
Definition: NSWDecodeBitmaps.h:106
Muon::nsw::bitPosSRocBCID
@ bitPosSRocBCID
Definition: NSWDecodeBitmaps.h:90
Muon::nsw::bitPosTrailL0ID
@ bitPosTrailL0ID
Definition: NSWDecodeBitmaps.h:107
Muon::nsw::bitPosTrailEXTENDED
@ bitPosTrailEXTENDED
Definition: NSWDecodeBitmaps.h:110
Muon::nsw::bitPosSRocNOTDC
@ bitPosSRocNOTDC
Definition: NSWDecodeBitmaps.h:93
Muon::nsw::bitPosSRocNullID
@ bitPosSRocNullID
Definition: NSWDecodeBitmaps.h:88
Muon::nsw::bitPosSRocNULL
@ bitPosSRocNULL
Definition: NSWDecodeBitmaps.h:92
Muon::nsw::bitPosTrailCHECKSUM
@ bitPosTrailCHECKSUM
Definition: NSWDecodeBitmaps.h:105
Muon::nsw::helper::get_bits
uint32_t get_bits(uint32_t word, uint32_t mask, uint8_t position)
Definition: NSWDecodeHelper.h:168
Muon::nsw::bitPosSRocNullL1ID
@ bitPosSRocNullL1ID
Definition: NSWDecodeBitmaps.h:87
Muon::nsw::bitMaskSRocNullID
@ bitMaskSRocNullID
Definition: NSWDecodeBitmaps.h:54
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
Muon::nsw::bitMaskTrailEXTENDED
@ bitMaskTrailEXTENDED
Definition: NSWDecodeBitmaps.h:76
Muon::nsw::bitPosFlxSTATUS
@ bitPosFlxSTATUS
Definition: NSWDecodeBitmaps.h:83
lumiFormat.i
int i
Definition: lumiFormat.py:85
Muon::nsw::bitMaskTrailLENGTH
@ bitMaskTrailLENGTH
Definition: NSWDecodeBitmaps.h:72
Muon::nsw::NSWResourceId
Definition: NSWResourceId.h:42
Muon::nsw::bitMaskTrailCHECKSUM
@ bitMaskTrailCHECKSUM
Definition: NSWDecodeBitmaps.h:71
Muon::nsw::VMMChannel
Definition: VMMChannel.h:16
Muon::nsw::NSWElinkROCHeaderException
NSWElinkROCHeaderException
Definition: NSWDecodeExceptions.h:22
Muon::nsw::bitMaskFlxSTATUS
@ bitMaskFlxSTATUS
Definition: NSWDecodeBitmaps.h:49
Muon::nsw::bitMaskSRocNOTDC
@ bitMaskSRocNOTDC
Definition: NSWDecodeBitmaps.h:59
Muon::nsw::bitMaskTrailTO
@ bitMaskTrailTO
Definition: NSWDecodeBitmaps.h:75
Muon::nsw::bitPosSRocORBIT
@ bitPosSRocORBIT
Definition: NSWDecodeBitmaps.h:91
Muon::nsw::bitPosTrailFLAGMISS
@ bitPosTrailFLAGMISS
Definition: NSWDecodeBitmaps.h:108
python.compressB64.c
def c
Definition: compressB64.py:93
Muon::nsw::bitMaskTrailFLAGMISS
@ bitMaskTrailFLAGMISS
Definition: NSWDecodeBitmaps.h:74