Skip to content

Commit 4d30167

Browse files
sawenzelnoferini
authored andcommitted
Digitization: Fix timestamps for querying CCDB when using BasicCCDBManager
This was wrong, especially for anchoredMC productions where timeframes are sampled from the whole run.
1 parent 2e10a1f commit 4d30167

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ void customize(std::vector<o2::framework::DispatchPolicy>& policies)
228228
policies.push_back({"prompt-for-simreader", matcher, DispatchOp::WhenReady});
229229
}
230230

231+
void setTimingInfoInHeaders(o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph)
232+
{
233+
const auto& hbfu = o2::raw::HBFUtils::Instance();
234+
const auto offset = int64_t(hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit);
235+
const auto increment = int64_t(hbfu.nHBFPerTF);
236+
const auto startTime = hbfu.startTime;
237+
const auto orbitFirst = hbfu.orbitFirst;
238+
dh.firstTForbit = offset + increment * dh.tfCounter;
239+
dh.runNumber = hbfu.runNumber;
240+
dph.creation = startTime + (dh.firstTForbit - orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3;
241+
}
242+
231243
void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
232244
{
233245
// we customize the time information sent in DPL headers
@@ -239,17 +251,10 @@ void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
239251
// simple linear enumeration from already updated HBFUtils (set via config key values)
240252
service.set<o2::framework::CallbackService::Id::NewTimeslice>(
241253
[](o2::header::DataHeader& dh, o2::framework::DataProcessingHeader& dph) {
242-
const auto& hbfu = o2::raw::HBFUtils::Instance();
243-
const auto offset = int64_t(hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit);
244-
const auto increment = int64_t(hbfu.nHBFPerTF);
245-
const auto startTime = hbfu.startTime;
246-
const auto orbitFirst = hbfu.orbitFirst;
247-
dh.firstTForbit = offset + increment * dh.tfCounter;
248-
LOG(info) << "Setting firstTForbit to " << dh.firstTForbit;
249-
dh.runNumber = hbfu.runNumber;
250-
LOG(info) << "Setting runNumber to " << dh.runNumber;
251-
dph.creation = startTime + (dh.firstTForbit - orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3;
252-
LOG(info) << "Setting timeframe creation time to " << dph.creation;
254+
setTimingInfoInHeaders(dh, dph);
255+
LOG(info) << "Setting DPL-header firstTForbit to " << dh.firstTForbit;
256+
LOG(info) << "Setting DPL-header runNumber to " << dh.runNumber;
257+
LOG(info) << "Setting DPL-header timeframe creation time to " << dph.creation;
253258
});
254259
}} // end of struct
255260
);
@@ -486,7 +491,13 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
486491
// init on a high level, the time for the CCDB queries
487492
// we expect that digitizers do not play with the manager themselves
488493
// this will only be needed until digitizers take CCDB objects via DPL mechanism
489-
o2::ccdb::BasicCCDBManager::instance().setTimestamp(hbfu.startTime);
494+
495+
// fix the timestamp for CCDB manager in the same way as for DPL-CCDB-fetcher
496+
o2::header::DataHeader dh;
497+
o2::framework::DataProcessingHeader dph;
498+
setTimingInfoInHeaders(dh, dph);
499+
LOG(info) << "Setting timestamp of BasicCCDBManager to " << dph.creation;
500+
o2::ccdb::BasicCCDBManager::instance().setTimestamp(dph.creation);
490501
// activate caching
491502
o2::ccdb::BasicCCDBManager::instance().setCaching(true);
492503
// this is asking the manager to check validity only locally - no further query to server done

0 commit comments

Comments
 (0)