-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·109 lines (88 loc) · 3.37 KB
/
setup.sh
File metadata and controls
executable file
·109 lines (88 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
action() {
# Set version of used software
local madgraph_download_dir="https://launchpad.net/mg5amcnlo/3.0/3.6.x/+download"
local madgraph_download_file="MG5_aMC_v3.5.11"
# Set main directories
local shell_is_zsh="$( [ -z "${ZSH_VERSION}" ] && echo "false" || echo "true" )"
local this_file="$( ${shell_is_zsh} && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "${this_file}" )" && pwd )"
# set PYTHONPATH
export PYTHONPATH="${this_dir}:${PYTHONPATH}"
CONFIG_FILE="${this_dir}/.config"
# Function to read the output directory from the config file
read_config() {
if [[ -f $CONFIG_FILE ]]; then
source $CONFIG_FILE
else
export GEN_OUT=""
fi
}
# Function to write the output directory to the config file
write_config() {
echo "export GEN_OUT=\"$GEN_OUT\"" > $CONFIG_FILE
}
# Prompt user for input if GEN_OUT is not set
prompt_user() {
read -p "Enter the output directory: " user_input
if [[ -n $user_input ]]; then
export GEN_OUT=$user_input
write_config
fi
}
# Main script execution
read_config
if [[ -z $GEN_OUT ]]; then
echo "No output directory configured."
prompt_user
fi
# Use the GEN_OUT in your script
echo "Using output directory: $GEN_OUT"
# Set code and law area
export GEN_CODE="${this_dir}"
export GEN_SLURM="${GEN_OUT}/slurm"
export LAW_HOME="${this_dir}/.law"
export LAW_CONFIG_FILE="${this_dir}/law.cfg"
# Setup software directories
export SOFTWARE_DIR="${this_dir}/software"
mkdir -p $SOFTWARE_DIR
export MADGRAPH_DIR="${SOFTWARE_DIR}/${madgraph_download_file//./_}"
# If no conda available, activate it
if ! command -v conda >/dev/null 2>&1; then
module load python
fi
# If conda env "madgraph" does not exist create it
if ! conda env list | grep -q '^madgraph'; then
yes | conda create --name madgraph
yes | conda env update -n madgraph --file madgraph.yml
fi
# If conda env "eventgen" does not exist create it
if ! conda env list | grep -q '^eventgen'; then
yes | conda create --name eventgen
yes | conda env update -n eventgen --file eventgen.yml
# Install temporary Delphes fix (H->yy filter) from:
# https://github.com/qibin2020/delphes/commit/2104fd9
CONDA_PREFIX="/$(conda env list | grep -Po 'eventgen\K.*' | cut -d '/' -f2-)"
cp /pscratch/sd/d/dnoll/projects/haxad/EventGenDelphes/bin/DelphesPythia8Filtered ${CONDA_PREFIX}/bin/
chmod u+x ${CONDA_PREFIX}/bin/DelphesPythia8Filtered
fi
# Activate conda environment eventgen
conda activate eventgen
echo "Using conda env 'eventgen', for madgraph NLO processes use env 'madgraph'"
# law setup
source "$( law completion )" ""
# If Pythia not installed yet, do so
if [ -d "$MADGRAPH_DIR" ]; then
echo "Madgraph already installed"
else
echo "Installing Madgraph"
cd $SOFTWARE_DIR
wget ${madgraph_download_dir}/${madgraph_download_file}.tar.gz
tar -xf "${madgraph_download_file}.tar.gz"
rm "${madgraph_download_file}.tar.gz"
cd $this_dir
fi
export PYTHIA_DIR="${CONDA_PREFIX}"
export DELPHES_DIR="${CONDA_PREFIX}"
}
action