Skip to content

Commit 6eebd07

Browse files
authored
[MCH] ROFRecord: moved bcWidth parameter in constructor (#6896)
A second constructor has been added to the ROFRecord class, enabling to set the bcWidth parameter to a value different from the default of 4 bunch crossings.
1 parent af3e5d5 commit 6eebd07

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

DataFormats/Detectors/MUON/MCH/include/DataFormatsMCH/ROFRecord.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ROFRecord
3737
public:
3838
ROFRecord() = default;
3939
ROFRecord(const BCData& bc, int firstIdx, int nEntries) : mBCData(bc), mDataRef(firstIdx, nEntries) {}
40+
ROFRecord(const BCData& bc, int firstIdx, int nEntries, int bcWidth) : mBCData(bc), mDataRef(firstIdx, nEntries), mBCWidth(bcWidth) {}
4041

4142
/// get the interaction record
4243
const BCData& getBCData() const { return mBCData; }
@@ -56,8 +57,6 @@ class ROFRecord
5657

5758
/// get the time span by this ROF, in BC unit
5859
int getBCWidth() const { return mBCWidth; }
59-
/// set the time span by this ROF, in BC unit
60-
void setBCWidth(int bcWidth);
6160

6261
bool operator==(const ROFRecord& other) const
6362
{

DataFormats/Detectors/MUON/MCH/src/ROFRecord.cxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,5 @@ std::ostream& operator<<(std::ostream& os, const ROFRecord& rof)
2323
rof.getBCWidth());
2424
return os;
2525
}
26-
void ROFRecord::setBCWidth(int bcWidth)
27-
{
28-
if (bcWidth < 4) {
29-
throw std::invalid_argument(fmt::format("bcWidth must be strictly greater than 4 bunch-crossings"));
30-
}
31-
}
3226

3327
} // namespace o2::mch

Detectors/MUON/MCH/DevIO/Digits/DigitIOV1.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ bool DigitReaderV1::read(std::istream& in,
5353
return false;
5454
}
5555
for (auto r0 : rofsr0) {
56-
ROFRecord r(r0.ir, r0.ref.getFirstEntry(), r0.ref.getEntries());
57-
r.setBCWidth(4);
56+
ROFRecord r(r0.ir, r0.ref.getFirstEntry(), r0.ref.getEntries(), 4);
5857
rofs.push_back(r);
5958
}
6059

