CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
utils.BinToBin1percent Class Reference
Inheritance diagram for utils.BinToBin1percent:
utils.StatisticalTest

Public Member Functions

def __init__ (self, threshold=1)
 
def checkBinningMatches (self)
 
def do_test (self)
 
- Public Member Functions inherited from utils.StatisticalTest
def __init__ (self, threshold)
 
def do_test (self)
 
def get_rank (self)
 
def get_status (self)
 
def set_operands (self, h1, h2)
 

Public Attributes

 epsilon
 
 name
 
 tolerance
 
- Public Attributes inherited from utils.StatisticalTest
 h1
 
 h2
 
 is_init
 
 name
 
 rank
 2D! return test_codes["2D"] More...
 
 threshold
 

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 354 of file utils.py.

Constructor & Destructor Documentation

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

Definition at line 360 of file utils.py.

360  def __init__(self, threshold=1):
361  StatisticalTest.__init__(self, threshold)
362  self.name='BinToBin1percent'
363  self.epsilon= 0.000001
364  self.tolerance= 0.01
365 
def __init__(self, threshold=1)
Definition: utils.py:360

Member Function Documentation

def utils.BinToBin1percent.checkBinningMatches (   self)

Definition at line 366 of file utils.py.

References funct.abs(), learn_.epsilon, HcalAutoPedestalValidator.epsilon, HcalPedestalsCheck.epsilon, HcalPedestalWidthsCheck.epsilon, HcalGainsCheck.epsilon, utils.BinToBin.epsilon, and utils.BinToBin1percent.epsilon.

Referenced by utils.BinToBin1percent.do_test().

367  if self.h1.GetNbinsX() != self.h2.GetNbinsX() \
368  or self.h1.GetNbinsY() != self.h2.GetNbinsY() \
369  or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \
370  or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \
371  or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \
372  or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \
373  or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \
374  or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \
375  or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon:
376  return False
377  return True
378 
def checkBinningMatches(self)
Definition: utils.py:366
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def utils.BinToBin1percent.do_test (   self)

Definition at line 379 of file utils.py.

References funct.abs(), utils.BinToBin.checkBinningMatches(), utils.BinToBin1percent.checkBinningMatches(), DQMStore.checkBinningMatches(), utils.getNbins(), FitSlicesYTool.h1, ConfigurableHisto.h1, DQMSourceExample.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, MuonGeometrySanityCheck.tolerance, and utils.BinToBin1percent.tolerance.

379  def do_test(self):
380  # fist check that binning matches
381  if not self.checkBinningMatches():
382  return test_codes["DIFF_BIN"]
383  # then do the real check
384  equal = 1
385  nbins = getNbins(self.h1)
386  n_ok_bins=0.0
387  for ibin in xrange(0,nbins):
388  ibin+=1
389  h1bin=self.h1.GetBinContent(ibin)
390  h2bin=self.h2.GetBinContent(ibin)
391  bindiff=h1bin-h2bin
392 
393  binavg=.5*(h1bin+h2bin)
394 
395  if binavg==0 or 100*abs(bindiff)/binavg < self.tolerance:
396  n_ok_bins+=1
397  #print "Bin %i bin: bindiff %s" %(ibin,bindiff)
398  else:
399  print "-->Bin %i bin: bindiff %s (%s - %s )" %(ibin,bindiff,h1bin,h2bin)
400 
401  #if abs(bindiff)!=0 :
402  #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
403 
404  rank=n_ok_bins/nbins
405 
406  if rank!=1:
407  print "%s nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins)
408 
409  return rank
410 #-------------------------------------------------------------------------------
411 Statistical_Tests={"KS":KS,
412  "Chi2":Chi2,
413  "BinToBin":BinToBin,
414  "BinToBin1percent":BinToBin1percent,
415  "Bin2Bin":BinToBin,
416  "b2b":BinToBin,}
417 #-------------------------------------------------------------------------------
418 
def checkBinningMatches(self)
Definition: utils.py:366
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def do_test(self)
Definition: utils.py:379
def getNbins(h)
Definition: utils.py:89

Member Data Documentation

utils.BinToBin1percent.epsilon

Definition at line 363 of file utils.py.

Referenced by utils.BinToBin1percent.checkBinningMatches().

utils.BinToBin1percent.name
utils.BinToBin1percent.tolerance

Definition at line 364 of file utils.py.

Referenced by utils.BinToBin1percent.do_test().