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
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;
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);
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
153
158
164
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
unsigned short int uint16_t
o2::raw::RawFileWriter * raw
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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.
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)