Skip to content

Commit b27a87e

Browse files
committed
Fix: ROF length must be a multiple of the clock period (std::round + fatal check)
1 parent 052419b commit b27a87e

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎Detectors/Upgrades/ALICE3/TRKFT3/TRK/base/include/TRKBase/AlmiraParam.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ struct AlmiraParam : public o2::conf::ConfigurableParamHelper<AlmiraParam> {
5050
return (layer < constants::VD::petal::nLayers ? 1 : 4) * o2::constants::lhc::LHCBunchSpacingNS; // the clock is synchronous with the LHC: 1 BC (VD), 4 BC (ML/OT/disks)
5151
}
5252

53-
/// number of clock cycles in a ROF; if the ROF is not a multiple of the clock period, the last cycle is shorter
54-
/// (e.g. ROF 18 BC, clock 4 BC -> 4.5 -> 5 cycles). Tolerance for the float rounding: 18 BC / 24.95 ns must give 18, not 19
53+
/// number of clock cycles in a ROF (the ROF length is a multiple of the clock period, as required by the ALMIRA design)
5554
static int computeNClockCycles(int rofLengthInBC, float clockPeriod)
5655
{
57-
return std::ceil(rofLengthInBC * o2::constants::lhc::LHCBunchSpacingNS / clockPeriod - 1e-3); // - 1e-3: tolerance for float rounding
56+
return std::round(rofLengthInBC * o2::constants::lhc::LHCBunchSpacingNS / clockPeriod);
5857
}
58+
5959
int getNClockCyclesPerROF(int layer) const { return computeNClockCycles(getROFLengthInBC(layer), getClockPeriod(layer)); }
6060

6161
/// timestamp [frame (ROF counter) | clock cycle in ROF] of a signal with time toa (ns) w.r.t. the start of the ROF with index rofIndex

‎Steer/DigitizerWorkflow/src/TRKDigitizerSpec.cxx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class TRKFT3DPLDigitizerTask : BaseDPLDigitizer
139139

140140
const int roFrameLengthInBC = mDigitizer.getParams().getROFrameLengthInBC(iLayer);
141141
const long tfLengthInBC = long(o2::constants::lhc::LHCMaxBunches) * raw::HBFUtils::Instance().getNOrbitsPerTF();
142-
const int nROFsTF = (tfLengthInBC + roFrameLengthInBC - 1) / roFrameLengthInBC; // rounded up: the last ROF may be truncated by the end of the TF
142+
const int nROFsTF = (tfLengthInBC + roFrameLengthInBC - 1) / roFrameLengthInBC; // rounded up: if the TF length is not a multiple of the ROF length, the last ROF is truncated by the end of the TF
143+
// (simulation artifact: the handling of ROFs across the TF boundary is still to be defined with DAQ)
143144

144145
mROFRecordsAccum[iLayer].reserve(nROFsTF);
145146

@@ -307,6 +308,12 @@ class TRKFT3DPLDigitizerTask : BaseDPLDigitizer
307308
digipar.setClockPeriod(aopt.getClockPeriod(parLayer), iLayer); // after setROFrameLengthInBC: computes and sets the clock cycles per ROF
308309

309310
const int nCycles = digipar.getNClockCyclesPerROF(iLayer);
311+
const float clockPeriod = digipar.getClockPeriod(iLayer);
312+
if (std::abs(nCycles * clockPeriod - frameNS) > 1e-3f * clockPeriod) { // tolerance for the float comparison only
313+
LOGP(fatal, "{} layer {}: ROF length {} BC ({:.2f} ns) is not a multiple of the clock period ({:.2f} ns), as required by the ALMIRA design",
314+
ID.getName(), iLayer, roFrameLengthInBC, frameNS, clockPeriod);
315+
}
316+
310317
const long tfLengthInBC = long(o2::constants::lhc::LHCMaxBunches) * o2::raw::HBFUtils::Instance().getNOrbitsPerTF();
311318
if (tfLengthInBC % roFrameLengthInBC != 0) {
312319
LOGP(warning, "{} layer {}: ROF length {} BC does not divide the TF length {} BC: the last ROF of the TF is truncated", ID.getName(), iLayer, roFrameLengthInBC, tfLengthInBC);

0 commit comments

Comments
 (0)