1 |
bortigno |
1.5 |
#!/bin/bash
|
2 |
bortigno |
1.29 |
#====================================================================
|
3 |
|
|
#
|
4 |
|
|
# FILE: runAll.sh
|
5 |
|
|
#
|
6 |
|
|
# USAGE: runAll.sh sample energy task
|
7 |
|
|
#
|
8 |
|
|
# DESCRIPTION: Script to be launched in the batch system.
|
9 |
|
|
# Can also be used, with some careful, to run locally.
|
10 |
|
|
#
|
11 |
|
|
# AUTHOR: VHbb team
|
12 |
|
|
# ETH Zurich
|
13 |
|
|
#
|
14 |
|
|
#=====================================================================
|
15 |
bortigno |
1.5 |
|
16 |
|
|
#Input argument:
|
17 |
bortigno |
1.29 |
sample=$1 # sample you want to run on. It has to match the naming in sample.info.
|
18 |
|
|
energy=$2 # sqrt(s) you want to run
|
19 |
|
|
task=$3 # the task
|
20 |
|
|
job_id=$4 # needed for train optimisation. @TO FIX: it does not have a unique meaning
|
21 |
|
|
additional_arg=$5 # needed for train optimisation. @TO FIX: it does not have a unique meaning
|
22 |
|
|
|
23 |
|
|
#-------------------------------------------------
|
24 |
|
|
# Check the number of input arguments
|
25 |
|
|
#-------------------------------------------------
|
26 |
peller |
1.9 |
if [ $# -lt 3 ]
|
27 |
bortigno |
1.7 |
then
|
28 |
peller |
1.9 |
echo "ERROR: You passed " $# "arguments while the script needs at least 3 arguments."
|
29 |
bortigno |
1.7 |
echo "Exiting..."
|
30 |
|
|
echo " ---------------------------------- "
|
31 |
peller |
1.9 |
echo " Usage : ./runAll.sh sample energy task"
|
32 |
bortigno |
1.7 |
echo " ---------------------------------- "
|
33 |
|
|
exit
|
34 |
|
|
fi
|
35 |
|
|
|
36 |
bortigno |
1.29 |
#------------------------------------------------
|
37 |
|
|
# get the log dir from the config and create it
|
38 |
|
|
#------------------------------------------------
|
39 |
|
|
logpath=`python << EOF
|
40 |
|
|
import os
|
41 |
|
|
from myutils import BetterConfigParser
|
42 |
|
|
config = BetterConfigParser()
|
43 |
|
|
config.read('./${energy}config/paths')
|
44 |
|
|
print config.get('Directories','logpath')
|
45 |
|
|
EOF`
|
46 |
|
|
if [ ! -d $logpath ]
|
47 |
|
|
then
|
48 |
|
|
mkdir $logpath
|
49 |
|
|
fi
|
50 |
|
|
|
51 |
|
|
#-------------------------------------------------
|
52 |
bortigno |
1.5 |
#Set the environment for the batch job execution
|
53 |
bortigno |
1.29 |
#-------------------------------------------------
|
54 |
nmohr |
1.18 |
cd $CMSSW_BASE/src/
|
55 |
|
|
source /swshare/psit3/etc/profile.d/cms_ui_env.sh
|
56 |
|
|
export SCRAM_ARCH="slc5_amd64_gcc462"
|
57 |
|
|
source $VO_CMS_SW_DIR/cmsset_default.sh
|
58 |
|
|
eval `scramv1 runtime -sh`
|
59 |
peller |
1.24 |
#export LD_PRELOAD="libglobus_gssapi_gsi_gcc64pthr.so.0":${LD_PRELOAD}
|
60 |
|
|
export LD_LIBRARY_PATH=/swshare/glite/globus/lib/:/swshare/glite/d-cache/dcap/lib64/:$LD_LIBRARY_PATH
|
61 |
|
|
export LD_PRELOAD="libglobus_gssapi_gsi_gcc64pthr.so.0:${LD_PRELOAD}"
|
62 |
peller |
1.15 |
mkdir $TMPDIR
|
63 |
bortigno |
1.5 |
|
64 |
bortigno |
1.29 |
cd - #back to the working dir
|
65 |
bortigno |
1.5 |
|
66 |
peller |
1.9 |
MVAList=`python << EOF
|
67 |
|
|
import os
|
68 |
nmohr |
1.22 |
from myutils import BetterConfigParser
|
69 |
peller |
1.9 |
config = BetterConfigParser()
|
70 |
peller |
1.21 |
config.read('./${energy}config/training')
|
71 |
peller |
1.9 |
print config.get('MVALists','List_for_submitscript')
|
72 |
|
|
EOF`
|
73 |
|
|
|
74 |
bortigno |
1.29 |
|
75 |
|
|
#----------------------------------------------
|
76 |
|
|
# load from the paths the configs to be used
|
77 |
|
|
#----------------------------------------------
|
78 |
|
|
input_configs=`python << EOF
|
79 |
|
|
import os
|
80 |
|
|
from myutils import BetterConfigParser
|
81 |
|
|
config = BetterConfigParser()
|
82 |
|
|
config.read('./${energy}config/paths')
|
83 |
|
|
print config.get('Configuration','List')
|
84 |
|
|
EOF`
|
85 |
|
|
required_number_of_configs=7 # set the number of required cconfig
|
86 |
|
|
input_configs_array=( $input_configs ) # create an array to count the number of elements
|
87 |
nmohr |
1.33 |
if [ ${#input_configs_array[*]} -lt $required_number_of_configs ] # check if the list contains the right number of configs
|
88 |
bortigno |
1.29 |
then
|
89 |
|
|
echo "@ERROR : The number of the elements in the config list is not correct"
|
90 |
|
|
exit
|
91 |
|
|
fi
|
92 |
|
|
configList=${input_configs// / -C ${energy}config\/} # replace the spaces with ' -C '
|
93 |
|
|
echo "@LOG : The config list you are using is"
|
94 |
|
|
echo ${configList}
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
#------------------------------------
|
98 |
bortigno |
1.5 |
#Run the scripts
|
99 |
bortigno |
1.29 |
#------------------------------------
|
100 |
peller |
1.9 |
|
101 |
|
|
if [ $task = "prep" ]; then
|
102 |
bortigno |
1.29 |
./prepare_environment_with_config.py --samples $sample --config ${energy}config/${configList}
|
103 |
peller |
1.9 |
fi
|
104 |
nmohr |
1.32 |
if [ $task = "trainReg" ]; then
|
105 |
|
|
./trainRegression.py --config ${energy}config/${configList}
|
106 |
|
|
fi
|
107 |
peller |
1.9 |
if [ $task = "sys" ]; then
|
108 |
bortigno |
1.29 |
./write_regression_systematics.py --samples $sample --config ${energy}config/${configList}
|
109 |
peller |
1.9 |
fi
|
110 |
|
|
if [ $task = "eval" ]; then
|
111 |
bortigno |
1.30 |
./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList}
|
112 |
peller |
1.9 |
fi
|
113 |
nmohr |
1.14 |
if [ $task = "syseval" ]; then
|
114 |
bortigno |
1.29 |
./write_regression_systematics.py --samples $sample --config ${energy}config/${configList}
|
115 |
|
|
./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList}
|
116 |
nmohr |
1.14 |
fi
|
117 |
peller |
1.24 |
if [ $task = "train" ]; then
|
118 |
bortigno |
1.29 |
./train.py --training $sample --config ${energy}config/${configList} --local True
|
119 |
peller |
1.24 |
fi
|
120 |
peller |
1.9 |
if [ $task = "plot" ]; then
|
121 |
bortigno |
1.29 |
./tree_stack.py --region $sample --config ${energy}config/${configList}
|
122 |
peller |
1.9 |
fi
|
123 |
|
|
if [ $task = "dc" ]; then
|
124 |
bortigno |
1.29 |
./workspace_datacard.py --variable $sample --config ${energy}config/${configList}
|
125 |
peller |
1.9 |
fi
|
126 |
bortigno |
1.25 |
if [ $task = "split" ]; then
|
127 |
bortigno |
1.29 |
./split_tree.py --samples $sample --config ${energy}config/${configList} --max-events $job_id
|
128 |
bortigno |
1.25 |
fi
|
129 |
|
|
|
130 |
|
|
if [ $task = "mva_opt" ]; then
|
131 |
|
|
if [ $# -lt 5 ]
|
132 |
|
|
then
|
133 |
|
|
echo "@ERROR: You passed " $# "arguments while BDT optimisation needs at least 5 arguments."
|
134 |
|
|
echo "Exiting..."
|
135 |
|
|
echo " ---------------------------------- "
|
136 |
|
|
echo " Usage : ./runAll.sh sample energy task jo_id bdt_factory_settings"
|
137 |
|
|
echo " ---------------------------------- "
|
138 |
|
|
exit
|
139 |
|
|
fi
|
140 |
|
|
echo "BDT factory settings"
|
141 |
|
|
echo $additional_arg
|
142 |
|
|
echo "Runnning"
|
143 |
bortigno |
1.31 |
./train.py --name ${sample} --training ${job_id} --config ${energy}config/${configList} --setting ${additional_arg} --local False
|
144 |
bortigno |
1.25 |
fi
|
145 |
peller |
1.15 |
|
146 |
|
|
rm -rf $TMPDIR
|