示例#1
0
def main(
		pdfset,
		flavours,
		output_filename,
		n_points,
		q,
		q2,  # q2 instead of q
		members,
		folder):
	"""evaluate a PDF set and write the resuling TGraph to disk"""

	if folder is not None and not os.path.exists(folder):
		os.makedirs(folder)
	out = ROOT.TFile((folder+"/" if folder is not None else "") + output_filename, "RECREATE")
	x_values = np.logspace(-4, -0.01, n_points)  # TODO get min, max x from PDF set

	## Version info, search paths, and metadata
	print "LHAPDF version", lhapdf.version()
	lhapdf.pathsPrepend(os.getcwd())
	lhapdf.setVerbosity(0)
	print "LHAPDF paths",lhapdf.paths()
	pset = lhapdf.getPDFSet(pdfset)
	print pset.description
	n_members = pset.size
	if members is not None:
		n_members=members

	# iterate over flavours, get pdfgraph, write
	for flavour in flavours:
		tgraph = get_pdf_tgraph(pset, flavour, x_values, n_points, n_members, q, q2)
		tgraph.Write(partondict[flavour].replace(' ', '_'))

	print "Written to", output_filename
	out.Close()
示例#2
0
文件: mkUncPDF.py 项目: UAEDF/vbfHbb
def prepare(opts):
	lhapdf.setVerbosity(opts.verbosity)
	makeDirs(os.path.split(opts.fout)[0])
	jsonsamp = json.loads(filecontent(opts.jsonsamp))
	jsonvars = json.loads(filecontent(opts.jsonvars))
	jsoninfo = json.loads(filecontent(opts.jsoninfo))
	jsonpdfs = json.loads(filecontent(opts.jsonpdfs))
	jsons = {'samp':jsonsamp,'vars':jsonvars,'info':jsoninfo,'pdfs':jsonpdfs}
	# fix binning
	if opts.binning:
		for v in opts.binning:
			#print v
			jsons['vars']['variables'][v[0]]['nbins_x'] = v[1]
			jsons['vars']['variables'][v[0]]['xmin'] = v[2]
			jsons['vars']['variables'][v[0]]['xmax'] = v[3]
	return jsons
示例#3
0
def setup_pdf_objs(all_pdfs, cache={}):
    import lhapdf
    lhapdf.setVerbosity(1)
    os.environ['LHAPDF_DATA_PATH'] = '/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/lhapdf/6.2.1-7149a/x86_64-centos7-gcc8-opt/share/LHAPDF/'

    paths = [
    '/cvmfs/sft.cern.ch/lcg/external/lhapdfsets/current/',
    ]
    lhapdf.setPaths(paths)

    pdf_objs = {}
    for p in all_pdfs:
        if p in cache:
            pdf_objs[p] = cache[p]
        else:
            pdf_objs[p] = lhapdf.mkPDF(p)
            cache[p] = pdf_objs[p]
    return pdf_objs
示例#4
0
def prepare(opts):
    lhapdf.setVerbosity(opts.verbosity)
    makeDirs(os.path.split(opts.fout)[0])
    jsonsamp = json.loads(filecontent(opts.jsonsamp))
    jsonvars = json.loads(filecontent(opts.jsonvars))
    jsoninfo = json.loads(filecontent(opts.jsoninfo))
    jsonpdfs = json.loads(filecontent(opts.jsonpdfs))
    jsons = {
        'samp': jsonsamp,
        'vars': jsonvars,
        'info': jsoninfo,
        'pdfs': jsonpdfs
    }
    # fix binning
    if opts.binning:
        for v in opts.binning:
            #print v
            jsons['vars']['variables'][v[0]]['nbins_x'] = v[1]
            jsons['vars']['variables'][v[0]]['xmin'] = v[2]
            jsons['vars']['variables'][v[0]]['xmax'] = v[3]
    return jsons
示例#5
0
文件: test.py 项目: felixhekhorn/PhD
#!/usr/bin/python
import numpy as np
from sys import path
path.append("./")

import DSSV
DSSV.dssvini()

import lhapdf
lhapdf.setVerbosity(0)
pdf = lhapdf.mkPDF("DSSV2014",0);

def DSSVxfxQ2(pid,x,Q2):
	DUV,DDV,DUBAR,DDBAR,DSTR,DGLU = DSSV.dssvgupdate(x,Q2)
	if -2 == pid: return DDBAR
	if -1 == pid: return DUBAR
	if 1 == pid: return DUBAR+DUV
	if 2 == pid: return DDBAR+DDV
	if 3 == pid or -3 == pid: return DSTR
	if 21 == pid: return DGLU
	raise "unknown PID"

pids = [-3, -2, -1, 1, 2, 3, 21]

xs = """1.000000e-05 4.000000e-05 6.700000e-05 1.000000e-04 1.400000e-04 2.000000e-04 3.000000e-04 4.500000e-04 6.700000e-04 1.000000e-03 1.400000e-03 2.000000e-03 3.000000e-03 4.500000e-03 6.700000e-03 1.000000e-02 1.400000e-02 2.000000e-02 3.000000e-02 4.500000e-02 6.000000e-02 8.000000e-02 1.000000e-01 1.250000e-01 1.500000e-01 1.750000e-01 2.000000e-01 2.250000e-01 2.500000e-01 2.750000e-01 3.000000e-01 3.250000e-01 3.500000e-01 3.750000e-01 4.000000e-01 4.500000e-01 5.000000e-01 5.500000e-01 6.000000e-01 6.500000e-01 7.000000e-01 7.500000e-01 8.000000e-01 8.500000e-01 9.000000e-01 9.500000e-01 1.000000e+00"""
Qs = """8.944272e-01 1.000000e+00 1.118034e+00 1.224745e+00 1.414214e+00 1.581139e+00 2.000000e+00 2.529822e+00 3.162278e+00 3.872983e+00 5.000000e+00 6.324555e+00 8.000000e+00 1.000000e+01 1.341641e+01 1.788854e+01 2.408319e+01 3.162278e+01 4.242641e+01 5.656854e+01 7.615773e+01 1.000000e+02 1.341641e+02 1.788854e+02 2.408319e+02 3.162278e+02 4.242641e+02 5.656854e+02 7.615773e+02 1.000000e+03"""

def printGrid():
	for xx in xs.split(" "):
		x = float(xx)
		for QQ in Qs.split(" "):
示例#6
0
#!/usr/bin/env python3

import json
import lhapdf
import argparse
from rich.console import Console
from pycompressor.pdfgrid import XGrid
from pycompressor.pdfgrid import PdfSet
from pycompressor.errfunction import ErfComputation

console = Console()
lhapdf.setVerbosity(0)

NF = 4
Q0 = 1.65
EST_DIC = {
    "corr_estimators": ["correlation"],
    "stat_estimators": ["kolmogorov_smirnov"],
    "moment_estimators": ["mean", "stdev", "skewness", "kurtosis"],
}


def arg_parser():
    """Perse input argument"""

    parser = argparse.ArgumentParser(
        description="Compute the ERFs between two PDFs.")
    parser.add_argument(
        "-p",
        "--prior",
        type=str,