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.8 by peller, Thu Sep 27 07:34:24 2012 UTC vs.
Revision 1.33 by nmohr, Fri Mar 22 21:54:00 2013 UTC

# Line 1 | Line 1
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 < if [ $# -lt 2 ]
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 2 arguments."
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"
31 >    echo " Usage : ./runAll.sh sample energy task"
32      echo " ---------------------------------- "
33      exit
34   fi
35  
36 < #Set the environment for the batch job execution
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 < #cd /shome/peller/CMSSW_5_2_4_patch4/src/
52 < # this doesnt work for me..?
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
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 < #Path where the script write_regression_systematic.py and evaluateMVA.py are stored
65 < #execute=$PWD/UserCode/VHbb/python/
66 < #execute=/shome/peller/UserCode/VHbb/python/
67 < #cd $execute
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  
36 #back to the working dir
37 cd -
74  
75 < #Parsing the path form the config
76 < pathAna=`python << EOF
75 > #----------------------------------------------
76 > # load from the paths the configs to be used
77 > #----------------------------------------------
78 > input_configs=`python << EOF
79   import os
80 < from BetterConfigParser import BetterConfigParser
80 > from myutils import BetterConfigParser
81   config = BetterConfigParser()
82 < config.read('./pathConfig$energy')
83 < print config.get('Directories','samplepath')
82 > config.read('./${energy}config/paths')
83 > print config.get('Configuration','List')
84   EOF`
85 < echo $pathAna
86 < configFile=config$energy
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 < #Create subdirs where processed samples will be stored
97 < if [ ! -d $pathAna/env/sys ]
98 <    then
99 <    mkdir $pathAna/env/sys
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 [ ! -d $pathAna/env/sys/MVAout ]
105 <    then
57 <    mkdir $pathAna/env/sys/MVAout
104 > if [ $task = "trainReg" ]; then
105 >    ./trainRegression.py --config ${energy}config/${configList}
106   fi
107 <
108 < #Create the link to th sample information in the new sudfolders
61 < if [ ! -f $pathAna/env/sys/samples.info ]
62 <    then
63 <    ln -s $pathAna/env/samples.info  $pathAna/env/sys/samples.info
107 > if [ $task = "sys" ]; then
108 >    ./write_regression_systematics.py --samples $sample --config ${energy}config/${configList}
109   fi
110 < if [ ! -f $pathAna/sys/MVAout/samples.info ]
111 <    then
112 <    ln -s $pathAna/env/samples.info $pathAna/env/sys/MVAout/samples.info
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 < #Run the scripts
131 < #./step1_prepare_trees.sh
132 < #./write_regression_systematics.py -P $pathAna/env/ -S $sample -C $configFile -C pathConfig$energy
133 < ./evaluateMVA.py -P $pathAna/env/sys/ -D 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,RPt50_ZZ_may,RIncl_ZZ_may -S $sample -U 0 -C ${configFile} -C pathConfig$energy
134 < #./showinfo.py $pathAna/env/sys
135 < #./evaluateMVA.py -P $pathAna/env/sys/ -D 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 -S $sample -U 0 -C ${configFile} -C pathConfig$energy
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines