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

Constructor & Destructor Documentation

def DQM.DQMReader.__init__ (   self,
  input_filename 
)

Definition at line 19 of file DQM.py.

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

Member Function Documentation

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

Definition at line 34 of file DQM.py.

References str.

Referenced by DQM.DQMReader.read_objects().

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

Definition at line 55 of file DQM.py.

Referenced by DQM.DQMReader.read_objects().

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

Member Data Documentation

DQM.DQMReader._root_file
private

Definition at line 20 of file DQM.py.

DQM.DQMReader.type