CMS 3D CMS Logo

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__ (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
 
- 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

◆ __init__()

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

Definition at line 315 of file utils.py.

References HcalAutoPedestalValidator.epsilon, HcalPedestalWidthsCheck.epsilon, HcalPedestalsCheck.epsilon, HcalGainsCheck.epsilon, and utils.BinToBin.epsilon.

315  def __init__(self, threshold=1):
316  StatisticalTest.__init__(self, threshold)
317  self.name='BinToBin'
318  self.epsilon= 0.000001
319 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ checkBinningMatches()

def utils.BinToBin.checkBinningMatches (   self)

Definition at line 320 of file utils.py.

References funct.abs(), utils.BinToBin.checkBinningMatches(), utils.BinToBin.do_test(), HcalAutoPedestalValidator.epsilon, HcalPedestalsCheck.epsilon, HcalPedestalWidthsCheck.epsilon, HcalGainsCheck.epsilon, utils.BinToBin.epsilon, ConfigurableHisto.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, FitSlicesYTool.h1, EgammaTowerIsolationNew< NC >::Sum.h2, ConfigurableHisto.h2, EgammaTowerIsolationNew< NC >.h2, utils.StatisticalTest.h2, PlotAlignmentValidation::DMRPlotInfo.h2, and FitSlicesYTool.h2.

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

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

◆ do_test()

def utils.BinToBin.do_test (   self)

Definition at line 333 of file utils.py.

References funct.abs(), HcalAutoPedestalValidator.epsilon, HcalPedestalsCheck.epsilon, HcalPedestalWidthsCheck.epsilon, HcalGainsCheck.epsilon, utils.BinToBin.epsilon, utils.getNbins(), ConfigurableHisto.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, FitSlicesYTool.h1, EgammaTowerIsolationNew< NC >::Sum.h2, ConfigurableHisto.h2, EgammaTowerIsolationNew< NC >.h2, utils.StatisticalTest.h2, PlotAlignmentValidation::DMRPlotInfo.h2, FitSlicesYTool.h2, print(), and isotrackApplyRegressor.range.

Referenced by utils.BinToBin.checkBinningMatches().

333  def do_test(self):
334  # fist check that binning matches
335  if not self.checkBinningMatches():
336  return test_codes["DIFF_BIN"]
337  # then do the real check
338  equal = 1
339  nbins = getNbins(self.h1)
340  n_ok_bins=0.0
341  for ibin in range(0, nbins):
342  h1bin=self.h1.GetBinContent(ibin)
343  h2bin=self.h2.GetBinContent(ibin)
344  bindiff=h1bin-h2bin
345 
346  binavg=.5*(h1bin+h2bin)
347 
348  if binavg==0 or abs(bindiff) < self.epsilon:
349  n_ok_bins+=1
350  #print("Bin %ibin: bindiff %s" %(ibin,bindiff))
351  else:
352  print("Bin %ibin: bindiff %s" %(ibin,bindiff))
353 
354  #if abs(bindiff)!=0 :
355  #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
356 
357  rank=n_ok_bins/nbins
358 
359  if rank!=1:
360  print("Histogram %s differs: nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins))
361 
362  return rank
363 
364 #-------------------------------------------------------------------------------
365 
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(h)
Definition: utils.py:94

Member Data Documentation

◆ epsilon

utils.BinToBin.epsilon

◆ name

utils.BinToBin.name