CMS 3D CMS Logo

Public Member Functions | Public Attributes

utils::Chi2 Class Reference

Inheritance diagram for utils::Chi2:
utils::StatisticalTest

List of all members.

Public Member Functions

def __init__
def absval
def check_filled_bins
def do_test

Public Attributes

 name

Detailed Description

Definition at line 238 of file utils.py.


Constructor & Destructor Documentation

def utils::Chi2::__init__ (   self,
  threshold 
)

Reimplemented from utils::StatisticalTest.

Definition at line 239 of file utils.py.

00240                                :
00241     StatisticalTest.__init__(self,threshold)
00242     self.name="Chi2"     


Member Function Documentation

def utils::Chi2::absval (   self)

Definition at line 254 of file utils.py.

00255                   :
00256     nbins=getNbins(self.h1)
00257     binc=0
00258     for i in xrange(1,nbins):
00259       for h in self.h1,self.h2:
00260         binc=h.GetBinContent(i)
00261         if binc<0:
00262           h.SetBinContent(i,-1*binc)
00263         if h.GetBinError(i)==0 and binc!=0:
00264           #print "Histo ",h.GetName()," Bin:",i,"-Content:",h.GetBinContent(i)," had zero error"
00265           h.SetBinContent(i,0)
00266 

def utils::Chi2::check_filled_bins (   self,
  min_filled 
)

Definition at line 243 of file utils.py.

00244                                         :
00245     nbins=self.h1.GetNbinsX()
00246     n_filled_l=[]
00247     for h in self.h1,self.h2:
00248       nfilled=0.
00249       for ibin in xrange(1,nbins+1):
00250         if h.GetBinContent(ibin)>0:
00251           nfilled+=1
00252       n_filled_l.append(nfilled)
00253     return len(filter (lambda x:x>=min_filled,n_filled_l) )>0

def utils::Chi2::do_test (   self)

Reimplemented from utils::StatisticalTest.

Definition at line 267 of file utils.py.

00268                    :
00269     self.absval()
00270     if self.check_filled_bins(3):
00271       if self.h1.InheritsFrom("TProfile") or  (self.h1.GetEntries()!=self.h1.GetSumOfWeights()):
00272         chi2=self.h1.Chi2Test(self.h2,'WW')
00273         #if chi2==0: print "DEBUG",self.h1.GetName(),"Chi2 is:", chi2
00274         return chi2
00275       else:
00276         return self.h1.Chi2Test(self.h2,'UU')
00277     else:
00278       return 1
00279       #return test_codes["FEW_BINS"]
00280 
00281 #-------------------------------------------------------------------------------


Member Data Documentation

Reimplemented from utils::StatisticalTest.

Definition at line 239 of file utils.py.