CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
DQM.DQMReader Class Reference
Inheritance diagram for DQM.DQMReader:

Public Member Functions

def __init__ (self, input_filename)
 
def close (self)
 
def read_objects (self)
 
def read_objects_dqmio (self)
 
def read_objects_root (self)
 

Public Attributes

 type
 

Private Attributes

 _root_file
 

Detailed Description

Reader for  DQM IO and DQM root files.

Definition at line 6 of file DQM.py.

Constructor & Destructor Documentation

def DQM.DQMReader.__init__ (   self,
  input_filename 
)

Definition at line 17 of file DQM.py.

17  def __init__(self, input_filename):
18  self._root_file = R.TFile.Open(input_filename)
19 
20  ioTest = self._root_file.Get("Indices")
21  if bool(ioTest):
22  self.type = "DQMIO"
23  else:
24  self.type = "ROOT"
25 
def __init__(self, input_filename)
Definition: DQM.py:17
_root_file
Definition: DQM.py:18

Member Function Documentation

def DQM.DQMReader.close (   self)
def DQM.DQMReader.read_objects (   self)
def DQM.DQMReader.read_objects_dqmio (   self)

Definition at line 32 of file DQM.py.

References str.

Referenced by DQM.DQMReader.read_objects().

32  def read_objects_dqmio(self):
33  indices = self._root_file.Get("Indices")
34 
35  for y in xrange(indices.GetEntries()):
36  indices.GetEntry(y)
37  # print indices.Run, indices.Lumi, indices.Type
38 
39  if indices.Type == 1000:
40  # nothing is stored here
41  # see https://github.com/cms-sw/cmssw/blob/8be445ac6fd9983d69156199d4d1fd3350f05d92/DQMServices/FwkIO/plugins/DQMRootOutputModule.cc#L437
42  continue
43 
44  object_type = self.DQMIO_TYPES[indices.Type]
45  t_tree = self._root_file.Get(object_type)
46 
47  for i in xrange(indices.FirstIndex, indices.LastIndex + 1):
48  t_tree.GetEntry(i)
49 
50  fullname = str(t_tree.FullName)
51  yield (fullname, t_tree.Value, )
52 
def read_objects_dqmio(self)
Definition: DQM.py:32
#define str(s)
def DQM.DQMReader.read_objects_root (   self)

Definition at line 53 of file DQM.py.

Referenced by DQM.DQMReader.read_objects().

53  def read_objects_root(self):
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():
58  entry = key.GetName()
59  rtype = key.GetClassName()
60  fullpath = "%s/%s" % (di, entry)
61 
62  if (rtype == "TDirectoryFile"):
63  for k, v in parse_directory(fullpath):
64  yield (k, v, )
65  else:
66  obj = self._root_file.Get(fullpath)
67  if obj:
68  yield (fullpath, obj, )
69  else:
70  # special case to parse the xml abomination
71  m = xml_re.search(entry)
72  if m:
73  name = m.group(1)
74  typecode = m.group(2)
75  value = m.group(3)
76 
77  fp = "%s/%s" % (di, name)
78  yield (fp, value, )
79  else:
80  raise Exception("Invalid xml:" + entry)
81 
82 
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)
88  if f[0] == "/":
89  f = f[1:]
90 
91  yield f, obj
92 
def read_objects_root(self)
Definition: DQM.py:53

Member Data Documentation

DQM.DQMReader._root_file
private

Definition at line 18 of file DQM.py.

DQM.DQMReader.type