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.Chi2 Class Reference
Inheritance diagram for utils.Chi2:
utils.StatisticalTest

Public Member Functions

def __init__
 
def absval
 
def check_filled_bins
 
def check_histograms
 
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

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

Detailed Description

Definition at line 246 of file utils.py.

Constructor & Destructor Documentation

def utils.Chi2.__init__ (   self,
  threshold 
)

Definition at line 247 of file utils.py.

248  def __init__(self, threshold):
249  StatisticalTest.__init__(self,threshold)
250  self.name="Chi2"
def __init__
Definition: utils.py:247

Member Function Documentation

def utils.Chi2.absval (   self)

Definition at line 262 of file utils.py.

References 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, and sistrip::SpyUtilities.range().

Referenced by utils.Chi2.do_test().

263  def absval(self):
264  nbins=getNbins(self.h1)
265  binc=0
266  for i in range(0,nbins):
267  for h in self.h1,self.h2:
268  binc=h.GetBinContent(i)
269  if binc<0:
270  h.SetBinContent(i,-1*binc)
271  if h.GetBinError(i)==0 and binc!=0:
272  #print "Histo ",h.GetName()," Bin:",i,"-Content:",h.GetBinContent(i)," had zero error"
273  h.SetBinContent(i,0)
def absval
Definition: utils.py:262
const uint16_t range(const Frame &aFrame)
def getNbins
Definition: utils.py:94
def utils.Chi2.check_filled_bins (   self,
  min_filled 
)

Definition at line 251 of file utils.py.

References 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, and sistrip::SpyUtilities.range().

Referenced by utils.Chi2.do_test().

252  def check_filled_bins(self,min_filled):
253  nbins=self.h1.GetNbinsX()
254  n_filled_l=[]
255  for h in self.h1,self.h2:
256  nfilled=0.
257  for ibin in range(0,nbins+2):
258  if h.GetBinContent(ibin)>0:
259  nfilled+=1
260  n_filled_l.append(nfilled)
261  return len([x for x in n_filled_l if x>=min_filled] )>0
def check_filled_bins
Definition: utils.py:251
const uint16_t range(const Frame &aFrame)
def utils.Chi2.check_histograms (   self,
  histogram 
)

Definition at line 274 of file utils.py.

Referenced by utils.Chi2.do_test().

275  def check_histograms(self, histogram):
276  if histogram.InheritsFrom("TProfile") or (histogram.GetEntries()!=histogram.GetSumOfWeights()):
277  return 'W'
278  else:
279  return 'U'
def check_histograms
Definition: utils.py:274
def utils.Chi2.do_test (   self)

Definition at line 280 of file utils.py.

References utils.Chi2.absval(), utils.Chi2.check_filled_bins(), utils.Chi2.check_histograms(), 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.

281  def do_test(self):
282  self.absval()
283  if self.check_filled_bins(3):
284  #if self.h1.InheritsFrom("TProfile") or (self.h1.GetEntries()!=self.h1.GetSumOfWeights()):
285  # chi2=self.h1.Chi2Test(self.h2,'WW')
286  # #if chi2==0: print "DEBUG",self.h1.GetName(),"Chi2 is:", chi2
287  # return chi2
288  #else:
289  # return self.h1.Chi2Test(self.h2,'UU')
290  hist1 = self.check_histograms(self.h1)
291  hist2 = self.check_histograms(self.h2)
292  if hist1 =='W' and hist2 =='W': ##in case
293  chi2 = self.h1.Chi2Test(self.h2,'WW') ## the both histograms are weighted
294  return chi2
295  elif hist1 == 'U' and hist2 == 'U':
296  chi2 = self.h1.Chi2Test(self.h2,'UU') ##the both histograms are unweighted
297  return chi2
298  elif hist1 == 'U' and hist2 == 'W':
299  chi2 = self.h1.Chi2Test(self.h2,'UW') ## 1st histogram is unweighted, 2nd weighted
300  return chi2
301  elif hist1 == 'W' and hist2 == 'U':
302  chi2 = self.h2.Chi2Test(self.h1,'UW') ## 1 is wieghted, 2nd unweigthed. so flip order to make a UW comparison
303  return chi2
304  else:
305  return 1
306  #return test_codes["FEW_BINS"]
307 
308 #-------------------------------------------------------------------------------
def do_test
Definition: utils.py:280
def absval
Definition: utils.py:262
def check_filled_bins
Definition: utils.py:251
def check_histograms
Definition: utils.py:274

Member Data Documentation

utils.Chi2.name

Definition at line 249 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().