CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static 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
 

Static Public Attributes

 DQMIO_TYPES
 

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

◆ __init__()

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, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
T * Get(Args... args)
Definition: Trend.h:122

Member Function Documentation

◆ close()

def DQM.DQMReader.close (   self)

Definition at line 95 of file DQM.py.

References DQM.DQMReader._root_file.

Referenced by esMonitoring.AsyncLineReaderMixin.handle_close(), and esMonitoring.FDJsonServer.handle_close().

95  def close(self):
96  self._root_file.Close()
97 

◆ read_objects()

def DQM.DQMReader.read_objects (   self)

◆ read_objects_dqmio()

def DQM.DQMReader.read_objects_dqmio (   self)

Definition at line 34 of file DQM.py.

References DQM.DQMReader._root_file, DQM.DQMReader.DQMIO_TYPES, Get(), isotrackApplyRegressor.range, and 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 
#define str(s)
T * Get(Args... args)
Definition: Trend.h:122

◆ read_objects_root()

def DQM.DQMReader.read_objects_root (   self)

Definition at line 55 of file DQM.py.

References DQM.DQMReader._root_file, and Get().

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(rootfile)
Definition: root2sqlite.py:70
T * Get(Args... args)
Definition: Trend.h:122

Member Data Documentation

◆ _root_file

DQM.DQMReader._root_file
private

◆ DQMIO_TYPES

DQM.DQMReader.DQMIO_TYPES
static

Definition at line 14 of file DQM.py.

Referenced by DQM.DQMReader.read_objects_dqmio().

◆ type

DQM.DQMReader.type