11Update beamspot ntuple for cool for runs that are in the calib loop or have exited in the last 24 hours
14print (
'Updating COOL ntuple ...')
21from InDetBeamSpotExample
import COOLUtils
27 oracle = cx_Oracle.connect(dsn=
"ATLAS_COOLPROD",user=
"ATLAS_COOL_READER_U",password=
"XXXXXXX")
31 sys.exit(
'ERROR: Unable to connect to ATLAS_COOLPROD database')
36 d = cur.execute(
"SELECT RUN FROM ATLAS_COOL_GLOBAL.NEMOP_RUN WHERE ACTIVE=1 AND RUNTYPE LIKE 'Physics' AND STATE=2")
37 runsCalib = [r[0]
for r
in sorted(d)]
40 sys.exit(
'Unable to retrieve runs in calibration loop')
43curtime = int(time.time())
44limit = curtime - 24*3600+30*60
49 d = cur.execute(
"SELECT RUN FROM ATLAS_COOL_GLOBAL.NEMOP_RUN WHERE ACTIVE=1 AND RUNTYPE LIKE 'Physics' AND STATE=4 AND UTIME>%s" % limit)
50 runsExited = [r[0]
for r
in sorted(d)]
53 sys.exit(
'Unable to retrieve runs exiting calibration loop')
56if not bool(runsExited + runsCalib):
57 sys.exit(
'No runs in calib loop or exited recently so nothing to do')
59run =
min(
set(runsExited + runsCalib))
64name =
'/tmp/b7eamspot.' + str(os.getpid()) +
'.root'
66stat = os.system(
"beamspotnt.py -q -f %s --status '' --ru %s -s BeamSpotNt merge ~atlidbs/nt/cool/beamspotnt-COOL-Current.root" % (name, runMax) )
68 sys.exit(
"Unable to copy previous COOL ntuple")
71tag = COOLUtils.resolveCurrentBeamSpotFolder()
74stat = os.system(
"beamspotnt.py -q -f %s --status '%s' --rl %s --fillCOOL -s BeamSpotCOOL merge %s" % (name, status, run, tag) )
76 sys.exit(
"Unable to merge new runs into COOL ntuple")
79stat = os.system(
"mv ~atlidbs/nt/cool/beamspotnt-COOL-Current.root ~atlidbs/nt/cool/beamspotnt-COOL-Current.previous.root")
81 sys.exit(
"ERROR: Unable to copy COOL ntuple to final location")
83stat = os.system(
"mv %s ~atlidbs/nt/cool/beamspotnt-COOL-Current.root" % name)
85 sys.exit(
"ERROR: Unable to copy COOL ntuple to final location")