Skip to content

Commit 90af7df

Browse files
wiechuladavidrohr
authored andcommitted
TPC: add trigger handling in ILBZS
1 parent 124a372 commit 90af7df

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct Header final : public CommonHeader {
7777
return std::bitset<80>((std::bitset<80>(bitMaskHigh) << 64) | std::bitset<80>(bitMaskLow));
7878
}
7979

80-
bool isFillWord() const { return ((word0 == 0xffffffffffffffff) && (word1 == 0xffffffffffffffff)) || ((word0 == 0x0000000000000000) && (word1 == 0x0000000000000000)); }
80+
bool isFillWord() const { return ((word0 == 0xffffffffffffffff) && (word1 == 0xffffffffffffffff)); }
8181
};
8282

8383
/// ADC data container
@@ -282,6 +282,37 @@ struct TriggerContainer {
282282
uint32_t getTriggerType() const { return triggerInfo.getTriggerType(); }
283283
};
284284

285+
/// Data definition of trigger bits in ILBZS format
286+
struct TriggerWord {
287+
static constexpr uint16_t HasTrigger = 0x8;
288+
static constexpr uint16_t LaserTriggerMask = 0x4;
289+
static constexpr uint16_t PulserTriggerMask = 0x2;
290+
static constexpr uint16_t PhysicsTriggerMask = 0x1;
291+
292+
union {
293+
uint16_t word = 0;
294+
struct {
295+
uint16_t bunchCrossing : 12;
296+
uint16_t triggerType : 4;
297+
};
298+
};
299+
300+
bool hasTrigger() const { return triggerType & HasTrigger; }
301+
bool hasLaserTrigger() const { return triggerType & LaserTriggerMask; }
302+
bool hasPulserTrigger() const { return triggerType & PulserTriggerMask; }
303+
bool hasPhysicsTrigger() const { return triggerType & PhysicsTriggerMask; }
304+
};
305+
306+
/// Trigger word of ILBZS
307+
///
308+
/// 128 bits, can hold up to 8 trigger information
309+
struct TriggerInfoV3 {
310+
uint64_t word0 = 0;
311+
uint64_t word1 = 0;
312+
313+
bool hasTrigger() const { return word0 & TriggerWord::HasTrigger; }
314+
uint16_t getFirstBC() const { return word0 & 0xFFF; }
315+
};
285316
#endif // !defined(GPUCA_GPUCODE)
286317

287318
} // namespace zerosupp_link_based

Detectors/TPC/reconstruction/src/RawProcessingHelpers.cxx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_ut
5959
if (!header.hasCorrectMagicWord()) {
6060
zsdata = (zerosupp_link_based::ContainerZS*)((const char*)zsdata + sizeof(zerosupp_link_based::Header));
6161
if (!header.isFillWord()) {
62-
LOGP(error, "Bad LinkZS magic word (0x{:08x}), for feeId 0x{:05x} (CRU: {:3}, link: {:2}, EP {}) , skipping data block", header.magicWord, feeId, rdh_utils::getCRU(feeId), rdh_utils::getLink(feeId), rdh_utils::getEndPoint(feeId));
62+
LOGP(error, "Bad LinkZS magic word (0x{:08x}), for feeId 0x{:05x} (CRU: {:3}, link: {:2}, EP {}), orbit {} , skipping data block", header.magicWord, feeId, cruID, link, endPoint, orbit);
6363
LOGP(error, "Full 128b word is: 0x{:016x}{:016x}", header.word1, header.word0);
6464
}
6565
continue;
@@ -88,7 +88,15 @@ bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_ut
8888
const auto& metaHDR = *((TPCZSHDRV2*)zsdata);
8989
zsVersion = metaHDR.version;
9090
timeOffset = metaHDR.timeOffset;
91-
zsdata = (zerosupp_link_based::ContainerZS*)((const char*)zsdata + sizeof(zerosupp_link_based::Header));
91+
92+
const auto& triggerInfo = *(zerosupp_link_based::TriggerInfoV3*)((const char*)&metaHDR + sizeof(metaHDR));
93+
if (triggerInfo.hasTrigger()) {
94+
const auto triggerBC = triggerInfo.getFirstBC();
95+
const auto triggerOrbit = orbit;
96+
triggerBCOffset = (int(triggerOrbit) - int(referenceOrbit)) * maxBunches + triggerBC;
97+
}
98+
99+
zsdata = (zerosupp_link_based::ContainerZS*)((const char*)&triggerInfo + sizeof(triggerInfo));
92100
continue;
93101
}
94102

@@ -108,7 +116,7 @@ bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_ut
108116
const int bcOffset = timeOffset + globalBCOffset + bunchCrossingHeader - triggerBCOffset;
109117
if (bcOffset < 0) {
110118
LOGP(info, "skipping time bin with negative BC offset timeOffset {} + globalBCoffset (({} - {}) * {} = {}) + bunchCrossingHeader ({}) - triggerBCOffset({}) = {}",
111-
timeOffset, orbit, referenceOrbit, o2::constants::lhc::LHCMaxBunches, globalBCOffset, bunchCrossingHeader, syncOffsetReference, bunchCrossingHeader, syncOffset, triggerBCOffset, bcOffset);
119+
timeOffset, orbit, referenceOrbit, o2::constants::lhc::LHCMaxBunches, globalBCOffset, bunchCrossingHeader, triggerBCOffset, bcOffset);
112120

113121
// go to next time bin
114122
zsdata = zsdata->next();

0 commit comments

Comments
 (0)