|
26 | 26 | import json |
27 | 27 | import itertools |
28 | 28 | import time |
| 29 | +import requests, re |
29 | 30 |
|
30 | 31 | sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils')) |
31 | 32 |
|
@@ -186,13 +187,34 @@ def addWhenActive(detID, needslist, appendstring): |
186 | 187 | if isActive(detID): |
187 | 188 | needslist.append(appendstring) |
188 | 189 |
|
| 190 | + |
| 191 | +def retrieve_sor(run_number): |
| 192 | + """ |
| 193 | + retrieves start of run (sor) |
| 194 | + from the RCT/RunInformation table with a simple http request |
| 195 | + in case of problems, 0 will be returned |
| 196 | + """ |
| 197 | + url="http://alice-ccdb.cern.ch/browse/RCT/RunInformation/"+str(run_number) |
| 198 | + ansobject=requests.get(url) |
| 199 | + tokens=ansobject.text.split("\n") |
| 200 | + |
| 201 | + SOR=0 |
| 202 | + # extract SOR by pattern matching |
| 203 | + for t in tokens: |
| 204 | + match_object=re.match("\s*(SOR\s*=\s*)([0-9]*)\s*", t) |
| 205 | + if match_object != None: |
| 206 | + SOR=match_object[2] |
| 207 | + break |
| 208 | + |
| 209 | + return SOR |
| 210 | + |
| 211 | + |
189 | 212 | # ----------- START WORKFLOW CONSTRUCTION ----------------------------- |
190 | 213 |
|
191 | | -# set the time |
| 214 | +# set the time to start of run (if no timestamp specified) |
192 | 215 | if args.timestamp==-1: |
193 | | - # 1000 to convert seconds into milliseconds. |
194 | | - args.timestamp = int(time.time() * 1000) |
195 | | - print("Setting timestamp to ", args.timestamp) |
| 216 | + args.timestamp = retrieve_sor(args.run) |
| 217 | + assert (args.timestamp != 0) |
196 | 218 |
|
197 | 219 | NTIMEFRAMES=int(args.tf) |
198 | 220 | NWORKERS=args.j |
@@ -310,8 +332,10 @@ def getDPL_global_options(bigshm=False): |
310 | 332 |
|
311 | 333 | BKGtask=createTask(name='bkgsim', lab=["GEANT"], needs=[BKG_CONFIG_task['name']], cpu=NWORKERS ) |
312 | 334 | BKGtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + SIMENGINE + ' -j ' + str(NWORKERS) + ' -n ' + str(NBKGEVENTS) \ |
313 | | - + ' -g ' + str(GENBKG) + ' ' + str(MODULES) + ' -o bkg ' + str(INIBKG) \ |
314 | | - + ' --field ' + str(BFIELD) + ' ' + str(CONFKEYBKG) + ' --timestamp ' + str(args.timestamp) |
| 335 | + + ' -g ' + str(GENBKG) + ' ' + str(MODULES) + ' -o bkg ' + str(INIBKG) \ |
| 336 | + + ' --field ' + str(BFIELD) + ' ' + str(CONFKEYBKG) \ |
| 337 | + + ('',' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + str(args.run) |
| 338 | + |
315 | 339 | if not "all" in activeDetectors: |
316 | 340 | BKGtask['cmd'] += ' --readoutDetectors ' + " ".join(activeDetectors) |
317 | 341 |
|
@@ -491,7 +515,8 @@ def getDPL_global_options(bigshm=False): |
491 | 515 | SGNtask['cmd']='${O2_ROOT}/bin/o2-sim -e ' + str(SIMENGINE) + ' ' + str(MODULES) + ' -n ' + str(NSIGEVENTS) + ' --seed ' + str(TFSEED) \ |
492 | 516 | + ' --field ' + str(BFIELD) + ' -j ' + str(NWORKERS) + ' -g ' + str(GENERATOR) \ |
493 | 517 | + ' ' + str(TRIGGER) + ' ' + str(CONFKEY) + ' ' + str(INIFILE) \ |
494 | | - + ' -o ' + signalprefix + ' ' + embeddinto + ' --timestamp ' + str(args.timestamp) |
| 518 | + + ' -o ' + signalprefix + ' ' + embeddinto \ |
| 519 | + + (' --timestamp ' + str(args.timestamp))[args.timestamp!=-1] + ' --run ' + args.run |
495 | 520 | if not "all" in activeDetectors: |
496 | 521 | SGNtask['cmd'] += ' --readoutDetectors ' + " ".join(activeDetectors) |
497 | 522 | workflow['stages'].append(SGNtask) |
@@ -547,10 +572,12 @@ def getDPL_global_options(bigshm=False): |
547 | 572 | startOrbit = (tf-1 + int(args.production_offset)*NTIMEFRAMES)*orbitsPerTF |
548 | 573 | globalTFConfigValues = { "HBFUtils.orbitFirstSampled" : args.first_orbit + startOrbit, |
549 | 574 | "HBFUtils.nHBFPerTF" : orbitsPerTF, |
550 | | - "HBFUtils.startTime" : args.timestamp, |
551 | 575 | "HBFUtils.orbitFirst" : args.first_orbit, |
552 | 576 | "HBFUtils.runNumber" : args.run } |
553 | | - |
| 577 | + # we set the timesamp here only if specified explicitely (otherwise it will come from |
| 578 | + # the simulation GRP and digitization) |
| 579 | + if (args.timestamp != -1): |
| 580 | + globalTFConfigValues["HBFUtils.startTime"] = args.timestamp |
554 | 581 |
|
555 | 582 | def putConfigValues(localCF = {}): |
556 | 583 | """ |
|
0 commit comments