def test_zero_centred_error(self): """Test 0-centred band (ERROR)""" fn0 = get_fns('TMath::Gaus', (0, 2), (-10, 10)) fn1 = get_fns('TMath::Gaus', (0, 1), (-10, 10)) self.hdata.FillRandom(fn0[0], 20000) self.href.FillRandom(fn1[0], 10000) cmpfn = ZeroCentredBandRef() dqscore = cmpfn.compare(self.hdata, self.href, 3) self.assertEqual(dqscore['lvl'], ERROR_LEVELS.ERROR) dqscore = cmpfn.compare(self.hdata, self.href, None) self.assertEqual(dqscore['lvl'], ERROR_LEVELS.ERROR)
def setUp(self): self.href = TH1D('href1', '', 100, -10, 10) self.hdata = TH1D('hdata1', '', 100, -10, 10) self.hdata_bad = TH1D('hdata_bad', '', 100, -10, 10) fn = get_fns('TMath::Gaus', (0, 3), (-10, 10)) self.href.FillRandom(fn[0], 10000) fn = get_fns('TMath::Gaus', (0, 3), (-10, 10)) self.hdata.FillRandom(fn[0], 10000) fn = get_fns('TMath::Gaus', (1, 3), (-10, 10)) self.hdata_bad.FillRandom(fn[0], 10000)
def test_mean_width_diff_error(self): """Test mean and width check with reference (ERROR)""" fn0 = get_fns('TMath::Gaus', (0, 3), (-10, 10)) fn1 = get_fns('TMath::Gaus', (1, 2), (-10, 10)) self.hdata.FillRandom(fn0[0], 20000) self.href.FillRandom(fn1[0], 10000) cmpfn = MeanWidthDiffRef() # mean = 0 & 1, width = 3 & 2 (RMS) dqscore = cmpfn.compare(self.hdata, self.href, 0.1) self.assertTrue(dqscore['score'] < Score(30)) self.assertEqual(dqscore['lvl'], ERROR_LEVELS.ERROR)
def setUp(self): self.href = TH1D('href1', '', 100, -10, 10) self.hdata = TH1D('hdata1', '', 100, -10 ,10) self.hdata_bad = TH1D('hdata_bad', '', 100, -10 ,10) fn = get_fns('TMath::Gaus', (0, 3), (-10, 10)) self.href.FillRandom(fn[0], 10000) fn = get_fns('TMath::Gaus', (0, 3), (-10, 10)) self.hdata.FillRandom(fn[0], 10000) fn = get_fns('TMath::Gaus', (1, 3), (-10, 10)) self.hdata_bad.FillRandom(fn[0], 10000)
def test_mean_width_diff_ok(self): """Test mean and width check with reference (OK)""" fn = get_fns('TMath::Gaus', (0, 3), (-10, 10)) self.hdata.FillRandom(fn[0], 20000) self.href.FillRandom(fn[0], 10000) cmpfn = MeanWidthDiffRef() # mean = 0, width = 3 (RMS) dqscore = cmpfn.compare(self.hdata, self.href, 0.1) self.assertTrue(dqscore['score'] > Score(90)) self.assertEqual(dqscore['lvl'], ERROR_LEVELS.OK)
def setUp(self): """Create dictionaries and ROOT files needed for testing.""" self.rfdata = TFile('/tmp/fdata.root', 'recreate') self.rfref = TFile('/tmp/fref.root', 'recreate') fns = {} fns['pol0'] = get_simple_fns('5', (-10, 10)) fns['gauss01'] = get_fns('TMath::Gaus', (0, 1), (-10, 10)) fns['gauss02'] = get_fns('TMath::Gaus', (0, 2), (-10, 10)) fns['gauss03'] = get_fns('TMath::Gaus', (0, 3), (-10, 10)) fns['gauss12'] = get_fns('TMath::Gaus', (1, 2), (-10, 10)) fns['landau03'] = get_fns('TMath::Landau', (0, 3), (-10, 10)) N = 10000 rho = N/100.0 comp_fns = [] comp_fns.append((FloorThreshold(), rho - 5*sqrt(rho), 'pol0', 'pol0', OK, 'FT1')) # 5 sigma comp_fns.append((FloorThreshold(), rho - sqrt(rho), 'pol0', 'pol0', ERROR, 'FT2')) # 1 sigma comp_fns.append((CeilingThreshold(), rho + 5*sqrt(rho), 'pol0', 'pol0', OK, 'CT1')) # 5 sigma comp_fns.append((CeilingThreshold(), rho + sqrt(rho), 'pol0', 'pol0', ERROR, 'CT2')) # 1 sigma comp_fns.append((MeanWidthDiffRef(), 0.1, 'gauss03', 'gauss03', OK, 'MWDR1')) comp_fns.append((MeanWidthDiffRef(), 0.1, 'gauss03', 'gauss12', ERROR, 'MWDR2')) comp_fns.append((ZeroCentredBandRef(), 5, 'gauss01', 'gauss01', OK, 'ZCBR1')) # 5 sigma comp_fns.append((ZeroCentredBandRef(), 3, 'gauss01', 'gauss02', ERROR, 'ZCBR2')) # 3 sigma # comp_fns.append( , , 'landau03', 'landau03', ) comb_dict = {} eval_dict = {} self.results = [] for i in comp_fns: name = '{}_{}_{}'.format(i[5], i[2], id(i)) # unique form: <name>_<fn>_<id> hname = 'hist_' + name cname = name + '_Combiner' # should be of the form: *Combiner comb_dict[cname] = create_leaf_dict_with_path(hname) eval_dict[cname] = {'Function': i[0], 'Argument': i[1]} href = TH1D(hname, '', 100, -10 ,10) href.FillRandom(fns[i[2]][0], N) self.rfref.WriteTObject(href) del href hdata = TH1D(hname, '', 100, -10 ,10) hdata.FillRandom(fns[i[3]][0], N) self.rfdata.WriteTObject(hdata) del hdata self.results.append((cname, i[4])) comb_dict = { 'MasterCombiner': merge_dicts( {"weight": 1.0, "minWW": 10, "minWE": 25, "minEW": 1, "minEE": 2}, comb_dict) } self.results.append(('MasterCombiner', ERROR)) # close files cleanly self.rfdata.Close() self.rfref.Close() self.mycombiner = Combiner(comb_dict, eval_dict, self.rfdata.GetName(), self.rfref.GetName()) self.mycombiner.evaluate()
def setUp(self): """Create dictionaries and ROOT files needed for testing.""" self.tdir = tempfile.mkdtemp() self.rfdata = TFile(os.path.join(self.tdir, 'fdata.root'), 'recreate') self.rfref = TFile(os.path.join(self.tdir, 'fref.root'), 'recreate') fns = {} fns['pol0'] = get_simple_fns('5', (-10, 10)) fns['gauss01'] = get_fns('TMath::Gaus', (0, 1), (-10, 10)) fns['gauss02'] = get_fns('TMath::Gaus', (0, 2), (-10, 10)) fns['gauss03'] = get_fns('TMath::Gaus', (0, 3), (-10, 10)) fns['gauss12'] = get_fns('TMath::Gaus', (1, 2), (-10, 10)) fns['landau03'] = get_fns('TMath::Landau', (0, 3), (-10, 10)) N = 10000 rho = N / 100.0 comp_fns = [] comp_fns.append((FloorThreshold(), rho - 5 * TMath.Sqrt(rho), 'pol0', 'pol0', OK, 'FT1')) # 5 sigma comp_fns.append((FloorThreshold(), rho - TMath.Sqrt(rho), 'pol0', 'pol0', ERROR, 'FT2')) # 1 sigma comp_fns.append((CeilingThreshold(), rho + 5 * TMath.Sqrt(rho), 'pol0', 'pol0', OK, 'CT1')) # 5 sigma comp_fns.append((CeilingThreshold(), rho + TMath.Sqrt(rho), 'pol0', 'pol0', ERROR, 'CT2')) # 1 sigma comp_fns.append( (MeanWidthDiffRef(), 0.1, 'gauss03', 'gauss03', OK, 'MWDR1')) comp_fns.append( (MeanWidthDiffRef(), 0.1, 'gauss03', 'gauss12', ERROR, 'MWDR2')) comp_fns.append((ZeroCentredBandRef(), 5, 'gauss01', 'gauss01', OK, 'ZCBR1')) # 5 sigma comp_fns.append((ZeroCentredBandRef(), 3, 'gauss01', 'gauss02', ERROR, 'ZCBR2')) # 3 sigma # comp_fns.append( , , 'landau03', 'landau03', ) comb_dict = {} eval_dict = {} childNames = [] self.results = [] for i in comp_fns: name = '{}_{}_{}'.format(i[5], i[2], id(i)) # unique form: <name>_<fn>_<id> hname = 'hist_' + name cname = name + '_Combiner' # should be of the form: *Combiner childNames.append(cname) comb_dict[cname] = { "weight": 1.0, "maxError": 50, "maxWarning": 80, "path": hname } eval_dict[cname] = {'Function': i[0], 'Argument': i[1]} href = TH1D(hname, '', 100, -10, 10) href.FillRandom(fns[i[2]][0], N) self.rfref.WriteTObject(href) del href hdata = TH1D(hname, '', 100, -10, 10) hdata.FillRandom(fns[i[3]][0], N) self.rfdata.WriteTObject(hdata) del hdata self.results.append((cname, i[4])) comb_dict['MasterCombiner'] = { "weight": 1.0, "minWW": 10, "minWE": 25, "minEW": 1, "minEE": 2, "children": childNames } self.results.append(('MasterCombiner', ERROR)) # close files cleanly self.rfdata.Close() self.rfref.Close() self.mycombiner = RootCombiner(comb_dict, eval_dict, self.rfdata.GetName(), self.rfref.GetName(), 0) self.mycombiner.evaluate()
def setUp(self): self.hist = TH1D('hist', '', 100, -10, 10) fn = get_fns('TMath::Gaus', (0, 3), (-10, 10)) self.hist.FillRandom(fn[0], 10000) self.delta = 0.05 # 5%