CMS 3D CMS Logo

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__ (self, threshold)
 
def absval (self)
 
def check_filled_bins (self, min_filled)
 
def check_histograms (self, histogram)
 
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

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

Constructor & Destructor Documentation

def utils.Chi2.__init__ (   self,
  threshold 
)

Definition at line 235 of file utils.py.

235  def __init__(self, threshold):
236  StatisticalTest.__init__(self,threshold)
237  self.name="Chi2"
238 
def __init__(self, threshold)
Definition: utils.py:235

Member Function Documentation

def utils.Chi2.absval (   self)

Definition at line 250 of file utils.py.

References utils.getNbins(), FitSlicesYTool.h1, ConfigurableHisto.h1, DQMSourceExample.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, FitSlicesYTool.h2, EgammaTowerIsolationNew< NC >::Sum.h2, ConfigurableHisto.h2, EgammaTowerIsolationNew< NC >.h2, DQMSourceExample.h2, utils.StatisticalTest.h2, and PlotAlignmentValidation::DMRPlotInfo.h2.

Referenced by utils.Chi2.do_test().

250  def absval(self):
251  nbins=getNbins(self.h1)
252  binc=0
253  for i in xrange(1,nbins):
254  for h in self.h1,self.h2:
255  binc=h.GetBinContent(i)
256  if binc<0:
257  h.SetBinContent(i,-1*binc)
258  if h.GetBinError(i)==0 and binc!=0:
259  #print "Histo ",h.GetName()," Bin:",i,"-Content:",h.GetBinContent(i)," had zero error"
260  h.SetBinContent(i,0)
261 
def absval(self)
Definition: utils.py:250
def getNbins(h)
Definition: utils.py:89
def utils.Chi2.check_filled_bins (   self,
  min_filled 
)

Definition at line 239 of file utils.py.

References FitSlicesYTool.h1, ConfigurableHisto.h1, DQMSourceExample.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, FitSlicesYTool.h2, EgammaTowerIsolationNew< NC >::Sum.h2, ConfigurableHisto.h2, EgammaTowerIsolationNew< NC >.h2, DQMSourceExample.h2, utils.StatisticalTest.h2, and PlotAlignmentValidation::DMRPlotInfo.h2.

Referenced by utils.Chi2.do_test().

239  def check_filled_bins(self,min_filled):
240  nbins=self.h1.GetNbinsX()
241  n_filled_l=[]
242  for h in self.h1,self.h2:
243  nfilled=0.
244  for ibin in xrange(1,nbins+1):
245  if h.GetBinContent(ibin)>0:
246  nfilled+=1
247  n_filled_l.append(nfilled)
248  return len(filter (lambda x:x>=min_filled,n_filled_l) )>0
249 
def check_filled_bins(self, min_filled)
Definition: utils.py:239
def utils.Chi2.check_histograms (   self,
  histogram 
)

Definition at line 262 of file utils.py.

Referenced by utils.Chi2.do_test().

262  def check_histograms(self, histogram):
263  if histogram.InheritsFrom("TProfile") or (histogram.GetEntries()!=histogram.GetSumOfWeights()):
264  return 'W'
265  else:
266  return 'U'
267 
def check_histograms(self, histogram)
Definition: utils.py:262
def utils.Chi2.do_test (   self)

Definition at line 268 of file utils.py.

References utils.Chi2.absval(), utils.Chi2.check_filled_bins(), utils.Chi2.check_histograms(), FitSlicesYTool.h1, ConfigurableHisto.h1, DQMSourceExample.h1, utils.StatisticalTest.h1, PlotAlignmentValidation::DMRPlotInfo.h1, FitSlicesYTool.h2, EgammaTowerIsolationNew< NC >::Sum.h2, ConfigurableHisto.h2, EgammaTowerIsolationNew< NC >.h2, DQMSourceExample.h2, utils.StatisticalTest.h2, and PlotAlignmentValidation::DMRPlotInfo.h2.

268  def do_test(self):
269  self.absval()
270  if self.check_filled_bins(3):
271  #if self.h1.InheritsFrom("TProfile") or (self.h1.GetEntries()!=self.h1.GetSumOfWeights()):
272  # chi2=self.h1.Chi2Test(self.h2,'WW')
273  # #if chi2==0: print "DEBUG",self.h1.GetName(),"Chi2 is:", chi2
274  # return chi2
275  #else:
276  # return self.h1.Chi2Test(self.h2,'UU')
277  hist1 = self.check_histograms(self.h1)
278  hist2 = self.check_histograms(self.h2)
279  if hist1 =='W' and hist2 =='W': ##in case
280  chi2 = self.h1.Chi2Test(self.h2,'WW') ## the both histograms are weighted
281  return chi2
282  elif hist1 == 'U' and hist2 == 'U':
283  chi2 = self.h1.Chi2Test(self.h2,'UU') ##the both histograms are unweighted
284  return chi2
285  elif hist1 == 'U' and hist2 == 'W':
286  chi2 = self.h1.Chi2Test(self.h2,'UW') ## 1st histogram is unweighted, 2nd weighted
287  return chi2
288  elif hist1 == 'W' and hist2 == 'U':
289  chi2 = self.h2.Chi2Test(self.h1,'UW') ## 1 is wieghted, 2nd unweigthed. so flip order to make a UW comparison
290  return chi2
291  else:
292  return 1
293  #return test_codes["FEW_BINS"]
294 
295 #-------------------------------------------------------------------------------
296 
def do_test(self)
Definition: utils.py:268
def absval(self)
Definition: utils.py:250
def check_filled_bins(self, min_filled)
Definition: utils.py:239
def check_histograms(self, histogram)
Definition: utils.py:262

Member Data Documentation

utils.Chi2.name