Project
Loading...
Searching...
No Matches
RawFormats.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 ALICEO2_CPV_RAWFORMATS_H
13#define ALICEO2_CPV_RAWFORMATS_H
14
15#include <cstdint>
17
18namespace o2
19{
20
21namespace cpv
22{
23
24// Pack information into 24 bit words
25union PadWord {
27 struct {
33 };
34 char mBytes[4];
35};
36
38{
39 public:
40 CpvWord() = default;
41 CpvWord(std::vector<char>::const_iterator b, std::vector<char>::const_iterator e)
42 { // Reading
43 // resposibility of coller to esure that
44 // array will not end while reading
45 for (int i = 0; i < 10 && b != e; i++, b++) {
46 mBytes[i] = *b;
47 }
48 }
49 ~CpvWord() = default;
50 bool isOK() const
51 {
52 return (mBytes[9] < static_cast<unsigned char>(24));
53 }
54 short ccId() const { return short(mBytes[9]); }
56 {
57 PadWord p = {0};
58 p.mBytes[0] = mBytes[3 * i];
59 p.mBytes[1] = mBytes[3 * i + 1];
60 p.mBytes[2] = mBytes[3 * i + 2];
61 return p.mDataWord;
62 }
63
64 public:
65 unsigned char mBytes[10] = {0};
66};
67
69{
70 public:
71 CpvHeader() = default;
72 CpvHeader(std::vector<char>::const_iterator b, std::vector<char>::const_iterator e)
73 { // reading header from file
74 for (int i = 0; i < 10 && b != e; i++, b++) { // read up to 10 mBytes
75 mBytes[i] = *b;
76 }
77 }
79 { // writing header
80 // header is 128-bit word.
81 // |127-120|119-112|111-104|103-96|95-88 |87-80 |79-72|71-64|63-56|55-48|47-40|39-32|31-24|23-16|15-8 |7-0 |
82 // byte15 byte14 byte13 byte12 byte11 byte10 byte9 byte8 byte7 byte6 byte5 byte4 byte3 byte2 byte1 byte0
83 // byte = |76543210|
84 mBytes[0] = (0x010 & 0x0ff); // bits 11 - 0 trigger id (0x010 = physics trigger)
85 mBytes[1] = ((0x010 & 0xf00) >> 8) // bits 11 - 0 trigger id (0x010 = physics trigger)
86 + 0b00100000 * isNoDataExpected + 0b0100000 * isDataContinued; // bit 13 (no data for this trigger) + bit 14 (payload continues from previous page)
87 mBytes[2] = (orbitBC.bc & 0x00ff); // bits 27 - 16 bunch crossing
88 mBytes[3] = (orbitBC.bc & 0x0f00) >> 8; // bits 27 - 16 bunch crossing
89 mBytes[4] = (orbitBC.orbit & 0x000000ff); // bits 63 - 32 orbit
90 mBytes[5] = (orbitBC.orbit & 0x0000ff00) >> 8; // bits 63 - 32 orbit
91 mBytes[6] = (orbitBC.orbit & 0x00ff0000) >> 16; // bits 63 - 32 orbit
92 mBytes[7] = (orbitBC.orbit & 0xff000000) >> 24; // bits 63 - 32 orbit
93 mBytes[8] = 0x00; // bits 64-71 reserved
94 mBytes[9] = 0xe0; // word ID of cpv header (bits 79 - 72)
95 }
96 ~CpvHeader() = default;
97 bool isOK() const { return (mBytes[9] == 0xe0); }
98 bool isNoDataExpected() const { return mBytes[1] & 0b00100000; }
99 bool isDataContinued() const { return mBytes[1] & 0b0100000; }
100 uint16_t bc() const { return static_cast<uint16_t>(mBytes[2]) + static_cast<uint16_t>((mBytes[3] & 0x0f) << 8); }
101 uint32_t orbit() const { return mBytes[4] + (mBytes[5] << 8) + (mBytes[6] << 16) + (mBytes[7] << 24); }
102
103 public:
104 unsigned char mBytes[10] = {0}; // 0 - 79 bits (10 bytes)
105};
106
108{
109 public:
110 CpvTrailer() = default;
111 CpvTrailer(std::vector<char>::const_iterator b, std::vector<char>::const_iterator e)
112 { // reading
113 for (int i = 0; i < 10 && b != e; i++, b++) { // read up to 10 mBytes
114 mBytes[i] = *b;
115 }
116 }
117 CpvTrailer(unsigned short wordCounter, uint16_t bunchCrossing, bool isAllDataSent)
118 { // writing
119 mBytes[0] = bunchCrossing & 0x00ff; // bits 11 - 0 bunch crossing
120 mBytes[1] = ((bunchCrossing & 0x0f00) >> 8) // bits 11 - 0 bunch crossing
121 + ((wordCounter & 0x0f) << 4); // bits 20 - 12 wordCounter
122 mBytes[2] = (wordCounter & 0b1111110000) >> 4; // bits 21 - 12 wordCounter
123
124 for (int i = 3; i < 8; i++) {
125 mBytes[i] = 0; // bits 70 - 22 reserved
126 }
127 mBytes[8] = isAllDataSent * 0b10000000; // bit 71 all data is sent for current trigger
128 mBytes[9] = char(0xf0); // word ID of cpv trailer
129 }
130 ~CpvTrailer() = default;
131 bool isOK() const { return (mBytes[9] == 0xf0); }
132 uint16_t wordCounter() const { return (mBytes[1] >> 4) + ((mBytes[2] & 0b00111111) << 4); }
133 bool isAllDataSent() const { return (mBytes[8] & 0b10000000); }
134 uint16_t bc() const { return mBytes[0] + ((mBytes[1] & 0x0f) << 8); }
135
136 public:
137 unsigned char mBytes[10] = {0};
138};
139
140} // namespace cpv
141
142} // namespace o2
143
144#endif
unsigned short int uint16_t
int32_t i
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 e
~CpvHeader()=default
unsigned char mBytes[10]
Definition RawFormats.h:104
CpvHeader(std::vector< char >::const_iterator b, std::vector< char >::const_iterator e)
Definition RawFormats.h:72
uint16_t bc() const
Definition RawFormats.h:100
bool isOK() const
Definition RawFormats.h:97
bool isNoDataExpected() const
Definition RawFormats.h:98
CpvHeader(InteractionRecord orbitBC, bool isNoDataExpected, bool isDataContinued)
Definition RawFormats.h:78
uint32_t orbit() const
Definition RawFormats.h:101
bool isDataContinued() const
Definition RawFormats.h:99
uint16_t bc() const
Definition RawFormats.h:134
uint16_t wordCounter() const
Definition RawFormats.h:132
bool isAllDataSent() const
Definition RawFormats.h:133
unsigned char mBytes[10]
Definition RawFormats.h:137
bool isOK() const
Definition RawFormats.h:131
CpvTrailer(std::vector< char >::const_iterator b, std::vector< char >::const_iterator e)
Definition RawFormats.h:111
CpvTrailer(unsigned short wordCounter, uint16_t bunchCrossing, bool isAllDataSent)
Definition RawFormats.h:117
CpvWord()=default
~CpvWord()=default
bool isOK() const
Definition RawFormats.h:50
short ccId() const
Definition RawFormats.h:54
uint32_t cpvPadWord(int i) const
Definition RawFormats.h:55
unsigned char mBytes[10]
Definition RawFormats.h:65
CpvWord(std::vector< char >::const_iterator b, std::vector< char >::const_iterator e)
Definition RawFormats.h:41
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t dil
Bits 21 - 22 : dilogic (1..24)
Definition RawFormats.h:31
uint32_t charge
Bits 0 - 11 : charge.
Definition RawFormats.h:28
uint32_t address
Bits 12 - 17 : address (0..47)
Definition RawFormats.h:29
uint32_t mDataWord
Definition RawFormats.h:26
uint32_t zero
Bits 23 - 23 : control bit (0 -> pad word, 1 -> FEE control word)
Definition RawFormats.h:32
uint32_t gas
Bits 18 - 20 : gasiplex (1..10)
Definition RawFormats.h:30