sys.stderr.write("It looks like you want to put %s in your LD_LIBRARY_PATH and PYTHONPATH shell variables.\n"%ROOTLIBDIR)
else:
sys.stderr.write("You should make sure that the directory containing libPyROOT and ROOT.py is in your LD_LIBRARY_PATH and PYTHONPATH shell variables.\n")
sys.stderr.write("You can test if PyROOT is properly set up by calling 'import ROOT' at the interactive Python shell\n")
sys.exit(1)
## Try to load faster but non-standard cElementTree module
try:
importxml.etree.cElementTreeasET
exceptImportError:
try:
importcElementTreeasET
exceptImportError:
try:
importxml.etree.ElementTreeasET
except:
sys.stderr.write("Can't load the ElementTree XML parser: please install it!\n")
sys.exit(1)
classHisto:
def__init__(self,nDim):
self._points=[]
self.name=""
self.title=""
self._nDim=nDim
defaddPoint(self,dp):
ifdp.dimensionality()!=self._nDim:
er="Tried to add a datapoint of dimensionality "+str(dp.dimensionality())+" to a histogram of dimensionality "+str(self._nDim)
sys.stderr.write(er)
sys.exit(1)
self._points.append(dp)
defnumPts(self):
returnlen(self._points)
defasTGraph(self):
tg=TGraph()
tg.SetName(self.name)
tg.SetTitle(self.title)
returntg
defasHisto(self):
tg=self.asTGraph()
histo=tg.Histogram().Clone()
returnhisto
@staticmethod
defequalFloats(left,right,precision=1.e-6):
try:
test=abs((left-right)/(left+right))
returntest<precision
exceptZeroDivisionError:
ifleft*right<0.:
returnFalse
else:
returnTrue
returnFalse
classHisto2D(Histo):
def__init__(self):
Histo.__init__(self,3)
defasTGraph(self):
xs=array.array("d",[])
ex=array.array("d",[])
ys=array.array("d",[])
ey=array.array("d",[])
zs=array.array("d",[])
ez=array.array("d",[])
forptinself._points:
x=pt.mean(0)
erx=pt.er(0)
y=pt.mean(1)
ery=pt.er(1)
z=pt.mean(2)
erz=pt.er(2)
xs.append(x)
ex.append(erx)
ys.append(y)
ey.append(ery)
zs.append(z)
ez.append(erz)
ifself.numPts()==0:
tg=TGraph2DErrors()
er="Tried to create TGraph2DErrors called "+self.name+" with zero datapoints"