ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/runAll.sh
(Generate patch)

Comparing UserCode/VHbb/python/runAll.sh (file contents):
Revision 1.2 by nmohr, Thu Aug 9 13:03:29 2012 UTC vs.
Revision 1.29 by bortigno, Wed Mar 20 16:16:30 2013 UTC

# Line 1 | Line 1
1 < sample=$1
2 < cd /shome/nmohr/CMSSW_5_3_2/src/
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 < unset TMP
60 < unset TMPDIR
61 < pathAna=/shome/nmohr/VHbbAnalysis/EDMNtuple_step2/May5/
62 < execute=/shome/nmohr/CMSSW_5_3_2/src/UserCode/VHbb/python/
63 < config=config7TeV
64 < mkdir $pathAna/env/sys
65 < cd $execute
66 < ./write_regression_systematics.py $pathAna/env/ $sample -C ${config}
67 < mkdir $pathAna/env/sys/MVAout
68 < ./evaluateMVA.py $pathAna/env/sys/ RTight_ZH110_may,RTight_ZH115_may,RTight_ZH120_may,RTight_ZH125_may,RTight_ZH130_may,RTight_ZH135_may,RMed_ZH110_may,RMed_ZH115_may,RMed_ZH120_may,RMed_ZH125_may,RMed_ZH130_may,RMed_ZH135_may $sample 0 -C ${config}
69 < ./showinfo.py $pathAna/env/sys
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[*]} -ne $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 = "sys" ]; then
105 >    ./write_regression_systematics.py --samples $sample --config ${energy}config/${configList}
106 > fi
107 > if [ $task = "eval" ]; then
108 > echo    ./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList}
109 > fi
110 > if [ $task = "syseval" ]; then
111 >    ./write_regression_systematics.py --samples $sample --config ${energy}config/${configList}
112 >    ./evaluateMVA.py --discr $MVAList --samples $sample --config ${energy}config/${configList}
113 > fi
114 > if [ $task = "train" ]; then
115 >    ./train.py --training $sample --config ${energy}config/${configList} --local True
116 > fi
117 > if [ $task = "plot" ]; then
118 >    ./tree_stack.py --region $sample --config ${energy}config/${configList}
119 > fi
120 > if [ $task = "dc" ]; then
121 >    ./workspace_datacard.py --variable $sample --config ${energy}config/${configList}
122 > fi
123 > if [ $task = "split" ]; then
124 >    ./split_tree.py --samples $sample --config ${energy}config/${configList} --max-events $job_id
125 > fi
126 >
127 > if [ $task = "mva_opt" ]; then
128 >    if [ $# -lt 5 ]
129 >        then
130 >        echo "@ERROR: You passed " $# "arguments while BDT optimisation needs at least 5 arguments."
131 >        echo "Exiting..."
132 >        echo " ---------------------------------- "
133 >        echo " Usage : ./runAll.sh sample energy task jo_id bdt_factory_settings"
134 >        echo " ---------------------------------- "
135 >        exit
136 >    fi
137 >    echo "BDT factory settings"
138 >    echo $additional_arg
139 >    echo "Runnning"
140 >    ./train.py --name ${sample} --training ${job_id} --config ${energy}config/${configList} --samples ${additional_arg} --local False
141 > fi
142 >
143 > rm -rf $TMPDIR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines