Skip to content

Commit fe4df2a

Browse files
matthiasrichterktf
authored andcommitted
Cleaning up use of DataHeader
- always use DataRefUtils to extract DataHeader properties - cleanup usage of DataHeader and Stack within DPL processors - removing obsolete headers One thing to come is to use the orbit information from DPL TimeInfo and replace code using the firstTFOrbit member of one of the DataHeaders.
1 parent 5f96b83 commit fe4df2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+85
-95
lines changed

DataFormats/Detectors/GlobalTracking/src/RecoContainer.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#include "ReconstructionDataFormats/VtxTrackRef.h"
2929
#include "ReconstructionDataFormats/TrackCosmics.h"
3030
#include "DataFormatsITSMFT/TrkClusRef.h"
31+
// FIXME: ideally, the data formats definition should be independent of the framework
32+
// collectData is using the input of ProcessingContext to extract the first valid
33+
// header and the TF orbit from it
34+
#include "Framework/ProcessingContext.h"
35+
#include "Framework/DataRefUtils.h"
3136

3237
using namespace o2::globaltracking;
3338
using namespace o2::framework;
@@ -337,7 +342,7 @@ void RecoContainer::collectData(ProcessingContext& pc, const DataRequest& reques
337342
{
338343
auto& reqMap = requests.requestMap;
339344

340-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getFirstValid(true).header);
345+
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true));
341346
startIR = {0, dh->firstTForbit};
342347

343348
auto req = reqMap.find("trackITS");

Detectors/GlobalTrackingWorkflow/src/TOFMatcherSpec.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "DetectorsBase/Propagator.h"
2020
#include "DetectorsCommonDataFormats/NameConf.h"
2121
#include "DataFormatsParameters/GRPObject.h"
22-
#include "Headers/DataHeader.h"
2322
#include "CommonDataFormat/InteractionRecord.h"
2423
#include "DataFormatsGlobalTracking/RecoContainer.h"
2524
#include "Framework/Task.h"

Detectors/GlobalTrackingWorkflow/src/TPCITSMatchingSpec.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "DataFormatsTPC/Constants.h"
1919
#include "Framework/DataProcessorSpec.h"
2020
#include "Framework/Task.h"
21+
#include "Framework/DataRefUtils.h"
2122
#include <string>
2223
#include "TStopwatch.h"
2324
#include "Framework/ConfigParamRegistry.h"
@@ -131,7 +132,7 @@ void TPCITSMatchingDPL::init(InitContext& ic)
131132

132133
void TPCITSMatchingDPL::run(ProcessingContext& pc)
133134
{
134-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getFirstValid(true).header);
135+
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true));
135136
LOG(INFO) << " startOrbit: " << dh->firstTForbit;
136137
mTimer.Start(false);
137138
RecoContainer recoData;

Detectors/HMPID/workflow/src/DataDecoderSpec2.cxx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "Framework/WorkflowSpec.h"
4040
#include "Framework/Logger.h"
4141
#include "Framework/InputRecordWalker.h"
42+
#include "Framework/DataRefUtils.h"
4243

4344
#include "Headers/RAWDataHeader.h"
4445
#include "DetectorsRaw/RDHUtils.h"
@@ -251,21 +252,17 @@ void DataDecoderTask2::decodeRawFile(framework::ProcessingContext& pc)
251252

