3 from __future__
import print_function
4 from builtins
import range
10 Reader for DQM IO and DQM root files. 14 DQMIO_TYPES = [
"Ints",
"Floats",
"Strings",
15 "TH1Fs",
"TH1Ss",
"TH1Ds",
16 "TH2Fs",
"TH2Ss",
"TH2Ds",
17 "TH3Fs",
"TProfiles",
"TProfile2Ds",
"kNIndicies"]
22 ioTest = self._root_file.Get(
"Indices")
29 if (self.
type ==
"DQMIO"):
35 indices = self._root_file.Get(
"Indices")
37 for y
in range(indices.GetEntries()):
41 if indices.Type == 1000:
46 object_type = self.DQMIO_TYPES[indices.Type]
47 t_tree = self._root_file.Get(object_type)
49 for i
in range(indices.FirstIndex, indices.LastIndex + 1):
52 fullname =
str(t_tree.FullName)
53 yield (fullname, t_tree.Value, )
56 xml_re = re.compile(
r"^<(.+)>(.+)=(.*)<\/\1>$")
57 def parse_directory(di):
58 directory = self._root_file.GetDirectory(di)
59 for key
in directory.GetListOfKeys():
61 rtype = key.GetClassName()
62 fullpath =
"%s/%s" % (di, entry)
64 if (rtype ==
"TDirectoryFile"):
65 for k, v
in parse_directory(fullpath):
68 obj = self._root_file.Get(fullpath)
70 yield (fullpath, obj, )
73 m = xml_re.search(entry)
79 fp =
"%s/%s" % (di, name)
85 path_fix = re.compile(
r"^\/Run \d+")
86 for fullname, obj
in parse_directory(
""):
87 f = fullname.replace(
"/DQMData",
"")
88 f = f.replace(
"/Run summary",
"")
89 f = path_fix.sub(
r"", f)
96 self._root_file.Close()
98 if __name__ ==
'__main__':
101 parser = argparse.ArgumentParser()
102 parser.add_argument(
"-i",
"--input", help =
"Input DQMIO ROOT file")
103 args = parser.parse_args()
107 for (fn, v)
in reader.read_objects():
108 if (hasattr(v,
"ClassName")):
109 print(fn, v.ClassName())
S & print(S &os, JobReport::InputFile const &f)
def read_objects_dqmio(self)
def __init__(self, input_filename)
def read_objects_root(self)