CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 53 of file ROOTData.py.

References mps_check.array, and 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().

53 
54 def literal2root (literal, rootType, debug=False):
55 
56  """Convert an hexadecimal string into a root-object. In case a
57  TStreamerInfo object is passed, this will be decoded by the
58  loadStreamerInfo function to handle it properly and a None object
59  will be returned. It is the responsibility of the user not the use
60  the returned object in this very case."""
61 
62  if rootType == "TStreamerInfo":
63  loadStreamerInfo(literal, debug)
64  return None
65 
66  bitsarray = array('B')
67  bitsarray.fromstring(literal.decode('hex'))
68 
69  tbuffer = TBufferFile(TBufferFile.kRead)
70  tbuffer.SetBuffer(bitsarray,len(bitsarray),False)
71 
72  # replace a couple of shortcuts with the real root class name
73  if rootType == 'TPROF':
74  rootType = 'TProfile'
75  if rootType == 'TPROF2D':
76  rootType = 'TProfile2D'
77 
78  root_class = eval(rootType+'.Class()')
79 
80  return tbuffer.ReadObject(root_class)
81 
tuple array
Definition: mps_check.py:216
def literal2root
Definition: ROOTData.py:53
def loadStreamerInfo
Definition: ROOTData.py:25
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 25 of file ROOTData.py.

References mps_check.array, and print().

Referenced by literal2root().

25 
26 def loadStreamerInfo(literal, debug):
27 
28  """Decode a literal made of TStreamerInfo informations and load
29  streamers that are not part of the currently used version of
30  ROOT. The implementation is a back-to-bone and simplified version of
31  the one contained in the DQM GUI source code."""
32 
33  bitsarray = array('B')
34  bitsarray.fromstring(literal.decode('hex'))
35 
36  tbuffer = TBufferFile(TBufferFile.kRead)
37  tbuffer.Reset();
38  tbuffer.SetBuffer(bitsarray, len(bitsarray), False)
39  while tbuffer.Length() != tbuffer.BufferSize():
40  obj = tbuffer.ReadObject(eval("TStreamerInfo.Class()"))
41  v = obj.GetClassVersion()
42  c = TClass.GetClass(obj.GetName(), kTRUE)
43  if c:
44  c.GetStreamerInfo();
45  if c.GetStreamerInfos().At(v):
46  if debug:
47  print("skipping already present streamer info version %d for %s" % (v, obj.GetName()))
48  continue
49  if debug:
50  print("Importing streamer info version %d for %s" % (v, obj.GetName()))
51  obj.BuildCheck();
52 
#-------------------------------------------------------------------------------
tuple array
Definition: mps_check.py:216
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def loadStreamerInfo
Definition: ROOTData.py:25
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 6 of file ROOTData.py.

References print().

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