3 from __future__
import print_function
9 Reader for DQM IO and DQM root files. 13 DQMIO_TYPES = [
"Ints",
"Floats",
"Strings",
14 "TH1Fs",
"TH1Ss",
"TH1Ds",
15 "TH2Fs",
"TH2Ss",
"TH2Ds",
16 "TH3Fs",
"TProfiles",
"TProfile2Ds",
"kNIndicies"]
21 ioTest = self._root_file.Get(
"Indices")
28 if (self.
type ==
"DQMIO"):
34 indices = self._root_file.Get(
"Indices")
36 for y
in xrange(indices.GetEntries()):
40 if indices.Type == 1000:
45 object_type = self.DQMIO_TYPES[indices.Type]
46 t_tree = self._root_file.Get(object_type)
48 for i
in xrange(indices.FirstIndex, indices.LastIndex + 1):
51 fullname =
str(t_tree.FullName)
52 yield (fullname, t_tree.Value, )
55 xml_re = re.compile(
r"^<(.+)>(.+)=(.+)<\/\1>$")
56 def parse_directory(di):
57 directory = self._root_file.GetDirectory(di)
58 for key
in directory.GetListOfKeys():
60 rtype = key.GetClassName()
61 fullpath =
"%s/%s" % (di, entry)
63 if (rtype ==
"TDirectoryFile"):
64 for k, v
in parse_directory(fullpath):
67 obj = self._root_file.Get(fullpath)
69 yield (fullpath, obj, )
72 m = xml_re.search(entry)
78 fp =
"%s/%s" % (di, name)
84 path_fix = re.compile(
r"^\/Run \d+")
85 for fullname, obj
in parse_directory(
""):
86 f = fullname.replace(
"/DQMData",
"")
87 f = f.replace(
"/Run summary",
"")
88 f = path_fix.sub(
r"", f)
95 self._root_file.Close()
97 if __name__ ==
'__main__':
100 parser = argparse.ArgumentParser()
101 parser.add_argument(
"-i",
"--input", help =
"Input DQMIO ROOT file")
102 args = parser.parse_args()
106 for (fn, v)
in reader.read_objects():
107 if (hasattr(v,
"ClassName")):
108 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)