CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
utils.BinToBin Class Reference
Inheritance diagram for utils.BinToBin:
utils.StatisticalTest

Public Member Functions

def __init__
 
def checkBinningMatches
 
def do_test
 
- Public Member Functions inherited from utils.StatisticalTest
def __init__
 
def do_test
 
def get_rank
 
def get_status
 
def set_operands
 

Public Attributes

 epsilon
 
 name
 
- 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 309 of file utils.py.

Constructor & Destructor Documentation

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

Definition at line 315 of file utils.py.

316  def __init__(self, threshold=1):
317  StatisticalTest.__init__(self, threshold)
318  self.name='BinToBin'
319  self.epsilon= 0.000001
def __init__
Definition: utils.py:315

Member Function Documentation

def utils.BinToBin.checkBinningMatches (   self)

Definition at line 320 of file utils.py.

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

Referenced by utils.BinToBin.do_test(), and utils.BinToBin1percent.do_test().

321  def checkBinningMatches(self):
322  if self.h1.GetNbinsX() != self.h2.GetNbinsX() \
323  or self.h1.GetNbinsY() != self.h2.GetNbinsY() \
324  or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \
325  or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \
326  or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \
327  or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \
328  or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \
329  or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \
330  or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon:
331  return False
332  return True
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def checkBinningMatches
Definition: utils.py:320
def utils.BinToBin.do_test (   self)

Definition at line 333 of file utils.py.

References funct.abs(), utils.BinToBin.checkBinningMatches(), HcalAutoPedestalValidator.epsilon, HcalPedestalsCheck.epsilon, HcalPedestalWidthsCheck.epsilon, HcalGainsCheck.epsilon, utils.BinToBin.epsilon, utils.getNbins(), ConfigurableHisto.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, FitSlicesYTool.h1, print(), and sistrip::SpyUtilities.range().

334  def do_test(self):
335  # fist check that binning matches
336  if not self.checkBinningMatches():
337  return test_codes["DIFF_BIN"]
338  # then do the real check
339  equal = 1
340  nbins = getNbins(self.h1)
341  n_ok_bins=0.0
342  for ibin in range(0, nbins):
343  h1bin=self.h1.GetBinContent(ibin)
344  h2bin=self.h2.GetBinContent(ibin)
345  bindiff=h1bin-h2bin
346 
347  binavg=.5*(h1bin+h2bin)
348 
349  if binavg==0 or abs(bindiff) < self.epsilon:
350  n_ok_bins+=1
351  #print("Bin %ibin: bindiff %s" %(ibin,bindiff))
352  else:
353  print("Bin %ibin: bindiff %s" %(ibin,bindiff))
354 
355  #if abs(bindiff)!=0 :
356  #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
357 
358  rank=n_ok_bins/nbins
359 
360  if rank!=1:
361  print("Histogram %s differs: nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins))
362 
363  return rank
364 
365 #-------------------------------------------------------------------------------
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def getNbins
Definition: utils.py:94
def do_test
Definition: utils.py:333
def checkBinningMatches
Definition: utils.py:320

Member Data Documentation

utils.BinToBin.epsilon

Definition at line 318 of file utils.py.

Referenced by utils.BinToBin.checkBinningMatches(), utils.BinToBin1percent.checkBinningMatches(), and utils.BinToBin.do_test().

utils.BinToBin.name

Definition at line 317 of file utils.py.

Referenced by config.CFG.__str__(), geometryComparison.GeometryComparison.createScript(), validation.Sample.digest(), primaryVertexResolution.PrimaryVertexResolution.getRepMap(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), and VIDSelectorBase.VIDSelectorBase.initialize().