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 | Private Member Functions
dqm_interfaces.DQMRootFile Class Reference
Inheritance diagram for dqm_interfaces.DQMRootFile:

Public Member Functions

def __init__
 
def cd
 
def getObj
 
def ls
 

Public Attributes

 rootfile
 
 rootfileprevpwd
 
 rootfilepwd
 

Private Member Functions

def __is_null
 

Detailed Description

Class acting as interface between the user and the harvested DQMRootFile.  
It skips the directories created by the DQM infrastructure so to provide an
interface as similar as possible to a real direcory structure and to the 
directory structure provided by the db interface.

Definition at line 470 of file dqm_interfaces.py.

Constructor & Destructor Documentation

def dqm_interfaces.DQMRootFile.__init__ (   self,
  rootfilename 
)

Definition at line 476 of file dqm_interfaces.py.

477  def __init__(self,rootfilename):
478  dqmdatadir="DQMData"
479  self.rootfile=TFile(rootfilename)
480  self.rootfilepwd=self.rootfile.GetDirectory(dqmdatadir)
481  self.rootfileprevpwd=self.rootfile.GetDirectory(dqmdatadir)
482  if self.rootfilepwd == None:
483  print "Directory %s does not exist: skipping. Is this a custom rootfile?" %dqmdatadir
484  self.rootfilepwd=self.rootfile
485  self.rootfileprevpwd=self.rootfile

Member Function Documentation

def dqm_interfaces.DQMRootFile.__is_null (   self,
  directory,
  name 
)
private

Definition at line 486 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMRootFile.cd(), dqm_interfaces.DQMRootFile.getObj(), and dqm_interfaces.DQMRootFile.ls().

487  def __is_null(self,directory,name):
488  is_null = not directory
489  if is_null:
490  print >> stderr, "Directory %s does not exist!" %name
491  return is_null
def dqm_interfaces.DQMRootFile.cd (   self,
  directory_name 
)
Change the current TDirectoryFile. The familiar "-" and ".." directories 
can be accessed as well.

Definition at line 506 of file dqm_interfaces.py.

References dqm_interfaces.DQMRootFile.__is_null(), dqm_interfaces.DQMRootFile.rootfileprevpwd, and dqm_interfaces.DQMRootFile.rootfilepwd.

Referenced by dqm_interfaces.DirWalkerFile.walk().

507  def cd(self,directory_name):
508  """Change the current TDirectoryFile. The familiar "-" and ".." directories
509  can be accessed as well.
510  """
511  if directory_name=="-":
512  tmp=self.rootfilepwd
513  self.rootfilepwd=self.rootfileprevpwd
514  self.rootfileprevpwd=tmp
515  if directory_name=="..":
516  #print "Setting prevpwd"
517  self.rootfileprevpwd=self.rootfilepwd
518  #print "The mom"
519  mom=self.rootfilepwd.GetMotherDir()
520  #print "In directory +%s+" %self.rootfilepwd
521  #print "Deleting the TFileDir"
522  if "Run " not in self.rootfilepwd.GetName():
523  self.rootfilepwd.Delete()
524  #print "Setting pwd to mom"
525  self.rootfilepwd=mom
526  else:
527  new_directory=self.rootfilepwd.GetDirectory(directory_name)
528  if not self.__is_null(new_directory,directory_name):
529  self.rootfileprevpwd=self.rootfilepwd
530  self.rootfilepwd=new_directory
def dqm_interfaces.DQMRootFile.getObj (   self,
  objname 
)
Get a TObject from the rootfile.

Definition at line 531 of file dqm_interfaces.py.

References dqm_interfaces.DQMRootFile.__is_null().

532  def getObj(self,objname):
533  """Get a TObject from the rootfile.
534  """
535  obj=self.rootfilepwd.Get(objname)
536  if not self.__is_null(obj,objname):
537  return obj
538 
539 #-------------------------------------------------------------------------------
def dqm_interfaces.DQMRootFile.ls (   self,
  directory_name = "" 
)

Definition at line 492 of file dqm_interfaces.py.

References dqm_interfaces.DQMRootFile.__is_null(), and dqm_interfaces.DQMRootFile.rootfilepwd.

Referenced by dqm_interfaces.DirWalkerFile.walk().

493  def ls(self,directory_name=""):
494  contents={}
495  directory=None
496  if len(directory_name)==0:
497  directory=self.rootfilepwd
498 
499  directory=self.rootfilepwd.GetDirectory(directory_name)
500  if self.__is_null(directory,directory_name):
501  return contents
502 
503  for key in directory.GetListOfKeys():
504  contents[key.GetName()]=key.GetClassName()
505  return contents

Member Data Documentation

dqm_interfaces.DQMRootFile.rootfile

Definition at line 478 of file dqm_interfaces.py.

dqm_interfaces.DQMRootFile.rootfileprevpwd

Definition at line 480 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMRootFile.cd().

dqm_interfaces.DQMRootFile.rootfilepwd

Definition at line 479 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMRootFile.cd(), and dqm_interfaces.DQMRootFile.ls().