252253
for (auto&& input : pc.inputs()) {
253254
if (input.spec->binding == "file") {
254-
const header::DataHeader* header = o2::header::get<header::DataHeader*>(input.header);
255-
if (!header) {
256-
return;
257-
}
258255

259256
auto const* raw = input.payload;
260-
size_t payloadSize = header->payloadSize;
257+
size_t payloadSize = DataRefUtils::getPayloadSize(input);
261258

262259
LOG(INFO) << " payloadSize=" << payloadSize;
263260
if (payloadSize == 0) {
264261
return;
265262
}
266263

267264
uint32_t* theBuffer = (uint32_t*)input.payload;
268-
int pagesize = header->payloadSize;
265+
int pagesize = payloadSize;
269266
mDeco->setUpStream(theBuffer, pagesize);
270267
try {
271268
if (mFastAlgorithm) {

Detectors/MUON/MCH/Calibration/src/pedestal-decoding-workflow.cxx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "Framework/WorkflowSpec.h"
3535
#include "Framework/ConfigParamSpec.h"
3636
#include "Framework/CompletionPolicyHelpers.h"
37+
#include "Framework/DataRefUtils.h"
3738

3839
#include "Headers/RDHAny.h"
3940
#include "MCHRawDecoder/PageDecoder.h"
@@ -283,13 +284,10 @@ class PedestalsTask
283284
// the decodeReadout() function processes the messages generated by o2-mch-cru-page-reader-workflow
284285
void decodeReadout(const o2::framework::DataRef& input)
285286
{
286-
const auto* header = o2::header::get<header::DataHeader*>(input.header);
287-
if (!header) {
288-
return;
289-
}
290-
287+
// Note: DPL allows to extract the san directly from the input
288+
// this would make this function obsolete
291289
auto const* raw = input.payload;
292-
size_t payloadSize = header->payloadSize;
290+
size_t payloadSize = DataRefUtils::getPayloadSize(input);
293291

294292
gsl::span<const std::byte> buffer(reinterpret_cast<const std::byte*>(raw), payloadSize);
295293
decodeBuffer(buffer);

Detectors/MUON/MCH/Workflow/src/DataDecoderSpec.cxx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "Framework/Output.h"
3434
#include "Framework/Task.h"
3535
#include "Framework/WorkflowSpec.h"
36+
#include "Framework/DataRefUtils.h"
3637

3738
#include "Headers/RAWDataHeader.h"
3839
#include "DetectorsRaw/RDHUtils.h"
@@ -98,7 +99,7 @@ class DataDecoderTask
9899
// the decodeTF() function processes the messages generated by the (sub)TimeFrame builder
99100
void decodeTF(framework::ProcessingContext& pc)
100101
{
101-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getFirstValid(true).header);
102+
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true));
102103
mFirstTForbit = dh->firstTForbit;
103104

104105
if (!mDecoder->getFirstOrbitInRun()) {
@@ -137,14 +138,9 @@ class DataDecoderTask
137138
return;
138139
}
139140

140-
const auto* header = o2::header::get<header::DataHeader*>(input.header);
141-
if (!header) {
142-
return;
143-
}
144-
145141
auto const* raw = input.payload;
146142
// size of payload
147-
size_t payloadSize = header->payloadSize;
143+
size_t payloadSize = DataRefUtils::getPayloadSize(input);
148144

149145
if (mDebug) {
150146
std::cout << nFrame << " payloadSize=" << payloadSize << std::endl;

Detectors/TOF/workflow/src/CompressedDecodingTask.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "Framework/Logger.h"
2828
#include "DetectorsRaw/RDHUtils.h"
2929
#include "Framework/InputRecordWalker.h"
30+
#include "Framework/DataRefUtils.h"
3031

3132
using namespace o2::framework;
3233

@@ -128,7 +129,7 @@ void CompressedDecodingTask::run(ProcessingContext& pc)
128129
mTimer.Start(false);
129130

130131
//RS set the 1st orbit of the TF from the O2 header, relying on rdhHandler is not good (in fact, the RDH might be eliminated in the derived data)
131-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getFirstValid(true).header);
132+
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true));
132133
mInitOrbit = dh->firstTForbit;
133134
if (!mConetMode) {
134135
mDecoder.setFirstIR({0, mInitOrbit});

Detectors/TOF/workflow/src/TOFClusterizerSpec.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "TOFCalibration/CalibTOFapi.h"
3030
#include "TStopwatch.h"
3131
#include "Framework/ConfigParamRegistry.h"
32+
#include "Framework/DataRefUtils.h"
3233

3334
#include <memory> // for make_shared, make_unique, unique_ptr
3435
#include <vector>
@@ -78,7 +79,7 @@ class TOFDPLClustererTask
7879
auto digits = pc.inputs().get<gsl::span<o2::tof::Digit>>("tofdigits");
7980
auto row = pc.inputs().get<gsl::span<o2::tof::ReadoutWindowData>>("readoutwin");
8081

81-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getFirstValid(true).header);
82+
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true));
8283
mClusterer.setFirstOrbit(dh->firstTForbit);
8384

8485
auto labelvector = std::make_shared<std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>>();

Detectors/TPC/workflow/src/ZSSpec.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "Framework/ControlService.h"
1818
#include "Framework/ConfigParamRegistry.h"
1919
#include "Framework/InputRecordWalker.h"
20+
#include "Framework/DataRefUtils.h"
2021
#include "DataFormatsTPC/TPCSectorHeader.h"
2122
#include "DataFormatsTPC/ZeroSuppression.h"
2223
#include "DataFormatsTPC/Helpers.h"
@@ -99,7 +100,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
99100

