3 from __future__
import print_function
5 import CoolConvUtilities.AtlCoolLib
as AtlCoolLib
6 from PyCool
import cool,coral
10 from MuonCalibDbOperations.MuonCalibResolveTag
import ResolveTag
11 from MuonCalibDbOperations.MuonCalibConvertTimeSlewing
import TimeSlewingApplied, NoTs2Ts, GasmonDriftTimeOffsetT0
13 sys.argv=[sys.argv[0],
'-b']
15 from ROOT
import TGraphErrors, TSpline3, gDirectory
21 if type(data)==coral.Blob:
22 blob=StringIO.StringIO()
23 for i
in range(data.size()):
24 blob.write(chr(data[i]))
25 unpacked=zlib.decompress(blob.getvalue())
29 return iov[0]*10000000 + iov[1]
34 db=AtlCoolLib.indirectOpen(db_string, readOnly=
True, debug=
True)
35 except Exception
as e:
36 print (
'Problem opening database',e)
40 cool_folder=db.getFolder(folder)
45 objs=cool_folder.browseObjects((run<<32), ((run+1)<<32), cool.ChannelSelection.all(), cool_tag)
47 objs=cool_folder.browseObjects(0, (999999<<32), cool.ChannelSelection.all(), cool_tag)
49 file_col=obj.payload()[
'file']
50 file_items=re.split(
'[A-Z,a-z]*', file_col)
53 if len(file_items)==2:
55 head_id =
int(file_items[1])
56 site = re.sub(
"[0-9]",
"", file_col)
62 ident=(obj.since()>>32, obj.until()>>32, site, head_id, ts)
63 if ident
not in counters:
66 for ident
in sorted(counters.keys(), key=iov_keygen):
67 print (
"[", ident[0],
",", ident[1],
"[", ident[2], ident[3], ident[4],
":" , counters[ident])
73 db=AtlCoolLib.indirectOpen(db_string, readOnly=
True, debug=
True)
74 except Exception
as e:
75 print (
'Problem opening database',e)
79 cool_folder=db.getFolder(folder)
87 myiov=(run_number<<32)
89 objs=cool_folder.browseObjects(myiov,myiov, cool.ChannelSelection.all(), cool_tag)
91 iov=(obj.since(), obj.until())
98 graphs[chamber]=TGraphErrors(n_points)
100 if up.stationNameString()==
'XXX':
101 print (
"Invalid station name in ", obj.payload()[
'file'])
103 nm=up.stationNameString() +
"_" +
str(up.stationPhi()) +
"_" +
str(up.stationEta())
106 for i
in range(0, n_points):
113 graphs[chamber].SetPoint(i, r, t)
114 graphs[chamber].SetPointError(i, 0, s)
115 splines[chamber]=TSpline3(
"sp_" + nm, graphs[chamber])
116 if gDirectory.IsWritable():
117 splines[chamber].Write(
"sp_" + nm)
118 graphs[chamber].Write(
"gr_" + nm)
120 return graphs, splines, iovs
126 db=AtlCoolLib.indirectOpen(db_string, readOnly=
True, debug=
True)
127 except Exception
as e:
128 print (
'Problem opening database',e)
132 cool_folder=db.getFolder(folder)
134 myiov=(run_number<<32)
138 objs=cool_folder.browseObjects(myiov,myiov, cool.ChannelSelection.all(), cool_tag)
143 ch_sp=sp1[0][2:].
split(
"_")
144 ch_id=(ch_sp[0],
int(ch_sp[1]),
int(ch_sp[2]))
147 t0_items=sp[1].
split(
",")
148 t0_values[ch_id] = []
150 for i
in range(0, ntubes):
151 t0=
float(t0_items[3*i+0])
153 t0+= GasmonDriftTimeOffsetT0
154 t0_values[ch_id].
append((t0,
int(t0_items[3*i+1]),
float(t0_items[3*i+2])))
160 dbSvc=cool.DatabaseSvcFactory.databaseService()
162 db=dbSvc.openDatabase(db_string)
163 except Exception
as e:
164 print (
'Problem opening database',e)
168 cool_folder=db.getFolder(folder)
169 for x
in cool_folder.listTags():