-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.sh
145 lines (125 loc) · 4.67 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
139
140
141
142
143
144
145
#!/bin/bash
if [ $# -ne 1 ] ; then
echo "To run: source setup.sh mode"
echo "e.g: source setup.sh NanoAOD_UL2018"
echo "Supported modes:"
echo "1) NanoAOD_UL2018 (for NanoAOD UL 2018 production) or CMSSW_X_Y_Z"
echo "2) conda (for analysis)"
echo "3) combine (for combine)"
return 1
fi
MODE=$1
BASE_PATH=$PWD
function run_cmd {
"$@"
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo "Error while running '$@'"
kill -INT $$
fi
}
if [[ $MODE = "NanoAOD_UL2018" || "$MODE" == *"CMSSW"* ]] ; then
if [[ $MODE == "NanoAOD_UL2018" ]] ; then
CMSSW_VER="CMSSW_12_6_0_patch1"
export SCRAM_ARCH=slc7_amd64_gcc10
elif [[ "$MODE" == *"CMSSW"* ]] ; then
CMSSW_VER=$MODE
export SCRAM_ARCH=slc7_amd64_gcc10
else
echo "Mode "$MODE" is not supported."
exit
fi
if ! [ -f soft/$CMSSW_VER/.installed ] ; then
run_cmd mkdir -p soft
run_cmd cd soft
if [ -d $CMSSW_VER ] ; then
echo "Removing incomplete $CMSSW_VER installation..."
run_cmd rm -rf $CMSSW_VER
fi
echo "Creating new $CMSSW_VER area..."
run_cmd scramv1 project CMSSW $CMSSW_VER
run_cmd cd $CMSSW_VER/src
run_cmd eval `scramv1 runtime -sh`
run_cmd mkdir LLStaus_Run2
run_cmd cd LLStaus_Run2
run_cmd ln -s ../../../../Production Production
run_cmd mkdir -p ../data
run_cmd cp -rf ../../../../Production/data/models/* ../data/
#run_cmd mkdir -p ../src/data
#run_cmd cp -rf ../../../../Production/data/models/* ../src/data
run_cmd scram b -j8
run_cmd touch ../../.installed
run_cmd cd ../../../..
else
run_cmd cd soft/$CMSSW_VER/src
run_cmd eval `scramv1 runtime -sh`
run_cmd cd ../../..
fi
elif [ $MODE = "conda" ] ; then
CONDA=$(which conda 2>/dev/null)
if [ x$CONDA = "x" -o x$CONDA = "x/usr/bin/conda" ] ; then
PRIVATE_CONDA_INSTALL=$BASE_PATH/soft/conda
if ! [ -f "$PRIVATE_CONDA_INSTALL/.installed" ] ; then
if [ -d $PRIVATE_CONDA_INSTALL ] ; then
echo "Removing incomplete private conda installation..."
run_cmd rm -rf $PRIVATE_CONDA_INSTALL
fi
echo "Installing conda..."
run_cmd mkdir -p soft
run_cmd cd soft
run_cmd curl https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh -o Miniconda2-latest-Linux-x86_64.sh
run_cmd bash Miniconda2-latest-Linux-x86_64.sh -b -p $PRIVATE_CONDA_INSTALL
run_cmd touch "$PRIVATE_CONDA_INSTALL/.installed"
fi
__conda_setup="$($PRIVATE_CONDA_INSTALL/bin/conda shell.${SHELL##*/} hook)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$PRIVATE_CONDA_INSTALL/etc/profile.d/conda.sh" ]; then
. "$PRIVATE_CONDA_INSTALL/etc/profile.d/conda.sh"
else
export PATH="$PRIVATE_CONDA_INSTALL/bin:$PATH"
fi
fi
unset __conda_setup
fi
env_found=$(conda env list | grep -E '^llstau .*' | wc -l)
if [ $env_found -ne 1 ]; then
echo "Creating llstau environment..."
run_cmd conda env create -f $BASE_PATH/conda-env.yaml
fi
run_cmd conda activate llstau
elif [[ $MODE = "combine" ]] ; then
CMSSW_VER="CMSSW_11_3_4"
#export SCRAM_ARCH=slc7_amd64_gcc10
if ! [ -f soft/$CMSSW_VER/.installed ] ; then
run_cmd mkdir -p soft
run_cmd cd soft
if [ -d $CMSSW_VER ] ; then
echo "Removing incomplete $CMSSW_VER installation..."
run_cmd rm -rf $CMSSW_VER
fi
echo "Creating new $CMSSW_VER area..."
run_cmd scramv1 project CMSSW $CMSSW_VER
run_cmd cd $CMSSW_VER/src
run_cmd eval `scramv1 runtime -sh`
echo "CMSSW_BASE: "$CMSSW_BASE
run_cmd git clone https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit.git HiggsAnalysis/CombinedLimit
run_cmd cd $CMSSW_BASE/src/HiggsAnalysis/CombinedLimit/
run_cmd git fetch origin
run_cmd git checkout v9.0.0
run_cmd cd $CMSSW_BASE/src/
run_cmd git clone https://github.com/cms-analysis/CombineHarvester.git CombineHarvester
run_cmd cd $CMSSW_BASE/src/CombineHarvester/
run_cmd git checkout v2.0.0
run_cmd cd $CMSSW_BASE/src/
run_cmd ln -s ../../../Limits Limits
run_cmd scramv1 b clean
run_cmd scramv1 b
fi
else
echo echo "Mode "$MODE" is not supported."
exit
fi
run_cmd cd $BASE_PATH
echo "$MODE environment is successfully loaded."