Skip to content

Commit 77c1804

Browse files
committed
MID: fixes: use RDHUtils to access RDH fields
1 parent caa69d6 commit 77c1804

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

Detectors/MUON/MID/Raw/src/CRUBareDecoder.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
#include "MIDRaw/CRUBareDecoder.h"
1717

1818
#include "RawInfo.h"
19+
#include "DetectorsRaw/RDHUtils.h"
1920

2021
namespace o2
2122
{
2223
namespace mid
2324
{
25+
using RDHUtils = o2::raw::RDHUtils;
2426

2527
void CRUBareDecoder::reset()
2628
{
@@ -110,7 +112,7 @@ void CRUBareDecoder::addBoard(size_t ilink)
110112
eventType = EventType::Dead;
111113
}
112114
auto firstEntry = mData.size();
113-
InteractionRecord intRec(localClock - sDelayBCToLocal, mBuffer.getRDH()->triggerOrbit);
115+
InteractionRecord intRec(localClock - sDelayBCToLocal, RDHUtils::getTriggerOrbit(*mBuffer.getRDH()));
114116
mData.push_back({mELinkDecoders[ilink].getStatusWord(), mELinkDecoders[ilink].getTriggerWord(), crateparams::makeUniqueLocID(mCrateId, mELinkDecoders[ilink].getId()), mELinkDecoders[ilink].getInputs()});
115117
mROFRecords.emplace_back(intRec, eventType, firstEntry, 1);
116118
}

Detectors/MUON/MID/Raw/src/RawBuffer.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
#include "MIDRaw/RawUnit.h"
1919
#include "RawInfo.h"
20+
#include "DetectorsRaw/RDHUtils.h"
2021

2122
namespace o2
2223
{
2324
namespace mid
2425
{
26+
using RDHUtils = o2::raw::RDHUtils;
2527

2628
template <typename T>
2729
unsigned int RawBuffer<T>::next(unsigned int nBits)
@@ -73,10 +75,10 @@ bool RawBuffer<T>::nextHeader()
7375
}
7476
mHeaderIndex = mNextHeaderIndex;
7577
mRDH = reinterpret_cast<const header::RAWDataHeader*>(&mBytes[mHeaderIndex]);
76-
mEndOfPayloadIndex = mHeaderIndex + (mRDH->memorySize / mElementSizeInBytes);
78+
mEndOfPayloadIndex = mHeaderIndex + (RDHUtils::getMemorySize(*mRDH) / mElementSizeInBytes);
7779
// Go to end of header, i.e. beginning of payload
78-
mElementIndex = mHeaderIndex + (mRDH->headerSize / mElementSizeInBytes);
79-
mNextHeaderIndex = mHeaderIndex + mRDH->offsetToNext / mElementSizeInBytes;
80+
mElementIndex = mHeaderIndex + (RDHUtils::getHeaderSize(*mRDH) / mElementSizeInBytes);
81+
mNextHeaderIndex = mHeaderIndex + RDHUtils::getOffsetToNext(*mRDH) / mElementSizeInBytes;
8082
mBitIndex = 0;
8183

8284
return true;
@@ -134,7 +136,7 @@ bool RawBuffer<T>::isHBClosed()
134136
if (!mRDH) {
135137
return false;
136138
}
137-
return mRDH->stop;
139+
return RDHUtils::getStop(*mRDH);
138140
}
139141

140142
template <typename T>

Detectors/MUON/MID/Raw/src/RawFileReader.cxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717

1818
#include <iostream>
1919
#include "Headers/RAWDataHeader.h"
20+
#include "DetectorsRaw/RDHUtils.h"
2021

2122
namespace o2
2223
{
2324
namespace mid
2425
{
26+
using RDHUtils = o2::raw::RDHUtils;
27+
2528
template <typename T>
2629
bool RawFileReader<T>::init(const char* inFilename, bool readContinuous)
2730
{
@@ -96,7 +99,7 @@ bool RawFileReader<T>::replaceRDH(size_t headerIndex)
9699
/// Replaces the current RDH with a custom one if needed.
97100
/// This is done to be able to correctly read test data
98101
/// that have a wrong RDH
99-
if (mCustomRDH.offsetToNext > 0) {
102+
if (RDHUtils::getOffsetToNext(mCustomRDH) > 0) {
100103
header::RAWDataHeader* rdh = reinterpret_cast<header::RAWDataHeader*>(&mBytes[headerIndex]);
101104
*rdh = mCustomRDH;
102105
return true;
@@ -140,13 +143,13 @@ bool RawFileReader<T>::readHB(bool sendCompleteHBs)
140143
mBuffer.setBuffer(mBytes, RawBuffer<T>::ResetMode::bufferOnly);
141144
mBuffer.nextHeader();
142145
isHBClosed = mBuffer.isHBClosed();
143-
gbtId = mBuffer.getRDH()->feeId;
146+
gbtId = RDHUtils::getFEEID(*mBuffer.getRDH());
144147
if (gbtId >= crateparams::sNGBTs) {
145148
// FIXME: this is a problem of the header of some test files
146149
gbtId = 0;
147150
}
148-
if (mBuffer.getRDH()->offsetToNext > raw::sHeaderSizeInBytes) {
149-
read(mBuffer.getRDH()->offsetToNext - raw::sHeaderSizeInBytes);
151+
if (RDHUtils::getOffsetToNext(*mBuffer.getRDH()) > raw::sHeaderSizeInBytes) {
152+
read(RDHUtils::getOffsetToNext(*mBuffer.getRDH()) - raw::sHeaderSizeInBytes);
150153
// CAVEAT: to save memory / CPU time, the RawBuffer does not hold a copy of the buffer,
151154
// but just a span of it.
152155
// If we add bytes to mBytes, the vector can go beyond the capacity
@@ -171,4 +174,4 @@ template class RawFileReader<raw::RawUnit>;
171174
template class RawFileReader<uint8_t>;
172175

173176
} // namespace mid
174-
} // namespace o2
177+
} // namespace o2

0 commit comments

Comments
 (0)