ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/runAll.sh
Revision: 1.33
Committed: Fri Mar 22 21:54:00 2013 UTC (12 years, 1 month ago) by nmohr
Content type: application/x-sh
Branch: MAIN
CVS Tags: lhcp_UnblindFix, hcp_Unblind, lhcp_11April, LHCP_PreAppFixAfterFreeze, LHCP_PreAppFreeze, HEAD
Changes since 1.32: +1 -1 lines
Log Message:
Add possibility to add more than minimum number of configs

File Contents

# Content
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=$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."
29 echo "Exiting..."
30 echo " ---------------------------------- "
31 echo " Usage : ./runAll.sh sample energy task"
32 echo " ---------------------------------- "
33 exit
34 fi
35
36 #------------------------------------------------
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 #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 myutils import BetterConfigParser
69 config = BetterConfigParser()
70 config.read('./${energy}config/training')
71 print config.get('MVALists','List_for_submitscript')
72 EOF`
73
74
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 --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 --samples $sample --config ${energy}config/${configList}
109 fi
110 if [ $task = "eval" ]; then
111 ./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList}
112 fi
113 if [ $task = "syseval" ]; then
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 --region $sample --config ${energy}config/${configList}
122 fi
123 if [ $task = "dc" ]; then
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