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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 372 of file utils.py.

References HcalAutoPedestalValidator.epsilon, HcalPedestalWidthsCheck.epsilon, HcalPedestalsCheck.epsilon, HcalGainsCheck.epsilon, utils.BinToBin.epsilon, utils.BinToBin1percent.epsilon, MuonGeometrySanityCheck.tolerance, and utils.BinToBin1percent.tolerance.

372  def __init__(self, threshold=1):
373  StatisticalTest.__init__(self, threshold)
374  self.name='BinToBin1percent'
375  self.epsilon= 0.000001
376  self.tolerance= 0.01
377 
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.BinToBin1percent.checkBinningMatches (   self)

Definition at line 378 of file utils.py.

References funct.abs(), utils.BinToBin.checkBinningMatches(), utils.BinToBin1percent.checkBinningMatches(), utils.BinToBin1percent.do_test(), HcalAutoPedestalValidator.epsilon, HcalPedestalsCheck.epsilon, HcalPedestalWidthsCheck.epsilon, HcalGainsCheck.epsilon, utils.BinToBin.epsilon, utils.BinToBin1percent.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.BinToBin1percent.checkBinningMatches().

378  def checkBinningMatches(self):
379  if self.h1.GetNbinsX() != self.h2.GetNbinsX() \
380  or self.h1.GetNbinsY() != self.h2.GetNbinsY() \
381  or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \
382  or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \
383  or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \
384  or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \
385  or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \
386  or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \
387  or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon:
388  return False
389  return True
390 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ do_test()

def utils.BinToBin1percent.do_test (   self)

Definition at line 391 of file utils.py.

References funct.abs(), utils.ask_ok(), 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(), FastTimerService_cff.range, MuonGeometrySanityCheck.tolerance, and utils.BinToBin1percent.tolerance.

Referenced by utils.BinToBin1percent.checkBinningMatches().

391  def do_test(self):
392  # fist check that binning matches
393  if not self.checkBinningMatches():
394  return test_codes["DIFF_BIN"]
395  # then do the real check
396  equal = 1
397  nbins = getNbins(self.h1)
398  n_ok_bins=0.0
399  for ibin in range(0,nbins):
400  ibin+=1
401  h1bin=self.h1.GetBinContent(ibin)
402  h2bin=self.h2.GetBinContent(ibin)
403  bindiff=h1bin-h2bin
404 
405  binavg=.5*(h1bin+h2bin)
406 
407  if binavg==0 or 100*abs(bindiff)/binavg < self.tolerance:
408  n_ok_bins+=1
409  #print "Bin %i bin: bindiff %s" %(ibin,bindiff)
410  else:
411  print("-->Bin %i bin: bindiff %s (%s - %s )" %(ibin,bindiff,h1bin,h2bin))
412 
413  #if abs(bindiff)!=0 :
414  #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
415 
416  rank=n_ok_bins/nbins
417 
418  if rank!=1:
419  print("%s nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins))
420 
421  return rank
422 #-------------------------------------------------------------------------------
423 Statistical_Tests={"KS":KS,
424  "Chi2":Chi2,
425  "BinToBin":BinToBin,
426  "BinToBin1percent":BinToBin1percent,
427  "Bin2Bin":BinToBin,
428  "b2b":BinToBin,}
429 #-------------------------------------------------------------------------------
430 
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.BinToBin1percent.epsilon

◆ name

utils.BinToBin1percent.name

◆ tolerance

utils.BinToBin1percent.tolerance

Definition at line 376 of file utils.py.

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