ATLAS Offline Software
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 
8 Importing this module will automatically apply workarounds
9 for known PyROOT issues.
10 
11 """
12 __docformat__ = "restructuredtext en"
13 
14 import ROOT
15 import cppyy # noqa: F401
16 ROOT.TClass
17 
18 def 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?...)
51 if cppyy.gbl.gSystem.FindDynamicLibrary( 'libGaudiKernel', True ):
52  cppyy.load_library( 'libGaudiKernel' )
53  pass
54 
55 ROOT.RootUtils.PyLogger
56 ROOT.RootUtils.PyROOTTypePatch.initialize()
python.PyROOTFixes.enable_pickling
def enable_pickling()
Definition: PyROOTFixes.py:29
python.PyROOTFixes._getClassIfDictionaryExists
def _getClassIfDictionaryExists(cname)
Definition: PyROOTFixes.py:38
python.PyROOTFixes.enable_tree_fixes
def enable_tree_fixes()
Definition: PyROOTFixes.py:22
python.PyROOTFixes.fix_method
def fix_method(clname, methname)
Definition: PyROOTFixes.py:18