Skip to content

Commit 42904b8

Browse files
authored
small changes in handling empty TF (#15778)
* small changes in handling empty TF * add protection against empty ROF container This is a follow up on #15705 and #15714. If there is no collision, we can as well skip entirely the noise-only digit generation to save time and send empty containers. A protection was missing in the MCH and MID digit readers when using IR frames.
1 parent 1f1bf16 commit 42904b8

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

Detectors/ITSMFT/common/workflow/src/DigitReaderSpec.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void DigitReader<N>::run(ProcessingContext& pc)
189189
std::vector<int> rofOld2New;
190190
rofOld2New.resize(mDigROFRec[0]->size(), -1);
191191

192-
if (mDigROFRec[0]->front().getBCData() <= irMax && (mDigROFRec[0]->back().getBCData() + mROFLengthInBC - 1) >= irMin) { // there is an overlap
192+
if (!mDigROFRec[0]->empty() && mDigROFRec[0]->front().getBCData() <= irMax && (mDigROFRec[0]->back().getBCData() + mROFLengthInBC - 1) >= irMin) { // there is an overlap
193193
for (int irof = 0; irof < (int)mDigROFRec[0]->size(); irof++) {
194194
const auto& rof = mDigROFRec[0]->at(irof);
195195
if (irfSel.check({rof.getBCData(), rof.getBCData() + mROFLengthInBC - 1}) != -1) {
@@ -208,7 +208,7 @@ void DigitReader<N>::run(ProcessingContext& pc)
208208
}
209209
}
210210
}
211-
if (mDigROFRec[0]->back().getBCData() + mROFLengthInBC - 1 < irMax) { // need to check the next entry
211+
if (mDigROFRec[0]->empty() || mDigROFRec[0]->back().getBCData() + mROFLengthInBC - 1 < irMax) { // need to check the next entry
212212
ent++;
213213
continue;
214214
}

Detectors/MUON/MCH/IO/src/DigitReaderSpec.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ class DigitsReaderDeviceDPL
152152
// get the IR frames to select
153153
auto irFrames = pc.inputs().get<gsl::span<dataformats::IRFrame>>("driverInfo");
154154

155-
if (!irFrames.empty()) {
155+
if (mTreeReader.GetEntries() == 0) {
156+
// A timeframe holds no collision at all whenever the interaction rate is low enough, and the
157+
// digit tree then has no entry. Nothing to select. Send empty containers.
158+
LOG(info) << "digit tree has no entry, sending empty output";
159+
} else if (!irFrames.empty()) {
156160
utils::IRFrameSelector irfSel{};
157161
irfSel.setSelectedIRFrames(irFrames, 0, 0, -mTimeOffset, true);
158162
const auto irMin = irfSel.getIRFrames().front().getMin();

Detectors/MUON/MID/Workflow/src/DigitReaderSpec.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ class DigitsReaderDeviceDPL
146146
// get the IR frames to select
147147
auto irFrames = pc.inputs().get<gsl::span<dataformats::IRFrame>>("driverInfo");
148148

149-
if (!irFrames.empty()) {
149+
if (mTreeReader.GetEntries() == 0) {
150+
// A timeframe holds no collision at all whenever the interaction rate is low enough, and the
151+
// digit tree then has no entry. Nothing to select. Send empty containers.
152+
LOG(info) << "digit tree has no entry, sending empty output";
153+
} else if (!irFrames.empty()) {
150154
utils::IRFrameSelector irfSel{};
151155
irfSel.setSelectedIRFrames(irFrames, 0, 0, 0, true);
152156
const auto irMin = irfSel.getIRFrames().front().getMin();

Steer/DigitizerWorkflow/src/MCHDigitizerSpec.cxx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "DataFormatsMCH/ROFRecord.h"
1616
#include "DataFormatsParameters/GRPObject.h"
1717
#include "DetectorsBase/BaseDPLDigitizer.h"
18-
#include "DetectorsRaw/HBFUtils.h"
1918
#include "Framework/ConfigParamRegistry.h"
2019
#include "Framework/ControlService.h"
2120
#include "Framework/DataProcessorSpec.h"
@@ -63,7 +62,7 @@ class MCHDPLDigitizerTask : public o2::base::BaseDPLDigitizer
6362
if (labels.getIndexedSize() != digits.size()) {
6463
LOGP(error, "Number of labels != number of digits");
6564
}
66-
LOGP(info, "Number of signal pileup : {} ({} %)", nPileup, 100. * nPileup / digits.size());
65+
LOGP(info, "Number of signal pileup : {} ({} %)", nPileup, digits.empty() ? 0. : 100. * nPileup / digits.size());
6766
auto tEnd = std::chrono::high_resolution_clock::now();
6867
auto duration = tEnd - start;
6968
auto d = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
@@ -104,20 +103,12 @@ class MCHDPLDigitizerTask : public o2::base::BaseDPLDigitizer
104103
}
105104

106105
// generate noise-only signals between first and last collisions ± 100 BC (= 25 ADC samples).
107-
// A timeframe can hold no collision at all when the interaction rate is low; take the range
108-
// from the timeframe itself in that case, since there are no collisions to take it from.
109-
int64_t firstLong, lastLong;
110-
if (eventRecords.empty()) {
111-
const auto& hbf = o2::raw::HBFUtils::Instance();
112-
firstLong = InteractionRecord(0, hbf.orbitFirstSampled).toLong();
113-
lastLong = InteractionRecord(0, hbf.orbitFirstSampled + hbf.nHBFPerTF).toLong();
114-
} else {
115-
firstLong = eventRecords.front().toLong();
116-
lastLong = eventRecords.back().toLong();
106+
// A timeframe can hold no collision at all when the interaction rate is low; skip it in that case.
107+
if (!eventRecords.empty()) {
108+
auto firstIR = InteractionRecord::long2IR(std::max(int64_t(0), eventRecords.front().toLong() - timeOffset - 100));
109+
auto lastIR = InteractionRecord::long2IR(std::max(int64_t(0), eventRecords.back().toLong() - timeOffset + 100));
110+
mDigitizer->addNoise(firstIR, lastIR);
117111
}
118-
auto firstIR = InteractionRecord::long2IR(std::max(int64_t(0), firstLong - timeOffset - 100));
119-
auto lastIR = InteractionRecord::long2IR(std::max(int64_t(0), lastLong - timeOffset + 100));
120-
mDigitizer->addNoise(firstIR, lastIR);
121112

122113
// digitize
123114
std::vector<Digit> digits{};

0 commit comments

Comments
 (0)