CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Member Functions

dqm_interfaces::DQMRootFile Class Reference

List of all members.

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.

00480                                  :
00481     dqmdatadir="DQMData"
00482     self.rootfile=TFile(rootfilename)  
00483     self.rootfilepwd=self.rootfile.GetDirectory(dqmdatadir)
00484     self.rootfileprevpwd=self.rootfile.GetDirectory(dqmdatadir)
00485     if self.rootfilepwd == None:
00486       print "Directory %s does not exist: skipping. Is this a custom rootfile?" %dqmdatadir
00487       self.rootfilepwd=self.rootfile
00488       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.

00490                                     :
00491     is_null = not directory
00492     if is_null:
00493         print >> stderr, "Directory %s does not exist!" %name
00494     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.

00510                              :
00511     """Change the current TDirectoryFile. The familiar "-" and ".." directories 
00512     can be accessed as well.
00513     """
00514     if directory_name=="-":
00515       tmp=self.rootfilepwd
00516       self.rootfilepwd=self.rootfileprevpwd
00517       self.rootfileprevpwd=tmp
00518     if directory_name=="..":
00519       #print "Setting prevpwd"
00520       self.rootfileprevpwd=self.rootfilepwd
00521       #print "The mom"
00522       mom=self.rootfilepwd.GetMotherDir()
00523       #print "In directory +%s+" %self.rootfilepwd
00524       #print "Deleting the TFileDir"
00525       if "Run " not in self.rootfilepwd.GetName():
00526         self.rootfilepwd.Delete()
00527       #print "Setting pwd to mom"
00528       self.rootfilepwd=mom
00529     else:
00530       new_directory=self.rootfilepwd.GetDirectory(directory_name)
00531       if not self.__is_null(new_directory,directory_name):
00532           self.rootfileprevpwd=self.rootfilepwd
00533           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.

00535                           :
00536     """Get a TObject from the rootfile.
00537     """
00538     obj=self.rootfilepwd.Get(objname)
00539     if not self.__is_null(obj,objname):
00540       return obj
00541 
00542 #-------------------------------------------------------------------------------

def dqm_interfaces::DQMRootFile::ls (   self,
  directory_name = "" 
)

Definition at line 495 of file dqm_interfaces.py.

00496                                 :
00497     contents={}
00498     directory=None
00499     if len(directory_name)==0:
00500       directory=self.rootfilepwd      
00501     
00502     directory=self.rootfilepwd.GetDirectory(directory_name)    
00503     if self.__is_null(directory,directory_name):
00504       return contents
00505     
00506     for key in directory.GetListOfKeys():
00507       contents[key.GetName()]=key.GetClassName()
00508     return contents
  

Member Data Documentation

Definition at line 479 of file dqm_interfaces.py.

Definition at line 479 of file dqm_interfaces.py.

Definition at line 479 of file dqm_interfaces.py.