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 7 of file DQM.py.

Constructor & Destructor Documentation

def DQM.DQMReader.__init__ (   self,
  input_filename 
)

Definition at line 18 of file DQM.py.

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

Member Function Documentation

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

Definition at line 33 of file DQM.py.

References str.

Referenced by DQM.DQMReader.read_objects().

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

Definition at line 54 of file DQM.py.

Referenced by DQM.DQMReader.read_objects().

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

Member Data Documentation

DQM.DQMReader._root_file
private

Definition at line 19 of file DQM.py.

DQM.DQMReader.type