Project
Loading...
Searching...
No Matches
SAC.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
15
16#ifndef ALICEO2_DATAFORMATSTPC_SAC_H
17#define ALICEO2_DATAFORMATSTPC_SAC_H
18
19#include <cstdint>
20#include <string_view>
21
22namespace o2::tpc::sac
23{
24
25static constexpr uint32_t FEsPerInstance = 9;
26
28struct headerDef {
29 static constexpr uint32_t MagicWord = 0xabcd;
30
31 union {
32 uint64_t word0 = 0;
33 struct {
34 uint32_t version : 8;
35 uint32_t instance : 4;
36 uint32_t empty0 : 8;
37 uint32_t bunchCrossing : 12;
38 uint32_t orbit : 32;
39 };
40 };
42 union {
43 uint64_t word1 = 0;
44 struct {
45 uint32_t pktCount : 16;
46 uint32_t empty1_0 : 16;
47 uint32_t empty1_1;
48 };
49 };
51 union {
52 uint64_t word2 = 0;
53 };
55 union {
56 uint64_t word3 = 0;
57 struct {
58 uint32_t empty3_0;
59 uint32_t empty3_1 : 16;
60 uint32_t magicWord : 16;
61 };
62 };
63
64 bool check() const { return magicWord == MagicWord; }
65};
66
67struct dataDef {
68 static constexpr uint32_t HeaderWord = 0xdeadbeef;
69 static constexpr uint32_t TrailerWord = 0xbeefdead;
70 static constexpr uint32_t PacketSize = 1024;
71 static constexpr uint32_t DataSize = 1000;
72
73 uint32_t header = 0;
75 union {
76 uint32_t sizeFE = 0;
77 struct {
78 uint32_t feid : 8;
79 uint32_t pktSize : 24;
80 };
81 };
83 uint32_t pktNumber = 0;
84 uint32_t timeStamp = 0;
86 uint32_t crc32 = 0;
87 uint32_t trailer = 0;
88
89 bool check() const
90 {
91 return (header == HeaderWord) && (trailer == TrailerWord) && (pktSize == PacketSize);
92 }
93};
94
95struct packet {
98
99 uint32_t getInstance() const
100 {
101 return header.instance;
102 }
103
107 uint32_t getFEIndex() const
108 {
109 return data.feid - 1 + header.instance * FEsPerInstance;
110 }
111
112 std::string_view getDataWords()
113 {
114 return std::string_view(data.dataWords, dataDef::DataSize);
115 }
116
117 bool check() const
118 {
119 return header.check() && data.check();
120 }
121
122 int getCheckMask() const
123 {
124 return (header.check() << 1) | data.check();
125 }
126};
127
128} // namespace o2::tpc::sac
129
130#endif
GLboolean * data
Definition glcorearb.h:298
uint32_t header
Definition SAC.h:73
uint32_t pktNumber
packet number of this front end card. Should always increase by 1
Definition SAC.h:83
uint32_t crc32
CRC32 checksum.
Definition SAC.h:86
uint32_t pktSize
total size of the packet in bytes, should always be 1024
Definition SAC.h:79
static constexpr uint32_t TrailerWord
Definition SAC.h:69
uint32_t feid
front end ID (card number in rack): 1 - 9
Definition SAC.h:78
uint32_t trailer
trailer magic word, should always be TrailerWord
Definition SAC.h:87
uint32_t timeStamp
time stamp
Definition SAC.h:84
static constexpr uint32_t DataSize
Definition SAC.h:71
static constexpr uint32_t PacketSize
Definition SAC.h:70
uint32_t sizeFE
Definition SAC.h:76
static constexpr uint32_t HeaderWord
Definition SAC.h:68
bool check() const
Definition SAC.h:89
char dataWords[DataSize]
ASCI encoded SAC data.
Definition SAC.h:85
256bit CRU header word of SACs
Definition SAC.h:28
uint64_t word2
bits 128 - 191
Definition SAC.h:52
bool check() const
Definition SAC.h:64
uint32_t version
header version number
Definition SAC.h:34
uint32_t bunchCrossing
bunch crossing when SAC packet was received
Definition SAC.h:37
uint32_t orbit
orbit when SAC packet was received
Definition SAC.h:38
uint32_t empty1_0
not used
Definition SAC.h:46
uint32_t pktCount
<
Definition SAC.h:45
uint32_t instance
0: TPC A (slave), 1: TPC C (master), 2/3: TRD
Definition SAC.h:35
uint32_t empty3_0
Definition SAC.h:58
uint32_t empty1_1
not used
Definition SAC.h:47
uint64_t word0
bits 0 - 63
Definition SAC.h:32
uint32_t empty3_1
Definition SAC.h:59
uint64_t word1
bits 64 - 127
Definition SAC.h:43
uint32_t magicWord
magic word should always correspond to MagicWord
Definition SAC.h:60
static constexpr uint32_t MagicWord
magic word
Definition SAC.h:29
uint32_t empty0
not used
Definition SAC.h:36
uint64_t word3
bits 192 - 255
Definition SAC.h:56
bool check() const
Definition SAC.h:117
uint32_t getInstance() const
Definition SAC.h:99
int getCheckMask() const
Definition SAC.h:122
dataDef data
Definition SAC.h:97
std::string_view getDataWords()
Definition SAC.h:112
headerDef header
Definition SAC.h:96
uint32_t getFEIndex() const
Definition SAC.h:107