Skip to content

Commit 2c37d27

Browse files
authored
TRD fix for empty frames (#6511)
* trd reading empty frames * safter sending of blank frames * ensure empty frame is indeed empty * flexible data description * move TRD eventrecord class to reconstruction dir * remove classdef for EventRecord, and local variables for emptry frames data
1 parent 4e57361 commit 2c37d27

9 files changed

Lines changed: 181 additions & 115 deletions

File tree

DataFormats/Detectors/TRD/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ o2_add_library(DataFormatsTRD
1818
src/CompressedDigit.cxx
1919
src/CTF.cxx
2020
src/Digit.cxx
21-
src/EventRecord.cxx
2221
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat O2::SimulationDataFormat)
2322

2423
o2_target_root_dictionary(DataFormatsTRD

Detectors/TRD/reconstruction/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ o2_add_library(TRDReconstruction
1919
src/CompressedRawReader.cxx
2020
src/DataReaderTask.cxx
2121
src/CruCompressorTask.cxx
22+
src/EventRecord.cxx
2223
PUBLIC_LINK_LIBRARIES O2::TRDBase
2324
O2::DataFormatsTRD
2425
O2::DataFormatsTPC

Detectors/TRD/reconstruction/include/TRDReconstruction/CruRawReader.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "DataFormatsTRD/Constants.h"
3434
#include "TRDBase/Digit.h"
3535
#include "CommonDataFormat/InteractionRecord.h"
36-
#include "DataFormatsTRD/EventRecord.h"
36+
#include "TRDReconstruction/EventRecord.h"
3737

3838
namespace o2::trd
3939
{
@@ -92,6 +92,8 @@ class CruRawReader
9292
std::vector<Digit>& getDigits(InteractionRecord& ir) { return mEventRecords.getDigits(ir); };
9393
// std::vector<o2::trd::TriggerRecord> getIR() { return mEventTriggers; }
9494
void getParsedObjects(std::vector<Tracklet64>& tracklets, std::vector<Digit>& cdigits, std::vector<TriggerRecord>& triggers);
95+
void getParsedObjectsandClear(std::vector<Tracklet64>& tracklets, std::vector<Digit>& digits, std::vector<TriggerRecord>& triggers);
96+
void buildDPLOutputs(o2::framework::ProcessingContext& outputs);
9597
int getDigitsFound() { return mTotalDigitsFound; }
9698
int getTrackletsFound() { return mTotalTrackletsFound; }
9799
int sumTrackletsFound() { return mEventRecords.sumTracklets(); }

Detectors/TRD/reconstruction/include/TRDReconstruction/DataReaderTask.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DataReaderTask : public Task
3838
DataReaderTask(bool compresseddata, bool byteswap, bool verbose, bool headerverbose, bool dataverbose) : mCompressedData(compresseddata), mByteSwap(byteswap), mVerbose(verbose), mHeaderVerbose(headerverbose), mDataVerbose(dataverbose) {}
3939
~DataReaderTask() override = default;
4040
void init(InitContext& ic) final;
41-
void sendData(ProcessingContext& pc);
41+
void sendData(ProcessingContext& pc, bool blankframe = false);
4242
void run(ProcessingContext& pc) final;
4343

4444
private:
@@ -47,16 +47,15 @@ class DataReaderTask : public Task
4747
// in both cases we pull the data from the vectors build message and pass on.
4848
// they will internally produce a vector of digits and a vector tracklets and associated indexing.
4949
// TODO templatise this and 2 versions of datareadertask, instantiated with the relevant parser.
50-
std::vector<Tracklet64> mTracklets;
51-
std::vector<Digit> mDigits;
52-
std::vector<o2::trd::TriggerRecord> mTriggers;
53-
// std::vector<o2::trd::FlpStats> mStats;
5450

5551
bool mVerbose{false}; // verbos output general debuggign and info output.
5652
bool mDataVerbose{false}; // verbose output of data unpacking
5753
bool mHeaderVerbose{false}; // verbose output of headers
5854
bool mCompressedData{false}; // are we dealing with the compressed data from the flp (send via option)
5955
bool mByteSwap{true}; // whether we are to byteswap the incoming data, mc is not byteswapped, raw data is (too be changed in cru at some point)
56+
// o2::header::DataDescription mDataDesc; // Data description of the incoming data
57+
std::string mDataDesc;
58+
o2::header::DataDescription mUserDataDescription = o2::header::gDataDescriptionInvalid; // alternative user-provided description to pick
6059
};
6160

6261
} // namespace o2::trd

DataFormats/Detectors/TRD/include/DataFormatsTRD/EventRecord.h renamed to Detectors/TRD/reconstruction/include/TRDReconstruction/EventRecord.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
#include "FairLogger.h"
2020
#include "DataFormatsTRD/Tracklet64.h"
2121

22+
namespace o2::framework
23+
{
24+
class ProcessingContext;
25+
}
26+
2227
namespace o2::trd
2328
{
2429
class Digit;
@@ -74,8 +79,6 @@ class EventRecord
7479
BCData mBCData; /// orbit and Bunch crossing data of the physics trigger
7580
std::vector<Digit> mDigits{}; /// digit data, for this event
7681
std::vector<Tracklet64> mTracklets{}; /// tracklet data, for this event
77-
78-
ClassDefNV(EventRecord, 1);
7982
};
8083

8184
class EventStorage
@@ -92,7 +95,10 @@ class EventStorage
9295
void addTracklet(InteractionRecord& ir, Tracklet64& tracklet);
9396
void addTracklets(InteractionRecord& ir, std::vector<Tracklet64>& tracklets);
9497
void addTracklets(InteractionRecord& ir, std::vector<Tracklet64>::iterator& start, std::vector<Tracklet64>::iterator& end);
95-
void unpackDataForSending(std::vector<TriggerRecord>& triggers, std::vector<Tracklet64>& tracklets, std::vector<Digit>& digits);
98+
void unpackData(std::vector<TriggerRecord>& triggers, std::vector<Tracklet64>& tracklets, std::vector<Digit>& digits);
99+
void sendData(o2::framework::ProcessingContext& pc);
100+
//this could replace by keeing a running total on addition TODO
101+
void sumTrackletsDigitsTriggers(uint64_t& tracklets, uint64_t& digits, uint64_t& triggers);
96102
int sumTracklets();
97103
int sumDigits();
98104
std::vector<Tracklet64>& getTracklets(InteractionRecord& ir);
@@ -104,7 +110,6 @@ class EventStorage
104110
//these 2 are hacks to be able to send bak a blank vector if interaction record is not found.
105111
std::vector<Tracklet64> mDummyTracklets;
106112
std::vector<Digit> mDummyDigits;
107-
ClassDefNV(EventStorage, 1);
108113
};
109114
std::ostream& operator<<(std::ostream& stream, const EventRecord& trg);
110115

Detectors/TRD/reconstruction/src/CruRawReader.cxx

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#include "TRDReconstruction/TrackletsParser.h"
2424
#include "DataFormatsTRD/Constants.h"
2525

26+
#include "Framework/ControlService.h"
27+
#include "Framework/ConfigParamRegistry.h"
28+
#include "Framework/RawDeviceService.h"
29+
#include "Framework/DeviceSpec.h"
30+
#include "Framework/DataSpecUtils.h"
31+
#include "Framework/Output.h"
32+
#include "Framework/InputRecordWalker.h"
33+
2634
#include <cstring>
2735
#include <string>
2836
#include <vector>
@@ -414,32 +422,21 @@ void CruRawReader::getParsedObjects(std::vector<Tracklet64>& tracklets, std::vec
414422
{
415423
int digitcountsum = 0;
416424
int trackletcountsum = 0;
417-
mEventRecords.unpackDataForSending(triggers, tracklets, digits);
418-
/*for(auto eventrecord: mEventRecords)//loop over triggers incase they have already been done.
419-
{
420-
int digitcount=0;
421-
int trackletcount=0;
422-
int start,end;
423-
LOG(info) << __func__ << " " << tracklets.size() << " "
424-
<< cdigits.size()<< " trackletv size:"<< mEventRecords.getTracklets(ir.getBCData());
425-
for(auto trackletv: mEventStores.getTracklets(ir.getBCData())){
426-
//loop through the vector of ranges
427-
start=trackletv.getFirstEntry();
428-
end= start+trackletv.getEntries();
429-
LOG(info) << "insert tracklets from " << start<< " " << end;
430-
tracklets.insert(tracklets.end(),mEventTracklets.begin()+start, mEventTracklets.begin()+end);
431-
trackletcount+=trackletv.getEntries();
432-
}
433-
for(auto digitv: mEventStores.getDigits(ir.getBCData())){
434-
start=digitv.getFirstEntry();
435-
end= start+digitv.getEntries();
436-
LOG(info) << "insert digits from " << start<< " " << end;
437-
cdigits.insert(cdigits.end(),mEventCompressedDigits.begin()+start , mEventCompressedDigits.begin()+end);
438-
digitcount+=digitv.getEntries();
439-
}
440-
triggers.emplace_back(ir.getBCData(),digitcountsum,digitcount,trackletcountsum,trackletcount);
441-
digitcountsum+=digitcount;
442-
trackletcountsum+=trackletcount;
443-
}*/
425+
mEventRecords.unpackData(triggers, tracklets, digits);
426+
}
427+
428+
void CruRawReader::getParsedObjectsandClear(std::vector<Tracklet64>& tracklets, std::vector<Digit>& digits, std::vector<TriggerRecord>& triggers)
429+
{
430+
getParsedObjects(tracklets, digits, triggers);
431+
clearall();
444432
}
433+
434+
//write the output data directly to the given DataAllocator from the datareader task.
435+
void CruRawReader::buildDPLOutputs(o2::framework::ProcessingContext& pc)
436+
{
437+
mEventRecords.sendData(pc);
438+
// pc.outputs().snapshot(Output{o2::header::gDataOriginTRD,"STATS",0,Lifetime::Timerframe},mStats);
439+
clearall(); // having now written the messages clear for next.
440+
}
441+
445442
} // namespace o2::trd

Detectors/TRD/reconstruction/src/DataReader.cxx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
2929
{
3030

3131
std::vector<o2::framework::ConfigParamSpec> options{
32-
{"trd-datareader-inputspec", VariantType::String, "RAWDATA", {"TRD raw data spec"}},
3332
{"trd-datareader-output-desc", VariantType::String, "TRDTLT", {"Output specs description string"}},
3433
{"trd-datareader-verbose", VariantType::Bool, false, {"Enable verbose epn data reading"}},
3534
{"trd-datareader-headerverbose", VariantType::Bool, false, {"Enable verbose header info"}},
3635
{"trd-datareader-dataverbose", VariantType::Bool, false, {"Enable verbose data info"}},
3736
{"trd-datareader-compresseddata", VariantType::Bool, false, {"The incoming data is compressed or not"}},
37+
{"ignore-dist-stf", VariantType::Bool, false, {"do not subscribe to FLP/DISTSUBTIMEFRAME/0 message (no lost TF recovery)"}},
3838
{"trd-datareader-enablebyteswapdata", VariantType::Bool, false, {"byteswap the incoming data, raw data needs it and simulation does not."}}};
3939

4040
o2::raw::HBFUtilsInitializer::addConfigOption(options);
@@ -55,44 +55,39 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
5555
// o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
5656
// o2::conf::ConfigurableParam::writeINI("o2trdrawreader-workflow_configuration.ini");
5757

58-
auto inputspec = cfgc.options().get<std::string>("trd-datareader-inputspec");
5958
//auto outputspec = cfgc.options().get<std::string>("trd-datareader-outputspec");
6059
auto verbose = cfgc.options().get<bool>("trd-datareader-verbose");
6160
auto byteswap = cfgc.options().get<bool>("trd-datareader-enablebyteswapdata");
6261
auto compresseddata = cfgc.options().get<bool>("trd-datareader-compresseddata");
6362
auto headerverbose = cfgc.options().get<bool>("trd-datareader-headerverbose");
6463
auto dataverbose = cfgc.options().get<bool>("trd-datareader-dataverbose");
65-
64+
auto askSTFDist = !cfgc.options().get<bool>("ignore-dist-stf");
6665
std::vector<OutputSpec> outputs;
6766
outputs.emplace_back("TRD", "TRACKLETS", 0, Lifetime::Timeframe);
6867
outputs.emplace_back("TRD", "DIGITS", 0, Lifetime::Timeframe);
6968
outputs.emplace_back("TRD", "TRKTRGRD", 0, Lifetime::Timeframe);
7069
//outputs.emplace_back("TRD", "FLPSTAT", 0, Lifetime::Timeframe);
71-
LOG(info) << "input spec is:" << inputspec;
7270
LOG(info) << "enablebyteswap :" << byteswap;
7371
AlgorithmSpec algoSpec;
7472
algoSpec = AlgorithmSpec{adaptFromTask<o2::trd::DataReaderTask>(compresseddata, byteswap, verbose, headerverbose, dataverbose)};
7573

7674
WorkflowSpec workflow;
7775

78-
/*
79-
* This is originally replicated from TOF
80-
We define at run time the number of devices to be attached
81-
to the workflow and the input matching string of the device.
82-
This is is done with a configuration string like the following
83-
one, where the input matching for each device is provide in
84-
comma-separated strings. For instance
85-
*/
86-
87-
// std::stringstream ssconfig(inputspec);
8876
std::string iconfig;
8977
std::string inputDescription;
9078
int idevice = 0;
91-
// LOG(info) << "expected incoming data definition : " << inputspec;
92-
// this is probably never going to be used but would to nice to know hence here.
79+
auto orig = o2::header::gDataOriginTRD;
80+
auto inputs = o2::framework::select(std::string("x:TRD/RAWDATA").c_str());
81+
for (auto& inp : inputs) {
82+
// take care of case where our data is not in the time frame
83+
inp.lifetime = Lifetime::Optional;
84+
}
85+
if (askSTFDist) {
86+
inputs.emplace_back("stdDist", "FLP", "DISTSUBTIMEFRAME", 0, Lifetime::Timeframe);
87+
}
9388
workflow.emplace_back(DataProcessorSpec{
9489
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()),
90+
inputs, //select(std::string("x:TRD/" + inputspec).c_str()),
9691
outputs,
9792
algoSpec,
9893
Options{}});

0 commit comments

Comments
 (0)