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 harvestTrackValidationPlots.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  object_type = self.DQMIO_TYPES[indices.Type]
40  t_tree = self._root_file.Get(object_type)
41 
42  for i in xrange(indices.FirstIndex, indices.LastIndex + 1):
43  t_tree.GetEntry(i)
44 
45  fullname = str(t_tree.FullName)
46  yield (fullname, t_tree.Value, )
47 
def read_objects_dqmio(self)
Definition: DQM.py:32
def DQM.DQMReader.read_objects_root (   self)

Definition at line 48 of file DQM.py.

Referenced by DQM.DQMReader.read_objects().

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

Member Data Documentation

DQM.DQMReader._root_file
private

Definition at line 18 of file DQM.py.

DQM.DQMReader.type