1 from __future__
import print_function
3 from array
import array
8 """ Safely re-build and navigate the directory structure. dirname is
9 considered to be an absolute path."""
12 if tfile.GetDirectory(dirname):
13 gDirectory.cd(dirname)
16 for component
in dirname.split(
'/'):
17 path +=
"/%s" % component
18 if not tfile.GetDirectory(path):
19 gDirectory.mkdir(component)
20 gDirectory.cd(component)
23 print(
"Current dir %s" % gDirectory.pwd())
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."""
32 bitsarray =
array(
'B')
33 bitsarray.fromstring(literal.decode(
'hex'))
35 tbuffer = TBufferFile(TBufferFile.kRead)
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)
44 if c.GetStreamerInfos().At(v):
46 print(
"skipping already present streamer info version %d for %s" % (v, obj.GetName()))
49 print(
"Importing streamer info version %d for %s" % (v, obj.GetName()))
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."""
61 if rootType ==
"TStreamerInfo":
65 bitsarray =
array(
'B')
66 bitsarray.fromstring(literal.decode(
'hex'))
68 tbuffer = TBufferFile(TBufferFile.kRead)
69 tbuffer.SetBuffer(bitsarray,len(bitsarray),
False)
72 if rootType ==
'TPROF':
74 if rootType ==
'TPROF2D':
75 rootType =
'TProfile2D'
77 root_class = eval(rootType+
'.Class()')
79 return tbuffer.ReadObject(root_class)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)