Project
Loading...
Searching...
No Matches
SampaHeader.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_MCH_RAW_SAMPA_HEADER
13#define O2_MCH_RAW_SAMPA_HEADER
14
15#include <cstdlib>
16#include <iostream>
18
19namespace o2
20{
21namespace mch
22{
23namespace raw
24{
25
26enum class SampaPacketType : uint8_t {
27 HeartBeat = 0,
28 DataTruncated = 1,
29 Sync = 2,
31 Data = 4,
32 DataNumWords = 5,
35};
36
49
51{
52 public:
53 explicit SampaHeader(uint64_t value = 0);
54
67 explicit SampaHeader(uint8_t hamming,
68 bool p,
70 uint16_t numWords,
71 uint8_t h,
73 uint32_t bx,
74 bool dp);
75
76 bool operator==(const SampaHeader& rhs) const;
77 bool operator!=(const SampaHeader& rhs) const;
78 bool operator<(const SampaHeader& rhs) const;
79 bool operator<=(const SampaHeader& rhs) const;
80 bool operator>(const SampaHeader& rhs) const;
81 bool operator>=(const SampaHeader& rhs) const;
82
84 bool hasError() const;
85 bool hasHammingError() const;
86 bool hasParityError() const;
87
91 uint8_t hammingCode() const;
92 bool headerParity() const;
94 uint16_t nof10BitWords() const;
95 uint8_t chipAddress() const;
97 uint32_t bunchCrossingCounter() const;
98 bool payloadParity() const;
100
105 void hammingCode(uint8_t hamming);
106 void headerParity(bool p);
107 void packetType(SampaPacketType pkt);
108 void nof10BitWords(uint16_t nofwords);
109 void chipAddress(uint8_t h);
111 void bunchCrossingCounter(uint32_t bx);
112 void payloadParity(bool dp);
114
116 constexpr uint64_t uint64() const { return mValue; }
117
120 void uint64(uint64_t value);
121
122 bool isHeartbeat() const;
123
124 private:
125 uint64_t mValue;
126};
127
128constexpr uint64_t sampaSyncWord{0x1555540f00113};
129
131constexpr bool isSampaSync(uint64_t w)
132{
133 constexpr uint64_t FIFTYBITSATONE = (static_cast<uint64_t>(1) << 50) - 1;
134 return ((w & FIFTYBITSATONE) == sampaSyncWord);
135}
136
138SampaHeader sampaSync();
139
141SampaHeader sampaHeartbeat(uint8_t elinkId, uint20_t bunchCrossing);
142
144DualSampaChannelId getDualSampaChannelId(const SampaHeader& sh);
145
147std::string packetTypeName(SampaPacketType pkt);
148
152int computeHammingCode(uint64_t value);
153
154int computeHammingCode1(uint64_t value);
155int computeHammingCode2(uint64_t value);
156int computeHammingCode3(uint64_t value);
157int computeHammingCode4(uint64_t value);
158
163int computeHeaderParity(uint64_t value);
164
165int computeHeaderParity1(uint64_t value);
166int computeHeaderParity2(uint64_t value);
167int computeHeaderParity3(uint64_t value);
168int computeHeaderParity4(uint64_t value);
169
170std::string asString(const SampaHeader& sh);
171
172std::ostream&
173 operator<<(std::ostream& os, const SampaHeader& sh);
174
175} // namespace raw
176} // namespace mch
177} // namespace o2
178
179#endif
Class for time synchronization of RawReader instances.
SampaHeader is the 50-bits header word used in Sampa data transmission protocol.
Definition SampaHeader.h:51
bool operator<=(const SampaHeader &rhs) const
bool operator<(const SampaHeader &rhs) const
bool hasError() const
whether the header has error (according to hamming and/or parity)
SampaChannelAddress channelAddress() const
uint16_t nof10BitWords() const
bool operator==(const SampaHeader &rhs) const
bool operator>=(const SampaHeader &rhs) const
uint8_t chipAddress() const
uint32_t bunchCrossingCounter() const
constexpr uint64_t uint64() const
return the header as a 64-bits integer
bool operator>(const SampaHeader &rhs) const
bool operator!=(const SampaHeader &rhs) const
SampaPacketType packetType() const
uint8_t hammingCode() const
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
constexpr bool isSampaSync(uint64_t w)
Whether the 50 LSB bits match the sync word.
uint5_t SampaChannelAddress
Definition DataFormats.h:64
int computeHeaderParity(uint64_t value)
int computeHammingCode3(uint64_t value)
DualSampaChannelId getDualSampaChannelId(const SampaHeader &sh)
Return channel number (0..63)
std::string packetTypeName(SampaPacketType pkt)
packetTypeName returns a string representation of the given packet type.
int computeHeaderParity1(uint64_t value)
SampaHeader sampaHeartbeat(uint8_t elinkId, uint20_t bunchCrossing)
Heartbeat packet.
constexpr uint64_t sampaSyncWord
SampaHeader sampaSync()
The 50-bits Sampa SYNC word.
int computeHammingCode2(uint64_t value)
int computeHeaderParity4(uint64_t value)
int computeHammingCode1(uint64_t value)
int computeHeaderParity2(uint64_t value)
uint6_t DualSampaChannelId
Definition DataFormats.h:65
uint32_t uint20_t
Definition DataFormats.h:68
int computeHeaderParity3(uint64_t value)
std::string asString(const SampaCluster &sc)
int computeHammingCode4(uint64_t value)
int computeHammingCode(uint64_t value)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)