11 : pset_(ps), fedId_(0), run_number_(0), orbit_number_(0), bx_(0), lv1_(0), trgtype_(0) {
26 int nLines, iz, ip,
ix,
iy, fed, kchip, pace, bundle, fiber, optorx;
33 file >> iz >> ip >>
ix >>
iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
35 zside_[kchip - 1][pace - 1] = iz;
36 pl_[kchip - 1][pace - 1] = ip;
37 x_[kchip - 1][pace - 1] =
ix;
38 y_[kchip - 1][pace - 1] =
iy;
42 edm::LogWarning(
"Invalid Data") <<
"ESUnpacker::ESUnpacker : Look up table file can not be found in " 58 int head, kPACE[4], kFlag1, kFlag2, kBC, kEC, optoBC, optoEC;
67 bool moreHeaders =
true;
71 if (!ESHeader.
check()) {
82 LogDebug(
"ESUnpacker") <<
"[ESUnpacker]: FED Header candidate. Is header? " << ESHeader.
check();
86 LogDebug(
"ESUnpacker") <<
" WARNING!, this is not a ES Header";
105 bool moreTrailers =
true;
106 while (moreTrailers) {
108 FEDTrailer ESTrailer(reinterpret_cast<const unsigned char*>(trailer));
109 if (!ESTrailer.
check()) {
117 edm::LogWarning(
"Invalid Data") <<
"Invalid ES data : the length is not correct !";
124 edm::LogWarning(
"Invalid Data") <<
"Invalid ES data : the length is not correct !";
129 slinkCRC = (*trailer >> 2) & 0
x1;
131 LogDebug(
"ESUnpacker") <<
"[ESUnpacker]: FED Trailer candidate. Is trailer? " << ESTrailer.
check();
132 if (ESTrailer.
check())
135 LogDebug(
"ESUnpacker") <<
" WARNING!, this is not a ES Trailer";
148 std::vector<int> FEch_status;
149 int dccHeaderCount = 0;
150 int dccLineCount = 0;
151 int dccHead, dccLine;
158 dccHead = (*
word >> 60) &
m4;
161 dccLine = (*
word >> 56) &
m4;
163 if (dccLine != dccLineCount) {
165 edm::LogWarning(
"Invalid Data") <<
"Invalid ES data : DCC header order is not correct !";
170 if (dccLineCount == 1) {
171 dccCRC1_ = (*
word >> 24) &
m1;
172 dccCRC2_ = (*
word >> 25) &
m1;
173 dccCRC3_ = (*
word >> 26) &
m1;
174 }
else if (dccLineCount == 2) {
189 if (dccLineCount == 3) {
198 if (dccLineCount == 4)
200 if (dccLineCount == 5)
202 if (dccLineCount == 6)
204 if (dccLineCount >= 4) {
205 for (
unsigned int j = 0;
j < 12; ++
j) {
206 FEch_[(dccLineCount - 4) * 12 +
j] = (*
word >> (
j * 4)) &
m4;
207 FEch_status.push_back(
FEch_[(dccLineCount - 4) * 12 +
j]);
216 if (dccHeaderCount != 6) {
217 edm::LogWarning(
"Invalid Data") <<
"Invalid ES data : DCC header lines are " << dccHeaderCount;
226 int enableOptoRX[3] = {-1, -1, -1};
227 int NenableOptoRX = 0;
229 enableOptoRX[NenableOptoRX] = 0;
233 enableOptoRX[NenableOptoRX] = 1;
237 enableOptoRX[NenableOptoRX] = 2;
247 head = (*
word >> 60) &
m4;
250 if ((opto == 0 && ESDCCHeader.
getOptoRX0() == 129) || (opto == 1 && ESDCCHeader.
getOptoRX1() == 129) ||
251 (opto == 2 && ESDCCHeader.
getOptoRX2() == 129))
253 }
else if (head == 9) {
254 kid = (*
word >> 2) & 0x07ff;
255 kPACE[0] = (*
word >> 16) &
m1;
256 kPACE[1] = (*
word >> 17) &
m1;
257 kPACE[2] = (*
word >> 18) &
m1;
258 kPACE[3] = (*
word >> 19) &
m1;
259 kFlag2 = (*
word >> 20) &
m4;
260 kFlag1 = (*
word >> 24) &
m8;
273 }
else if (head == 6) {
275 optoEC = (*
word >> 48) &
m8;
277 opto = enableOptoRX[iopto];
293 int pace = (
word >> 53) &
m2;
294 if (kPACE[pace] == 0)
296 if (kid > 1511 || kid < 1)
306 LogDebug(
"ESUnpacker") << kid <<
" " <<
strip <<
" " << pace <<
" " <<
adc[0] <<
" " <<
adc[1] <<
" " <<
adc[2];
310 plane =
pl_[kid - 1][pace];
311 ix =
x_[kid - 1][pace];
312 iy =
y_[kid - 1][pace];
316 if (
zside == 1 && plane == 1 &&
iy <= 20)
318 if (
zside == 1 && plane == 2 &&
ix > 20)
320 if (
zside == -1 && plane == 1 &&
iy > 20)
322 if (
zside == -1 && plane == 2 &&
ix <= 20)
327 LogDebug(
"ESUnpacker") <<
"DetId : " <<
zside <<
" " << plane <<
" " <<
ix <<
" " <<
iy <<
" " <<
strip + 1;
334 for (
int i = 0;
i < 3;
i++)
341 <<
detId.siy() <<
" " <<
detId.strip() <<
" (" << kid <<
"," << pace <<
") " 342 <<
df.sample(0).adc() <<
" " <<
df.sample(1).adc() <<
" " <<
df.sample(2).adc();
347 std::ostringstream
str;
348 str <<
"Word64: " <<
reinterpret_cast<const std::bitset<64>&
>(
word);
T getParameter(std::string const &) const
void setOptoBC(const int &OptoBC)
void setId(const int &kId)
std::string fullPath() const
void push_back(T const &t)
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
T getUntrackedParameter(std::string const &, T const &) const
ESUnpacker(const edm::ParameterSet &ps)
void setEC(const int &EC)
void setFlag1(const int &flag1)
void interpretRawData(int fedId, const FEDRawData &rawData, ESRawDataCollection &dccs, ESLocalRawDataCollection &kchips, ESDigiCollection &digis)
void setOptoEC(const int &OptoEC)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
void word2digi(int kchip, int kPACE[4], const Word64 &word, ESDigiCollection &digis)
void setFlag2(const int &flag2)
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
void push_back(unsigned int i)
void setBC(const int &BC)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
const edm::ParameterSet pset_
Log< level::Warning, false > LogWarning
unsigned long long Word64
bool check() const
Check that the trailer is OK.
bool moreTrailers() const
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::string print(const Word64 &word) const