ATLAS Offline Software
Loading...
Searching...
No Matches
PyROOTFixes.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3"""Functions to work around PyROOT bugs for accessing DataVector.
4
5:author: scott snyder
6:contact: snyder@bnl.gov
7
8Importing this module will automatically apply workarounds
9for known PyROOT issues.
10
11"""
12__docformat__ = "restructuredtext en"
13
14import ROOT
15import cppyy # noqa: F401
16ROOT.TClass
17
18def fix_method (clname, methname):
19 # Now only a stub.
20 return
21
23 """Additional pythonizations for TTree."""
24 ROOT.RootUtils.PyROOTTTreePatch.Initialize (ROOT.TTree,
25 ROOT.TChain,
26 ROOT.TBranch)
27 return
28
30 """Enable pickling of object proxy's"""
31 import libPyROOT
32 ROOT.RootUtils.PyROOTPickle.Initialize (libPyROOT, ROOT.ObjectProxy)
33 del libPyROOT
34 return
35
36
37# Convert from class name to TClass; try to avoid autoparsing.
39 cl = ROOT.gROOT.GetListOfClasses().FindObject(cname)
40 if cl:
41 if cl.IsLoaded() and cl.HasDictionary(): return cl
42 return None
43 if ROOT.gInterpreter.GetClassSharedLibs (cname):
44 cl = ROOT.TClass.GetClass (cname)
45 if cl.HasDictionary(): return cl
46 return None
47
48# Force-load the main Gaudi library if it's available. If this package's library
49# is loaded before Gaudi, the application gets into a weird state. Hopefully we
50# will be able to remove this with future compiler versions. (GCC 10?...)
51if cppyy.gbl.gSystem.FindDynamicLibrary( cppyy.gbl.TString('libGaudiKernel'), True ):
52 cppyy.load_library( 'libGaudiKernel' )
53 pass
54
55ROOT.RootUtils.PyLogger
56ROOT.RootUtils.PyROOTTypePatch.initialize()
_getClassIfDictionaryExists(cname)
fix_method(clname, methname)