CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
DQMIO2histo.DQMIO Class Reference

Public Member Functions

def __init__
 
def print_index
 
def write_to_file
 

Public Attributes

 f
 

Static Public Attributes

list types
 

Private Attributes

 _canvas
 
 _filename
 
 _root_file
 

Detailed Description

Class responsible for browsing the content of a DQM file produced
with the DQMIO I/O framework of CMSSW

Definition at line 17 of file DQMIO2histo.py.

Constructor & Destructor Documentation

def DQMIO2histo.DQMIO.__init__ (   self,
  input_filename,
  output_filename 
)

Definition at line 27 of file DQMIO2histo.py.

27 
28  def __init__(self, input_filename, output_filename):
29  self._filename = input_filename
30  self._canvas = None
31  self.f = R.TFile(output_filename, "RECREATE")
32  if os.path.exists(self._filename): #we try to open input file if fail
33  self._root_file = R.TFile.Open(self._filename) #-> close script
34  if args.debug:
35  print "## DEBUG ##:"
36  print " Input: %s\n Output: %s" % (input_filename,
37  output_filename)
38 
39  else:
40  print "File %s does not exists" % self._filename
41  sys.exit(1)

Member Function Documentation

def DQMIO2histo.DQMIO.print_index (   self)
Loop over the complete index and dump it on the screen.

Definition at line 42 of file DQMIO2histo.py.

References DQMIO2histo.DQMIO.types, and DQMIO2histo.DQMIO.write_to_file().

42 
43  def print_index(self):
44  """
45  Loop over the complete index and dump it on the screen.
46  """
47  indices = self._root_file.Get("Indices")
48  if args.debug:
49  print "## DEBUG ##:"
50  print "Run,\tLumi,\tType,\t\tFirstIndex,\tLastIndex"
51  for i in xrange(indices.GetEntries()):
52  indices.GetEntry(i)
53  print '{0:4d}\t{1:4d}\t{2:4d}({3:s})\t\t{4:4d}\t{5:4d}'.format(
54  indices.Run, indices.Lumi, indices.Type,
55  DQMIO.types[indices.Type], indices.FirstIndex, indices.LastIndex)
56 
57  for i in xrange(indices.GetEntries()):
58  indices.GetEntry(i)
59  if indices.Type < len(DQMIO.types):
60  self.write_to_file(self.types[indices.Type],
61  [indices.FirstIndex,indices.LastIndex], str(indices.Run))
62 
63  else:
64  print "Unknown histogram type. Type numer: %s" % (indices.Type)
65  self.f.Close()
def DQMIO2histo.DQMIO.write_to_file (   self,
  hist_type,
  index_range,
  run 
)
Method looping over entries for specified histogram type and 
writing to FullName path to output ROOT File

Definition at line 66 of file DQMIO2histo.py.

References join().

Referenced by DQMIO2histo.DQMIO.print_index().

