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 object_type = self.DQMIO_TYPES[indices.Type]
40 t_tree = self._root_file.Get(object_type)
42 for i
in xrange(indices.FirstIndex, indices.LastIndex + 1):
45 fullname =
str(t_tree.FullName)
46 yield (fullname, t_tree.Value, )
49 xml_re = re.compile(
r"^<(.+)>(.+)=(.+)<\/\1>$")
50 def parse_directory(di):
51 directory = self._root_file.GetDirectory(di)
52 for key
in directory.GetListOfKeys():
54 rtype = key.GetClassName()
55 fullpath =
"%s/%s" % (di, entry)
57 if (rtype ==
"TDirectoryFile"):
58 for k, v
in parse_directory(fullpath):
61 obj = self._root_file.Get(fullpath)
63 yield (fullpath, obj, )
66 m = xml_re.search(entry)
72 fp =
"%s/%s" % (di, name)
78 path_fix = re.compile(
r"^\/Run \d+")
79 for fullname, obj
in parse_directory(
""):
80 f = fullname.replace(
"/DQMData",
"")
81 f = f.replace(
"/Run summary",
"")
82 f = path_fix.sub(
r"", f)
89 self._root_file.Close()
91 if __name__ ==
'__main__':
95 parser.add_argument(
"-i",
"--input", help =
"Input DQMIO ROOT file")
96 args = parser.parse_args()
100 for (fn, v)
in reader.read_objects():
101 if (hasattr(v,
"ClassName")):
102 print fn, v.ClassName()
def read_objects_dqmio(self)
def __init__(self, input_filename)
def read_objects_root(self)