Skip to content

Commit fea5bf7

Browse files
committed
CTFReader loads/sends per-TF IRFrames if requested
1 parent c371d64 commit fea5bf7

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct CTFReaderInp {
3030
std::string tffileRegex{};
3131
std::string remoteRegex{};
3232
std::string metricChannel{};
33+
std::string fileIRFrames{};
3334
std::vector<int> ctfIDs{};
3435
bool allowMissingDetectors = false;
3536
bool sup0xccdb = false;

Detectors/CTF/workflow/src/CTFReaderSpec.cxx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "Framework/RateLimiter.h"
2424
#include "CommonUtils/StringUtils.h"
2525
#include "CommonUtils/FileFetcher.h"
26+
#include "CommonUtils/IRFrameSelector.h"
2627
#include "CTFWorkflow/CTFReaderSpec.h"
2728
#include "DetectorsCommonDataFormats/EncodedBlocks.h"
2829
#include "CommonUtils/NameConf.h"
@@ -88,6 +89,7 @@ class CTFReaderSpec : public o2::framework::Task
8889
void setMessageHeader(ProcessingContext& pc, const CTFHeader& ctfHeader, const std::string& lbl, unsigned subspec) const; // keep just for the reference
8990
void tryToFixCTFHeader(CTFHeader& ctfHeader) const;
9091
CTFReaderInp mInput{};
92+
o2::utils::IRFrameSelector mIRFrameSelector; // optional IR frames selector
9193
std::unique_ptr<o2::utils::FileFetcher> mFileFetcher;
9294
std::unique_ptr<TFile> mCTFFile;
9395
std::unique_ptr<TTree> mCTFTree;
@@ -146,6 +148,9 @@ void CTFReaderSpec::init(InitContext& ic)
146148
mFileFetcher->setMaxFilesInQueue(mInput.maxFileCache);
147149
mFileFetcher->setMaxLoops(mInput.maxLoops);
148150
mFileFetcher->start();
151+
if (!mInput.fileIRFrames.empty()) {
152+
mIRFrameSelector.loadIRFrames(mInput.fileIRFrames);
153+
}
149154
}
150155

151156
///_______________________________________
@@ -274,6 +279,14 @@ void CTFReaderSpec::processTF(ProcessingContext& pc)
274279
processDetector<o2::zdc::CTF>(DetID::ZDC, ctfHeader, pc);
275280
processDetector<o2::ctp::CTF>(DetID::CTP, ctfHeader, pc);
276281

282+
if (mIRFrameSelector.isSet()) {
283+
o2::InteractionRecord ir0(0, timingInfo.firstTForbit);
284+
// we cannot have GRPECS via DPL CCDB fetcher in the CTFReader, so we take max possible TF length of 256 orbits
285+
o2::InteractionRecord ir1(o2::constants::lhc::LHCMaxBunches - 1, timingInfo.firstTForbit < 0xffffffff - 255 ? timingInfo.firstTForbit + 255 : 0xffffffff);
286+
auto irSpan = mIRFrameSelector.getMatchingFrames({ir0, ir1});
287+
auto outVec = pc.outputs().make<std::vector<o2::dataformats::IRFrame>>(OutputRef{"selIRFrames"}, irSpan.begin(), irSpan.end());
288+
}
289+
277290
// send sTF acknowledge message
278291
if (!mInput.sup0xccdb) {
279292
auto& stfDist = pc.outputs().make<o2::header::STFHeader>(OutputRef{"TFDist", 0xccdb});
@@ -395,6 +408,7 @@ void CTFReaderSpec::tryToFixCTFHeader(CTFHeader& ctfHeader) const
395408
///_______________________________________
396409
DataProcessorSpec getCTFReaderSpec(const CTFReaderInp& inp)
397410
{
411+
std::vector<InputSpec> inputs;
398412
std::vector<OutputSpec> outputs;
399413
std::vector<ConfigParamSpec> options;
400414

@@ -405,6 +419,9 @@ DataProcessorSpec getCTFReaderSpec(const CTFReaderInp& inp)
405419
outputs.emplace_back(OutputLabel{det.getName()}, det.getDataOrigin(), "CTFDATA", inp.subspec, Lifetime::Timeframe);
406420
}
407421
}
422+
if (!inp.fileIRFrames.empty()) {
423+
outputs.emplace_back(OutputLabel{"selIRFrames"}, "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
424+
}
408425
if (!inp.sup0xccdb) {
409426
outputs.emplace_back(OutputSpec{{"TFDist"}, o2::header::gDataOriginFLP, o2::header::gDataDescriptionDISTSTF, 0xccdb});
410427
}
@@ -418,7 +435,7 @@ DataProcessorSpec getCTFReaderSpec(const CTFReaderInp& inp)
418435

419436
return DataProcessorSpec{
420437
"ctf-reader",
421-
Inputs{},
438+
inputs,
422439
outputs,
423440
AlgorithmSpec{adaptFromTask<CTFReaderSpec>(inp)},
424441
options};

Detectors/CTF/workflow/src/ctf-reader-workflow.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "Framework/InputSpec.h"
1919
#include "CommonUtils/NameConf.h"
2020
#include "CTFWorkflow/CTFReaderSpec.h"
21-
#include "DataFormatsParameters/GRPObject.h"
2221
#include "DetectorsCommonDataFormats/DetID.h"
2322
#include "CommonUtils/ConfigurableParam.h"
2423
#include "Algorithm/RangeTokenizer.h"
@@ -63,6 +62,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
6362
options.push_back(ConfigParamSpec{"ctf-reader-verbosity", VariantType::Int, 0, {"verbosity level (0: summary per detector, 1: summary per block"}});
6463
options.push_back(ConfigParamSpec{"ctf-data-subspec", VariantType::Int, 0, {"subspec to use for decoded CTF messages (use non-0 if CTF writer will be attached downstream)"}});
6564
options.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}});
65+
options.push_back(ConfigParamSpec{"ir-frames-files", VariantType::String, "", {"If non empty, inject selected IRFrames from this file"}});
6666
//
6767
options.push_back(ConfigParamSpec{"its-digits", VariantType::Bool, false, {"convert ITS clusters to digits"}});
6868
options.push_back(ConfigParamSpec{"mft-digits", VariantType::Bool, false, {"convert MFT clusters to digits"}});
@@ -118,6 +118,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
118118
ctfInput.allowMissingDetectors = configcontext.options().get<bool>("allow-missing-detectors");
119119
ctfInput.sup0xccdb = !configcontext.options().get<bool>("send-diststf-0xccdb");
120120
ctfInput.minSHM = std::stoul(configcontext.options().get<std::string>("timeframes-shm-limit"));
121+
ctfInput.fileIRFrames = configcontext.options().get<std::string>("ir-frames-files");
121122
int verbosity = configcontext.options().get<int>("ctf-reader-verbosity");
122123

123124
int rateLimitingIPCID = std::stoi(configcontext.options().get<std::string>("timeframes-rate-limit-ipcid"));

0 commit comments

Comments
 (0)