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

Constructor & Destructor Documentation

def dqm_interfaces.DQMRootFile.__init__ (   self,
  rootfilename 
)

Definition at line 481 of file dqm_interfaces.py.

482  def __init__(self,rootfilename):
483  dqmdatadir="DQMData"
484  self.rootfile=ROOT.TFile(rootfilename)
485  self.rootfilepwd=self.rootfile.GetDirectory(dqmdatadir)
486  self.rootfileprevpwd=self.rootfile.GetDirectory(dqmdatadir)
487  if self.rootfilepwd == None:
488  print("Directory %s does not exist: skipping. Is this a custom rootfile?" %dqmdatadir)
489  self.rootfilepwd=self.rootfile
490  self.rootfileprevpwd=self.rootfile
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Member Function Documentation

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

Definition at line 491 of file dqm_interfaces.py.

References print().

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

492  def __is_null(self,directory,name):
493  is_null = not directory
494  if is_null:
495  print("Directory %s does not exist!" %name, file=stderr)
496  return is_null
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def dqm_interfaces.DQMRootFile.cd (   self,
  directory_name 
)
Change the current TDirectoryFile. The familiar "-" and ".." directories 
can be accessed as well.

Definition at line 511 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().

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

Definition at line 536 of file dqm_interfaces.py.

References dqm_interfaces.DQMRootFile.__is_null().

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

Definition at line 497 of file dqm_interfaces.py.

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

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Member Data Documentation

dqm_interfaces.DQMRootFile.rootfile

Definition at line 483 of file dqm_interfaces.py.

dqm_interfaces.DQMRootFile.rootfileprevpwd

Definition at line 485 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMRootFile.cd().

dqm_interfaces.DQMRootFile.rootfilepwd

Definition at line 484 of file dqm_interfaces.py.

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