CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes
utils_v2.Chi2Test Class Reference
Inheritance diagram for utils_v2.Chi2Test:
utils_v2.StatisticalTest

Public Member Functions

def do_test (self, h1, h2)
 
def enough_filled_bins (self, h, bin_count, more_than=3)
 
def make_absolute (self, h, bin_count)
 
- Public Member Functions inherited from utils_v2.StatisticalTest
def do_test (self, h1, h2)
 
def get_N_bins (self, h)
 
def is_empty (self, h)
 

Static Public Attributes

 name
 
- Static Public Attributes inherited from utils_v2.StatisticalTest
 name
 

Detailed Description

Definition at line 347 of file utils_v2.py.

Member Function Documentation

◆ do_test()

def utils_v2.Chi2Test.do_test (   self,
  h1,
  h2 
)

Definition at line 367 of file utils_v2.py.

References utils_v2.Chi2Test.enough_filled_bins(), utils_v2.StatisticalTest.get_N_bins(), and utils_v2.Chi2Test.make_absolute().

367  def do_test(self, h1, h2):
368  p_value = super(Chi2Test, self).do_test(h1, h2)
369  if p_value is not None:
370  return p_value
371 
372  bin_count = self.get_N_bins(h1)
373 
374  # Make histograms absolute.
375  self.make_absolute(h1, bin_count)
376  self.make_absolute(h2, bin_count)
377 
378  # Check if there is enough filled bins in bouth histograms.
379  if not self.enough_filled_bins(h1, bin_count) or\
380  not self.enough_filled_bins(h2, bin_count):
381  return 1
382 
383  if h1.InheritsFrom("TProfile") or (h1.GetEntries() != h1.GetSumOfWeights()):
384  return h1.Chi2Test(h2, 'WW')
385  return h1.Chi2Test(h2, 'UU')
386 
387 

◆ enough_filled_bins()

def utils_v2.Chi2Test.enough_filled_bins (   self,
  h,
  bin_count,
  more_than = 3 
)

Definition at line 358 of file utils_v2.py.

References isotrackApplyRegressor.range.

Referenced by utils_v2.Chi2Test.do_test().

358  def enough_filled_bins(self, h, bin_count, more_than=3):
359  filled_bins = 0
360  for i in range(1, bin_count):
361  if h.GetBinContent(i) > 0:
362  filled_bins += 1
363  if filled_bins > more_than:
364  return True
365  return False
366 

◆ make_absolute()

def utils_v2.Chi2Test.make_absolute (   self,
  h,
  bin_count 
)

Definition at line 350 of file utils_v2.py.

References isotrackApplyRegressor.range.

Referenced by utils_v2.Chi2Test.do_test().

350  def make_absolute(self, h, bin_count):
351  for i in range(1, bin_count): # Why here is no +1?
352  content = h.GetBinContent(i)
353  if content < 0:
354  h.SetBinContent(i, -1 * content)
355  if h.GetBinError(i) == 0 and content != 0:
356  h.SetBinContent(i, 0)
357 

Member Data Documentation

◆ name

utils_v2.Chi2Test.name
static