66 
67  def write_to_file(self, hist_type, index_range, run):
68  """
69  Method looping over entries for specified histogram type and
70  writing to FullName path to output ROOT File
71  """
72  print "Working on: %s indexes: %s..%s" % (hist_type ,index_range[0],
73  index_range[1])
74  t_tree = self._root_file.Get(hist_type)
75  __run_dir = "Run %s" % (run)
76  ###we set Branch for the needed type
77  if hist_type == "TProfiles":
78  R.gROOT.ProcessLine("TProfile* _tprof;")
79  t_tree.SetBranchAddress("Value", R._tprof)
80  t_tree.GetEntry(0)
81  elif hist_type == "TProfile2Ds":
82  R.gROOT.ProcessLine("TProfile2D* _tprof2d;")
83  t_tree.SetBranchAddress("Value", R._tprof2d)
84  t_tree.GetEntry(0)
85  elif hist_type == "TH2Fs":
86  R.gROOT.ProcessLine("TH2F* _th2f;")
87  t_tree.SetBranchAddress("Value", R._th2f)
88  t_tree.GetEntry(0)
89  elif hist_type == "TH2Ds":
90  R.gROOT.ProcessLine("TH2D* _th2d;")
91  t_tree.SetBranchAddress("Value", R._th2d)
92  t_tree.GetEntry(0)
93 
94  for i in range(0,t_tree.GetEntries()+1): ##iterate on entries for specified type
95  t_tree.GetEntry(i)
96  name = str(t_tree.FullName)
97  #if args.debug:
98  # print " %s" % (name)
99  if i >= index_range[0] and i <= index_range[1]: ##if entries as in range:
100  file_path = name.split("/")[:-1] ## same run/lumi histograms
101  __directory = "%s/%s" % (os.path.join("DQMData", __run_dir),
102  "/".join(file_path))
103  directory_ret = self.f.GetDirectory(__directory)
104  if not directory_ret:
105  self.f.mkdir(os.path.join(__directory))
106  self.f.cd(os.path.join(__directory))
107  if hist_type == "Strings":
108  construct_str = '<%s>s=%s</%s>' % (name.split("/")[-1:][0],
109  t_tree.Value, name.split("/")[-1:][0])
110  tmp_str = R.TObjString(construct_str)
111  tmp_str.Write()
112  elif hist_type == "Ints":
113  construct_str = '<%s>i=%s</%s>' % (name.split("/")[-1:][0],
114  t_tree.Value, name.split("/")[-1:][0])
115  tmp_str = R.TObjString(construct_str)
116  tmp_str.Write()
117  elif hist_type == "Floats":
118  construct_str = '<%s>f=%s</%s>' % (name.split("/")[-1:][0],
119  t_tree.Value, name.split("/")[-1:][0])
120  tmp_str = R.TObjString(construct_str)
121  tmp_str.Write()
122  else:
123  if hist_type in ["TProfiles", "TProfile2Ds", "TH2Fs", "TH2Ds"]:
124  if hist_type == "TProfiles": #if type is specific we write it.
125  R._tprof.Write()
126  elif hist_type == "TProfile2Ds":
127  R._tprof2d.Write()
128  elif hist_type == "TH2Fs":
129  R._th2f.Write()
130  elif hist_type == "TH2Ds":
131  R._th2d.Write()
132  else: #else we wirte ne Leafs Value which is a histogram
133  t_tree.Value.Write()
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Data Documentation

DQMIO2histo.DQMIO._canvas
private

Definition at line 29 of file DQMIO2histo.py.

DQMIO2histo.DQMIO._filename
private

Definition at line 28 of file DQMIO2histo.py.

Referenced by Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor._readHeaderInfo(), Vispa.Main.TabController.TabController.checkModificationTimestamp(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor.configFile(), Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.dumpPython(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController.eventContent(), Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.exportDot(), Vispa.Main.TabController.TabController.filename(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor.fullFilename(), Vispa.Main.TabController.TabController.getFileBasename(), Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.importConfig(), Vispa.Plugins.EventBrowser.EventBrowserTabController.EventBrowserTabController.navigate(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor.open(), Vispa.Main.TabController.TabController.open(), Vispa.Plugins.EdmBrowser.EdmDataAccessor.EdmDataAccessor.open(), Vispa.Main.TabController.TabController.refresh(), Vispa.Main.TabController.TabController.save(), Vispa.Main.TabController.TabController.setFilename(), Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.startEditMode(), and Vispa.Main.TabController.TabController.updateLabel().

DQMIO2histo.DQMIO._root_file
private

Definition at line 32 of file DQMIO2histo.py.

DQMIO2histo.DQMIO.f

Definition at line 30 of file DQMIO2histo.py.

Referenced by Vispa.Views.RootCanvasView.RootCanvasView.createGraph(), Vispa.Views.RootCanvasView.RootCanvasView.createLegoPlot(), and ztail.Decoder.initial_synchronize().

list DQMIO2histo.DQMIO.types
static
Initial value:
1 = ["Ints","Floats","Strings", ##defined DQMIO types
2  "TH1Fs","TH1Ss","TH1Ds",
3  "TH2Fs", "TH2Ss", "TH2Ds",
4  "TH3Fs", "TProfiles","TProfile2Ds", "kNIndicies"]

Definition at line 22 of file DQMIO2histo.py.

Referenced by DQMIO2histo.DQMIO.print_index().