Skip to content

Commit feccd0f

Browse files
sawenzelalcaliva
authored andcommitted
Use new AggregatedRunInfo to fetch SOR/EOX/FirstOrbit (#1767)
Instead of manually calculating FirstOrbit and other run parameters we use the new dedicated O2 function for that purpose. (cherry picked from commit f2a05a2)
1 parent 889a797 commit feccd0f

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

MC/bin/o2dpg_sim_workflow_anchored.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,34 @@ def retrieve_CCDBObject_asJSON(ccdbreader, path, timestamp, objtype_external = N
9999
return json.loads(jsonTString.Data())
100100

101101

102+
def retrieve_Aggregated_RunInfos(run_number):
103+
"""
104+
Retrieves start of run (sor), end of run (eor) and other global parameters by using the
105+
AggregatedRunInfo object in O2 which takes care of building the information consistently.
106+
This is the prefered way over older function "retrieve_params_fromGRPECS_and_OrbitReset".
107+
"""
108+
109+
runInfo = o2.parameters.AggregatedRunInfo.buildAggregatedRunInfo(o2.ccdb.BasicCCDBManager.instance(), run_number)
110+
detList = o2.detectors.DetID.getNames(runInfo.grpECS.getDetsReadOut())
111+
assert (run_number == runInfo.runNumber)
112+
assert (run_number == runInfo.grpECS.getRun())
113+
return {"SOR" : runInfo.sor,
114+
"EOR" : runInfo.eor,
115+
"FirstOrbit" : runInfo.orbitSOR,
116+
"LastOrbit" : runInfo.orbitEOR,
117+
"OrbitsPerTF" : int(runInfo.orbitsPerTF),
118+
"detList" : detList}
119+
120+
102121
def retrieve_params_fromGRPECS_and_OrbitReset(ccdbreader, run_number, run_start, run_end):
103122
"""
104123
Retrieves start of run (sor), end of run (eor) and other global parameters from the GRPECS object,
105124
given a run number. We first need to find the right object
106125
... but this is possible with a browsing request and meta_data filtering.
107126
Optionally, we can pass an existing result from RCT/Info/RunInformation to check for consistency.
108127
In this case and when information is inconsistent we will take time from RCT and issue a warning message.
128+
129+
NOTE: This function is deprecated; It should no longer be used and might be removed soon.
109130
"""
110131

111132
# make a simple HTTP request on the "browsing" endpoint
@@ -300,15 +321,11 @@ def main():
300321

301322
# make a CCDB accessor object
302323
ccdbreader = CCDBAccessor(args.ccdb_url)
303-
# fetch the EOR/SOR
304-
run_duration = ccdbreader.get_run_duration(args.run_number)
305-
run_start = run_duration.first
306-
run_end = run_duration.second
307-
308-
GLOparams = retrieve_params_fromGRPECS_and_OrbitReset(ccdbreader, args.run_number, run_start, run_end)
309-
if not GLOparams:
310-
print ("ERROR: Could not retrieve information from GRPECS")
311-
sys.exit(1)
324+
325+
# fetch the EOR/SOR/FirstOrbit and other important run parameters
326+
GLOparams = retrieve_Aggregated_RunInfos(args.run_number)
327+
run_start = GLOparams["SOR"]
328+
run_end = GLOparams["EOR"]
312329

313330
# determine timestamp, and production offset for the final MC job to run
314331
timestamp, prod_offset = determine_timestamp(run_start, run_end, [args.split_id - 1, args.prod_split], args.cycle, args.tf, GLOparams["OrbitsPerTF"])

0 commit comments

Comments
 (0)