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// /_______________________________________
396409DataProcessorSpec 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};
0 commit comments