Skip to content

Commit 5362ede

Browse files
committed
Fix for unanchored Run 3 MC
1 parent 7607086 commit 5362ede

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

Common/TableProducer/eventSelection.cxx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,30 @@ struct BcSelectionTask {
266266

267267
if (run != lastRun) {
268268
lastRun = run;
269-
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
270-
// first bc of the first orbit
271-
bcSOR = runInfo.orbitSOR * nBCsPerOrbit;
272-
// duration of TF in bcs
273-
nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit;
274-
// SOR and EOR timestamps
275-
sorTimestamp = runInfo.sor;
276-
eorTimestamp = runInfo.eor;
269+
if (run >= 300000 && run < 500000) { // unanchored Run3 MC
270+
auto runDuration = ccdb->getRunDuration(run, true); // fatalise if timestamps are not found
271+
// SOR and EOR timestamps
272+
sorTimestamp = runDuration.first; // timestamp of the SOR/SOX/STF in ms
273+
eorTimestamp = runDuration.second; // timestamp of the EOR/EOX/ETF in ms
274+
auto ctp = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", sorTimestamp / 2 + eorTimestamp / 2);
275+
auto orbitResetMUS = (*ctp)[0];
276+
// first bc of the first orbit
277+
bcSOR = static_cast<int64_t>((sorTimestamp * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS) * nBCsPerOrbit;
278+
// duration of TF in bcs
279+
nBCsPerTF = 32; // hard-coded for Run3 MC (no info from ccdb at the moment)
280+
} else {
281+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
282+
// SOR and EOR timestamps
283+
sorTimestamp = runInfo.sor;
284+
eorTimestamp = runInfo.eor;
285+
// first bc of the first orbit
286+
bcSOR = runInfo.orbitSOR * nBCsPerOrbit;
287+
// duration of TF in bcs
288+
nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit;
289+
}
290+
277291
// timestamp of the middle of the run used to access run-wise CCDB entries
278-
int64_t ts = runInfo.sor / 2 + runInfo.eor / 2;
292+
int64_t ts = sorTimestamp / 2 + eorTimestamp / 2;
279293
// access ITSROF and TF border margins
280294
par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
281295
mITSROFrameStartBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin;

0 commit comments

Comments
 (0)