-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·138 lines (111 loc) · 4 KB
/
setup.sh
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/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.6"
local pythia_download_dir="https://pythia.org/download/pythia83"
local pythia_download_file="pythia8311"
local delphes_download_dir="http://cp3.irmp.ucl.ac.be/downloads"
local delphes_download_file="Delphes-3.5.0"
# 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"
# Setup software directories
export SOFTWARE_DIR="${this_dir}/software"
mkdir -p $SOFTWARE_DIR
export MADGRAPH_DIR="${SOFTWARE_DIR}/${madgraph_download_file//./_}"
export PYTHIA_DIR="${SOFTWARE_DIR}/${pythia_download_file}"
export DELPHES_DIR="${SOFTWARE_DIR}/${delphes_download_file}"
# If no conda available, activate it
if ! command -v conda >/dev/null 2>&1; then
module load python
fi
# If conda env "withroot" does not exist create it
if ! conda env list | grep -q '^withroot'; then
mamba create --name withroot
mamba env update -n withroot --file environment.yml
fi
# Activate conda environment
conda activate withroot
# 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
# If Pythia not installed yet, do so
if [ -d "$PYTHIA_DIR" ]; then
echo "Pythia already installed"
else
echo "Installing Pythia"
cd $SOFTWARE_DIR
wget "${pythia_download_dir}/${pythia_download_file}.tgz"
tar xzvf "${pythia_download_file}.tgz"
rm "${pythia_download_file}.tgz"
cd $pythia_download_file
make -j4
cd $this_dir
fi
# Link pythia installation
export PYTHIA8="${PYTHIA_DIR}"
export PYTHIA8DATA="${PYTHIA_DIR}/share/Pythia8/xmldoc"
export LD_LIBRARY_PATH="${PYTHIA_DIR}/lib:${LD_LIBRARY_PATH}"
# If Delphes not installed yet, do so
if [ -d "$DELPHES_DIR" ]; then
echo "Delphes already installed"
else
echo "Installing Delphes"
cd $SOFTWARE_DIR
wget "${delphes_download_dir}/${delphes_download_file}.tar.gz"
tar -zxf "${delphes_download_file}.tar.gz"
rm "${delphes_download_file}.tar.gz"
cd $delphes_download_file
make -j4
make -j4 HAS_PYTHIA8=true DelphesPythia8
cd $this_dir
fi
export LD_LIBRARY_PATH="${DELPHES_DIR}:${LD_LIBRARY_PATH}"
}
action