1 |
|
#!/bin/bash |
2 |
+ |
#==================================================================== |
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 |
|
|
16 |
|
#Input argument: |
17 |
< |
#sample you want to run on. It has to match the naming in sample.info. |
18 |
< |
sample=$1 |
19 |
< |
#sqrt(s) you want to run |
20 |
< |
energy=$2 |
21 |
< |
|
22 |
< |
task=$3 |
23 |
< |
|
17 |
> |
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 |
|
if [ $# -lt 3 ] |
27 |
|
then |
28 |
|
echo "ERROR: You passed " $# "arguments while the script needs at least 3 arguments." |
33 |
|
exit |
34 |
|
fi |
35 |
|
|
36 |
< |
#Set the environment for the batch job execution |
37 |
< |
|
38 |
< |
#cd /shome/peller/CMSSW_5_2_4_patch4/src/ |
39 |
< |
# this doesnt work for me..? |
25 |
< |
|
26 |
< |
#cd $CMSSW_BASE/src/ |
27 |
< |
#source /swshare/psit3/etc/profile.d/cms_ui_env.sh |
28 |
< |
#export SCRAM_ARCH="slc5_amd64_gcc462" |
29 |
< |
#source $VO_CMS_SW_DIR/cmsset_default.sh |
30 |
< |
#eval `scramv1 runtime -sh` |
31 |
< |
#export LD_LIBRARY_PATH=/swshare/glite/d-cache/dcap/lib/:$LD_LIBRARY_PATH |
32 |
< |
|
33 |
< |
|
34 |
< |
#source /swshare/psit3/etc/profile.d/cms_ui_env.sh |
35 |
< |
export LD_LIBRARY_PATH=/swshare/glite/d-cache/dcap/lib/:$LD_LIBRARY_PATH |
36 |
< |
#export SCRAM_ARCH="slc5_amd64_gcc462" |
37 |
< |
#source $VO_CMS_SW_DIR/cmsset_default.sh |
38 |
< |
#eval `scramv1 runtime -sh` |
39 |
< |
source /swshare/ROOT/root_v5.30.01_slc5_amd64/bin/thisroot.sh |
40 |
< |
|
41 |
< |
mkdir $TMPDIR |
42 |
< |
|
43 |
< |
printenv |
44 |
< |
|
45 |
< |
#Path where the script write_regression_systematic.py and evaluateMVA.py are stored |
46 |
< |
#execute=$PWD/UserCode/VHbb/python/ |
47 |
< |
#execute=/shome/peller/UserCode/VHbb/python/ |
48 |
< |
#cd $execute |
49 |
< |
|
50 |
< |
#back to the working dir |
51 |
< |
cd - |
52 |
< |
|
53 |
< |
#Parsing the path form the config |
54 |
< |
pathAna=`python << EOF |
36 |
> |
#------------------------------------------------ |
37 |
> |
# get the log dir from the config and create it |
38 |
> |
#------------------------------------------------ |
39 |
> |
logpath=`python << EOF |
40 |
|
import os |
41 |
< |
from BetterConfigParser import BetterConfigParser |
41 |
> |
from myutils import BetterConfigParser |
42 |
|
config = BetterConfigParser() |
43 |
< |
config.read('./pathConfig$energy') |
44 |
< |
print config.get('Directories','samplepath') |
43 |
> |
config.read('./${energy}config/paths') |
44 |
> |
print config.get('Directories','logpath') |
45 |
|
EOF` |
46 |
< |
echo $pathAna |
47 |
< |
configFile=config$energy |
46 |
> |
if [ ! -d $logpath ] |
47 |
> |
then |
48 |
> |
mkdir $logpath |
49 |
> |
fi |
50 |
|
|
51 |
< |
storagesamples=`python << EOF |
52 |
< |
import os |
53 |
< |
from BetterConfigParser import BetterConfigParser |
54 |
< |
config = BetterConfigParser() |
55 |
< |
config.read('./pathConfig$energy') |
56 |
< |
print config.get('Directories','storagesamples') |
57 |
< |
EOF` |
51 |
> |
#------------------------------------------------- |
52 |
> |
#Set the environment for the batch job execution |
53 |
> |
#------------------------------------------------- |
54 |
> |
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 |
> |
#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 |
> |
mkdir $TMPDIR |
63 |
|
|
64 |
+ |
cd - #back to the working dir |
65 |
|
|
66 |
|
MVAList=`python << EOF |
67 |
|
import os |
68 |
< |
from BetterConfigParser import BetterConfigParser |
68 |
> |
from myutils import BetterConfigParser |
69 |
|
config = BetterConfigParser() |
70 |
< |
config.read('./config$energy') |
70 |
> |
config.read('./${energy}config/training') |
71 |
|
print config.get('MVALists','List_for_submitscript') |
72 |
|
EOF` |
80 |
– |
configFile=config$energy |
73 |
|
|
74 |
|
|
75 |
< |
#Create subdirs where processed samples will be stored |
76 |
< |
if [ ! -d $pathAna/env ] |
77 |
< |
then |
78 |
< |
mkdir $pathAna/env |
79 |
< |
fi |
80 |
< |
if [ ! -d $pathAna/env/sys ] |
81 |
< |
then |
82 |
< |
mkdir $pathAna/env/sys |
83 |
< |
fi |
84 |
< |
if [ ! -d $pathAna/env/sys/MVAout ] |
85 |
< |
then |
86 |
< |
mkdir $pathAna/env/sys/MVAout |
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 |
> |
if [ ${#input_configs_array[*]} -lt $required_number_of_configs ] # check if the list contains the right number of configs |
88 |
> |
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 |
|
#Run the scripts |
99 |
+ |
#------------------------------------ |
100 |
|
|
101 |
|
if [ $task = "prep" ]; then |
102 |
< |
./prepare_environment_with_config.py -I $storagesamples -O $pathAna/env/ -C ${energy}samples_nosplit.cfg |
102 |
> |
./prepare_environment_with_config.py --samples $sample --config ${energy}config/${configList} |
103 |
> |
fi |
104 |
> |
if [ $task = "trainReg" ]; then |
105 |
> |
./trainRegression.py --config ${energy}config/${configList} |
106 |
|
fi |
107 |
|
if [ $task = "sys" ]; then |
108 |
< |
./write_regression_systematics.py -P $pathAna/env/ -S $sample -C $configFile -C pathConfig$energy |
108 |
> |
./write_regression_systematics.py --samples $sample --config ${energy}config/${configList} |
109 |
|
fi |
110 |
|
if [ $task = "eval" ]; then |
111 |
< |
./evaluateMVA.py -D $MVAList -S $sample -U 0 -C ${configFile} -C pathConfig$energy |
111 |
> |
./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList} |
112 |
|
fi |
113 |
|
if [ $task = "syseval" ]; then |
114 |
< |
./write_regression_systematics.py -P $pathAna/env/ -S $sample -C $configFile -C pathConfig$energy |
115 |
< |
./evaluateMVA.py -P $pathAna/env/sys/ -D $MVAList -S $sample -U 0 -C ${configFile} -C pathConfig$energy |
114 |
> |
./write_regression_systematics.py --samples $sample --config ${energy}config/${configList} |
115 |
> |
./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList} |
116 |
> |
fi |
117 |
> |
if [ $task = "train" ]; then |
118 |
> |
./train.py --training $sample --config ${energy}config/${configList} --local True |
119 |
|
fi |
120 |
|
if [ $task = "plot" ]; then |
121 |
< |
./tree_stack.py -P $pathAna/env/sys/MVAout/ -C ${configFile} -C pathConfig$energy -R $sample |
121 |
> |
./tree_stack.py --region $sample --config ${energy}config/${configList} |
122 |
|
fi |
123 |
|
if [ $task = "dc" ]; then |
124 |
< |
./workspace_datacard.py -P $pathAna/env/sys/MVAout/ -C ${configFile} -C pathConfig$energy -V $sample |
124 |
> |
./workspace_datacard.py --variable $sample --config ${energy}config/${configList} |
125 |
> |
fi |
126 |
> |
if [ $task = "split" ]; then |
127 |
> |
./split_tree.py --samples $sample --config ${energy}config/${configList} --max-events $job_id |
128 |
> |
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 |
> |
./train.py --name ${sample} --training ${job_id} --config ${energy}config/${configList} --setting ${additional_arg} --local False |
144 |
|
fi |
145 |
|
|
146 |
|
rm -rf $TMPDIR |