Skip to content

Commit 059b064

Browse files
committed
TPC ZS: Adapt datatypes for version 4 = Dense Link Based ZS
1 parent b1e6b02 commit 059b064

5 files changed

Lines changed: 31 additions & 17 deletions

File tree

DataFormats/Detectors/TPC/include/DataFormatsTPC/ZeroSuppression.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum ZSVersion : unsigned char {
2929
ZSVersionRowBased10BitADC = 1,
3030
ZSVersionRowBased12BitADC = 2,
3131
ZSVersionLinkBasedWithMeta = 3,
32+
ZSVersionDenseLinkBased = 4
3233
};
3334

3435
struct TPCZSHDR {
@@ -43,8 +44,8 @@ struct TPCZSHDR {
4344
// 1: original row-based format with 10-bit ADC values
4445
// 2: original row-based format with 12-bit ADC values
4546
// 3: improved link-based format with extra META header
46-
// 4: tightly-packed link based
47-
unsigned char nTimeBins; // Number of time bins in this raw page
47+
// 4: dense link based
48+
unsigned char nTimeBinSpan; // Span of time bins in this raw page, i.e. last timeBin is <= timeOffset + nTimeBinSpan
4849
unsigned short cruID; // CRU id
4950
unsigned short timeOffset; // Time offset in BC after orbit in RDH
5051
unsigned short nADCsamples; // Total number of ADC samples in this raw page
@@ -53,10 +54,16 @@ struct TPCZSHDRV2 : public TPCZSHDR {
5354
static constexpr unsigned int TPC_ZS_NBITS_V3 = 12;
5455
static constexpr bool TIGHTLY_PACKED_V3 = false;
5556
static constexpr unsigned int SAMPLESPER64BIT = 64 / TPC_ZS_NBITS_V3; // 5 12-bit samples with 4 bit padding per 64 bit word for non-TIGHTLY_PACKED data
57+
enum ZSFlags : unsigned char {
58+
TriggerWordPresent = 1,
59+
nTimeBinSpanBit8 = 2
60+
};
5661

57-
unsigned short firstZSDataOffset; // Offset (after the TPCZSHDRV2 header) in 128bit words to first ZS data (in between can be trigger words, etc.)
62+
unsigned short firstZSDataOffset; // zs Version 3: Offset (after the TPCZSHDRV2 header) in 128bit words to first ZS data (in between can be trigger words, etc.)
63+
// zs Version 4: Offset (after the RDH) in bytes of the first ZS data.
5864
unsigned short nTimebinHeaders; // Number of timebin headers
59-
unsigned short reserved1; // 16 reserved bits, header is 128 bit
65+
unsigned char flags; // flag field (zs version 4 only): 0 = triggerWordPresent, 1 = bit 8 of nTimeBinSpan (i.e. nTimeBinSpan += 256)
66+
unsigned char reserved1; // 16 reserved bits, header is 128 bit
6067
unsigned char reserved2; // 8 reserved bits, header is 128 bit
6168
unsigned char magicWord; // Magic word
6269
};

Detectors/TPC/base/src/ZeroSuppress.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ZeroSuppress::DecodeZSPages(gsl::span<const ZeroSuppressedContainer8kb>* z0
6969
unsigned int ct = 0;
7070
startPtr += (sizeof(z0Container->rdh) + sizeof(z0Container->hdr)); // move to first time bin
7171
// iterate through all time bins indicated in the z0 header
72-
for (int tb = 0; tb < z0Container->hdr.nTimeBins; tb++) {
72+
for (int tb = 0; tb < z0Container->hdr.nTimeBinSpan; tb++) {
7373
startPtr += (startPtr - pageStart) % 2;
7474
TPCZSTBHDR* tbHdr = reinterpret_cast<TPCZSTBHDR*>(startPtr);
7575
unsigned int numberRows = __builtin_popcount((tbHdr->rowMask & 0x7FFF)); // number of ones, excluding upper/lower bit

GPU/GPUTracking/Base/GPUReconstructionConvert.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int GPUReconstructionConvert::GetMaxTimeBin(const GPUTrackingInOutZS& zspages)
164164
for (unsigned int l = 0; l < zspages.slice[i].nZSPtr[j][k]; l++) {
165165
o2::header::RAWDataHeader* rdh = (o2::header::RAWDataHeader*)(page + l * TPCZSHDR::TPC_ZS_PAGE_SIZE);
166166
TPCZSHDR* hdr = (TPCZSHDR*)(page + l * TPCZSHDR::TPC_ZS_PAGE_SIZE + sizeof(o2::header::RAWDataHeader));
167-
unsigned int timeBin = (hdr->timeOffset + (o2::raw::RDHUtils::getHeartBeatOrbit(*rdh) - firstHBF) * o2::constants::lhc::LHCMaxBunches) / LHCBCPERTIMEBIN + hdr->nTimeBins;
167+
unsigned int timeBin = (hdr->timeOffset + (o2::raw::RDHUtils::getHeartBeatOrbit(*rdh) - firstHBF) * o2::constants::lhc::LHCMaxBunches) / LHCBCPERTIMEBIN + hdr->nTimeBinSpan;
168168
if (timeBin > retVal) {
169169
retVal = timeBin;
170170
}
@@ -306,7 +306,7 @@ bool zsEncoderRow::checkInput(std::vector<o2::tpc::Digit>& tmpBuffer, unsigned i
306306
break;
307307
}
308308
}
309-
if (lastEndpoint >= 0 && lastTime != -1 && (int)hdr->nTimeBins + tmpBuffer[k].getTimeStamp() - lastTime >= 256) {
309+
if (lastEndpoint >= 0 && lastTime != -1 && (int)hdr->nTimeBinSpan + tmpBuffer[k].getTimeStamp() - lastTime >= 256) {
310310
lastEndpoint = -1;
311311
}
312312
if (endpoint == lastEndpoint) {
@@ -350,10 +350,10 @@ unsigned int zsEncoderRow::encodeSequence(std::vector<o2::tpc::Digit>& tmpBuffer
350350
{
351351
if (tmpBuffer[k].getTimeStamp() != lastTime) {
352352
if (lastTime != -1) {
353-
hdr->nTimeBins += tmpBuffer[k].getTimeStamp() - lastTime - 1;
353+
hdr->nTimeBinSpan += tmpBuffer[k].getTimeStamp() - lastTime - 1;
354354
pagePtr += (tmpBuffer[k].getTimeStamp() - lastTime - 1) * 2;
355355
}
356-
hdr->nTimeBins++;
356+
hdr->nTimeBinSpan++;
357357
if ((pagePtr - reinterpret_cast<unsigned char*>(page)) & 1) {
358358
pagePtr++;
359359
}
@@ -408,7 +408,7 @@ void zsEncoderRow::decodePage(std::vector<o2::tpc::Digit>& outputBuffer, const z
408408
int nRowsRegion = param->tpcGeometry.GetRegionRows(region);
409409

410410
int timeBin = (decHDR->timeOffset + (unsigned long)(o2::raw::RDHUtils::getHeartBeatOrbit(*rdh) - firstOrbit) * o2::constants::lhc::LHCMaxBunches) / LHCBCPERTIMEBIN;
411-
for (int l = 0; l < decHDR->nTimeBins; l++) {
411+
for (int l = 0; l < decHDR->nTimeBinSpan; l++) {
412412
if ((decPagePtr - reinterpret_cast<const unsigned char*>(decPage)) & 1) {
413413
decPagePtr++;
414414
}
@@ -536,7 +536,7 @@ void zsEncoderLinkBased::createBitmask(std::vector<o2::tpc::Digit>& tmpBuffer, u
536536
}
537537
nSamples = l - k;
538538
finishPage = endpoint != lastEndpoint || (firstTimebinInPage != -1 && tmpBuffer[k].getTimeStamp() - firstTimebinInPage >= (1 << 8));
539-
if (tmpBuffer[k].getTimeStamp() - firstTimebinInPage + 1 > (1 << (sizeof(hdr->nTimeBins) * 8)) - 1) {
539+
if (tmpBuffer[k].getTimeStamp() - firstTimebinInPage + 1 > (1 << (sizeof(hdr->nTimeBinSpan) * 8)) - 1) {
540540
finishPage = true;
541541
}
542542
}
@@ -611,7 +611,7 @@ unsigned int zsEncoderImprovedLinkBased::encodeSequence(std::vector<o2::tpc::Dig
611611
tbHdr->bitMaskLow = (bitmask & std::bitset<80>(0xFFFFFFFFFFFFFFFFlu)).to_ulong();
612612
tbHdr->syncOffsetBC = 0;
613613
tbHdr->fecInPartition = link;
614-
hdr->nTimeBins = tmpBuffer[k].getTimeStamp() - firstTimebinInPage + 1;
614+
hdr->nTimeBinSpan = tmpBuffer[k].getTimeStamp() - firstTimebinInPage + 1;
615615
hdr->nTimebinHeaders++;
616616
if (TPCZSHDRV2::TIGHTLY_PACKED_V3) {
617617
tbHdr->numWordsPayload = (nSamples * TPCZSHDRV2::TPC_ZS_NBITS_V3 + 127) / 128; // tightly packed ADC samples
@@ -751,7 +751,7 @@ unsigned int zsEncoderDenseLinkBased::encodeSequence(std::vector<o2::tpc::Digit>
751751
free4bitPointer = nullptr;
752752
curTimeBin = newTimeBin;
753753
pagePtr += sizeof(unsigned char);
754-
hdr->nTimeBins = tmpBuffer[k].getTimeStamp() - firstTimebinInPage + 1;
754+
hdr->nTimeBinSpan = tmpBuffer[k].getTimeStamp() - firstTimebinInPage + 1;
755755
hdr->nTimebinHeaders++;
756756
} else {
757757
(*linkCounter)++;

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,22 @@ std::pair<unsigned int, unsigned int> GPUChainTracking::TPCClusterizerDecodeZSCo
153153
nDigits += hdr->nADCsamples;
154154
endpointAdcSamples[j] += hdr->nADCsamples;
155155
unsigned int timeBin = (hdr->timeOffset + (o2::raw::RDHUtils::getHeartBeatOrbit(*rdh) - firstHBF) * o2::constants::lhc::LHCMaxBunches) / LHCBCPERTIMEBIN;
156-
if (timeBin + hdr->nTimeBins > mCFContext->tpcMaxTimeBin) {
157-
mCFContext->tpcMaxTimeBin = timeBin + hdr->nTimeBins;
156+
unsigned int maxTimeBin = timeBin + hdr->nTimeBinSpan;
157+
if (mCFContext->zsVersion == ZSVersion::ZSVersionDenseLinkBased) {
158+
const TPCZSHDRV2* const hdr2 = (const TPCZSHDRV2*) hdr;
159+
if (hdr2->flags & TPCZSHDRV2::ZSFlags::nTimeBinSpanBit8) {
160+
maxTimeBin += 256;
161+
}
162+
}
163+
if (maxTimeBin > mCFContext->tpcMaxTimeBin) {
164+
mCFContext->tpcMaxTimeBin = maxTimeBin;
158165
}
159166
while (firstPossibleFragment && (unsigned int)fragments[firstPossibleFragment - 1].first.last() > timeBin) {
160167
firstPossibleFragment--;
161168
}
162169
for (unsigned int f = firstPossibleFragment; f < mCFContext->nFragments; f++) {
163170
if (timeBin < (unsigned int)fragments[f].first.last()) {
164-
if ((unsigned int)fragments[f].first.first() <= timeBin + hdr->nTimeBins) {
171+
if ((unsigned int)fragments[f].first.first() <= maxTimeBin) {
165172
if (!fragments[f].second[4]) {
166173
fragments[f].second[4] = 1;
167174
fragments[f].second[0] = k;

GPU/GPUTracking/TPCClusterFinder/GPUTPCCFDecodeZS.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ GPUdii() void GPUTPCCFDecodeZS::decode(GPUTPCClusterFinder& clusterer, GPUShared
9494
const int rowOffset = s.regionStartRow + ((endpoint & 1) ? (s.nRowsRegion / 2) : 0);
9595
const int nRows = (endpoint & 1) ? (s.nRowsRegion - s.nRowsRegion / 2) : (s.nRowsRegion / 2);
9696

97-
for (int l = 0; l < hdr->nTimeBins; l++) { // TODO: Parallelize over time bins
97+
for (int l = 0; l < hdr->nTimeBinSpan; l++) { // TODO: Parallelize over time bins
9898
pagePtr += (pagePtr - page) & 1; // Ensure 16 bit alignment
9999
const TPCZSTBHDR* tbHdr = reinterpret_cast<const TPCZSTBHDR*>(pagePtr);
100100
if ((tbHdr->rowMask & 0x7FFF) == 0) {

0 commit comments

Comments
 (0)