Skip to content

Commit c97ca70

Browse files
committed
trd reading empty frames
1 parent 1ff1460 commit c97ca70

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

Detectors/TRD/reconstruction/src/DataReader.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
3535
{"trd-datareader-headerverbose", VariantType::Bool, false, {"Enable verbose header info"}},
3636
{"trd-datareader-dataverbose", VariantType::Bool, false, {"Enable verbose data info"}},
3737
{"trd-datareader-compresseddata", VariantType::Bool, false, {"The incoming data is compressed or not"}},
38+
{"ignore-dist-stf", VariantType::Bool, false, {"do not subscribe to FLP/DISTSUBTIMEFRAME/0 message (no lost TF recovery)"}},
3839
{"trd-datareader-enablebyteswapdata", VariantType::Bool, false, {"byteswap the incoming data, raw data needs it and simulation does not."}}};
3940

4041
o2::raw::HBFUtilsInitializer::addConfigOption(options);
@@ -62,7 +63,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
6263
auto compresseddata = cfgc.options().get<bool>("trd-datareader-compresseddata");
6364
auto headerverbose = cfgc.options().get<bool>("trd-datareader-headerverbose");
6465
auto dataverbose = cfgc.options().get<bool>("trd-datareader-dataverbose");
65-
66+
auto askSTFDist = !cfgc.options().get<bool>("ignore-dist-stf");
6667
std::vector<OutputSpec> outputs;
6768
outputs.emplace_back("TRD", "TRACKLETS", 0, Lifetime::Timeframe);
6869
outputs.emplace_back("TRD", "DIGITS", 0, Lifetime::Timeframe);
@@ -90,9 +91,14 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
9091
int idevice = 0;
9192
// LOG(info) << "expected incoming data definition : " << inputspec;
9293
// this is probably never going to be used but would to nice to know hence here.
94+
auto orig = o2::header::gDataOriginTRD;
95+
std::vector<InputSpec> inputs{{"stf", ConcreteDataTypeMatcher{orig, "RAWDATA"}, Lifetime::Optional}};
96+
if (askSTFDist) {
97+
inputs.emplace_back("stdDist", "FLP", "DISTSUBTIMEFRAME", 0, Lifetime::Timeframe);
98+
}
9399
workflow.emplace_back(DataProcessorSpec{
94100
std::string("trd-datareader"), // left as a string cast incase we append stuff to the string
95-
select(std::string("x:TRD/" + inputspec).c_str()),
101+
inputs, //select(std::string("x:TRD/" + inputspec).c_str()),
96102
outputs,
97103
algoSpec,
98104
Options{}});

Detectors/TRD/reconstruction/src/DataReaderTask.cxx

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
#include "TRDReconstruction/DataReaderTask.h"
1717
#include "TRDReconstruction/CruRawReader.h"
18+
1819
#include "Framework/ControlService.h"
1920
#include "Framework/ConfigParamRegistry.h"
2021
#include "Framework/RawDeviceService.h"
2122
#include "Framework/DeviceSpec.h"
2223
#include "Framework/DataSpecUtils.h"
24+
#include "Framework/InputRecordWalker.h"
25+
2326
#include "DataFormatsTRD/Constants.h"
27+
2428
#include <fairmq/FairMQDevice.h>
2529

2630
//using namespace o2::framework;
@@ -62,28 +66,45 @@ void DataReaderTask::run(ProcessingContext& pc)
6266
auto outputRoutes = pc.services().get<o2::framework::RawDeviceService>().spec().outputs;
6367
auto fairMQChannel = outputRoutes.at(0).channel;
6468
int inputcount = 0;
69+
std::vector<InputSpec> dummy{InputSpec{"filter", ConcreteDataTypeMatcher{"FLP", "DISTSUBTIMEFRAME"}, Lifetime::Timeframe}};
70+
// if we see requested data type input with 0xDEADBEEF subspec and 0 payload this means that the "delayed message"
71+
// // mechanism created it in absence of real data from upstream. Processor should send empty output to not block the workflow
72+
73+
for (const auto& ref : InputRecordWalker(pc.inputs(), dummy)) {
74+
const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
75+
if (dh->payloadSize == 16) {
76+
LOGP(WARNING, "Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF",
77+
dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, dh->payloadSize);
78+
sendData(pc); //send the empty tf data.
79+
return;
80+
}
81+
LOG(info) << " matched DEADBEEF";
82+
}
83+
//TODO combine the previous and subsequent loops.
84+
int inputcounts = 0;
6585
/* loop over inputs routes */
6686
for (auto iit = pc.inputs().begin(), iend = pc.inputs().end(); iit != iend; ++iit) {
87+
LOG(info) << " looping over inputs " << inputcounts;
88+
inputcounts++;
6789
if (!iit.isValid()) {
6890
continue;
6991
}
7092
/* loop over input parts */
93+
int inputpartscount = 0;
7194
for (auto const& ref : iit) {
72-
95+
LOG(info) << " looping over parts " << inputpartscount;
96+
if (mVerbose) {
97+
const auto dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
98+
LOGP(info, "Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF",
99+
dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, dh->payloadSize);
100+
}
73101
const auto* headerIn = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
74102
auto payloadIn = ref.payload;
75103
auto payloadInSize = headerIn->payloadSize;
76104
if (!mCompressedData) { //we have raw data coming in from flp
77105
if (mVerbose) {
78-
LOG(info) << " parsing non compressed data in the data reader task";
106+
LOG(info) << " parsing non compressed data in the data reader task with a payload of " << payloadInSize << " payload size";
79107
}
80-
81-
int a = 1;
82-
int d = 1;
83-
// while(d==1){
84-
// a=sin(rand());
85-
// }
86-
87108
mReader.setDataBuffer(payloadIn);
88109
mReader.setDataBufferSize(payloadInSize);
89110
mReader.configure(mByteSwap, mVerbose, mHeaderVerbose, mDataVerbose);

0 commit comments

Comments
 (0)