Skip to content

Commit 6b98383

Browse files
committed
Add ever-incrementing TF counter and runNumber to DataHeader
The DataHeader::firstTForbit will not be unique when the same TFs are replayed in loop, this counter will resolve the ambiguity. runNumber is needed for conversion of firstTForbit to abs. timestamp
1 parent 6268b77 commit 6b98383

3 files changed

Lines changed: 33 additions & 12 deletions

File tree

DataFormats/Headers/include/Headers/DataHeader.h

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,11 @@ struct DataHeader : public BaseHeader {
666666
using SplitPayloadPartsType = uint32_t;
667667
using PayloadSizeType = uint64_t;
668668
using TForbitType = uint32_t;
669+
using TFCounterType = uint32_t;
670+
using RunNumberType = uint32_t;
669671

670672
//static data for this header type/version
671-
static constexpr uint32_t sVersion{2};
673+
static constexpr uint32_t sVersion{3};
672674
static constexpr o2::header::HeaderType sHeaderType{String2<uint64_t>("DataHead")};
673675
static constexpr o2::header::SerializationMethod sSerializationMethod{gSerializationMethodNone};
674676

@@ -711,10 +713,20 @@ struct DataHeader : public BaseHeader {
711713
//___NEW STUFF GOES BELOW
712714

713715
///
714-
/// first orbit of time frame as unique identifier within the run
716+
/// first orbit of time frame, since v2
715717
///
716718
TForbitType firstTForbit;
717719

720+
///
721+
/// ever incrementing TF counter, allows to disentangle even TFs with same firstTForbit in case of replay, since v3
722+
///
723+
TFCounterType tfCounter;
724+
725+
///
726+
/// run number TF belongs to, since v3
727+
///
728+
RunNumberType runNumber;
729+
718730
//___the functions:
719731
//__________________________________________________________________________________________________
720732
constexpr DataHeader()
@@ -726,7 +738,9 @@ struct DataHeader : public BaseHeader {
726738
subSpecification(0),
727739
splitPayloadIndex(0),
728740
payloadSize(0),
729-
firstTForbit{0}
741+
firstTForbit{0},
742+
tfCounter(0),
743+
runNumber(0)
730744
{
731745
}
732746

@@ -740,7 +754,9 @@ struct DataHeader : public BaseHeader {
740754
subSpecification(subspec),
741755
splitPayloadIndex(0),
742756
payloadSize(size),
743-
firstTForbit{0}
757+
firstTForbit{0},
758+
tfCounter(0),
759+
runNumber(0)
744760
{
745761
}
746762

@@ -754,7 +770,9 @@ struct DataHeader : public BaseHeader {
754770
subSpecification(subspec),
755771
splitPayloadIndex(partIndex),
756772
payloadSize(size),
757-
firstTForbit{0}
773+
firstTForbit{0},
774+
tfCounter(0),
775+
runNumber(0)
758776
{
759777
}
760778

@@ -808,8 +826,8 @@ static_assert(sizeof(BaseHeader) == 32,
808826
"BaseHeader struct must be of size 32");
809827
static_assert(sizeof(DataOrigin) == 4,
810828
"DataOrigin struct must be of size 4");
811-
static_assert(sizeof(DataHeader) == 88,
812-
"DataHeader struct must be of size 88");
829+
static_assert(sizeof(DataHeader) == 96,
830+
"DataHeader struct must be of size 96");
813831
static_assert(gSizeMagicString == sizeof(BaseHeader::magicStringInt),
814832
"Size mismatch in magic string union");
815833
static_assert(sizeof(BaseHeader::sMagicString) == sizeof(BaseHeader::magicStringInt),

DataFormats/Headers/src/DataHeader.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ void o2::header::BaseHeader::throwInconsistentStackError() const
5454
//__________________________________________________________________________________________________
5555
void o2::header::DataHeader::print() const
5656
{
57-
printf("Data header version %i, flags: %i\n", headerVersion, flags);
57+
printf("Data header version %u, flags: %u\n", headerVersion, flags);
5858
printf(" origin : %s\n", dataOrigin.str);
5959
printf(" serialization: %s\n", payloadSerializationMethod.str);
6060
printf(" description : %s\n", dataDescription.str);
6161
printf(" sub spec. : %llu\n", (long long unsigned int)subSpecification);
62-
printf(" header size : %i\n", headerSize);
62+
printf(" header size : %d\n", headerSize);
6363
printf(" payloadSize : %llu\n", (long long unsigned int)payloadSize);
64+
printf(" firstTFOrbit : %u\n", firstTForbit);
65+
printf(" tfCounter : %u\n", tfCounter);
66+
printf(" runNumber : %u\n", runNumber);
6467
}
6568

6669
//__________________________________________________________________________________________________

DataFormats/Headers/test/testDataHeader.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ BOOST_AUTO_TEST_CASE(DataHeader_test)
236236
<< "size " << std::setw(2) << sizeof(dh.payloadSize) << " at " << (char*)(&dh.payloadSize) - (char*)(&dh) << std::endl;
237237
}
238238

239-
// DataHeader must have size 88
240-
static_assert(sizeof(DataHeader) == 88,
241-
"DataHeader struct must be of size 88");
239+
// DataHeader must have size 96
240+
static_assert(sizeof(DataHeader) == 96,
241+
"DataHeader struct must be of size 96");
242242
DataHeader dh2;
243243
BOOST_CHECK(dh == dh2);
244244
DataHeader dh3{gDataDescriptionInvalid, gDataOriginInvalid, DataHeader::SubSpecificationType{0}, 0};

0 commit comments

Comments
 (0)