CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
ROOTData Namespace Reference

Functions

def literal2root
 
def loadStreamerInfo
 
def tfile_cd
 

Function Documentation

def ROOTData.literal2root (   literal,
  rootType,
  debug = False 
)
Convert an hexadecimal string into a root-object. In case a
TStreamerInfo object is passed, this will be decoded by the
loadStreamerInfo function to handle it properly and a None object
will be returned. It is the responsibility of the user not the use
the returned object in this very case.

Definition at line 52 of file ROOTData.py.

References loadStreamerInfo().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects(), dqm_interfaces.DQMcommunicator.get_root_objects_list(), dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), and dqm_interfaces.DirWalkerDB.run().

52 
53 def literal2root (literal, rootType, debug=False):
54 
55  """Convert an hexadecimal string into a root-object. In case a
56  TStreamerInfo object is passed, this will be decoded by the
57  loadStreamerInfo function to handle it properly and a None object
58  will be returned. It is the responsibility of the user not the use
59  the returned object in this very case."""
60 
61  if rootType == "TStreamerInfo":
62  loadStreamerInfo(literal, debug)
63  return None
64 
65  bitsarray = array('B')
66  bitsarray.fromstring(literal.decode('hex'))
67 
68  tbuffer = TBufferFile(TBufferFile.kRead)
69  tbuffer.SetBuffer(bitsarray,len(bitsarray),False)
70 
71  # replace a couple of shortcuts with the real root class name
72  if rootType == 'TPROF':
73  rootType = 'TProfile'
74  if rootType == 'TPROF2D':
75  rootType = 'TProfile2D'
76 
77  root_class = eval(rootType+'.Class()')
78 
79  return tbuffer.ReadObject(root_class)
80 
def literal2root
Definition: ROOTData.py:52
def loadStreamerInfo
Definition: ROOTData.py:24
def ROOTData.loadStreamerInfo (   literal,
  debug 
)
Decode a literal made of TStreamerInfo informations and load
streamers that are not part of the currently used version of
ROOT. The implementation is a back-to-bone and simplified version of
the one contained in the DQM GUI source code.

Definition at line 24 of file ROOTData.py.

Referenced by literal2root().

24 
25 def loadStreamerInfo(literal, debug):
26 
27  """Decode a literal made of TStreamerInfo informations and load
28  streamers that are not part of the currently used version of
29  ROOT. The implementation is a back-to-bone and simplified version of
30  the one contained in the DQM GUI source code."""
31 
32  bitsarray = array('B')
33  bitsarray.fromstring(literal.decode('hex'))
34 
35  tbuffer = TBufferFile(TBufferFile.kRead)
36  tbuffer.Reset();
37  tbuffer.SetBuffer(bitsarray, len(bitsarray), False)
38  while tbuffer.Length() != tbuffer.BufferSize():
39  obj = tbuffer.ReadObject(eval("TStreamerInfo.Class()"))
40  v = obj.GetClassVersion()
41  c = TClass.GetClass(obj.GetName(), kTRUE)
42  if c:
43  c.GetStreamerInfo();
44  if c.GetStreamerInfos().At(v):
45  if debug:
46  print "skipping already present streamer info version %d for %s" % (v, obj.GetName())
47  continue
48  if debug:
49  print "Importing streamer info version %d for %s" % (v, obj.GetName())
50  obj.BuildCheck();
51 
#-------------------------------------------------------------------------------
def loadStreamerInfo
Definition: ROOTData.py:24
def ROOTData.tfile_cd (   dirname,
  tfile,
  debug = False 
)
Safely re-build and navigate the directory structure. dirname is
considered to be an absolute path.

Definition at line 5 of file ROOTData.py.

5 
6 def tfile_cd(dirname, tfile, debug=False):
7 
8  """ Safely re-build and navigate the directory structure. dirname is
9  considered to be an absolute path."""
10 
11  gDirectory.cd("/")
12  if tfile.GetDirectory(dirname):
13  gDirectory.cd(dirname)
14  else:
15  path=""
16  for component in dirname.split('/'):
17  path += "/%s" % component
18  if not tfile.GetDirectory(path):
19  gDirectory.mkdir(component)
20  gDirectory.cd(component)
21 
22  if debug:
23  print "Current dir %s" % gDirectory.pwd()
def tfile_cd
Definition: ROOTData.py:5