Exemple #1
0
    def test_output_reload(self):
        """ Outputs existing HwU histograms in the gnuplot format and makes sure
        that they remain identical when reloading them."""

        one_histo = histograms.HwUList([copy.copy(self.histo_list[0])])

        with misc.TMP_directory() as tmpdir:
            one_histo.output(pjoin(tmpdir, 'OUT'), format='gnuplot')
            new_histo = histograms.HwUList(pjoin(tmpdir, 'OUT.HwU'))

        one_histo = one_histo[0][0]
        one_histo.trim_auxiliary_weights()
        new_histo = new_histo[0]
        self.assertEqual(one_histo.type, new_histo.type)
        self.assertEqual(one_histo.title, new_histo.title)
        self.assertEqual(one_histo.x_axis_mode, new_histo.x_axis_mode)
        self.assertEqual(one_histo.y_axis_mode, new_histo.y_axis_mode)
        self.assertEqual(one_histo.bins.weight_labels,
                         new_histo.bins.weight_labels)
        self.assertEqual(len(one_histo.bins), len(new_histo.bins))
        for i, bin in enumerate(one_histo.bins):
            self.assertEqual(set(bin.wgts.keys()),
                             set(new_histo.bins[i].wgts.keys()))
            for label, wgt in bin.wgts.items():
                self.assertEqual(wgt, new_histo.bins[i].wgts[label])
Exemple #2
0
    def testIO_DJR_histograms(self):
        """ target: MLM_djrs_output.HwU
            target: MLM_djrs_output.gnuplot
            target: CKKWL_djrs_output.HwU
            target: CKKWL_djrs_output.gnuplot
        """
        # MLM first
        histos = histograms.HwUList(pjoin(_input_file_path, 'MLM_djrs.dat'),
                                    consider_reweights='ALL',
                                    run_id=0)
        histo_output_options = {
            'format':
            'gnuplot',
            'uncertainties':
            ['scale', 'pdf', 'statistical', 'merging_scale', 'alpsfact'],
            'ratio_correlations':
            True,
            'arg_string':
            'Automatic plotting from MG5aMC',
            'jet_samples_to_keep':
            None,
            'use_band': ['merging', 'alpsfact'],
            'auto_open':
            False
        }
        histos.output(pjoin(self.IOpath, 'MLM_djrs_output'),
                      **histo_output_options)
        histos_2 = histograms.HwUList(pjoin(self.IOpath,
                                            'MLM_djrs_output.HwU'))
        histos_2.output(pjoin(self.IOpath, 'MLM_djrs_output_2'),
                        **histo_output_options)
        self.assertEqual(
            open(pjoin(self.IOpath, 'MLM_djrs_output.HwU')).read(),
            open(pjoin(self.IOpath, 'MLM_djrs_output_2.HwU')).read())

        # then CKKWL
        histos = histograms.HwUList(pjoin(_input_file_path, 'CKKWL_djrs.dat'),
                                    consider_reweights='ALL',
                                    run_id=0)
        histo_output_options = {
            'format': 'gnuplot',
            'uncertainties': ['scale', 'pdf', 'statistical', 'merging_scale'],
            'ratio_correlations': True,
            'arg_string': 'Automatic plotting from MG5aMC',
            'jet_samples_to_keep': None,
            'use_band': ['merging'],
            'auto_open': False
        }
        histos.output(pjoin(self.IOpath, 'CKKWL_djrs_output'),
                      **histo_output_options)
        histos_2 = histograms.HwUList(
            pjoin(self.IOpath, 'CKKWL_djrs_output.HwU'))
        histos_2.output(pjoin(self.IOpath, 'CKKWL_djrs_output_2'),
                        **histo_output_options)
        self.assertEqual(
            open(pjoin(self.IOpath, 'CKKWL_djrs_output.HwU')).read(),
            open(pjoin(self.IOpath, 'CKKWL_djrs_output_2.HwU')).read())
 def create_HwUList(self):
     HwUs = []
     for obs in self:
         HwUs.append(obs.HwU)
     self.HwUList = histograms.HwUList(HwUs)
Exemple #4
0
    def setUp(self):
        """ Load the histograms"""

        # load the base histograms
        self.histo_list = histograms.HwUList(_HwU_source)
Exemple #5
0
 def testIO_gnuplot_histo_output(self):
     """ target: HistoOut.HwU
         target: HistoOut.gnuplot
     """
     histo_list = histograms.HwUList(_HwU_source)
     histo_list.output(pjoin(self.IOpath, 'HistoOut'), format='gnuplot')
    import madgraph.various.histograms as HwU 
except ZeroDivisionError:
    print "WARNING: Could not import the histograms package from MadGraph5_aMC@NLO.\n"+\
          "Make sure that the specified root path of your MG5aMC installation is correct: %s\n"%MG5aMC_root_path+\
          "Note: you can specify this path either by editing this script or through the env. variable MG5AMC or with the option --MGpath."
    sys.exit(1)


observable_to_histo_title = {'ptj1' : 'j1 pT',
                             'ptj2' : 'j2 pT',
                             'ptj3' : 'j3 pT',
                             'xsec' : 'total rate %s'%args.perturbative_order
                            }

# Find the histogram with the specified observable
all_histos = HwU.HwUList(args.HwU_path)
selected_histo = None
for histo in all_histos:
    #print "title: %s vs %s"%(histo.title, observable_to_histo_title[args.observable])
    if histo.title != observable_to_histo_title[args.observable]:
        continue
    # We do no need to check the type when interested in the overall xsec
    if args.observable=='xsec':
        selected_histo = histo
        break
    #print "type: %s vs %s"%(histo.type, args.perturbative_order)    
    if histo.type != args.perturbative_order:
        continue
    selected_histo = histo
    break
if selected_histo is None: