Skip to content

Commit 79debec

Browse files
authored
Merge pull request AliceO2Group#18 from noferini/tof-dev
add event counter and tracing of empty crates in TOF decoding
2 parents 723bbe6 + 814ba40 commit 79debec

File tree

5 files changed

+59
-6
lines changed

5 files changed

+59
-6
lines changed

Detectors/TOF/base/include/TOFBase/Digit.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ struct ReadoutWindowData {
116116
o2::dataformats::RangeReference<int, int> refDiagnostic;
117117

118118
// crate info for diagnostic patterns
119-
int mNdiaCrate[72] = {0};
119+
int mNdiaCrate[Geo::kNCrate] = {0};
120+
int mDeltaBCCrate[Geo::kNCrate] = {0};
121+
int mDeltaEventCounterCrate[Geo::kNCrate] = {0};
120122

121123
InteractionRecord mFirstIR{0, 0};
124+
int mEventCounter = 0;
122125

123126
const InteractionRecord& getBCData() const { return mFirstIR; }
124127

@@ -164,7 +167,14 @@ struct ReadoutWindowData {
164167
void setFirstEntryDia(int first) { refDiagnostic.setFirstEntry(first); }
165168
void setNEntriesDia(int ne) { refDiagnostic.setEntries(ne); }
166169

167-
ClassDefNV(ReadoutWindowData, 3);
170+
void setEventCounter(int ev) { mEventCounter = ev; }
171+
void setDeltaEventCounterCrate(int crate, int ev) { mDeltaEventCounterCrate[crate] = ev; }
172+
int getEventCounter() const { return mEventCounter; }
173+
int getDeltaEventCounterCrate(int crate) const { return mDeltaEventCounterCrate[crate]; }
174+
void setDeltaBCCrate(int crate, int bc) { mDeltaBCCrate[crate] = bc; }
175+
int getDeltaBCCrate(int crate) const { return mDeltaBCCrate[crate]; }
176+
177+
ClassDefNV(ReadoutWindowData, 4);
168178
};
169179

170180
} // namespace tof

Detectors/TOF/base/include/TOFBase/WindowFiller.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class WindowFiller
7878
void addPattern(const uint32_t val, int icrate, int orbit, int bc) { mCratePatterns.emplace_back(val, icrate, orbit * 3 + (bc + 100) / Geo::BC_IN_WINDOW); }
7979
void addCrateHeaderData(unsigned long orbit, int crate, int32_t bc, uint32_t eventCounter);
8080

81+
void setTraceEmptyCrates(bool val) { mTraceEmptyCrates = val; }
82+
8183
protected:
8284
// info TOF timewindow
8385
uint64_t mReadoutWindowCurrent = 0;
@@ -91,6 +93,8 @@ class WindowFiller
9193
int mMaskNoiseRate = -1;
9294
int mChannelCounts[o2::tof::Geo::NCHANNELS]; // count of channel hits in the current TF (if MaskNoiseRate enabled)
9395

96+
bool mTraceEmptyCrates = 1; // set to 0 not to trace empty crates
97+
9498
// digit info
9599
//std::vector<Digit>* mDigits;
96100

@@ -145,7 +149,7 @@ class WindowFiller
145149
return true;
146150
}
147151

148-
ClassDefNV(WindowFiller, 1);
152+
ClassDefNV(WindowFiller, 2);
149153
};
150154
} // namespace tof
151155
} // namespace o2

Detectors/TOF/base/src/WindowFiller.cxx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,34 +140,59 @@ void WindowFiller::fillOutputContainer(std::vector<Digit>& digits)
140140
ReadoutWindowData info(first, ne);
141141
int orbit_shift = mReadoutWindowData.size() / Geo::NWINDOW_IN_ORBIT;
142142

