def get_pdf(pdfset, parton, q, xs):
	"""get the PDF (xfx) for a certain set, parton, x and Q"""

	lhapdf.initPDFSetByName(pdfset)
	npdfs = lhapdf.numberPDF()
	pdf = np.zeros((npdfs, len(xs)))

	for member in range(1, npdfs + 1):
		lhapdf.initPDF(member)
		for (i, xi) in enumerate(xs):
			if parton < 7:
				pdf[member - 1][i] = lhapdf.xfx(xi, q, parton)
			elif parton == 7:
				#DVAL 1-(-1)
				pdf[member - 1][i] = lhapdf.xfx(xi, q, 1) - \
								 lhapdf.xfx(xi, q, -1)
			elif parton == 8:
				#UVAL 2-(-2)
				pdf[member - 1][i] = lhapdf.xfx(xi, q, 2) - \
								 lhapdf.xfx(xi, q, -2)
			elif parton == 9:
				#Light sea: xS=2(xubar + xdbar + xsbar)
				pdf[member - 1][i] = 2*(lhapdf.xfx(xi, q, -1) + \
								 lhapdf.xfx(xi, q, -2) + \
								 lhapdf.xfx(xi, q, -3))
			else:
				raise ValueError('Parton id not in range 0...9')
	return pdf
Beispiel #2
0
    def _get_lhapdf_flavor(self, flavor, lhgrid_filename):

        lhapdf.initPDFSetByName(lhgrid_filename)
        npdfs = lhapdf.numberPDF()
        pdf = numpy.zeros((npdfs + 1, self._xrange.size))
        for member in range(0, npdfs + 1):
            lhapdf.initPDF(member)
            for (i, xi) in enumerate(self._xrange):
                if flavor < 7:
                    pdf[member][i] = lhapdf.xfx(xi, self._q, flavor)
                elif flavor == 7:
                    #DVAL 1-(-1)
                    pdf[member][i] = lhapdf.xfx(xi, self._q, 1) - \
                                     lhapdf.xfx(xi, self._q, -1)
                elif flavor == 8:
                    #UVAL 2-(-2)
                    pdf[member][i] = lhapdf.xfx(xi, self._q, 2) - \
                                     lhapdf.xfx(xi, self._q, -2)
                elif flavor == 9:
                    #Light sea: xS=2(xubar + xdbar + xsbar)
                    pdf[member][i] = 2*(lhapdf.xfx(xi, self._q, -1) + \
                                     lhapdf.xfx(xi, self._q, -2) + \
                                     lhapdf.xfx(xi, self._q, -3))
                else:
                    raise Exception('Flavor not defined')
        return pdf
        retval = 0.
    if jet[0].Pt() < 30. or jet[1].Pt() < 30.:
        retval = 0.
    if ROOT.TMath.Abs(jet[0].Eta()) > 4.7 or ROOT.TMath.Abs(jet[1].Eta()) > 4.7:
        retval = 0.

    return retval
    

        
if __name__ == "__main__":

    # This here has to match the generation info in run_card.dat
    
    lhapdf.initPDFSetByName("cteq6ll.LHpdf")
    lhapdf.initPDF(0)
    mjj_min = 150.
    detajj_min = 1.5

    # Be careful, this thing will stash all the weights in memory.
    # It shouldn't be much, but don't go crazy with extremely large LHE files

    print 'Reading WmWm EWK + QCD'
    WmWmEWKQCD = readFiles(['../WmWm_VBS_QED4_QCD99_SM/Events/run_01/unweighted_events.lhe',
                            '../WmWm_VBS_QED4_QCD99_SM/Events/run_02/unweighted_events.lhe',
                            '../WmWm_VBS_QED4_QCD99_SM/Events/run_03/unweighted_events.lhe',
                            '../WmWm_VBS_QED4_QCD99_SM/Events/run_04/unweighted_events.lhe',
                            '../WmWm_VBS_QED4_QCD99_SM/Events/run_05/unweighted_events.lhe',
                            '../WmWm_VBS_QED4_QCD99_SM/Events/run_06/unweighted_events.lhe'])
    print 'Reading WmWm EWK'
    WmWmEWK = readFiles(['../WmWm_VBS_QED4_QCD0_SM/Events/run_01/unweighted_events.lhe',
Beispiel #4
0
import matplotlib
# import mpmath as mp
import numpy as np
# import pylab as pl
# from scipy import interpolate, signal
import matplotlib.font_manager as fm
from matplotlib.ticker import MultipleLocator
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.path as path

## import LHAPDF and initialize PDFs
import lhapdf
## initializes PDF member object (for protons)
lhapdf.initPDFSetByName("cteq6ll.LHpdf")
lhapdf.initPDF(0)


## what follows depends on matplotlib/numpy
## (taken from http://matplotlib.org/examples/api/histogram_path_demo.html)
def generate_histo(array, name):

    fig, ax = plt.subplots()
    n, bins = np.histogram(array, 30)

    # get the corners of the rectangles for the histogram
    left = np.array(bins[:-1])
    right = np.array(bins[1:])
    bottom = np.zeros(len(left))
    top = bottom + n