2 from array
import array
7 """ Safely re-build and navigate the directory structure. dirname is
8 considered to be an absolute path."""
11 if tfile.GetDirectory(dirname):
12 gDirectory.cd(dirname)
15 for component
in dirname.split(
'/'):
16 path +=
"/%s" % component
17 if not tfile.GetDirectory(path):
18 gDirectory.mkdir(component)
19 gDirectory.cd(component)
22 print "Current dir %s" % gDirectory.pwd()
26 """Decode a literal made of TStreamerInfo informations and load
27 streamers that are not part of the currently used version of
28 ROOT. The implementation is a back-to-bone and simplified version of
29 the one contained in the DQM GUI source code."""
31 bitsarray = array(
'B')
32 bitsarray.fromstring(literal.decode(
'hex'))
34 tbuffer = TBufferFile(TBufferFile.kRead)
36 tbuffer.SetBuffer(bitsarray, len(bitsarray),
False)
37 while tbuffer.Length() != tbuffer.BufferSize():
38 obj = tbuffer.ReadObject(eval(
"TStreamerInfo.Class()"))
39 v = obj.GetClassVersion()
40 c = TClass.GetClass(obj.GetName(), kTRUE)
43 if c.GetStreamerInfos().At(v):
45 print "skipping already present streamer info version %d for %s" % (v, obj.GetName())
48 print "Importing streamer info version %d for %s" % (v, obj.GetName())
54 """Convert an hexadecimal string into a root-object. In case a
55 TStreamerInfo object is passed, this will be decoded by the
56 loadStreamerInfo function to handle it properly and a None object
57 will be returned. It is the responsibility of the user not the use
58 the returned object in this very case."""
60 if rootType ==
"TStreamerInfo":
64 bitsarray = array(
'B')
65 bitsarray.fromstring(literal.decode(
'hex'))
67 tbuffer = TBufferFile(TBufferFile.kRead)
68 tbuffer.SetBuffer(bitsarray,len(bitsarray),
False)
71 if rootType ==
'TPROF':
73 if rootType ==
'TPROF2D':
74 rootType =
'TProfile2D'
76 root_class = eval(rootType+
'.Class()')
78 return tbuffer.ReadObject(root_class)