CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 
def close
 
def read_objects
 
def read_objects_dqmio
 
def read_objects_root
 

Public Attributes

 type
 

Static Public Attributes

list 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

def DQM.DQMReader.__init__ (   self,
  input_filename 
)

Definition at line 19 of file DQM.py.

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

Member Function Documentation

def DQM.DQMReader.close (   self)

Definition at line 95 of file DQM.py.

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

95 
96  def close(self):
97  self._root_file.Close()
def close
Definition: DQM.py:95
def DQM.DQMReader.read_objects (   self)

Definition at line 28 of file DQM.py.

References DQM.DQMReader.read_objects_dqmio(), DQM.DQMReader.read_objects_root(), AlignableObjectId::entry.type, BCoptions.type, HcalSiPMParametersGPU::Product.type, TotemTriggerCounters.type, DQM.DQMReader.type, plottingOptions.BasePlottingOptions.type, DB_ME.type, cond::TimeTypeSpecs.type, SummationStep.type, DQMGenericClient::EfficOption.type, DTTMax::TMax.type, metsig::SigInputObj.type, PrimaryVertexMonitor.type, MuonGeometrySanityCheckPoint.type, ME::Settings.type, SiStripOfflineDQM::MapOptions.type, BeamSpotDipServer.type, HcalRaddamMuon.type, ME.type, and nanoaod::FlatTable::Column.type.

28 
29  def read_objects(self):
30  if (self.type == "DQMIO"):
31  return self.read_objects_dqmio()
32  else:
33  return self.read_objects_root()
def read_objects
Definition: DQM.py:28
def read_objects_root
Definition: DQM.py:55
def read_objects_dqmio
Definition: DQM.py:34
def DQM.DQMReader.read_objects_dqmio (   self)

Definition at line 34 of file DQM.py.

References DQM.DQMReader.DQMIO_TYPES, sistrip::SpyUtilities.range(), and str.

Referenced by DQM.DQMReader.read_objects().

34 
35  def read_objects_dqmio(self):
36  indices = self._root_file.Get("Indices")
37 
38  for y in range(indices.GetEntries()):
39  indices.GetEntry(y)
40  # print indices.Run, indices.Lumi, indices.Type
41 
42  if indices.Type == 1000:
43  # nothing is stored here
44  # see https://github.com/cms-sw/cmssw/blob/8be445ac6fd9983d69156199d4d1fd3350f05d92/DQMServices/FwkIO/plugins/DQMRootOutputModule.cc#L437
45  continue
46 
47  object_type = self.DQMIO_TYPES[indices.Type]
48  t_tree = self._root_file.Get(object_type)
49 
50  for i in range(indices.FirstIndex, indices.LastIndex + 1):
51  t_tree.GetEntry(i)
52 
53  fullname = str(t_tree.FullName)
54  yield (fullname, t_tree.Value, )
list DQMIO_TYPES
Definition: DQM.py:14
const uint16_t range(const Frame &aFrame)
def read_objects_dqmio
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 
56  def read_objects_root(self):
57  xml_re = re.compile(r"^<(.+)>(.+)=(.*)<\/\1>$")
58  def parse_directory(di):
59  directory = self._root_file.GetDirectory(di)
60  for key in directory.GetListOfKeys():
61  entry = key.GetName()
62  rtype = key.GetClassName()
63  fullpath = "%s/%s" % (di, entry)
64 
65  if (rtype == "TDirectoryFile"):
66  for k, v in parse_directory(fullpath):
67  yield (k, v, )
68  else:
69  obj = self._root_file.Get(fullpath)
70  if obj:
71  yield (fullpath, obj, )
72  else:
73  # special case to parse the xml abomination
74  m = xml_re.search(entry)
75  if m:
76  name = m.group(1)
77  typecode = m.group(2)
78  value = m.group(3)
79 
80  fp = "%s/%s" % (di, name)
81  yield (fp, value, )
82  else:
83  raise Exception("Invalid xml:" + entry)
84 
85 
86  path_fix = re.compile(r"^\/Run \d+")
87  for fullname, obj in parse_directory(""):
88  f = fullname.replace("/DQMData", "")
89  f = f.replace("/Run summary", "")
90  f = path_fix.sub(r"", f)
91  if f[0] == "/":
92  f = f[1:]
93 
94  yield f, obj
def read_objects_root
Definition: DQM.py:55

Member Data Documentation

DQM.DQMReader._root_file
private

Definition at line 20 of file DQM.py.

list DQM.DQMReader.DQMIO_TYPES
static
Initial value:
1 = ["Ints","Floats","Strings",
2  "TH1Fs","TH1Ss","TH1Ds",
3  "TH2Fs", "TH2Ss", "TH2Ds",
4  "TH3Fs", "TProfiles","TProfile2Ds", "kNIndicies"]

Definition at line 14 of file DQM.py.

Referenced by DQM.DQMReader.read_objects_dqmio().

DQM.DQMReader.type

Definition at line 24 of file DQM.py.

Referenced by core.autovars.NTupleVariable.makeBranch(), DQM.DQMReader.read_objects(), and core.AutoHandle.AutoHandle.ReallyLoad().