CMS 3D CMS Logo

Functions

ROOTData Namespace Reference

Functions

def literal2root
def tfile_cd

Function Documentation

def ROOTData::literal2root (   literal,
  rootType,
  tstreamerinfo = None 
)
Convert an hexadecimal string into a root-object. The correct TStreamerInfo
is passed in order to avoid inconsistencies.

Definition at line 24 of file ROOTData.py.

00025                                                       :
00026   """
00027   Convert an hexadecimal string into a root-object. The correct TStreamerInfo
00028   is passed in order to avoid inconsistencies.
00029   """
00030   bitsarray = array('B')
00031   bitsarray.fromstring(literal.decode('hex'))
00032 
00033   tbuffer = TBufferFile(TBufferFile.kRead)
00034   if tstreamerinfo:
00035     tbuffer.IncrementLevel(tstreamerinfo)
00036   tbuffer.SetBuffer(bitsarray,len(bitsarray),False)
00037 
00038   # replace a couple of shortcuts with the real root class name
00039   if rootType == 'TPROF':
00040       rootType = 'TProfile'
00041   if rootType == 'TPROF2D':
00042       rootType = 'TProfile2D'
00043 
00044   root_class=eval(rootType+'.Class()')
00045 
00046   return tbuffer.ReadObject(root_class)
00047 
def ROOTData::tfile_cd (   dirname,
  tfile,
  debug = False 
)
Safely re-build and navigate the directory structure.

Definition at line 5 of file ROOTData.py.

00006                                        :
00007   """
00008   Safely re-build and navigate the directory structure.
00009   """
00010 
00011   if not tfile.GetDirectory(dirname):
00012     gDirectory.cd("/")
00013     path=""
00014     for component in dirname.split('/'):
00015       path+="/%s" %component
00016       if not tfile.GetDirectory(path):
00017         gDirectory.mkdir(component)
00018       gDirectory.cd(component)
00019 
00020       if debug:
00021         print "Current dir"
00022         gDirectory.pwd()
00023 
#-------------------------------------------------------------------------------