Skip to content

Commit 677eea7

Browse files
committed
raw-file-reader optionaly propagates HBFUtils.startTime + orbit increment as DPH.creation
1 parent 5f93654 commit 677eea7

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

Detectors/Raw/include/DetectorsRaw/RawFileReader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct ReaderInp {
4646
uint32_t errMap = 0xffffffff;
4747
uint32_t minTF = 0;
4848
uint32_t maxTF = 0xffffffff;
49-
uint32_t startTime = 0;
5049
bool partPerSP = true;
5150
bool cache = false;
5251
bool autodetectTF0 = false;

Detectors/Raw/src/RawFileReaderWorkflow.cxx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class RawReaderSpecs : public o2f::Task
6868
uint32_t mDelayUSec = 0; // Delay in microseconds between TFs
6969
uint32_t mMinTFID = 0; // 1st TF to extract
7070
uint32_t mMaxTFID = 0xffffffff; // last TF to extrct
71-
uint64_t mStartTimeMS = 0; // start time to inject to DPH
7271
size_t mLoopsDone = 0;
7372
size_t mSentSize = 0;
7473
size_t mSentMessages = 0;
@@ -144,6 +143,11 @@ void RawReaderSpecs::init(o2f::InitContext& ic)
144143
if (mMaxTFID >= mReader->getNTimeFrames()) {
145144
mMaxTFID = mReader->getNTimeFrames() ? mReader->getNTimeFrames() - 1 : 0;
146145
}
146+
const auto& hbfU = HBFUtils::Instance();
147+
if (!hbfU.startTime) {
148+
hbfU.setValue("HBFUtils.startTime", std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count()));
149+
LOG(warning) << "Run start time is not provided via HBFUtils.startTime, will use now() = " << hbfU.startTime << " ms.";
150+
}
147151
}
148152

149153
//___________________________________________________________
@@ -208,21 +212,22 @@ void RawReaderSpecs::run(o2f::ProcessingContext& ctx)
208212
return;
209213
}
210214
}
211-
uint64_t creationTime = mStartTimeMS ? 0UL : std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
212215

213216
if (tfID < mMinTFID) {
214217
tfID = mMinTFID;
215218
}
216219
mReader->setNextTFToRead(tfID);
217220
std::vector<RawFileReader::PartStat> partsSP;
218-
const auto& hbfU = HBFUtils::Instance();
219221

220222
// read next time frame
221223
LOG(info) << "Reading TF#" << mTFCounter << " (" << tfID << " at iteration " << mLoopsDone << ')';
222224
o2::header::Stack dummyStack{o2h::DataHeader{}, o2::framework::DataProcessingHeader{0}}; // dummy stack to just to get stack size
223225
auto hstackSize = dummyStack.size();
224226

225227
uint32_t firstOrbit = 0;
228+
uint64_t creationTime = 0;
229+
const auto& hbfU = HBFUtils::Instance();
230+
226231
for (int il = 0; il < nlinks; il++) {
227232
auto& link = mReader->getLink(il);
228233

@@ -265,9 +270,7 @@ void RawReaderSpecs::run(o2f::ProcessingContext& ctx)
265270
auto ir = o2::raw::RDHUtils::getHeartBeatIR(plMessage->GetData());
266271
auto tfid = hbfU.getTF(ir);
267272
firstOrbit = hdrTmpl.firstTForbit = hbfU.getIRTF(tfid).orbit; // will be picked for the following parts
268-
if (!creationTime) {
269-
creationTime = mStartTimeMS + std::ceil(firstOrbit * o2::constants::lhc::LHCOrbitMUS * 1e-3);
270-
}
273+
creationTime = hbfU.getTFTimeStamp({0, firstOrbit});
271274
}
272275
o2::header::Stack headerStack{hdrTmpl, o2::framework::DataProcessingHeader{mTFCounter, 1, creationTime}};
273276
memcpy(hdMessage->GetData(), headerStack.data(), headerStack.size());
@@ -307,8 +310,8 @@ void RawReaderSpecs::run(o2f::ProcessingContext& ctx)
307310
}
308311
mTimer[TimerTotal].Stop();
309312

310-
LOGF(info, "Sent payload of %zu bytes in %zu parts in %zu messages for TF %d | Timing (total/IO): %.3e / %.3e", tfSize, tfNParts,
311-
messagesPerRoute.size(), mTFCounter, mTimer[TimerTotal].CpuTime() - tTotStart, mTimer[TimerIO].CpuTime() - tIOStart);
313+
LOGP(info, "Sent payload of {} bytes in {} parts in {} messages for TF#{} firstTForbit={} timeStamp={} | Timing (total/IO): {} / {}", tfSize, tfNParts,
314+
messagesPerRoute.size(), mTFCounter, firstOrbit, creationTime, mTimer[TimerTotal].CpuTime() - tTotStart, mTimer[TimerIO].CpuTime() - tIOStart);
312315

313316
mSentSize += tfSize;
314317
mSentMessages += tfNParts;

Detectors/Raw/src/rawfile-reader-workflow.cxx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "RawFileReaderWorkflow.h"
1313
#include "DetectorsRaw/RawFileReader.h"
14+
#include "DetectorsCommonDataFormats/NameConf.h"
1415
#include "CommonUtils/ConfigurableParam.h"
1516
#include "Framework/Logger.h"
1617
#include <string>
@@ -37,8 +38,8 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
3738
options.push_back(ConfigParamSpec{"detect-tf0", VariantType::Bool, false, {"autodetect HBFUtils start Orbit/BC from 1st TF seen"}});
3839
options.push_back(ConfigParamSpec{"calculate-tf-start", VariantType::Bool, false, {"calculate TF start instead of using TType"}});
3940
options.push_back(ConfigParamSpec{"drop-tf", VariantType::String, "none", {"Drop each TFid%(1)==(2) of detector, e.g. ITS,2,4;TPC,4[,0];..."}});
40-
options.push_back(ConfigParamSpec{"start-time", VariantType::Int64, 0L, {"define TF creation time as start-time + firstTForbit*orbit_duration, ms, otherwise: current time"}});
4141
options.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"semicolon separated key=value strings"}});
42+
options.push_back(ConfigParamSpec{"hbfutils-config", VariantType::String, std::string(o2::base::NameConf::DIGITIZATIONCONFIGFILE), {"configKeyValues ini file for HBFUtils (used if exists)"}});
4243
// options for error-check suppression
4344

4445
for (int i = 0; i < RawFileReader::NErrorsDefined; i++) {
@@ -68,7 +69,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
6869
rinp.rawChannelConfig = configcontext.options().get<std::string>("raw-channel-config");
6970
rinp.delay_us = uint32_t(1e6 * configcontext.options().get<float>("delay")); // delay in microseconds
7071
rinp.dropTF = configcontext.options().get<std::string>("drop-tf");
71-
rinp.startTime = configcontext.options().get<int64_t>("start-time");
7272
rinp.errMap = 0;
7373
for (int i = RawFileReader::NErrorsDefined; i--;) {
7474
auto ei = RawFileReader::ErrTypes(i);
@@ -78,6 +78,9 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
7878
}
7979
}
8080
o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
81-
81+
auto hbfini = configcontext.options().get<std::string>("hbfutils-config");
82+
if (!hbfini.empty() && o2::utils::Str::pathExists(hbfini)) {
83+
o2::conf::ConfigurableParam::updateFromFile(hbfini, "HBFUtils", true); // update only those values which were not touched yet (provenance == kCODE)
84+
}
8285
return std::move(o2::raw::getRawFileReaderWorkflow(rinp));
8386
}

0 commit comments

Comments
 (0)