7from collections
import namedtuple
9from DQUtils.db
import Databases, fetch_iovs
10from DQUtils.quick_retrieve
import browse_coracool
15os.environ[
'CLING_STANDARD_PCH'] =
'none'
16from PyCool
import cool
18folder_path =
"/SCT/DAQ/Configuration/Module"
20database = Databases.get_instance(
"COOLONL_SCT/COMP200")
21folder = database.getFolder(folder_path)
22since, until = 1221973544491128285, 1221995264779751560
27 Read the timestamps of all luminosity blocks between
28 the run-lumi IoV (since, until)
30 timestamps = fetch_iovs(
"COOLONL_TRIGGER/COMP200::/TRIGGER/LUMI/LBLB", since, until,
31 with_channel=
False, what=
"all")
32 return timestamps[0].StartTime, timestamps[-1].EndTime, timestamps
36 if "<coracool>" not in folder.description():
37 print(f
"{folder.fullPath()} is not a coracool folder")
40 variables = [
"group",
"id"]
42 record = namedtuple(
"coracool_record",
"since until channel elements")
43 element = namedtuple(
"element",
" ".join(variables))
48 cool.ChannelSelection(),
"", variables, record, element)
50 elapsed = time()-start
51 print(
"Took %.2f to browse_coracool" % elapsed)
55 bad = [x
for x
in objects
if any(el.group == -1
for el
in x.elements)]
61 record = namedtuple(
"coracool_record",
"since until channel elements")
62 element = namedtuple(
"element",
"group id")
74 before_objects =
set(id(x)
for x
in gc.get_objects())
77 try:
raise RuntimeError
78 except Exception:
pass
80 print(
"Objects alive before call:", len(gc.get_objects()))
84 cool.ChannelSelection(),
"", [
"group",
"id"],
87 except Exception
as e:
88 print(
"Caught exception ", e)
91 elapsed = time() - start
92 print(
"Took %.3f to browse folder" % elapsed)
94 assert objects
is not None,
'Null return from browse_coracool'
97 print(
"Result length =", len(objects))
98 print(
"Result index 0 length =", len(objects[0]))
99 print(
"Result index 0 =", objects[0])
103 print(
"Objects alive before cleanup:", len(gc.get_objects()))
107 print(
"Objects alive after:", len(gc.get_objects()))
109 after_objects = gc.get_objects()
111 new_objects =
set(id(x)
for x
in after_objects) - before_objects
114 new_objects = [x
for x
in after_objects
if id(x)
in new_objects
and x != before_objects
and x != new_objects]
116 assert new_objects == [],
'Lingering objects after garbage collection'
119if __name__ ==
"__main__":
void print(char *figname, TCanvas *c1)
PyObject * browse_coracool(IDatabasePtr cooldb, const string &folder, ValidityKey since, ValidityKey until, const ChannelSelection &cs=ChannelSelection::all(), const char *tag="", PyObject *to_fetch=NULL, PyObject *object_converter=NULL, PyObject *inner_object_converter=NULL, PyObject *iovkey_wrapper=NULL)
fetch_lb_timestamps(since, until)