100101
const auto& inputs = getWorkflowTPCInput(pc, 0, false, false, tpcSectorMask, true);
101102
sizes.resize(NSectors * NEndpoints);
102-
const auto* dh = o2::header::get<o2::header::DataHeader*>(pc.inputs().getFirstValid(true).header);
103+
const auto* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(pc.inputs().getFirstValid(true));
103104
o2::InteractionRecord ir{0, dh->firstTForbit};
104105
o2::gpu::GPUReconstructionConvert::RunZSEncoder<o2::tpc::Digit, DigitArray>(inputs->inputDigits, &zsoutput, sizes.data(), nullptr, &ir, _GPUParam, true, verify, config.configReconstruction.tpc.zsThreshold);
105106
ZeroSuppressedContainer8kb* page = reinterpret_cast<ZeroSuppressedContainer8kb*>(zsoutput.get());

Framework/Core/include/Framework/InputRecord.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class InputRecord
234234
// the buffer to be deleted when it goes out of scope. The string is built
235235
// from the data and its lengh, null-termination is not necessary.
236236
// return std::string object
237-
auto header = header::get<const header::DataHeader*>(ref.header);
237+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
238238
assert(header);
239239
return std::string(ref.payload, header->payloadSize);
240240

@@ -253,7 +253,7 @@ class InputRecord
253253
// substitution for TableConsumer
254254
// For the moment this is dummy, as it requires proper support to
255255
// create the RDataSource from the arrow buffer.
256-
auto header = header::get<const header::DataHeader*>(ref.header);
256+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
257257
assert(header);
258258
auto data = reinterpret_cast<uint8_t const*>(ref.payload);
259259
return std::make_unique<TableConsumer>(data, header->payloadSize);
@@ -264,7 +264,7 @@ class InputRecord
264264
// We have to deserialize the ostringstream.
265265
// FIXME: check that the string is null terminated.
266266
// @return deserialized copy of payload
267-
auto header = header::get<const header::DataHeader*>(ref.header);
267+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
268268
assert(header);
269269
auto str = std::string(ref.payload, header->payloadSize);
270270
assert(header->payloadSize == sizeof(T));
@@ -279,7 +279,7 @@ class InputRecord
279279
// substitution for span of messageable objects
280280
// FIXME: there will be std::span in C++20
281281
static_assert(is_messageable<typename T::value_type>::value, "span can only be created for messageable types");
282-
auto header = header::get<const header::DataHeader*>(ref.header);
282+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
283283
assert(header);
284284
if (sizeof(typename T::value_type) > 1 && header->payloadSerializationMethod != o2::header::gSerializationMethodNone) {
285285
throw runtime_error("Inconsistent serialization method for extracting span");
@@ -297,7 +297,7 @@ class InputRecord
297297
} else if constexpr (is_container<T>::value) {
298298
// currently implemented only for vectors
299299
if constexpr (is_specialization<typename std::remove_const<T>::type, std::vector>::value) {
300-
auto header = o2::header::get<const DataHeader*>(ref.header);
300+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
301301
auto method = header->payloadSerializationMethod;
302302
if (method == o2::header::gSerializationMethodNone) {
303303
// TODO: construct a vector spectator
@@ -340,7 +340,7 @@ class InputRecord
340340
// unserialized objects
341341
using DataHeader = o2::header::DataHeader;
342342

343-
auto header = o2::header::get<const DataHeader*>(ref.header);
343+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
344344
auto method = header->payloadSerializationMethod;
345345
if (method != o2::header::gSerializationMethodNone) {
346346
// FIXME: we could in principle support serialized content here as well if we
@@ -357,7 +357,7 @@ class InputRecord
357357
using DataHeader = o2::header::DataHeader;
358358
using ValueT = typename std::remove_pointer<T>::type;
359359

360-
auto header = o2::header::get<const DataHeader*>(ref.header);
360+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
361361
auto method = header->payloadSerializationMethod;
362362
if (method == o2::header::gSerializationMethodNone) {
363363
if constexpr (is_messageable<ValueT>::value) {
@@ -402,7 +402,7 @@ class InputRecord
402402
// the operation depends on the transmitted serialization method
403403
using DataHeader = o2::header::DataHeader;
404404

405-
auto header = o2::header::get<const DataHeader*>(ref.header);
405+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
406406
auto method = header->payloadSerializationMethod;
407407
if (method == o2::header::gSerializationMethodNone) {
408408
// this code path is only selected if the type is non-messageable
@@ -425,7 +425,7 @@ class InputRecord
425425
T get_boost(char const* binding) const
426426
{
427427
DataRef ref = get<DataRef>(binding);
428-
auto header = header::get<const header::DataHeader*>(ref.header);
428+
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
429429
assert(header);
430430
auto str = std::string(ref.payload, header->payloadSize);
431431
auto desData = o2::utils::BoostDeserialize<T>(str);

0 commit comments

Comments
 (0)