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"
1920using 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 ();
0 commit comments