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 352 of file utils.py.
00353 : 00354 if self.h1.GetNbinsX() != self.h2.GetNbinsX() \ 00355 or self.h1.GetNbinsY() != self.h2.GetNbinsY() \ 00356 or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \ 00357 or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \ 00358 or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \ 00359 or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \ 00360 or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \ 00361 or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \ 00362 or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon: 00363 return False 00364 return True
def utils::BinToBin1percent::do_test | ( | self | ) |
Reimplemented from utils::StatisticalTest.
Definition at line 365 of file utils.py.
00366 : 00367 # fist check that binning matches 00368 if not self.checkBinningMatches(): 00369 return test_codes["DIFF_BIN"] 00370 # then do the real check 00371 equal = 1 00372 nbins = getNbins(self.h1) 00373 n_ok_bins=0.0 00374 for ibin in xrange(0,nbins): 00375 ibin+=1 00376 h1bin=self.h1.GetBinContent(ibin) 00377 h2bin=self.h2.GetBinContent(ibin) 00378 bindiff=h1bin-h2bin 00379 00380 binavg=.5*(h1bin+h2bin) 00381 00382 if binavg==0 or 100*abs(bindiff)/binavg < self.tolerance: 00383 n_ok_bins+=1 00384 #print "Bin %i bin: bindiff %s" %(ibin,bindiff) 00385 else: 00386 print "-->Bin %i bin: bindiff %s (%s - %s )" %(ibin,bindiff,h1bin,h2bin) 00387 00388 #if abs(bindiff)!=0 : 00389 #print "Bin %ibin: bindiff %s" %(ibin,bindiff) 00390 00391 rank=n_ok_bins/nbins 00392 00393 if rank!=1: 00394 print "%s nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins) 00395 00396 return rank 00397 #------------------------------------------------------------------------------- 00398 Statistical_Tests={"KS":KS, 00399 "Chi2":Chi2, 00400 "BinToBin":BinToBin, 00401 "BinToBin1percent":BinToBin1percent, 00402 "Bin2Bin":BinToBin, 00403 "b2b":BinToBin,} 00404 #-------------------------------------------------------------------------------
Reimplemented from utils::StatisticalTest.