8 Reader for DQM IO and DQM root files. 12 DQMIO_TYPES = [
"Ints",
"Floats",
"Strings",
13 "TH1Fs",
"TH1Ss",
"TH1Ds",
14 "TH2Fs",
"TH2Ss",
"TH2Ds",
15 "TH3Fs",
"TProfiles",
"TProfile2Ds",
"kNIndicies"]
20 ioTest = self._root_file.Get(
"Indices")
27 if (self.
type ==
"DQMIO"):
33 indices = self._root_file.Get(
"Indices")
35 for y
in xrange(indices.GetEntries()):
39 if indices.Type == 1000:
44 object_type = self.DQMIO_TYPES[indices.Type]
45 t_tree = self._root_file.Get(object_type)
47 for i
in xrange(indices.FirstIndex, indices.LastIndex + 1):
50 fullname =
str(t_tree.FullName)
51 yield (fullname, t_tree.Value, )
54 xml_re = re.compile(
r"^<(.+)>(.+)=(.+)<\/\1>$")
55 def parse_directory(di):
56 directory = self._root_file.GetDirectory(di)
57 for key
in directory.GetListOfKeys():
59 rtype = key.GetClassName()
60 fullpath =
"%s/%s" % (di, entry)
62 if (rtype ==
"TDirectoryFile"):
63 for k, v
in parse_directory(fullpath):
66 obj = self._root_file.Get(fullpath)
68 yield (fullpath, obj, )
71 m = xml_re.search(entry)
77 fp =
"%s/%s" % (di, name)
83 path_fix = re.compile(
r"^\/Run \d+")
84 for fullname, obj
in parse_directory(
""):
85 f = fullname.replace(
"/DQMData",
"")
86 f = f.replace(
"/Run summary",
"")
87 f = path_fix.sub(
r"", f)
94 self._root_file.Close()
96 if __name__ ==
'__main__':
99 parser = argparse.ArgumentParser()
100 parser.add_argument(
"-i",
"--input", help =
"Input DQMIO ROOT file")
101 args = parser.parse_args()
105 for (fn, v)
in reader.read_objects():
106 if (hasattr(v,
"ClassName")):
107 print fn, v.ClassName()
def read_objects_dqmio(self)
def __init__(self, input_filename)
def read_objects_root(self)