Detectors/MUON/MCH/DevIO/Digits/DigitIOV4.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ bool DigitReaderV4::read(std::istream& in,
6464
in.read(reinterpret_cast<char*>(&firstIdx), sizeof(uint32_t));
6565
in.read(reinterpret_cast<char*>(&nentries), sizeof(uint32_t));
6666
in.read(reinterpret_cast<char*>(&bcWidth), sizeof(uint32_t));
67-
rofs.emplace_back(o2::InteractionRecord{bc, orbit}, firstIdx, nentries);
68-
rofs.back().setBCWidth(bcWidth);
67+
rofs.emplace_back(o2::InteractionRecord{bc, orbit}, firstIdx, nentries, bcWidth);
6968
if (in.fail()) {
7069
return false;
7170
}

Detectors/MUON/MCH/Raw/Decoder/src/ROFFinder.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ namespace raw
3737

3838
using namespace std;
3939

40+
static constexpr int sBcInOneADCclock = 4;
41+
4042
//_________________________________________________________________________________________________
4143
ROFFinder::ROFFinder(const DataDecoder::RawDigitVector& digits, uint32_t firstTForbit) : mInputDigits(digits), mFirstTForbit(firstTForbit)
4244
{
@@ -115,9 +117,8 @@ void ROFFinder::process(bool dummyROFs)
115117
std::cout << fmt::format(" checking digit {} -> {}\n", id2, inputId2);
116118
#endif
117119

118-
constexpr int oneADCclock = 4;
119120
auto tdiff = digit.getTime() - rofSeed.getTime();
120-
if (std::abs(tdiff) < oneADCclock) {
121+
if (std::abs(tdiff) < sBcInOneADCclock) {
121122
mEntries += 1;
122123
#ifdef ROFDEBUG
123124
std::cout << fmt::format(" digit {} -> {} added to current ROF\n", id2, inputId2);
@@ -196,7 +197,7 @@ o2::InteractionRecord ROFFinder::digitTime2IR(const RawDigit& digit)
196197
void ROFFinder::storeROF()
197198
{
198199
if (mEntries > 0) {
199-
mOutputROFs.emplace_back(mIR, mFirstIdx, mEntries);
200+
mOutputROFs.emplace_back(mIR, mFirstIdx, mEntries, sBcInOneADCclock);
200201
}
201202
}
202203

Detectors/MUON/MCH/Raw/Decoder/src/testROFFinder.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE(TwoDigitsInOneROF)
7676
BOOST_CHECK_EQUAL(rofRecords[0].getNEntries(), 2);
7777

7878
BOOST_CHECK_EQUAL(rofRecords[0].getBCData(), rofFinder.digitTime2IR(digits[0]));
79+
BOOST_CHECK_EQUAL(rofRecords[0].getBCWidth(), 4);
7980

8081
BOOST_CHECK_EQUAL(rofFinder.isDigitsTimeAligned(), true);
8182
}
@@ -103,6 +104,7 @@ BOOST_AUTO_TEST_CASE(TwoDigitsInOneROFUnaligned)
103104
BOOST_CHECK_EQUAL(rofRecords[0].getNEntries(), 2);
104105

105106
BOOST_CHECK_EQUAL(rofRecords[0].getBCData(), rofFinder.digitTime2IR(digits[0]));
107+
BOOST_CHECK_EQUAL(rofRecords[0].getBCWidth(), 4);
106108

107109
BOOST_CHECK_EQUAL(rofFinder.isDigitsTimeAligned(), false);
108110
}
@@ -130,6 +132,7 @@ BOOST_AUTO_TEST_CASE(TwoDigitsInOneROFsConsecutiveOrbits)
130132
BOOST_CHECK_EQUAL(rofRecords[0].getNEntries(), 2);
131133

132134
BOOST_CHECK_EQUAL(rofRecords[0].getBCData(), rofFinder.digitTime2IR(digits[0]));
135+
BOOST_CHECK_EQUAL(rofRecords[0].getBCWidth(), 4);
133136
}
134137

135138
//----------------------------------------------------------------------------
@@ -154,10 +157,12 @@ BOOST_AUTO_TEST_CASE(TwoDigitsInTwoROFs)
154157
BOOST_CHECK_EQUAL(rofRecords[0].getFirstIdx(), 0);
155158
BOOST_CHECK_EQUAL(rofRecords[0].getNEntries(), 1);
156159
BOOST_CHECK_EQUAL(rofRecords[0].getBCData(), rofFinder.digitTime2IR(digits[0]));
160+
BOOST_CHECK_EQUAL(rofRecords[0].getBCWidth(), 4);
157161

158162
BOOST_CHECK_EQUAL(rofRecords[1].getFirstIdx(), 1);
159163
BOOST_CHECK_EQUAL(rofRecords[1].getNEntries(), 1);
160164
BOOST_CHECK_EQUAL(rofRecords[1].getBCData(), rofFinder.digitTime2IR(digits[1]));
165+
BOOST_CHECK_EQUAL(rofRecords[1].getBCWidth(), 4);
161166

162167
const auto rofDigit1 = rofFinder.getOrderedDigit(rofRecords[0].getFirstIdx());
163168
const auto rofDigit2 = rofFinder.getOrderedDigit(rofRecords[1].getFirstIdx());
@@ -194,10 +199,12 @@ BOOST_AUTO_TEST_CASE(TwoDigitsInTwoROFsConsecutiveOrbits)
194199
BOOST_CHECK_EQUAL(rofRecords[0].getFirstIdx(), 0);
195200
BOOST_CHECK_EQUAL(rofRecords[0].getNEntries(), 1);
196201
BOOST_CHECK_EQUAL(rofRecords[0].getBCData(), rofFinder.digitTime2IR(digits[1]));
202+
BOOST_CHECK_EQUAL(rofRecords[0].getBCWidth(), 4);
197203

198204
BOOST_CHECK_EQUAL(rofRecords[1].getFirstIdx(), 1);
199205
BOOST_CHECK_EQUAL(rofRecords[1].getNEntries(), 1);
200206
BOOST_CHECK_EQUAL(rofRecords[1].getBCData(), rofFinder.digitTime2IR(digits[0]));
207+
BOOST_CHECK_EQUAL(rofRecords[1].getBCWidth(), 4);
201208

202209
const auto rofDigit1 = rofFinder.getOrderedDigit(rofRecords[0].getFirstIdx());
203210
const auto rofDigit2 = rofFinder.getOrderedDigit(rofRecords[1].getFirstIdx());

0 commit comments

Comments
 (0)