Skip to content

Commit eef4e26

Browse files
committed
TRKDigitizerSpec workflow: now the number of ROFs per TF is computed from the TF length and rounded up. This was introduced to cope with the new default ROF length of 16 BC (required by designers) which does not divide exactly the orbit.
1 parent 3e6db16 commit eef4e26

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎Steer/DigitizerWorkflow/src/TRKDigitizerSpec.cxx‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ class TRKFT3DPLDigitizerTask : BaseDPLDigitizer
138138
auto& digitsAccum = pc.outputs().make<std::vector<trkft3::Digit>>(Output{Origin, "DIGITS", iLayer});
139139

140140
const int roFrameLengthInBC = mDigitizer.getParams().getROFrameLengthInBC(iLayer);
141-
const int nROFsPerOrbit = o2::constants::lhc::LHCMaxBunches / roFrameLengthInBC;
142-
const int nROFsTF = nROFsPerOrbit * raw::HBFUtils::Instance().getNOrbitsPerTF();
141+
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
143+
143144
mROFRecordsAccum[iLayer].reserve(nROFsTF);
144145

145146
auto accumulate = [this, &digitsAccum, &iLayer]() {
@@ -288,6 +289,10 @@ class TRKFT3DPLDigitizerTask : BaseDPLDigitizer
288289

289290
// FT3's discs take the AlmiraParam entries after TRK's barrel layers, which it reserves for them.
290291
constexpr int firstParLayer = N == o2::detectors::DetID::TRK ? 0 : o2::trk::AlmiraParam::getNLayers() - o2::trk::constants::MLOTDisks::nLayers;
292+
if (aopt.nTimestampBits > 16 || aopt.nFineBits < 0 || aopt.nFineBits > aopt.nTimestampBits) { // TODO: check once the bits division has been definitively chosen
293+
LOGP(fatal, "Invalid timestamp format: {} bits with {} fine bits (the digit timestamp is a uint16_t)", aopt.nTimestampBits, aopt.nFineBits);
294+
}
295+
291296
for (int iLayer = 0; iLayer < mLayers; ++iLayer) {
292297
const int parLayer = std::min<int>(firstParLayer + iLayer, o2::trk::AlmiraParam::getNLayers() - 1);
293298
const auto roFrameLengthInBC = aopt.getROFLengthInBC(parLayer);
@@ -299,6 +304,19 @@ class TRKFT3DPLDigitizerTask : BaseDPLDigitizer
299304
const auto strobeLengthCont = aopt.getStrobeLengthCont(parLayer);
300305
digipar.setStrobeLength(strobeLengthCont > 0 ? strobeLengthCont : frameNS - aopt.getStrobeDelay(parLayer), iLayer);
301306
digipar.setROFrameLength(frameNS, iLayer);
307+
digipar.setClockPeriod(aopt.getClockPeriod(parLayer), iLayer); // after setROFrameLengthInBC: computes and sets the clock cycles per ROF
308+
309+
const int nCycles = digipar.getNClockCyclesPerROF(iLayer);
310+
const long tfLengthInBC = long(o2::constants::lhc::LHCMaxBunches) * o2::raw::HBFUtils::Instance().getNOrbitsPerTF();
311+
if (tfLengthInBC % roFrameLengthInBC != 0) {
312+
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);
313+
}
314+
if ((1L << (aopt.nTimestampBits - aopt.nFineBits)) * roFrameLengthInBC <= o2::constants::lhc::LHCMaxBunches) {
315+
LOGP(warning, "{} layer {}: the timestamp frame counter ({} bits) rolls over within an orbit with ROF length {} BC", ID.getName(), iLayer, aopt.nTimestampBits - aopt.nFineBits, roFrameLengthInBC);
316+
}
317+
if (nCycles > (1 << aopt.nFineBits)) {
318+
LOGP(fatal, "{} layer {}: {} clock cycles per ROF do not fit in the {} fine bits of the timestamp. Possible values: 16 BC for VD; 16,32,64 BC for MLOT/FT3.", ID.getName(), iLayer, nCycles, aopt.nFineBits);
319+
}
302320
}
303321
// parameters of signal time response: flat-top duration, max rise time and q @ which rise time is 0
304322
digipar.getSignalShape().setParameters(dopt.strobeFlatTop, dopt.strobeMaxRiseTime, dopt.strobeQRiseTime0);

0 commit comments

Comments
 (0)