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

Constructor & Destructor Documentation

◆ __init__()

def utils.Chi2.__init__ (   self,
  threshold 
)

Definition at line 247 of file utils.py.

247  def __init__(self, threshold):
248  StatisticalTest.__init__(self,threshold)
249  self.name="Chi2"
250 
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

◆ absval()

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 FastTimerService_cff.range.

Referenced by utils.Chi2.do_test().

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

◆ check_filled_bins()

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 FastTimerService_cff.range.

Referenced by utils.Chi2.do_test().

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

◆ check_histograms()

def utils.Chi2.check_histograms (   self,
  histogram 
)

Definition at line 274 of file utils.py.

Referenced by utils.Chi2.do_test().

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

◆ do_test()

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.

280  def do_test(self):
281  self.absval()
282  if self.check_filled_bins(3):
283  #if self.h1.InheritsFrom("TProfile") or (self.h1.GetEntries()!=self.h1.GetSumOfWeights()):
284  # chi2=self.h1.Chi2Test(self.h2,'WW')
285  # #if chi2==0: print "DEBUG",self.h1.GetName(),"Chi2 is:", chi2
286  # return chi2
287  #else:
288  # return self.h1.Chi2Test(self.h2,'UU')
289  hist1 = self.check_histograms(self.h1)
290  hist2 = self.check_histograms(self.h2)
291  if hist1 =='W' and hist2 =='W':
292  chi2 = self.h1.Chi2Test(self.h2,'WW')
293  return chi2
294  elif hist1 == 'U' and hist2 == 'U': chi2 = self.h1.Chi2Test(self.h2,'UU')
295  return chi2
296  elif hist1 == 'U' and hist2 == 'W': chi2 = self.h1.Chi2Test(self.h2,'UW')
297  return chi2
298  elif hist1 == 'W' and hist2 == 'U': chi2 = self.h2.Chi2Test(self.h1,'UW')
299  return chi2
300  else:
301  return 1
302  #return test_codes["FEW_BINS"]
303 
304 #-------------------------------------------------------------------------------
305 
306 

Member Data Documentation

◆ name

utils.Chi2.name