コード例 #1
0
    def setUp(self):
        """Create dictionaries needed by combiners."""

        dirname = os.path.dirname(__file__) + '/'
        orfdata = TFile(os.path.abspath(dirname+'data/dqm_data.root'), 'read')
        orfref = TFile(os.path.abspath(dirname+'data/dqm_ref.root'), 'read')

        # valid ROOT files
        assert(not orfdata.IsZombie())
        assert(not orfref.IsZombie())

        self.rfdata = TFile('/tmp/fdata.root', 'recreate')
        self.rfref = TFile('/tmp/fref.root', 'recreate')

        # histogram names: folder, old name, new name
        hist_recipes = [
            ('Velo/VeloClusterMonitor', '# VELO clusters', 'velo_clusters'),
            ('Velo/VeloClusterMonitor', '# VELO clusters (zoom)', 'velo_clusters_zoom'),
            ('Velo/VeloClusterMonitor', 'Cluster size', 'cluster_size')
        ]

        # comparison fns: fn, options, expected DQ status, histogram
        # to compare
        comp_fns = [
            (KolmogorovSmirnovTest(), '', OK, 0),      # Velo clusters
            (KolmogorovSmirnovTest(), '', OK, 1),
            # (KolmogorovSmirnovTest(), '', ERROR, 2), # cluster size
            (Chi2Test(), '', OK, 0),
            (Chi2Test(), '', OK, 1),
            (Chi2Test(), 'chi2/ndf', OK, 0),
            (Chi2Test(), 'chi2/ndf', OK, 1),
            # (Chi2Test(), '', ERROR, 2),
            # (Chi2Test(), 'chi2/ndf', ERROR, 2)
        ]
        # FIXME: Does not work with cluster size because of really
        # small errors; see commit message for detailed explanation.

        comb_dict = {}
        eval_dict = {}
        self.results = []
        for i in comp_fns:
            # last element is histogram name index
            hname = hist_recipes[i[-1]][-1]
            # should be of the form: *Combiner
            cname = '{}_{}_{}_Combiner'.format(hname, type(i[0]).__name__, i[1])
            comb_dict[cname] = create_leaf_dict_with_path(hname)
            eval_dict[cname] = {'Function': i[0], 'Argument': i[1]}
            # expected result
            self.results.append((cname, i[2]))

        comb_dict = {
            'MasterCombiner': merge_dicts(
                {"weight": 1.0, "minWW": 10, "minWE": 25, "minEW": 1, "minEE": 2},
                comb_dict)
        }
        self.results.append(('MasterCombiner', OK))

        # histograms: make, save, and cleanup
        for recipe in hist_recipes:
            href = orfref.Get('/'.join(recipe[:-1]))
            href.SetName(recipe[-1])
            self.rfref.WriteTObject(href)
            del href
            hdata = orfdata.Get('/'.join(recipe[:-1]))
            hdata.SetName(recipe[-1])
            self.rfdata.WriteTObject(hdata)
            del hdata
        self.rfref.Close()
        self.rfdata.Close()

        self.mycombiner = Combiner(comb_dict, eval_dict,
                                   self.rfdata.GetName(), self.rfref.GetName())
        self.mycombiner.evaluate()
コード例 #2
0
    def setUp(self):
        """Create dictionaries needed by combiners."""

        dirname = os.path.dirname(__file__) + '/'
        orfdata = TFile(os.path.abspath(dirname+'data/dqm_data.root'), 'read')
        orfref = TFile(os.path.abspath(dirname+'data/dqm_ref.root'), 'read')

        # valid ROOT files
        assert(not orfdata.IsZombie())
        assert(not orfref.IsZombie())

        self.rfdata = TFile('/tmp/fdata.root', 'recreate')
        self.rfref = TFile('/tmp/fref.root', 'recreate')

        # histogram recipes: function to call, dir in orig ROOT file,
        # rest of the arguments for function (orig hist name, new hist
        # name, other options, etc)
        hist_recipes = [
            (get_avg_trend, 'Vetra/NoiseMon/ADCCMSuppressed',
             ('RMSNoise_vs_ChipChannel', 'AvgRMSNoise_trend')),
            (get_avg_hist, 'Vetra/NoiseMon/ADCCMSuppressed',
             ('RMSNoise_vs_ChipChannel', 'AvgRMSNoise_all')),
            (get_avg_hist, 'Vetra/NoiseMon/ADCCMSuppressed',
             ('RMSNoise_vs_ChipChannel', 'AvgRMSNoise_R', 'r')),
            (get_avg_hist, 'Vetra/NoiseMon/ADCCMSuppressed',
             ('RMSNoise_vs_ChipChannel', 'AvgRMSNoise_Phi', 'p')),
            # (get_avg_hist, 'Vetra/VeloPedestalSubtractorMoni',
            #  ('Ped_Sub_ADCs_Profile', 'Ped_Sub_ADCs_all'))
        ]

        # comparison fns: fn, argument, expected DQ status, histogram
        # to compare
        comp_fns = [
            (FloorThreshold(), 1.5, OK, 0), # avg noise trend
            (CeilingThreshold(), 2.5, OK, 0),
            (MeanWidthDiffRef(), 0.1, OK, 1), # avg all TELL1 noise
            (MeanWidthDiffRef(), 0.1, OK, 2), # avg R TELL1 noise
            (MeanWidthDiffRef(), 0.1, OK, 3), # avg Phi TELL1 noise
            # (ZeroCentredBandRef(), 5, OK, 4), # pedestal subtracted ADC
        ]

        # FIXME: add uniformity tests, maybe in different test file

        comb_dict = {}
        eval_dict = {}
        self.results = []
        for i in comp_fns:
            # i[] - recipe #, last element in recipe, 2nd argument
            hname = hist_recipes[i[-1]][-1][1]
            # should be of the form: *Combiner
            cname = '{}_{}_Combiner'.format(hname, type(i[0]).__name__)
            comb_dict[cname] = create_leaf_dict_with_path(hname)
            eval_dict[cname] = {'Function': i[0], 'Argument': i[1]}
            # expected result
            self.results.append((cname, i[2]))

        comb_dict = {
            'MasterCombiner': merge_dicts(
                {"weight": 1.0, "minWW": 10, "minWE": 25, "minEW": 1, "minEE": 2},
                comb_dict)
        }
        self.results.append(('MasterCombiner', OK))

        # histograms: make, save, and cleanup
        for recipe in hist_recipes:
            href = recipe[0](orfref.GetDirectory(recipe[1]), *recipe[2])
            self.rfref.WriteTObject(href)
            del href
            hdata = recipe[0](orfdata.GetDirectory(recipe[1]), *recipe[2])
            self.rfdata.WriteTObject(hdata)
            del hdata
        self.rfref.Close()
        self.rfdata.Close()

        self.mycombiner = Combiner(comb_dict, eval_dict,
                                   self.rfdata.GetName(), self.rfref.GetName())
        self.mycombiner.evaluate()
コード例 #3
0
    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()