104def SaveResultAsJson( result, filename = 'atlrunquery.json'):
105
106
107
108
109 ignoreForNow = [
110
111
112 "lhc:beamenergy",
113 "olc:lumi:0",
114 "olc:beam1intensity",
115 "olc:beam2intensity",
116
117
118
119 "olc:bcidmask"
120 ]
121
122 runs = [r["runNr"] for r in result[DataKey("Run")]]
123 store = { runNr:{} for runNr in runs}
124
125 for datakey in result:
126 key = datakey.pickled()
127 if key in ignoreForNow:
128 print(
"Not storing in json file: ", key)
129 continue
130
131 for (runNr, x) in zip(runs, result[datakey]):
132 if isinstance(x, (DataEntry,DataEntryList)):
133 store[runNr][key] = x.json()
134 else:
135 store[runNr][key] = x
136
137 with open( '%s/atlrunquery.json' % QC.datapath, 'w' ) as pf:
138 try:
139 import json
140 json.dump(store, pf)
141 except Exception as e:
142 print ('ERROR: could not create json file with results: "%r"' % e)
143
144