Skip to content

Commit f0c7a81

Browse files
committed
better ctf shuffle
1 parent 68bd501 commit f0c7a81

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Detectors/CTF/workflow/src/CTFReaderSpec.cxx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,22 @@ void CTFReaderSpec::openCTFFile(const std::string& flname)
304304
throw std::runtime_error(fmt::format("CTF tree in {} has 0 entries, skipping", flname));
305305
}
306306
if (mInput.shuffle) {
307+
if (mInput.ctfIDs.empty()) {
308+
int entries = mCTFTree->GetEntries();
309+
if (mInput.maxTFs > 0) {
310+
entries = std::min(entries, mInput.maxTFs);
311+
}
312+
if (mInput.maxTFsPerFile > 0) {
313+
entries = std::min(entries, mInput.maxTFsPerFile);
314+
}
315+
mInput.ctfIDs.clear();
316+
mInput.ctfIDs.resize(entries);
317+
std::iota(mInput.ctfIDs.begin(), mInput.ctfIDs.end(), 0);
318+
}
307319
std::random_device dev;
308320
std::mt19937 gen{dev()};
309-
int entries = mCTFTree->GetEntries();
310-
if (mInput.maxTFs > 0) {
311-
entries = std::min(entries, mInput.maxTFs);
312-
}
313-
if (mInput.maxTFsPerFile > 0) {
314-
entries = std::min(entries, mInput.maxTFsPerFile);
315-
}
316-
mInput.ctfIDs.clear();
317-
mInput.ctfIDs.resize(entries);
318-
std::iota(mInput.ctfIDs.begin(), mInput.ctfIDs.end(), 0);
319321
std::shuffle(mInput.ctfIDs.begin(), mInput.ctfIDs.end(), gen);
320-
LOGP(info, "will shuffle CTF entries in this order:");
322+
LOGP(info, "will shuffle reading of CTF entries in this order:");
321323
for (int i{0}; i < (int)mInput.ctfIDs.size(); ++i) {
322324
LOGP(info, "\tTF {:02} -> {:02}", i, mInput.ctfIDs[i]);
323325
}

0 commit comments

Comments
 (0)