diff --git a/Detectors/MUON/MID/Workflow/include/MIDWorkflow/ColumnDataSpecsUtils.h b/Detectors/MUON/MID/Workflow/include/MIDWorkflow/ColumnDataSpecsUtils.h index d8ec401e6a473..e26a6ed5c1ccf 100644 --- a/Detectors/MUON/MID/Workflow/include/MIDWorkflow/ColumnDataSpecsUtils.h +++ b/Detectors/MUON/MID/Workflow/include/MIDWorkflow/ColumnDataSpecsUtils.h @@ -42,21 +42,28 @@ namespace mid namespace specs { -/// Returns the input specs for MID Column Data and corresponding ROFs and labels +/// Returns the input specs for MID Column Data and corresponding ROFs and labels for EventType Standard /// \param dataBind Data binding name /// \param dataDesc Input data description /// \param useMC Builds output specs for labels /// \return Vector of input specs -std::vector buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC); +std::vector buildStandardInputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC); -/// Returns the input specs for MID Column Data and corresponding ROFs and labels +/// Returns the input specs for MID Column Data and corresponding ROFs and labels for EventType Standard /// \param dataBind Data binding name /// \param dataDesc Input data description /// \param rofDesc Input ROF record description /// \param labelsDesc Input MC labels description /// \param useMC Builds output specs for labels /// \return Vector of input specs -std::vector buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, std::string_view rofDesc, std::string_view labelsDesc, bool useMC); +std::vector buildStandardInputSpecs(std::string_view dataBind, std::string_view dataDesc, std::string_view rofDesc, std::string_view labelsDesc, bool useMC); + +/// Returns the input specs for MID Column Data and corresponding ROFs and labels for all three EventTypes +/// \param dataBind Data binding name +/// \param dataDesc Input data description +/// \param rofDesc Input ROF record description +/// \return Vector of input specs +std::vector buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, std::string_view rofDesc); /// Returns the output specs for the different event types /// \param bind Binding name @@ -71,22 +78,19 @@ std::vector buildOutputSpecs(std::string_view bind, std:: /// \return Vector of Output specs std::vector buildStandardOutputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC); -/// Returns the inputs for the different event types +/// Returns the input matching a specific binding /// \param pc Processing context /// \param bind Binding name /// \return Array of spans template -std::array, NEvTypes> getInput(framework::ProcessingContext& pc, std::string_view bind) +gsl::span getInput(framework::ProcessingContext& pc, std::string_view bind) { - std::array, 3> data; for (auto const& inputRef : framework::InputRecordWalker(pc.inputs())) { - auto const* dh = framework::DataRefUtils::getHeader(inputRef); - auto subSpecIdx = static_cast(dh->subSpecification); if (framework::DataRefUtils::match(inputRef, bind.data())) { - data[subSpecIdx] = pc.inputs().get>(inputRef); + return pc.inputs().get>(inputRef); } } - return data; + return gsl::span(); } /// Gets the outputs @@ -94,7 +98,7 @@ std::array, NEvTypes> getInput(framework::ProcessingContext& /// \return vector of outputs std::vector buildOutputs(std::vector outputSpecs); -/// Returns the array of Column Data +/// Returns the array of Column Data for all three EventTypes /// \param pc Processing context /// \param dataBind Data binding name /// \return Array of Column Data spans @@ -107,7 +111,7 @@ std::array, NEvTypes> getData(framework::ProcessingC /// \return Span of ColumnData gsl::span getData(framework::ProcessingContext& pc, std::string_view dataBind, EventType eventType); -/// Returns the array of ROF records +/// Returns the array of ROF records for all three EventTypes /// \param pc Processing context /// \param dataBind Data binding name /// \return Array of ROF Records spans @@ -124,7 +128,7 @@ gsl::span getRofs(framework::ProcessingContext& pc, std::string /// \param pc Processing context /// \param dataBind Data binding name /// \return Pointer to MC labels -std::unique_ptr> getLabels(framework::ProcessingContext& pc, std::string_view dataBind); +std::unique_ptr> getLabels(framework::ProcessingContext& pc, std::string_view dataBind, EventType eventType = EventType::Standard); } // namespace specs } // namespace mid diff --git a/Detectors/MUON/MID/Workflow/src/CalibDataProcessorSpec.cxx b/Detectors/MUON/MID/Workflow/src/CalibDataProcessorSpec.cxx index 1a6f2de9cd886..036178c04e867 100644 --- a/Detectors/MUON/MID/Workflow/src/CalibDataProcessorSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/CalibDataProcessorSpec.cxx @@ -61,19 +61,9 @@ class CalibDataProcessorDPL std::array, 3> data; std::array, 3> dataRof; - std::vector filter = { - {"check_data", of::ConcreteDataTypeMatcher{header::gDataOriginMID, "DATA"}, of::Lifetime::Timeframe}, - {"check_rof", of::ConcreteDataTypeMatcher{header::gDataOriginMID, "DATAROF"}, of::Lifetime::Timeframe}, - }; - - for (auto const& inputRef : of::InputRecordWalker(pc.inputs(), filter)) { - auto const* dh = framework::DataRefUtils::getHeader(inputRef); - auto subSpecIdx = static_cast(dh->subSpecification); - if (of::DataRefUtils::match(inputRef, "mid_data")) { - data[subSpecIdx] = pc.inputs().get>(inputRef); - } else if (of::DataRefUtils::match(inputRef, "mid_data_rof")) { - dataRof[subSpecIdx] = pc.inputs().get>(inputRef); - } + for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) { + data[subSpec] = pc.inputs().get>(fmt::format("mid_data_{}", subSpec)); + dataRof[subSpec] = pc.inputs().get>(fmt::format("mid_data_rof_{}", subSpec)); } mNoise.clear(); @@ -151,8 +141,10 @@ class CalibDataProcessorDPL of::DataProcessorSpec getCalibDataProcessorSpec(const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks) { std::vector inputSpecs; - inputSpecs.emplace_back("mid_data", of::ConcreteDataTypeMatcher(header::gDataOriginMID, "DATA"), of::Lifetime::Timeframe); - inputSpecs.emplace_back("mid_data_rof", of::ConcreteDataTypeMatcher(header::gDataOriginMID, "DATAROF"), of::Lifetime::Timeframe); + for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) { + inputSpecs.emplace_back(fmt::format("mid_data_{}", subSpec), header::gDataOriginMID, "DATA", subSpec, of::Lifetime::Timeframe); + inputSpecs.emplace_back(fmt::format("mid_data_rof_{}", subSpec), header::gDataOriginMID, "DATAROF", subSpec, of::Lifetime::Timeframe); + } std::vector outputSpecs; outputSpecs.emplace_back(header::gDataOriginMID, "NOISE", 0); diff --git a/Detectors/MUON/MID/Workflow/src/ClusterizerSpec.cxx b/Detectors/MUON/MID/Workflow/src/ClusterizerSpec.cxx index c544ce19fcdea..bf0d9608a2119 100644 --- a/Detectors/MUON/MID/Workflow/src/ClusterizerSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/ClusterizerSpec.cxx @@ -132,7 +132,7 @@ framework::DataProcessorSpec getClusterizerSpec(bool isMC, std::string_view inDa if (isMC) { outputSpecs.emplace_back(of::OutputSpec{header::gDataOriginMID, "CLUSTERSLABELS"}); } - auto inputSpecs = specs::buildInputSpecs("mid_cluster_in", inDataDesc, inRofDesc, inLabelsDesc, isMC); + auto inputSpecs = specs::buildStandardInputSpecs("mid_cluster_in", inDataDesc, inRofDesc, inLabelsDesc, isMC); return of::DataProcessorSpec{ "MIDClusterizer", diff --git a/Detectors/MUON/MID/Workflow/src/ColumnDataSpecsUtils.cxx b/Detectors/MUON/MID/Workflow/src/ColumnDataSpecsUtils.cxx index e0d41cd8d91d2..c7af5e23ac2e4 100644 --- a/Detectors/MUON/MID/Workflow/src/ColumnDataSpecsUtils.cxx +++ b/Detectors/MUON/MID/Workflow/src/ColumnDataSpecsUtils.cxx @@ -83,14 +83,26 @@ std::string buildSelectors(std::string_view dataBind, std::string_view dataDesc, return selector; } -std::vector buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC) +std::vector buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, std::string_view rofDesc) { - return buildInputSpecs(dataBind, dataDesc, getROFDescription(dataDesc), getLabelsDescription(dataDesc), useMC); + std::string selector; + for (size_t ievt = 0; ievt < NEvTypes; ++ievt) { + if (!selector.empty()) { + selector += ";"; + } + selector += buildSelectors(dataBind, dataDesc, rofDesc, "", false, ievt); + } + return framework::select(selector.c_str()); +} + +std::vector buildStandardInputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC) +{ + return buildStandardInputSpecs(dataBind, dataDesc, getROFDescription(dataDesc), getLabelsDescription(dataDesc), useMC); } -std::vector buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, std::string_view rofDesc, std::string_view labelsDesc, bool useMC) +std::vector buildStandardInputSpecs(std::string_view dataBind, std::string_view dataDesc, std::string_view rofDesc, std::string_view labelsDesc, bool useMC) { - std::string selector = buildSelectors(dataBind, dataDesc, rofDesc, labelsDesc, useMC); + std::string selector = buildSelectors(dataBind, dataDesc, rofDesc, labelsDesc, useMC, 0); return framework::select(selector.c_str()); } @@ -134,29 +146,39 @@ std::vector buildOutputs(std::vector o std::array, NEvTypes> getData(framework::ProcessingContext& pc, std::string_view dataBind) { - return getInput(pc, dataBind); + std::array, 3> data; + for (size_t ievt = 0; ievt < NEvTypes; ++ievt) { + data[ievt] = getInput(pc, fmt::format("{}_{}", dataBind, ievt)); + } + + return data; } gsl::span getData(framework::ProcessingContext& pc, std::string_view dataBind, EventType eventType) { auto idx = static_cast(eventType); - return getData(pc, dataBind)[idx]; + return getInput(pc, fmt::format("{}_{}", dataBind.data(), idx)); } std::array, NEvTypes> getRofs(framework::ProcessingContext& pc, std::string_view dataBind) { - return getInput(pc, getROFBind(dataBind)); + std::array, 3> data; + for (size_t ievt = 0; ievt < NEvTypes; ++ievt) { + data[ievt] = getInput(pc, fmt::format("{}_{}", getROFBind(dataBind).data(), ievt)); + } + + return data; } gsl::span getRofs(framework::ProcessingContext& pc, std::string_view dataBind, EventType eventType) { auto idx = static_cast(eventType); - return getRofs(pc, dataBind)[idx]; + return getInput(pc, fmt::format("{}_{}", getROFBind(dataBind).data(), idx)); } -std::unique_ptr> getLabels(framework::ProcessingContext& pc, std::string_view dataBind) +std::unique_ptr> getLabels(framework::ProcessingContext& pc, std::string_view dataBind, EventType eventType) { - return pc.inputs().get*>(getLabelsBind(dataBind).data()); + return pc.inputs().get*>(fmt::format("{}_{}", getLabelsBind(dataBind).data(), static_cast(eventType))); } } // namespace specs diff --git a/Detectors/MUON/MID/Workflow/src/DecodedDataAggregatorSpec.cxx b/Detectors/MUON/MID/Workflow/src/DecodedDataAggregatorSpec.cxx index 192b4c52be9cc..54b1a458fec0f 100644 --- a/Detectors/MUON/MID/Workflow/src/DecodedDataAggregatorSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/DecodedDataAggregatorSpec.cxx @@ -58,7 +58,7 @@ class DecodedDataAggregatorDeviceDPL mAggregator.process(data, inROFRecords); mTimerAlgo += std::chrono::high_resolution_clock::now() - tAlgoStart; - for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < 3; ++subSpec) { + for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) { EventType evtType = static_cast(subSpec); pc.outputs().snapshot(of::Output{o2::header::gDataOriginMID, "DATA", subSpec}, mAggregator.getData(evtType)); pc.outputs().snapshot(of::Output{o2::header::gDataOriginMID, "DATAROF", subSpec}, mAggregator.getROFRecords(evtType)); @@ -79,7 +79,7 @@ framework::DataProcessorSpec getDecodedDataAggregatorSpec() { std::vector inputSpecs{of::InputSpec{"mid_decoded", header::gDataOriginMID, "DECODED"}, of::InputSpec{"mid_decoded_rof", header::gDataOriginMID, "DECODEDROF"}}; std::vector outputSpecs; - for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < 3; ++subSpec) { + for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) { outputSpecs.emplace_back(of::OutputSpec{header::gDataOriginMID, "DATA", subSpec}); outputSpecs.emplace_back(of::OutputSpec{header::gDataOriginMID, "DATAROF", subSpec}); } diff --git a/Detectors/MUON/MID/Workflow/src/EntropyEncoderSpec.cxx b/Detectors/MUON/MID/Workflow/src/EntropyEncoderSpec.cxx index d75fe3fa6fbf2..f8d9922db25fa 100644 --- a/Detectors/MUON/MID/Workflow/src/EntropyEncoderSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/EntropyEncoderSpec.cxx @@ -56,26 +56,15 @@ void EntropyEncoderSpec::run(ProcessingContext& pc) mTimer.Start(false); mCTFCoder.updateTimeDependentParams(pc, true); CTFHelper::TFData tfData; - std::vector - filter = { - {"check", ConcreteDataTypeMatcher{header::gDataOriginMID, "DATA"}, Lifetime::Timeframe}, - {"check", ConcreteDataTypeMatcher{header::gDataOriginMID, "DATAROF"}, Lifetime::Timeframe}, - }; size_t insize = 0; - for (auto const& inputRef : InputRecordWalker(pc.inputs(), filter)) { - auto const* dh = framework::DataRefUtils::getHeader(inputRef); - if (dh->subSpecification >= NEvTypes) { - throw std::runtime_error(fmt::format("SubSpecification={} does not match EvenTypes for {}", dh->subSpecification, dh->dataDescription.as())); - } - if (DataRefUtils::match(inputRef, "cols")) { - tfData.colData[dh->subSpecification] = pc.inputs().get>(inputRef); - insize += tfData.colData[dh->subSpecification].size() * sizeof(o2::mid::ColumnData); - } - if (DataRefUtils::match(inputRef, "rofs")) { - tfData.rofData[dh->subSpecification] = pc.inputs().get>(inputRef); - insize += tfData.rofData[dh->subSpecification].size() * sizeof(o2::mid::ROFRecord); - } + for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) { + tfData.colData[subSpec] = pc.inputs().get>(fmt::format("cols_{}", subSpec)); + insize += tfData.colData[subSpec].size() * sizeof(o2::mid::ColumnData); + + tfData.rofData[subSpec] = pc.inputs().get>(fmt::format("rofs_{}", subSpec)); + insize += tfData.rofData[subSpec].size() * sizeof(o2::mid::ROFRecord); } + if (mSelIR) { mCTFCoder.setSelectedIRFrames(pc.inputs().get>("selIRFrames")); } @@ -102,8 +91,10 @@ void EntropyEncoderSpec::endOfStream(EndOfStreamContext& ec) DataProcessorSpec getEntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt) { std::vector inputs; - inputs.emplace_back("rofs", ConcreteDataTypeMatcher(header::gDataOriginMID, "DATAROF"), Lifetime::Timeframe); - inputs.emplace_back("cols", ConcreteDataTypeMatcher(header::gDataOriginMID, "DATA"), Lifetime::Timeframe); + for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) { + inputs.emplace_back(fmt::format("cols_{}", subSpec), header::gDataOriginMID, "DATA", subSpec, Lifetime::Timeframe); + inputs.emplace_back(fmt::format("rofs_{}", subSpec), header::gDataOriginMID, "DATAROF", subSpec, Lifetime::Timeframe); + } if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") { inputs.emplace_back("ctfdict", header::gDataOriginMID, "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("MID/Calib/CTFDictionaryTree")); diff --git a/Detectors/MUON/MID/Workflow/src/FilteringBCSpec.cxx b/Detectors/MUON/MID/Workflow/src/FilteringBCSpec.cxx index 2aadabeab0bed..2d697f4bc5b1d 100644 --- a/Detectors/MUON/MID/Workflow/src/FilteringBCSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/FilteringBCSpec.cxx @@ -100,7 +100,7 @@ class FilteringBCDeviceDPL of::DataProcessorSpec getFilteringBCSpec(bool useMC, std::string_view inDesc) { - auto inputSpecs = specs::buildInputSpecs("mid_filter_BC_in", inDesc, useMC); + auto inputSpecs = specs::buildStandardInputSpecs("mid_filter_BC_in", inDesc, useMC); auto ggRequest = std::make_shared(false, // orbitResetTime false, // GRPECS=true true, // GRPLHCIF diff --git a/Detectors/MUON/MID/Workflow/src/FilteringSpec.cxx b/Detectors/MUON/MID/Workflow/src/FilteringSpec.cxx index 0ccbbe237b9a5..6ef3424e1ec29 100644 --- a/Detectors/MUON/MID/Workflow/src/FilteringSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/FilteringSpec.cxx @@ -143,7 +143,7 @@ class FilteringDeviceDPL of::DataProcessorSpec getFilteringSpec(bool useMC, std::string_view inDesc, std::string_view outDesc) { - auto inputSpecs = specs::buildInputSpecs("mid_filter_in", inDesc, useMC); + auto inputSpecs = specs::buildStandardInputSpecs("mid_filter_in", inDesc, useMC); inputSpecs.emplace_back("mid_bad_channels", header::gDataOriginMID, "BAD_CHANNELS", 0, of::Lifetime::Condition, of::ccdbParamSpec("MID/Calib/BadChannels")); inputSpecs.emplace_back("mid_rejectlist", header::gDataOriginMID, "REJECTLIST", 0, of::Lifetime::Condition, of::ccdbParamSpec("MID/Calib/RejectList")); diff --git a/Detectors/MUON/MID/Workflow/src/MaskMakerSpec.cxx b/Detectors/MUON/MID/Workflow/src/MaskMakerSpec.cxx index 28d2ff953ea23..d4b63de7e5d3f 100644 --- a/Detectors/MUON/MID/Workflow/src/MaskMakerSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/MaskMakerSpec.cxx @@ -69,28 +69,10 @@ class MaskMakerDeviceDPL gsl::span calibData, fetData; gsl::span calibDataRof, fetDataRof; - std::vector filter = { - {"check_data", of::ConcreteDataTypeMatcher{header::gDataOriginMID, "DATA"}, of::Lifetime::Timeframe}, - {"check_rof", of::ConcreteDataTypeMatcher{header::gDataOriginMID, "DATAROF"}, of::Lifetime::Timeframe}, - }; - - for (auto const& inputRef : of::InputRecordWalker(pc.inputs(), filter)) { - auto const* dh = framework::DataRefUtils::getHeader(inputRef); - if (of::DataRefUtils::match(inputRef, "mid_data")) { - if (dh->subSpecification == 1) { - calibData = pc.inputs().get>(inputRef); - } else if (dh->subSpecification == 2) { - fetData = pc.inputs().get>(inputRef); - } - } - if (of::DataRefUtils::match(inputRef, "mid_data_rof")) { - if (dh->subSpecification == 1) { - calibDataRof = pc.inputs().get>(inputRef); - } else if (dh->subSpecification == 2) { - fetDataRof = pc.inputs().get>(inputRef); - } - } - } + calibData = pc.inputs().get>("mid_data_1"); + calibDataRof = pc.inputs().get>("mid_data_rof_1"); + fetData = pc.inputs().get>("mid_data_2"); + fetDataRof = pc.inputs().get>("mid_data_rof_2"); unsigned long nEvents = calibDataRof.size(); if (nEvents == 0) { @@ -145,8 +127,10 @@ class MaskMakerDeviceDPL framework::DataProcessorSpec getMaskMakerSpec(const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks) { std::vector inputSpecs; - inputSpecs.emplace_back("mid_data", of::ConcreteDataTypeMatcher(header::gDataOriginMID, "DATA"), of::Lifetime::Timeframe); - inputSpecs.emplace_back("mid_data_rof", of::ConcreteDataTypeMatcher(header::gDataOriginMID, "DATAROF"), of::Lifetime::Timeframe); + for (o2::header::DataHeader::SubSpecificationType subSpec = 1; subSpec < NEvTypes; ++subSpec) { + inputSpecs.emplace_back(fmt::format("mid_data_{}", subSpec), o2::header::gDataOriginMID, "DATA", subSpec, of::Lifetime::Timeframe); + inputSpecs.emplace_back(fmt::format("mid_data_rof_{}", subSpec), o2::header::gDataOriginMID, "DATAROF", subSpec, of::Lifetime::Timeframe); + } std::vector outputSpecs{ of::OutputSpec{header::gDataOriginMID, "MASKS", 1}, diff --git a/Detectors/MUON/MID/Workflow/src/TimingSpec.cxx b/Detectors/MUON/MID/Workflow/src/TimingSpec.cxx index 05f669ab76ba4..5a397de9a045f 100644 --- a/Detectors/MUON/MID/Workflow/src/TimingSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/TimingSpec.cxx @@ -71,7 +71,7 @@ class TimingDeviceDPL of::DataProcessorSpec getTimingSpec(int localToBC, std::string_view inRofDesc) { - auto inputSpecs = specs::buildInputSpecs("mid_timing_in", "", inRofDesc, "", false); + auto inputSpecs = specs::buildInputSpecs("mid_timing_in", "", inRofDesc); auto outputSpecs = specs::buildOutputSpecs("mid_timing_out", "TDATAROF"); return of::DataProcessorSpec{ diff --git a/Detectors/MUON/MID/Workflow/src/ZeroSuppressionSpec.cxx b/Detectors/MUON/MID/Workflow/src/ZeroSuppressionSpec.cxx index 5d89eee81c629..7298ad9e506e3 100644 --- a/Detectors/MUON/MID/Workflow/src/ZeroSuppressionSpec.cxx +++ b/Detectors/MUON/MID/Workflow/src/ZeroSuppressionSpec.cxx @@ -103,7 +103,7 @@ class ZeroSuppressionDeviceDPL framework::DataProcessorSpec getZeroSuppressionSpec(bool useMC, std::string_view dataDesc) { - auto inputSpecs = specs::buildInputSpecs("mid_zs_in", dataDesc, useMC); + auto inputSpecs = specs::buildStandardInputSpecs("mid_zs_in", dataDesc, useMC); auto outputSpecs = specs::buildStandardOutputSpecs("mid_zs_out", "DATA", useMC); return of::DataProcessorSpec{