Skip to content

Commit 98bc3ed

Browse files
wiechuladavidrohr
authored andcommitted
first attempt to use trigger info in decoding
1 parent 7de1c35 commit 98bc3ed

4 files changed

Lines changed: 40 additions & 22 deletions

File tree

Detectors/TPC/reconstruction/include/TPCReconstruction/RawProcessingHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace raw_processing_helpers
2424

2525
using ADCCallback = std::function<bool(int cru, int rowInSector, int padInRow, int timeBin, float adcValue)>;
2626

27-
bool processZSdata(const char* data, size_t size, rdh_utils::FEEIDType feeId, uint32_t globalBCoffset, ADCCallback fillADC, bool useTimeBin = false);
27+
bool processZSdata(const char* data, size_t size, rdh_utils::FEEIDType feeId, uint32_t orbit, uint32_t referenceOrbit, ADCCallback fillADC, bool useTimeBin = false);
2828

2929
} // namespace raw_processing_helpers
3030
} // namespace tpc

Detectors/TPC/reconstruction/src/RawProcessingHelpers.cxx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <array>
1212

13+
#include "CommonConstants/LHCConstants.h"
1314
#include "Framework/Logger.h"
1415
#include "TPCBase/Mapper.h"
1516
#include "DataFormatsTPC/ZeroSuppressionLinkBased.h"
@@ -19,7 +20,7 @@
1920
using namespace o2::tpc;
2021

2122
//______________________________________________________________________________
22-
bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_utils::FEEIDType feeId, uint32_t globalBCoffset, ADCCallback fillADC, bool useTimeBin)
23+
bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_utils::FEEIDType feeId, uint32_t orbit, uint32_t referenceOrbit, ADCCallback fillADC, bool useTimeBin)
2324
{
2425
const auto& mapper = Mapper::instance();
2526

@@ -36,6 +37,9 @@ bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_ut
3637
const int tpcGlobalLinkID = cruID * 24 + globalLinkID;
3738
static std::array<uint32_t, 360 * 24> syncOffsetLinks;
3839

40+
const uint32_t maxBunches = (uint32_t)o2::constants::lhc::LHCMaxBunches;
41+
int globalBCOffset = int(orbit - referenceOrbit) * o2::constants::lhc::LHCMaxBunches;
42+
3943
bool hasData{false};
4044

4145
zerosupp_link_based::ContainerZS* zsdata = (zerosupp_link_based::ContainerZS*)data;
@@ -54,6 +58,20 @@ bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_ut
5458
continue;
5559
}
5660

