CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 238 of file utils.py.

Constructor & Destructor Documentation

def utils.Chi2.__init__ (   self,
  threshold 
)

Definition at line 239 of file utils.py.

240  def __init__(self, threshold):
241  StatisticalTest.__init__(self,threshold)
242  self.name="Chi2"
def __init__
Definition: utils.py:239

Member Function Documentation

def utils.Chi2.absval (   self)

Definition at line 254 of file utils.py.

References utils.getNbins(), FitSlicesYTool.h1, ConfigurableHisto.h1, XmasToDQMSource.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().

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

Definition at line 243 of file utils.py.

References FitSlicesYTool.h1, ConfigurableHisto.h1, XmasToDQMSource.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().

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

Definition at line 266 of file utils.py.

Referenced by utils.Chi2.do_test().

267  def check_histograms(self, histogram):
268  if histogram.InheritsFrom("TProfile") or (histogram.GetEntries()!=histogram.GetSumOfWeights()):
269  return 'W'
270  else:
271  return 'U'
def check_histograms
Definition: utils.py:266
def utils.Chi2.do_test (   self)

Definition at line 272 of file utils.py.

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

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

Member Data Documentation

utils.Chi2.name

Definition at line 241 of file utils.py.

Referenced by dataset.Dataset.__getFileInfoList(), cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), BeautifulSoup.Tag._invert(), and Vispa.Views.PropertyView.Property.valueChanged().