143+
bool isCrateMissing[Geo::kNCrate];
144+
143145
int bc_shift = -1;
144-
if (mReadoutWindowData.size() >= mCrateHeaderData.size())
146+
int eventcounter = -1;
147+
if (mReadoutWindowData.size() >= mCrateHeaderData.size()) {
145148
bc_shift = (mReadoutWindowData.size() % Geo::NWINDOW_IN_ORBIT) * Geo::BC_IN_WINDOW; // insert default value
146-
else {
149+
eventcounter = mReadoutWindowData.size() % 4096;
150+
for (int icrate = 0; icrate < Geo::kNCrate; icrate++)
151+
isCrateMissing[icrate] = mTraceEmptyCrates;
152+
} else {
147153
unsigned long irow = mReadoutWindowData.size();
148154
for (int icrate = 0; icrate < Geo::kNCrate; icrate++) {
149155
if (mCrateHeaderData[irow].bc[icrate] == -1) { // crate not read
156+
isCrateMissing[icrate] = mTraceEmptyCrates;
150157
continue;
151158
}
159+
isCrateMissing[icrate] = false;
152160
if (bc_shift == -1 || mCrateHeaderData[irow].bc[icrate] < bc_shift)
153161
bc_shift = mCrateHeaderData[irow].bc[icrate];
162+
if (eventcounter == -1 || mCrateHeaderData[irow].eventCounter[icrate] < eventcounter)
163+
eventcounter = mCrateHeaderData[irow].eventCounter[icrate];
154164
}
165+
155166
if (bc_shift == -1)
156167
bc_shift = (mReadoutWindowData.size() % Geo::NWINDOW_IN_ORBIT) * Geo::BC_IN_WINDOW; // insert default value
168+
if (eventcounter == -1)
169+
eventcounter = mReadoutWindowData.size() % 4096; // insert default value
157170
}
158171

159172
info.setBCData(mFirstIR.orbit + orbit_shift, mFirstIR.bc + bc_shift);
173+
info.setEventCounter(eventcounter);
160174
int firstPattern = mPatterns.size();
161175
int npatterns = 0;
162176

177+
int icrateToBeChecked = 0;
178+
163179
// check if patterns are in the current row
164180
for (std::vector<PatternData>::reverse_iterator it = mCratePatterns.rbegin(); it != mCratePatterns.rend(); ++it) {
165-
if (it->row > mReadoutWindowCurrent)
181+
if (it->row > mReadoutWindowCurrent) {
166182
break;
183+
}
167184

168185
if (it->row < mReadoutWindowCurrent) { // this should not happen
169186
LOG(ERROR) << "One pattern skipped because appears to occur early of the current row " << it->row << " < " << mReadoutWindowCurrent << " ?!";
170187
} else {
188+
for (; icrateToBeChecked < it->icrate; icrateToBeChecked++) { // checks all crates before the one provided by patterns to see if they were read (fill pattern 0 for all not read)
189+
if (isCrateMissing[icrateToBeChecked]) {
190+
mPatterns.push_back(0);
191+
info.addedDiagnostic(icrateToBeChecked);
192+
npatterns++;
193+
}
194+
}
195+
171196
mPatterns.push_back(it->pattern);
172197
info.addedDiagnostic(it->icrate);
173198

@@ -176,6 +201,14 @@ void WindowFiller::fillOutputContainer(std::vector<Digit>& digits)
176201
mCratePatterns.pop_back();
177202
}
178203

204+
for (; icrateToBeChecked < Geo::kNCrate; icrateToBeChecked++) { // check if remaining crates were read otherwise add pattern=0 to crates not read
205+
if (isCrateMissing[icrateToBeChecked]) {
206+
mPatterns.push_back(0);
207+
info.addedDiagnostic(icrateToBeChecked);
208+
npatterns++;
209+
}
210+
}
211+
179212
info.setFirstEntryDia(firstPattern);
180213
info.setNEntriesDia(npatterns);
181214
if (digits.size() || npatterns) {

Detectors/TOF/workflow/include/TOFWorkflowUtils/CompressedDecodingTask.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class CompressedDecodingTask : public DecoderBase, public Task
6868
uint32_t mInitOrbit = 0;
6969
bool mRowFilter = false;
7070
bool mMaskNoise = false;
71+
bool mSkipEmptyCrates = false;
7172
int mNoiseRate = 1000;
7273
TStopwatch mTimer;
7374
};

Detectors/TOF/workflow/src/CompressedDecodingTask.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ void CompressedDecodingTask::init(InitContext& ic)
4242
mMaskNoise = ic.options().get<bool>("mask-noise");
4343
mNoiseRate = ic.options().get<int>("noise-counts");
4444
mRowFilter = ic.options().get<bool>("row-filter");
45+
mSkipEmptyCrates = ic.options().get<bool>("skip-empty-crates");
4546

4647
if (mMaskNoise)
4748
mDecoder.maskNoiseRate(mNoiseRate);
4849

50+
if (mSkipEmptyCrates)
51+
mDecoder.setTraceEmptyCrates(0);
52+
4953
auto finishFunction = [this]() {
5054
LOG(INFO) << "CompressedDecoding finish";
5155
};
@@ -327,6 +331,7 @@ DataProcessorSpec getCompressedDecodingSpec(const std::string& inputDesc, bool c
327331
Options{
328332
{"row-filter", VariantType::Bool, false, {"Filter empty row"}},
329333
{"mask-noise", VariantType::Bool, false, {"Flag to mask noisy digits"}},
334+
{"skip-empty-crates", VariantType::Bool, false, {"Flag not to trace empty crates"}},
330335
{"noise-counts", VariantType::Int, 1000, {"Counts in a single (TF) payload"}}}};
331336
}
332337

0 commit comments

Comments
 (0)