61+
// set trigger offset and skip trigger info
62+
if (header.isTriggerInfo()) {
63+
// for the moment only skip the trigger info
64+
/*
65+
const auto triggerInfo = (zerosupp_link_based::TriggerContainer*)zsdata;
66+
const auto triggerOrbit = triggerInfo->triggerInfo.getOrbit();
67+
const auto triggerBC = triggerInfo->triggerInfo.bunchCrossing;
68+
globalBCOffset = int(orbit - triggerOrbit) * maxBunches - triggerBC;
69+
fmt::print("orbit: {}, triggerOrbit: {}, triggerBC: {}, globalBCOffset: {}\n", orbit, triggerOrbit, triggerBC, globalBCOffset);
70+
*/
71+
zsdata = (zerosupp_link_based::ContainerZS*)((const char*)zsdata + sizeof(zerosupp_link_based::Header) * (1 + header.numWordsPayload));
72+
continue;
73+
}
74+
5775
const auto channelBits = zsdata->getChannelBits();
5876
const uint32_t expectedWords = std::ceil(channelBits.count() * 0.1f);
5977
const uint32_t numberOfWords = zsdata->getDataWords();
@@ -65,14 +83,15 @@ bool raw_processing_helpers::processZSdata(const char* data, size_t size, rdh_ut
6583
if (useTimeBin) {
6684
const uint32_t timebinHeader = (header.syncOffsetCRUCycles << 8) | header.syncOffsetBC;
6785
if (syncOffsetLinks[tpcGlobalLinkID] == 0) {
68-
syncOffsetLinks[tpcGlobalLinkID] = (bunchCrossingHeader + 3564 - (timebinHeader * 8) % 3564) % 3564 % 16;
86+
syncOffsetLinks[tpcGlobalLinkID] = (bunchCrossingHeader + maxBunches - (timebinHeader * 8) % maxBunches) % maxBunches % 16;
6987
}
7088
syncOffset = syncOffsetLinks[tpcGlobalLinkID];
7189
}
7290

73-
const int timebin = (int(globalBCoffset) + int(bunchCrossingHeader) - int(syncOffset)) / 8;
74-
if (timebin < 0) {
75-
LOGP(debug, "skipping negative time bin with (globalBCoffset ({}) + bunchCrossingHeader ({}) - syncOffset({})) / 8 = {}", globalBCoffset, bunchCrossingHeader, syncOffset, timebin);
91+
const int bcOffset = (int(globalBCOffset) + int(bunchCrossingHeader) - int(syncOffset));
92+
const int timebin = bcOffset / 8;
93+
if (bcOffset < 0) {
94+
LOGP(debug, "skipping negative time bin with (globalBCoffset ({}) + bunchCrossingHeader ({}) - syncOffset({})) / 8 = {}", globalBCOffset, bunchCrossingHeader, syncOffset, timebin);
7695

7796
// go to next time bin
7897
zsdata = zsdata->next();

Detectors/TPC/reconstruction/src/RawReaderCRU.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ int RawReaderCRU::scanFile()
211211

212212
auto& file = getFileHandle();
213213

214+
LOGP(info, "scanning file {}", mInputFileName);
214215
// get length of file in bytes
215216
file.seekg(0, file.end);
216217
mFileSize = file.tellg();
@@ -247,7 +248,7 @@ int RawReaderCRU::scanFile()
247248

248249
// ===| skip IDC data |=====================================================
249250
const auto detField = o2::raw::RDHUtils::getDetectorField(rdh);
250-
if ((detField > 1) || (payloadSize == 0)) {
251+
if (((detField != 0xdeadbeef) && (detField > 1)) || (payloadSize == 0)) {
251252
file.seekg(offset, file.cur);
252253
++currentPacket;
253254
currentPos = file.tellg();
@@ -268,13 +269,13 @@ int RawReaderCRU::scanFile()
268269
const uint64_t pageCnt = RDHUtils::getPageCounter(rdh);
269270
const uint64_t linkID = RDHUtils::getLinkID(rdh);
270271

271-
if (pageCnt == 0) {
272-
if (linkID == 15) {
273-
mManager->mRawDataType = RAWDataType::LinkZS;
274-
LOGP(info, "Detected LinkZS data");
275-
mManager->mDetectDataType = false;
276-
}
272+
//if (pageCnt == 0) {
273+
if ((linkID == 15) || (detField == 0x1)) {
274+
mManager->mRawDataType = RAWDataType::LinkZS;
275+
LOGP(info, "Detected LinkZS data");
276+
mManager->mDetectDataType = false;
277277
}
278+
//}
278279

279280
if (pageCnt == 1) {
280281
if (triggerType == triggerTypeForTriggeredData) {
@@ -774,8 +775,7 @@ void RawReaderCRU::processLinkZS()
774775
}
775776
file.seekg(payloadOffset, file.beg);
776777
file.read(buffer, payloadSize);
777-
const auto globalBCOffset = (packet.getHeartBeatOrbit() - firstOrbitInEvent) * 3564;
778-
o2::tpc::raw_processing_helpers::processZSdata(buffer, payloadSize, packet.getFEEID(), globalBCOffset, mManager->mLinkZSCallback, false); // last parameter should be true for MW2 data
778+
o2::tpc::raw_processing_helpers::processZSdata(buffer, payloadSize, packet.getFEEID(), packet.getHeartBeatOrbit(), firstOrbitInEvent, mManager->mLinkZSCallback, false); // last parameter should be true for MW2 data
779779
}
780780
}
781781

Detectors/TPC/workflow/src/CalibProcessingHelper.cxx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "DPLUtils/RawParser.h"
1818
#include "DetectorsRaw/RDHUtils.h"
1919
#include "Headers/DataHeaderHelpers.h"
20-
#include "CommonConstants/LHCConstants.h"
2120

2221
#include "TPCBase/RDHUtils.h"
2322
#include "TPCReconstruction/RawReaderCRU.h"
@@ -83,9 +82,9 @@ uint64_t calib_processing_helper::processRawData(o2::framework::InputRecord& inp
8382
rdh_utils::FEEIDType cruID, linkID, endPoint;
8483
rdh_utils::getMapping(feeID, cruID, endPoint, linkID);
8584
const auto globalLinkID = linkID + endPoint * 12;
86-
LOGP(info, "Specifier: {}/{}/{}", dh->dataOrigin, dh->dataDescription, subSpecification);
87-
LOGP(info, "Payload size: {}", dh->payloadSize);
88-
LOGP(info, "CRU: {}; linkID: {}; endPoint: {}; globalLinkID: {}", cruID, linkID, endPoint, globalLinkID);
85+
LOGP(debug, "Specifier: {}/{}/{}", dh->dataOrigin, dh->dataDescription, subSpecification);
86+
LOGP(debug, "Payload size: {}", dh->payloadSize);
87+
LOGP(debug, "CRU: {}; linkID: {}; endPoint: {}; globalLinkID: {}", cruID, linkID, endPoint, globalLinkID);
8988
// ^^^^^^
9089

9190
// TODO: exception handling needed?
@@ -100,7 +99,8 @@ uint64_t calib_processing_helper::processRawData(o2::framework::InputRecord& inp
10099
LOGP(fatal, "could not get RDH from packet");
101100
}
102101
const auto link = RDHUtils::getLinkID(*rdhPtr);
103-
if (link == rdh_utils::UserLogicLinkID) {
102+
const auto detField = RDHUtils::getDetectorField(*rdhPtr);
103+
if ((link == rdh_utils::UserLogicLinkID) || (detField == 1)) {
104104
LOGP(info, "Detected Link-based zero suppression");
105105
isLinkZS = true;
106106
if (!reader->getManager() || !reader->getManager()->getLinkZSCallback()) {
@@ -178,7 +178,6 @@ void processLinkZS(o2::framework::RawParser<>& parser, std::unique_ptr<RawReader
178178
const auto orbit = RDHUtils::getHeartBeatOrbit(*rdhPtr);
179179
const auto data = (const char*)it.data();
180180
const auto size = it.size();
181-
const auto globalBCOffset = (orbit - firstOrbit) * o2::constants::lhc::LHCMaxBunches;
182-
raw_processing_helpers::processZSdata(data, size, feeID, globalBCOffset, reader->getManager()->getLinkZSCallback(), useTimeBins);
181+
raw_processing_helpers::processZSdata(data, size, feeID, orbit, firstOrbit, reader->getManager()->getLinkZSCallback(), useTimeBins);
183182
}
184183
}

0 commit comments

Comments
 (0)