CMS 3D CMS Logo

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__ (self, rootfilename)
 
def cd (self, directory_name)
 
def getObj (self, objname)
 
def ls (self, directory_name="")
 

Public Attributes

 rootfile
 
 rootfileprevpwd
 
 rootfilepwd
 

Private Member Functions

def __is_null (self, directory, name)
 

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

◆ __init__()

def dqm_interfaces.DQMRootFile.__init__ (   self,
  rootfilename 
)

Definition at line 481 of file dqm_interfaces.py.

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

Member Function Documentation

◆ __is_null()

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

Definition at line 491 of file dqm_interfaces.py.

491  def __is_null(self,directory,name):
492  is_null = not directory
493  if is_null:
494  print("Directory %s does not exist!" %name, file=stderr)
495  return is_null
496 

References edm.print().

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

◆ cd()

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.

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

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

Referenced by dqm_interfaces.DirWalkerFile.walk().

◆ getObj()

def dqm_interfaces.DQMRootFile.getObj (   self,
  objname 
)
Get a TObject from the rootfile.

Definition at line 536 of file dqm_interfaces.py.

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

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

◆ ls()

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

Definition at line 497 of file dqm_interfaces.py.

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

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

Referenced by dqm_interfaces.DirWalkerFile.walk().

Member Data Documentation

◆ rootfile

dqm_interfaces.DQMRootFile.rootfile

Definition at line 483 of file dqm_interfaces.py.

◆ rootfileprevpwd

dqm_interfaces.DQMRootFile.rootfileprevpwd

Definition at line 485 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMRootFile.cd().

◆ rootfilepwd

dqm_interfaces.DQMRootFile.rootfilepwd
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40