ATLAS Offline Software
Classes | Functions | Variables
python.PyRootLib Namespace Reference

Classes

class  Linear
 
class  OptionStyle
 
class  Polynom
 
class  Style
 

Functions

def importRoot (batch=True)
 
def setupRootStyle ()
 
def rtString (inStr)
 style.SetPadTopMargin(0.05); style.SetPadRightMargin(0.05); style.SetPadBottomMargin(0.16); style.SetPadLeftMargin(0.15); More...
 

Variables

string __author__ = 'Sebastien Binet'
 
string __doc__ = "a set of classes to ease the day-to-day work with ROOT."
 
list _root_files = []
 globals ----------------------------------------------------------------— More...
 
def ROOT = importRoot()
 

Function Documentation

◆ importRoot()

def python.PyRootLib.importRoot (   batch = True)

Definition at line 17 of file PyRootLib.py.

17 def importRoot( batch = True ):
18  import os
19  import ROOT
20  x_display = None
21  if batch:
22  ROOT.gROOT.SetBatch(True)
23  if 'DISPLAY' in os.environ:
24  x_display = os.environ['DISPLAY']
25  del os.environ['DISPLAY']
26 
27 
28  ROOT.gErrorIgnoreLevel = ROOT.kError
29  if ROOT.gROOT.GetVersionInt() >= 51800:
30  ROOT.kOrange
31  ROOT.kMyBlue = ROOT.kBlue -4
32  ROOT.kMyRed = ROOT.kRed -4
33  ROOT.kMyGreen = ROOT.kGreen+1
34  ROOT.kDarkGreen = ROOT.kGreen +1
35  else:
36  ROOT.kOrange = ROOT.kYellow
37  ROOT.kMyBlue = ROOT.kBlue
38  ROOT.kMyRed = ROOT.kRed
39  ROOT.kMyGreen = ROOT.kGreen+100
40  ROOT.kDarkGreen = ROOT.kGreen +100
41 
42 
43  if batch:
44  if x_display:
45  os.environ['DISPLAY'] = x_display
46  #
47  # Root has a global dtor ordering problem: the cintex trampolines
48  # may be deleted before open files are closed. Workaround is to explicitly
49  # close open files before terminating.
50  #
51  global _root_files
52  def _close_files():
53  global _root_files
54  for f in _root_files:
55  if hasattr (f, 'Close'):
56  f.Close()
57  del _root_files[0:-1]
58  return
59  import atexit
60  atexit.register(_close_files)
61 
62  # monkey-patch TFile.Open to populate the _allfiles attribute
63  def fopen(*args):
64  global _root_files
65  f = ROOT.TFile.Open(*args)
66  if f not in _root_files:
67  _root_files.append(f)
68  return f
69  ROOT.fopen = fopen
70  return ROOT
71 

◆ rtString()

def python.PyRootLib.rtString (   inStr)

style.SetPadTopMargin(0.05); style.SetPadRightMargin(0.05); style.SetPadBottomMargin(0.16); style.SetPadLeftMargin(0.15);

normalize an input string (ie: it makes sure that it can be used by
ROOT as an id). eg: replaces '/' by '_'.

Definition at line 128 of file PyRootLib.py.

128 def rtString( inStr ):
129  """ normalize an input string (ie: it makes sure that it can be used by
130  ROOT as an id). eg: replaces '/' by '_'.
131  """
132  outStr = inStr\
133  .replace( '/', '_' )\
134  .replace( ':', '_' )\
135  .replace( '#', '_' )
136  return outStr
137 

◆ setupRootStyle()

def python.PyRootLib.setupRootStyle ( )
Somehow beautify the ugly default ROOT display style

Definition at line 74 of file PyRootLib.py.

74 def setupRootStyle():
75  """Somehow beautify the ugly default ROOT display style"""
76 
77  style = ROOT.gROOT.GetStyle( "Plain" )
78 
79  # no borders, white color
80  style.SetCanvasColor(ROOT.kWhite)
81  style.SetTitleFillColor(ROOT.kWhite)
82  #style.SetTitleBorderSize(0)
83 
84  # title in the middle
85  #style.SetTitleAlign(23)
86  style.SetTitleX(0.30)
87  style.SetTitleY(0.97)
88  style.SetTitleW(0.60)
89  #style.SetPadTopMargin(0.15)
90  style.SetTitleSize(0.035)
91  style.SetTitleOffset(1.1)
92  style.SetTitleSize(0.035,"Y")
93  style.SetTitleOffset(1.1,"Y")
94 
95  # canvas stuff
96  style.SetCanvasBorderSize(0)
97  style.SetCanvasDefH( 800)
98  style.SetCanvasDefW(1000)
99  style.SetFrameBorderMode(0)
100  style.SetFrameBorderSize(0)
101 
102  style.SetStatX(0.95)
103  style.SetStatY(0.9)
104  style.SetStatW(0.18)
105  style.SetStatH(0.2)
106  style.SetStatColor(ROOT.kWhite)
107  # style.SetAxisColor( ROOT.kBlack )
108  # style.SetAxisColor( ROOT.kBlack, "Y")
109  # style.SetLabelColor( ROOT.kBlack )
110  # style.SetLabelColor( ROOT.kBlack, "Y" )
111  style.SetLabelSize(0.04)
112  style.SetLabelSize(0.04,"Y")
113 

Variable Documentation

◆ __author__

string python.PyRootLib.__author__ = 'Sebastien Binet'
private

Definition at line 11 of file PyRootLib.py.

◆ __doc__

string python.PyRootLib.__doc__ = "a set of classes to ease the day-to-day work with ROOT."
private

Definition at line 12 of file PyRootLib.py.

◆ _root_files

list python.PyRootLib._root_files = []
private

globals ----------------------------------------------------------------—

Definition at line 15 of file PyRootLib.py.

◆ ROOT

def python.PyRootLib.ROOT = importRoot()

Definition at line 72 of file PyRootLib.py.

replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.PyRootLib.setupRootStyle
def setupRootStyle()
Definition: PyRootLib.py:74
python.PyRootLib.importRoot
def importRoot(batch=True)
Definition: PyRootLib.py:17
python.PyRootLib.rtString
def rtString(inStr)
style.SetPadTopMargin(0.05); style.SetPadRightMargin(0.05); style.SetPadBottomMargin(0....
Definition: PyRootLib.py:128