CMS 3D CMS Logo

Public Member Functions | Public Attributes

utils::BinToBin1percent Class Reference

Inheritance diagram for utils::BinToBin1percent:
utils::StatisticalTest

List of all members.

Public Member Functions

def __init__
def checkBinningMatches
def do_test

Public Attributes

 epsilon
 name
 tolerance

Detailed Description

The bin to bin comparison builds a fake pvalue. It is 0 if the number of 
bins is different. It is % of corresponding bins otherwhise.
A threshold of 1 is needed to require a 1 to 1 correspondance between 
hisograms.

Definition at line 359 of file utils.py.


Constructor & Destructor Documentation

def utils::BinToBin1percent::__init__ (   self,
  threshold = 1 
)

Reimplemented from utils::StatisticalTest.

Definition at line 365 of file utils.py.

00366                                  :
00367     StatisticalTest.__init__(self, threshold)
00368     self.name='BinToBin1percent'
00369     self.epsilon= 0.000001
00370     self.tolerance= 0.01


Member Function Documentation

def utils::BinToBin1percent::checkBinningMatches (   self)

Definition at line 371 of file utils.py.

00372                                :
00373     if self.h1.GetNbinsX() != self.h2.GetNbinsX() \
00374            or self.h1.GetNbinsY() != self.h2.GetNbinsY() \
00375            or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \
00376            or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \
00377            or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \
00378            or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \
00379            or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \
00380            or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \
00381            or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon:
00382       return False
00383     return True

def utils::BinToBin1percent::do_test (   self)

Reimplemented from utils::StatisticalTest.

Definition at line 384 of file utils.py.

00385                    :
00386     # fist check that binning matches
00387     if not self.checkBinningMatches():
00388       return test_codes["DIFF_BIN"]
00389     # then do the real check
00390     equal = 1
00391     nbins = getNbins(self.h1)
00392     n_ok_bins=0.0
00393     for ibin in xrange(0,nbins):
00394       ibin+=1
00395       h1bin=self.h1.GetBinContent(ibin)
00396       h2bin=self.h2.GetBinContent(ibin)
00397       bindiff=h1bin-h2bin
00398 
00399       binavg=.5*(h1bin+h2bin)
00400 
00401       if binavg==0 or 100*abs(bindiff)/binavg < self.tolerance:
00402         n_ok_bins+=1
00403         #print "Bin %i bin: bindiff %s" %(ibin,bindiff)
00404       else:
00405         print "-->Bin %i bin: bindiff %s (%s - %s )" %(ibin,bindiff,h1bin,h2bin)
00406 
00407       #if abs(bindiff)!=0 :
00408         #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
00409     
00410     rank=n_ok_bins/nbins
00411     
00412     if rank!=1:
00413       print "%s nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins)
00414     
00415     return rank
00416 #-------------------------------------------------------------------------------
00417 Statistical_Tests={"KS":KS,
00418                    "Chi2":Chi2,
00419                    "BinToBin":BinToBin,
00420                    "BinToBin1percent":BinToBin1percent,
00421                    "Bin2Bin":BinToBin,
00422                    "b2b":BinToBin,}
00423 #-------------------------------------------------------------------------------  


Member Data Documentation

Definition at line 365 of file utils.py.

Reimplemented from utils::StatisticalTest.

Definition at line 365 of file utils.py.

Definition at line 365 of file utils.py.