Skip to content

Commit

Permalink
Merge pull request #5 from jeriek/dev
Browse files Browse the repository at this point in the history
Minor updates for v1.0.2
  • Loading branch information
jeriek authored Jul 2, 2020
2 parents b9aca76 + 4fa83cf commit 4ce8fbc
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 75 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ see [https://arxiv.org/abs/2006.16273](https://arxiv.org/abs/2006.16273).
`xsec` is compatible with both Python 2.7 and 3.
The following external Python libraries are required to run `xsec`:

- Setuptools 20.7.0 or later
- NumPy 1.14 or later
- SciPy 1.0.0 or later
- Joblib 0.12.2 or later
- PySLHA 3.2.3 or later
- setuptools 20.7.0 or later
- numpy 1.14 or later
- scipy 1.0.0 or later
- joblib 0.12.2 or later
- dill 0.3.2 or later
- pyslha 3.2.3 or later

### `pip` installation
`xsec` can be installed from [PyPI](https://pypi.org/project/xsec/) using
Expand Down Expand Up @@ -67,9 +68,10 @@ The default option is `all`.
### Testing the installation
To check whether the `xsec` installation works properly, download the gluino pair production data (`gg`) and try a test cross-section evaluation:
```
xsec-test [GP_DIR]
xsec-download-gprocs -t gg [-g GP_DIR]
xsec-test [-g GP_DIR]
```
If no argument is given, the data is assumed to be in a directory called `gprocs` in the current working directory, otherwise the user-specified path `GP_DIR` is used.
If no argument is given to `xsec-test`, the data files are assumed to be in a subdirectory called `gprocs` in the current working directory, otherwise the user-specified path `GP_DIR` is used.

### Removing the package
Uninstalling `xsec` is as simple as running
Expand All @@ -78,7 +80,7 @@ pip uninstall xsec
```

## Code examples
An example main program showing how to use `xsec` can be found in the [`example_xsec_eval.py`](examples/example_xsec_eval.py) file. This shows evaluation both by specifying the model parameters by hand and by importing an SLHA file. An example showing a simple loop over parameters is available in [`example_xsec_loop.py`](examples/example_xsec_loop.py)
An example main program showing how to use `xsec` can be found in the [`example_xsec_eval.py`](examples/example_xsec_eval.py) file. This shows evaluation both by specifying the model parameters by hand and by importing an SLHA file. An example showing a simple loop over parameters is available in [`example_xsec_loop.py`](examples/example_xsec_loop.py).

## Licence

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.0.2
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ setuptools>=20.7.0
numpy>=1.14
scipy>=1.0.0
joblib>=0.13.2
dill>=0.3.2
pyslha>=3.2.3
148 changes: 89 additions & 59 deletions scripts/xsec-test
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,97 @@ Run a simple test instance of the evaluation module.
This script can be used as a basis for a more complete routine to
evaluate cross sections.
Use: xsec-test <directory-for-xsec-data>
If no argument <directory-for-xsec-data> is given, the code looks
for a folder called 'gprocs' in the current working directory.
Use: xsec-test [-g GP_DIR]
If no argument is given, the code looks for a folder called 'gprocs'
in the current working directory.
"""

import os
import sys
import argparse

# Import xsec, first assume we have pip installed it
try:
import xsec
# Someone is using our fine programme without pip installing
except ImportError:
# Our current absolute directory
abs_dir = os.path.dirname(os.path.abspath(__file__))
# Parent directory containing xsec
parent_dir = os.path.dirname(abs_dir)
sys.path.append(parent_dir)
import xsec

try:
input_dir = sys.argv[1]
except IndexError:
# By default, look for './gprocs'
cwd = os.getcwd()
input_dir = os.path.join(cwd, "gprocs")

# Set directory and cache choices
xsec.init(data_dir=input_dir) # run with default settings (no caching)

# Set center-of-mass energy (in GeV)
xsec.set_energy(13000)

# Load GP models for the specified process(es)
processes = [(1000021, 1000021)]
xsec.load_processes(processes)

# Enter parameter values
xsec.set_parameters(
{
"m1000021": 1000,
"m1000001": 500,
"m1000002": 500,
"m1000003": 500,
"m1000004": 500,
"m1000005": 500,
"m1000006": 500,
"m2000001": 500,
"m2000002": 500,
"m2000003": 500,
"m2000004": 500,
"m2000005": 500,
"m2000006": 500,
"sbotmix11": 0,
"stopmix11": 0,
"mean": 500,
}
)

# Evaluate the cross section with the given input parameters
xsec.eval_xsection()

# Finalise the evaluation procedure
xsec.finalise()

def main():
"""
Run a test cross-section evaluation for gluino pair production.
"""

# Get the script name
prog_name = "xsec-test"

# Set up the argument parser
parser = argparse.ArgumentParser(
prog=prog_name,
description="Tool for checking the xsec setup with a test evaluation.",
)

# Take the download directory as an optional argument
parser.add_argument(
"-g",
"--gp_dir",
nargs="?",
metavar="PATH",
type=str,
action="store",
default=os.path.join(os.getcwd(), "gprocs"),
help="set the path where the downloaded files are stored. "
"The default path is %(default)s",
)

# Parse the arguments
args = parser.parse_args()

# Import xsec, first assume we have pip installed it
try:
import xsec
# Someone is using our fine programme without pip installing
except ImportError:
# Our current absolute directory
abs_dir = os.path.dirname(os.path.abspath(__file__))
# Parent directory containing xsec
parent_dir = os.path.dirname(abs_dir)
sys.path.append(parent_dir)
import xsec

# Set directory and cache choices
xsec.init(data_dir=args.gp_dir) # run with default settings (no caching)

# Set center-of-mass energy (in GeV)
xsec.set_energy(13000)

# Load GP models for the specified process(es)
processes = [(1000021, 1000021)]
xsec.load_processes(processes)

# Enter parameter values
xsec.set_parameters(
{
"m1000021": 1000,
"m1000001": 500,
"m1000002": 500,
"m1000003": 500,
"m1000004": 500,
"m1000005": 500,
"m1000006": 500,
"m2000001": 500,
"m2000002": 500,
"m2000003": 500,
"m2000004": 500,
"m2000005": 500,
"m2000006": 500,
"sbotmix11": 0,
"stopmix11": 0,
"mean": 500,
}
)

# Evaluate the cross section with the given input parameters
xsec.eval_xsection()

# Finalise the evaluation procedure
xsec.finalise()


# When the code is executed as a script, run the following.
if __name__ == "__main__":
main()
20 changes: 13 additions & 7 deletions xsec/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,31 @@ def eval_xsection(verbose=2, check_consistency=True):
# the xsection value at the lower scale, but at the higher one,
# and vice versa for scaleup_rel.
# --- Get the DGP medians, discard regression errors on the variations
mu_dgp_scldn_rel, _ = np.array(list(zip(*dgp_results["scldn"])))
mu_dgp_sclup_rel, _ = np.array(list(zip(*dgp_results["sclup"])))
mu_dgp_scldn_rel, _ = np.array(
list(zip(*dgp_results["scldn"])), dtype=object
)
mu_dgp_sclup_rel, _ = np.array(
list(zip(*dgp_results["sclup"])), dtype=object
)

scaledown_rel = (
np.array(
list(map(np.min, list(zip(mu_dgp_scldn_rel, mu_dgp_sclup_rel))))
list(map(np.min, list(zip(mu_dgp_scldn_rel, mu_dgp_sclup_rel)))),
dtype=object,
)
- 1.0
)
scaleup_rel = (
np.array(
list(map(np.max, list(zip(mu_dgp_scldn_rel, mu_dgp_sclup_rel))))
list(map(np.max, list(zip(mu_dgp_scldn_rel, mu_dgp_sclup_rel)))),
dtype=object,
)
- 1.0
)

# -- Signed PDF errors divided by xsection_central
# --- Get the DGP medians, discard regression errors on the variations
delta_pdf_rel, _ = np.array(list(zip(*dgp_results["pdf"])))
delta_pdf_rel, _ = np.array(list(zip(*dgp_results["pdf"])), dtype=object)

pdfdown_rel = (-1.0) * np.abs(delta_pdf_rel)
pdfup_rel = np.abs(delta_pdf_rel)
Expand All @@ -172,8 +178,8 @@ def eval_xsection(verbose=2, check_consistency=True):
# calculated with upper and lower (1 sigma) alpha_s values.
# (Therefore this cross-section uncertainty is symmetric.)
# --- Get the DGP medians, discard regression errors on the variations
mu_dgp_adn_rel, _ = np.array(list(zip(*dgp_results["adn"])))
mu_dgp_aup_rel, _ = np.array(list(zip(*dgp_results["aup"])))
mu_dgp_adn_rel, _ = np.array(list(zip(*dgp_results["adn"])), dtype=object)
mu_dgp_aup_rel, _ = np.array(list(zip(*dgp_results["aup"])), dtype=object)

delta_alphas_rel = np.array(
[
Expand Down

0 comments on commit 4ce8fbc

Please sign in to comment.