Skip to content

Commit

Permalink
Improve AggregatedRunInfo: prioritize use of CTP/Calib/FirstRunOrbit
Browse files Browse the repository at this point in the history
use CTP/Calib/FirstRunOrbit when available. Otherwise fallback to
RunInformation.
  • Loading branch information
sawenzel committed Oct 10, 2024
1 parent 015c38a commit 546fd62
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions DataFormats/Parameters/src/AggregatedRunInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,38 @@ o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo(o2::

// adjust to the nearest TF edge to satisfy condition (orbitSOR % nOrbitsPerTF == 0)
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF;
orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF;

// fetch SOR directly from CTP entry on CCDB
bool oldFatalState = ccdb.getFatalWhenNull();
ccdb.setFatalWhenNull(false);
auto ctp_first_run_orbit = ccdb.getForTimeStamp<std::vector<int64_t>>("CTP/Calib/FirstRunOrbit", run_mid_timestamp);
ccdb.setFatalWhenNull(oldFatalState);
if (ctp_first_run_orbit && ctp_first_run_orbit->size() >= 3) {
// if we have CTP first run orbit available, we should use it

// int64_t creation_time = (*ctp_first_run_orbit)[0];
int64_t ctp_run_number = (*ctp_first_run_orbit)[1];
int64_t ctp_orbitSOR = (*ctp_first_run_orbit)[2];

if (ctp_run_number != runnumber) {
LOG(error) << "AggregatedRunInfo: run number inconsistency found (asked: " << runnumber << " vs CTP found: " << ctp_run_number << ")";
}

// overwrite orbitSOR
if (ctp_orbitSOR != orbitSOR) {
LOG(warn) << "The calculated orbitSOR " << orbitSOR << " differs from CTP orbitSOR " << ctp_orbitSOR;
// reasons for this is different unit of time storage in RunInformation (ms) and orbitReset (us), etc.

// so we need to adjust the SOR timings to be consistent
auto sor_new = (int64_t)((tsOrbitReset + ctp_orbitSOR * o2::constants::lhc::LHCOrbitMUS) / 1000.);
if (sor_new != sor) {
LOG(warn) << "Adjusting SOR from " << sor << " to " << sor_new;
sor = sor_new;
}
}
orbitSOR = ctp_orbitSOR;
}

return AggregatedRunInfo{runnumber, sor, eor, nOrbitsPerTF, tsOrbitReset, orbitSOR, orbitEOR};
}

0 comments on commit 546fd62

Please sign in to comment.