-
Notifications
You must be signed in to change notification settings - Fork 5
/
dcsonly_2015_noBfield.py
executable file
·73 lines (61 loc) · 3.31 KB
/
dcsonly_2015_noBfield.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python26
import os,string,sys,commands,time,json
from rrapi import RRApi, RRApiError
def toOrdinaryJSON(fromRR3, verbose=False):
result = {}
for block in fromRR3:
if len(block) == 3:
runNum = block['runNumber']
lumiStart = block['sectionFrom']
lumiEnd = block['sectionTo']
if verbose:
print " debug: Run ", runNum, " Lumi ", lumiStart, ", ", lumiEnd
result.setdefault(str(runNum), []).append([lumiStart, lumiEnd])
return result
def getRunList(minRun, save=False):
runlist = []
FULLADDRESS = "http://runregistry.web.cern.ch/runregistry/"
print "RunRegistry from: ",FULLADDRESS
try:
api = RRApi(FULLADDRESS, debug = True)
except RRApiError, e:
print e
#old filter (no det active)
# filter = {"runNumber": ">= %d" % minRun, "dataset": {"rowClass": "org.cern.cms.dqm.runregistry.user.model.RunDatasetRowGlobal", "filter": {"online": "= true", "datasetName": "like %Online%ALL", "runClassName" : "Collisions13", "run": {"rowClass": "org.cern.cms.dqm.runregistry.user.model.RunSummaryRowGlobal", "filter": {"pixelPresent": "= true", "trackerPresent": "= true"}}}}}
filter = {"runNumber": ">= %d" % minRun, "dataset": {"rowClass": "org.cern.cms.dqm.runregistry.user.model.RunDatasetRowGlobal", "filter": {"online": "= true", "datasetName": "like %Online%ALL", "runClassName" : "Collisions15", "run": {"rowClass": "org.cern.cms.dqm.runregistry.user.model.RunSummaryRowGlobal", "filter": {"pixelPresent": "= true", "trackerPresent": "= true"}}}}}
filter.setdefault("fpixReady", "isNull OR = true")
filter.setdefault("bpixReady", "isNull OR = true")
filter.setdefault("tecmReady", "isNull OR = true")
filter.setdefault("tecpReady", "isNull OR = true")
filter.setdefault("tobReady", "isNull OR = true")
filter.setdefault("tibtidReady", "isNull OR = true")
filter.setdefault("cmsActive", "isNull OR = true")
filter.setdefault("beam1Present","isNull OR = true")
filter.setdefault("beam2Present","isNull OR = true")
filter.setdefault("beam1Stable", "isNull OR = true")
filter.setdefault("beam2Stable", "isNull OR = true")
template = 'json'
table = 'datasetlumis'
print json.dumps(filter)
dcs_only = api.data(workspace = 'GLOBAL', table = table, template = template, columns = ['runNumber', 'sectionFrom', 'sectionTo'], filter = filter)
print json.dumps(dcs_only, indent=2)
print json.dumps(toOrdinaryJSON(dcs_only, verbose=False), indent=2)
print len(dcs_only)
if len(dcs_only)!=0:
if save:
lumiSummary = open('/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/DCSOnly/json_DCSONLY.txt', 'w')
# lumiSummary = open('./json_DCSONLY.txt', 'w')
json.dump(toOrdinaryJSON(dcs_only, verbose=False), lumiSummary, indent=2, sort_keys=True)
lumiSummary.close()
else:
print " Something wrong, the DCSONLY file has 0 length... skipping it"
# for line in run_data.split("\n"):
# #print line
# run=line.split(',')[0]
# if "RUN_NUMBER" in run or run == "":
# continue
# #print "RUN: " + run
# runlist.append(int(run))
# return runlist
# getRunList(190389, save=True)
getRunList(246908, save=True)