Public Member Functions | |
def | __init__ |
def | checkBinningMatches |
def | do_test |
Public Attributes | |
epsilon | |
name | |
tolerance |
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.
def utils::BinToBin1percent::__init__ | ( | self, | |
threshold = 1 |
|||
) |
Reimplemented from utils::StatisticalTest.
def utils::BinToBin1percent::checkBinningMatches | ( | self | ) |
Definition at line 370 of file utils.py.
00371 : 00372 if self.h1.GetNbinsX() != self.h2.GetNbinsX() \ 00373 or self.h1.GetNbinsY() != self.h2.GetNbinsY() \ 00374 or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \ 00375 or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \ 00376 or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \ 00377 or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \ 00378 or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \ 00379 or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \ 00380 or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon: 00381 return False 00382 return True
def utils::BinToBin1percent::do_test | ( | self | ) |
Reimplemented from utils::StatisticalTest.
Definition at line 383 of file utils.py.
00384 : 00385 # fist check that binning matches 00386 if not self.checkBinningMatches(): 00387 return test_codes["DIFF_BIN"] 00388 # then do the real check 00389 equal = 1 00390 nbins = getNbins(self.h1) 00391 n_ok_bins=0.0 00392 for ibin in xrange(0,nbins): 00393 ibin+=1 00394 h1bin=self.h1.GetBinContent(ibin) 00395 h2bin=self.h2.GetBinContent(ibin) 00396 bindiff=h1bin-h2bin 00397 00398 binavg=.5*(h1bin+h2bin) 00399 00400 if binavg==0 or 100*abs(bindiff)/binavg < self.tolerance: 00401 n_ok_bins+=1 00402 #print "Bin %i bin: bindiff %s" %(ibin,bindiff) 00403 else: 00404 print "-->Bin %i bin: bindiff %s (%s - %s )" %(ibin,bindiff,h1bin,h2bin) 00405 00406 #if abs(bindiff)!=0 : 00407 #print "Bin %ibin: bindiff %s" %(ibin,bindiff) 00408 00409 rank=n_ok_bins/nbins 00410 00411 if rank!=1: 00412 print "%s nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins) 00413 00414 return rank 00415 #------------------------------------------------------------------------------- 00416 Statistical_Tests={"KS":KS, 00417 "Chi2":Chi2, 00418 "BinToBin":BinToBin, 00419 "BinToBin1percent":BinToBin1percent, 00420 "Bin2Bin":BinToBin, 00421 "b2b":BinToBin,} 00422 #-------------------------------------------------------------------------------
Reimplemented from utils::StatisticalTest.