Skip to content

Commit 1dc0877

Browse files
committed
CTF: add reverse opt for injected IDs
1 parent 60ed0d2 commit 1dc0877

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Detectors/CTF/workflow/include/CTFWorkflow/CTFReaderSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct CTFReaderInp {
3333
std::string fileIRFrames{};
3434
std::string fileRunTimeSpans{};
3535
std::vector<int> ctfIDs{};
36+
bool reverseCTFIDs{false};
3637
bool skipSkimmedOutTF = false;
3738
bool invertIRFramesSelection = false;
3839
bool allowMissingDetectors = false;

Detectors/CTF/workflow/src/CTFReaderSpec.cxx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ void CTFReaderSpec::stopReader()
159159
void CTFReaderSpec::init(InitContext& ic)
160160
{
161161
mInput.ctfIDs = o2::RangeTokenizer::tokenize<int>(ic.options().get<std::string>("select-ctf-ids"));
162+
if ((mInput.reverseCTFIDs = ic.options().get<bool>("reverse-select-ctf-ids"))) {
163+
std::reverse(mInput.ctfIDs.begin(), mInput.ctfIDs.end());
164+
}
162165
mUseLocalTFCounter = ic.options().get<bool>("local-tf-counter");
163166
mImposeRunStartMS = ic.options().get<int64_t>("impose-run-start-timstamp");
164167
mInput.checkTFLimitBeforeReading = ic.options().get<bool>("limit-tf-before-reading");
@@ -347,10 +350,10 @@ void CTFReaderSpec::run(ProcessingContext& pc)
347350
long startWait = 0;
348351

349352
while (mRunning) {
350-
if (mCTFTree) { // there is a tree open with multiple CTF
351-
if (mInput.ctfIDs.empty() || mInput.ctfIDs[mSelIDEntry] == mCTFCounter || mInput.shuffle) { // no selection requested or matching CTF ID is found
353+
if (mCTFTree) { // there is a tree open with multiple CTF
354+
if (mInput.ctfIDs.empty() || mInput.ctfIDs[mSelIDEntry] == mCTFCounter || mInput.shuffle || mInput.reverseCTFIDs) { // no selection requested or matching CTF ID is found
352355
LOG(debug) << "TF " << mCTFCounter << " of " << mInput.maxTFs << " loop " << mFileFetcher->getNLoops();
353-
if (mInput.shuffle) {
356+
if (mInput.shuffle || mInput.reverseCTFIDs) {
354357
mCurrTreeEntry = mInput.ctfIDs[mSelIDEntry];
355358
}
356359
mSelIDEntry++;
@@ -529,7 +532,7 @@ bool CTFReaderSpec::processTF(ProcessingContext& pc)
529532
void CTFReaderSpec::checkTreeEntries()
530533
{
531534
bool reachedEnd{false};
532-
if (mInput.shuffle) { // last entry is last id
535+
if (mInput.shuffle || mInput.reverseCTFIDs) { // last entry is last id
533536
reachedEnd = (mCurrTreeEntry == mInput.ctfIDs.back());
534537
} else { // check if the tree has entries left, if needed, close current tree/file
535538
reachedEnd = (++mCurrTreeEntry >= mCTFTree->GetEntries());
@@ -644,6 +647,7 @@ DataProcessorSpec getCTFReaderSpec(const CTFReaderInp& inp)
644647
}
645648

646649
options.emplace_back(ConfigParamSpec{"select-ctf-ids", VariantType::String, "", {"comma-separated list CTF IDs to inject (from cumulative counter of CTFs seen)"}});
650+
options.emplace_back(ConfigParamSpec{"reverse-select-ctf-ids", VariantType::Bool, false, {"reverse order of to inject CTF IDs"}});
647651
options.emplace_back(ConfigParamSpec{"impose-run-start-timstamp", VariantType::Int64, 0L, {"impose run start time stamp (ms), ignored if 0"}});
648652
options.emplace_back(ConfigParamSpec{"local-tf-counter", VariantType::Bool, false, {"reassign header.tfCounter from local TF counter"}});
649653
options.emplace_back(ConfigParamSpec{"fetch-failure-threshold", VariantType::Float, 0.f, {"Fail if too many failures( >0: fraction, <0: abs number, 0: no threshold)"}});

0 commit comments

Comments
 (0)