ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1CaloFEX
L1CaloFEXByteStream
src
infraL1Calo
src
EfexTrexFibrePacker.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
infraL1Calo/EfexTrexFibrePacker.h
"
5
6
#include <iostream>
7
#include <cstdlib>
8
#include <cmath>
9
#include <map>
10
11
12
std::vector<FibrePackerBase::myDataWord>
EfexTrexFibrePacker::getPackedData
(
const
std::vector<myDataWord>& inFrame,
13
myDataWord
bcNumber,
14
InputDataFrameType
frameType)
const
{
15
16
std::vector<myDataWord> dataToLoad(
FexDefs::num32BitWordsPerFibre
(),0);
17
auto
supercells = inFrame;
18
19
switch
(frameType){
20
21
case
InputDataFrameType::Normal
:
// Standard data pattern
22
{
23
for
(
auto
& icell:supercells)
24
icell = icell & 0x3ff;
// truncate to 10 bits
25
26
myDataWord
bcId
= bcNumber & 0x7f ;
// 7 bits from BCID
27
myDataWord
bcIdFull = bcNumber & 0xfff;
// full 12 bit BCID
28
myDataWord
bcId02 =
bcId
& 0x7;
29
myDataWord
bcId34 = (
bcId
>> 3) & 0x3;
30
myDataWord
bcId56 = (
bcId
>> 5) & 0x3;
31
32
dataToLoad.at(0) = (bcId56 << 8) | ((supercells.at(0)&0xff) <<10) |
33
((supercells.at(1)&0xff) << 20) | (bcId34 << 30);
34
dataToLoad.at(1) = (supercells.at(2)&0xff) | ((supercells.at(3)&0xff) << 10) |
35
((supercells.at(4)&0xff) << 20);
36
dataToLoad.at(2) = (supercells.at(5)&0xff) | ((supercells.at(6)&0xff) << 10) |
37
((supercells.at(7)&0xff) << 20);
38
dataToLoad.at(3) = (supercells.at(8)&0xff) | ((supercells.at(9)&0xff) << 10) |
39
((supercells.at(10)&0xff) << 20);
40
dataToLoad.at(4) = (supercells.at(11)&0xff) | ((supercells.at(12)&0xff) << 10) |
41
((supercells.at(13)&0xff) << 20);
42
dataToLoad.at(5) = (supercells.at(14)&0xff) | ((supercells.at(15)&0xff) << 10) ;
43
dataToLoad.at(6) = bcIdFull | bcId02 << 20;
44
45
myDataWord
tempCRC =
crc9d32
(dataToLoad,6l,
true
);
// calculate CRC32 on first 6 words
46
myDataWord
myCRCReminder =
crc9d23
(dataToLoad[6],tempCRC,
true
);
// CRC23 on the last word
47
48
dataToLoad.at(0) =
K_28_5
| dataToLoad.at(0) ;
// add K-character
49
dataToLoad[6] = dataToLoad[6] | ( myCRCReminder << 23) ;
// add CRC check
50
51
break
;
52
}
53
case
InputDataFrameType::Alignement
:
// Special pattern, LATOME alignement/mapping frame
54
{
55
56
myDataWord
bcId
= bcNumber & 0xfff ;
// 12 bits of BCID
57
58
dataToLoad.at(6) =
bcId
;
59
dataToLoad.at(0) = (
K_28_0
<< 8) | dataToLoad.at(0) ;
// add K_28_0 -character, used for CRC calculation
60
61
myDataWord
tempCRC =
crc9d32
(dataToLoad,6l,
true
);
// calculate CRC32 on first 6 words
62
myDataWord
myCRCReminder =
crc9d23
(dataToLoad[6],tempCRC,
true
);
// CRC23 on the last word
63
64
dataToLoad.at(0) =
K_28_5
| dataToLoad.at(0) ;
// add K-character
65
dataToLoad[6] = dataToLoad[6] | ( myCRCReminder << 23) ;
// add CRC check to the famous last word
66
67
break
;
68
}
69
}
70
71
return
dataToLoad;
72
73
}
74
75
std::vector<FibrePackerBase::myDataWord>
EfexTrexFibrePacker::getPackedControl
(
const
std::vector<myDataWord>&
/*inFrame*/
,
76
myDataWord
/*bcNumber*/
,
77
InputDataFrameType
frameType)
const
{
78
79
std::vector<myDataWord> controlWords(
FexDefs::num32BitWordsPerFibre
(),0);
80
81
switch
(frameType){
82
83
case
InputDataFrameType::Normal
:
// one K character in first data word
84
controlWords.at(0) = 0x1;
85
break
;
86
87
case
InputDataFrameType::Alignement
:
// two K characters in first data word
88
controlWords.at(0) = 0x3;
89
break
;
90
91
}
92
93
return
controlWords;
94
}
95
96
bool
EfexTrexFibrePacker::checkCRC
(
const
std::vector<myDataWord>& encodedData,
97
InputDataFrameType
frameType)
const
{
98
99
auto
inputData = encodedData;
100
myDataWord
CRCCheck = 0;
101
102
switch
(frameType){
103
104
case
InputDataFrameType::Normal
:
// one K character in first data word
105
inputData.at(0) = inputData.at(0) & 0xffffff00;
106
CRCCheck =
crc9d32
(inputData,7l,
true
);
// calculate CRC32 on first 6 words
107
break
;
108
109
case
InputDataFrameType::Alignement
:
// two K characters in first data word, mask the first one
110
inputData.at(0) = inputData.at(0) & 0xffffff00;
111
CRCCheck =
crc9d32
(inputData,7l,
true
);
// calculate CRC32 on first 6 words
112
break
;
113
114
}
115
116
return
(CRCCheck == 0);
117
}
118
119
FibrePackerBase::myDataWord
EfexTrexFibrePacker::getBcNumber
(
const
std::vector<myDataWord>& encodedData,
120
InputDataFrameType
/*frameType*/
)
const
{
121
myDataWord
BcNumber = encodedData.at(6) & 0xfff;
122
return
BcNumber;
123
}
124
125
FibrePackerBase::myDataWord
EfexTrexFibrePacker::getBcMask
(
InputDataFrameType
/*frameType*/
)
const
{
126
// BC number is the full 12 bits from any frame.
127
return
0xfff;
128
}
129
130
std::vector<FibrePackerBase::myDataWord>
EfexTrexFibrePacker::getUnpackedData
(
const
std::vector<myDataWord>& encodedData,
131
InputDataFrameType
frameType)
const
{
132
std::vector<myDataWord> unpackedData;
133
134
switch
(frameType){
135
136
case
InputDataFrameType::Normal
:
137
{
138
std::vector<myDataWord> supercells(
EfexDefs::maxSuperCellsPerFibre
(),0);
139
140
supercells[0] = (encodedData[0] >> 10) & 0x3ff;
141
supercells[1] = (encodedData[0] >> 20) & 0x3ff;
142
supercells[2] = (encodedData[1] ) & 0x3ff;
143
supercells[3] = (encodedData[1] >> 10) & 0x3ff;
144
supercells[4] = (encodedData[1] >> 20) & 0x3ff;
145
supercells[5] = (encodedData[2] ) & 0x3ff;
146
supercells[6] = (encodedData[2] >> 10) & 0x3ff;
147
supercells[7] = (encodedData[2] >> 20) & 0x3ff;
148
supercells[8] = (encodedData[3] ) & 0x3ff;
149
supercells[9] = (encodedData[3] >> 10) & 0x3ff;
150
supercells[10] = (encodedData[3] >> 20) & 0x3ff;
151
supercells[11] = (encodedData[4] ) & 0x3ff;
152
supercells[12] = (encodedData[4] >> 10) & 0x3ff;
153
supercells[13] = (encodedData[4] >> 20) & 0x3ff;
154
supercells[14] = (encodedData.at(5) ) & 0x3ff;
155
supercells.at(15) = (encodedData[5] >> 10) & 0x3ff;
156
157
unpackedData=std::move(supercells);
158
break
;
159
}
160
case
InputDataFrameType::Alignement
:
161
{
162
break
;
// no hyper data in the frame
163
}
164
}
165
166
return
unpackedData;
167
168
}
169
EfexTrexFibrePacker.h
bcId
uint16_t bcId(uint32_t data)
Definition
TgcByteStreamData.h:326
EfexDefs::maxSuperCellsPerFibre
static int maxSuperCellsPerFibre()
Definition
EfexDefs.h:27
EfexTrexFibrePacker::getPackedData
virtual std::vector< myDataWord > getPackedData(const std::vector< myDataWord > &inFrame, myDataWord bcNumber, InputDataFrameType frameType) const override
Function packing the data into the LATOME format, either standard or alignement frame.
Definition
EfexTrexFibrePacker.cxx:12
EfexTrexFibrePacker::getBcNumber
virtual myDataWord getBcNumber(const std::vector< myDataWord > &encodedData, InputDataFrameType frameType) const override
Definition
EfexTrexFibrePacker.cxx:119
EfexTrexFibrePacker::getPackedControl
virtual std::vector< myDataWord > getPackedControl(const std::vector< myDataWord > &inFrame, myDataWord bcNumber, InputDataFrameType frameType) const override
Function returning control words.
Definition
EfexTrexFibrePacker.cxx:75
EfexTrexFibrePacker::getBcMask
virtual myDataWord getBcMask(InputDataFrameType frameType) const override
Definition
EfexTrexFibrePacker.cxx:125
EfexTrexFibrePacker::getUnpackedData
virtual std::vector< myDataWord > getUnpackedData(const std::vector< myDataWord > &encodedData, InputDataFrameType frameType) const override
Function unpacking the data from LATOME format, either standard or alignement frame.
Definition
EfexTrexFibrePacker.cxx:130
EfexTrexFibrePacker::checkCRC
virtual bool checkCRC(const std::vector< myDataWord > &encodedData, InputDataFrameType frameType) const override
Definition
EfexTrexFibrePacker.cxx:96
FexDefs::num32BitWordsPerFibre
static int num32BitWordsPerFibre()
Definition
FexDefs.h:17
FibrePackerBase::crc9d32
virtual myDataWord crc9d32(const std::vector< myDataWord > &inwords, size_t num_words, bool bit_reverse) const
Definition
FibrePackerBase.cxx:40
FibrePackerBase::K_28_5
myDataWord K_28_5
Definition
FibrePackerBase.h:30
FibrePackerBase::InputDataFrameType
InputDataFrameType
type of input data frame
Definition
FibrePackerBase.h:37
FibrePackerBase::InputDataFrameType::Normal
@ Normal
Standard data frame.
Definition
FibrePackerBase.h:38
FibrePackerBase::InputDataFrameType::Alignement
@ Alignement
Special mapping/alignement frame.
Definition
FibrePackerBase.h:39
FibrePackerBase::K_28_0
myDataWord K_28_0
Definition
FibrePackerBase.h:32
FibrePackerBase::myDataWord
uint32_t myDataWord
Definition
FibrePackerBase.h:25
FibrePackerBase::crc9d23
virtual myDataWord crc9d23(myDataWord inword, myDataWord in_crc, bool bit_reverse) const
Definition
FibrePackerBase.cxx:111
Generated on
for ATLAS Offline Software by
1.17.0