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 473 of file dqm_interfaces.py.

Constructor & Destructor Documentation

def dqm_interfaces.DQMRootFile.__init__ (   self,
  rootfilename 
)

Definition at line 479 of file dqm_interfaces.py.

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

Member Function Documentation

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

Definition at line 489 of file dqm_interfaces.py.

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

490  def __is_null(self,directory,name):
491  is_null = not directory
492  if is_null:
493  print >> stderr, "Directory %s does not exist!" %name
494  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 509 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().

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

Definition at line 534 of file dqm_interfaces.py.

References dqm_interfaces.DQMRootFile.__is_null().

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

Definition at line 495 of file dqm_interfaces.py.

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

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Member Data Documentation

dqm_interfaces.DQMRootFile.rootfile

Definition at line 481 of file dqm_interfaces.py.

dqm_interfaces.DQMRootFile.rootfileprevpwd

Definition at line 483 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMRootFile.cd().

dqm_interfaces.DQMRootFile.rootfilepwd

Definition at line 482 of file dqm_interfaces.py.

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