@@ -41,47 +41,43 @@ o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo(o2::
4141 std::map<std::string, std::string> metadata;
4242 metadata[" runNumber" ] = Form (" %d" , runnumber);
4343 auto grpecs = ccdb.getSpecific <o2::parameters::GRPECSObject>(" GLO/Config/GRPECS" , run_mid_timestamp, metadata);
44- auto nOrbitsPerTF = grpecs->getNHBFPerTF ();
45-
46- // calculate SOR orbit
47- int64_t orbitSOR = (sor * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
48- int64_t orbitEOR = (eor * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
49-
50- // adjust to the nearest TF edge to satisfy condition (orbitSOR % nOrbitsPerTF == 0)
51- orbitSOR = (orbitSOR / nOrbitsPerTF + 1 ) * nOrbitsPerTF; // +1 to choose the safe boundary ... towards run middle
52- orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF;
53-
54- // fetch SOR directly from CTP entry on CCDB
5544 bool oldFatalState = ccdb.getFatalWhenNull ();
5645 ccdb.setFatalWhenNull (false );
57- auto ctp_first_run_orbit = ccdb.getForTimeStamp <std::vector<int64_t >>(" CTP/Calib/FirstRunOrbit" , run_mid_timestamp);
46+ auto ctp_first_run_orbit = ccdb.getForTimeStamp <std::vector<Long64_t >>(" CTP/Calib/FirstRunOrbit" , run_mid_timestamp);
5847 ccdb.setFatalWhenNull (oldFatalState);
59- if (ctp_first_run_orbit && ctp_first_run_orbit->size () >= 3 ) {
60- // if we have CTP first run orbit available, we should use it
61-
62- // int64_t creation_time = (*ctp_first_run_orbit)[0];
63- int64_t ctp_run_number = (*ctp_first_run_orbit)[1 ];
64- int64_t ctp_orbitSOR = (*ctp_first_run_orbit)[2 ];
48+ return buildAggregatedRunInfo (runnumber, sor, eor, tsOrbitReset, grpecs, ctp_first_run_orbit);
49+ }
6550
66- if (ctp_run_number == runnumber) {
67- // overwrite orbitSOR
51+ o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo (int runnumber, long sorMS, long eorMS, long orbitResetMUS, const o2::parameters::GRPECSObject* grpecs, const std::vector<Long64_t>* ctfFirstRunOrbitVec)
52+ {
53+ auto nOrbitsPerTF = grpecs->getNHBFPerTF ();
54+ // calculate SOR/EOR orbits
55+ int64_t orbitSOR = (sorMS * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS;
56+ int64_t orbitEOR = (eorMS * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS;
57+ // adjust to the nearest TF edge to satisfy condition (orbitSOR % nOrbitsPerTF == 0)
58+ orbitSOR = (orbitSOR / nOrbitsPerTF + 1 ) * nOrbitsPerTF; // +1 to choose the safe boundary ... towards run middle
59+ orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF;
60+ if (ctfFirstRunOrbitVec && ctfFirstRunOrbitVec->size () >= 3 ) { // if we have CTP first run orbit available, we should use it
61+ int64_t creation_timeIGNORED = (*ctfFirstRunOrbitVec)[0 ]; // do not use CTP start of run time!
62+ int64_t ctp_run_number = (*ctfFirstRunOrbitVec)[1 ];
63+ int64_t ctp_orbitSOR = (*ctfFirstRunOrbitVec)[2 ];
64+ if (creation_timeIGNORED == -1 && ctp_run_number == -1 && ctp_orbitSOR == -1 ) {
65+ LOGP (warn, " Default dummy CTP/Calib/FirstRunOrbit was provide, ignoring" );
66+ } else if (ctp_run_number == runnumber) { // overwrite orbitSOR
6867 if (ctp_orbitSOR != orbitSOR) {
69- LOG (warn) << " The calculated orbitSOR " << orbitSOR << " differs from CTP orbitSOR " << ctp_orbitSOR;
68+ LOGP (warn, " The calculated orbitSOR {} differs from CTP orbitSOR {} " , orbitSOR, ctp_orbitSOR) ;
7069 // reasons for this is different unit of time storage in RunInformation (ms) and orbitReset (us), etc.
71-
7270 // so we need to adjust the SOR timings to be consistent
73- auto sor_new = (int64_t )((tsOrbitReset + ctp_orbitSOR * o2::constants::lhc::LHCOrbitMUS) / 1000 .);
74- if (sor_new != sor ) {
75- LOG (warn) << " Adjusting SOR from " << sor << " to " << sor_new;
76- sor = sor_new;
71+ auto sor_new = (int64_t )((orbitResetMUS + ctp_orbitSOR * o2::constants::lhc::LHCOrbitMUS) / 1000 .);
72+ if (sor_new != sorMS ) {
73+ LOGP (warn, " Adjusting SOR from {} to {} " , sorMS, sor_new) ;
74+ sorMS = sor_new;
7775 }
7876 }
7977 orbitSOR = ctp_orbitSOR;
8078 } else {
81- LOG (error) << " AggregatedRunInfo: run number inconsistency found (asked: " << runnumber << " vs CTP found: " << ctp_run_number << " )" ;
82- LOG (error) << " ... not using CTP info" ;
79+ LOGP (error, " AggregatedRunInfo: run number inconsistency found (asked: {} vs CTP found: {}, ignoring" , runnumber, ctp_run_number);
8380 }
8481 }
85-
86- return AggregatedRunInfo{runnumber, sor, eor, nOrbitsPerTF, tsOrbitReset, orbitSOR, orbitEOR, grpecs};
82+ return AggregatedRunInfo{runnumber, sorMS, eorMS, nOrbitsPerTF, orbitResetMUS, orbitSOR, orbitEOR, grpecs};
8783}
0 commit comments