ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Angles/script/trainAngles.sh
Revision: 1.1
Committed: Tue Oct 23 10:07:46 2012 UTC (12 years, 6 months ago) by dkralph
Content type: application/x-sh
Branch: MAIN
CVS Tags: compiled
Log Message:
finally ci'ing all dkralph's changes

File Contents

# Content
1 #!/bin/sh
2
3 alias grep='grep --color=auto'
4
5 limit_procs() {
6 string=`echo $1 | sed 's/\(..............\).*/\1/'`
7 nprocs=`ps | grep $string | wc -l`
8 # echo -e "\tchecking procs: $nprocs"
9 while (( $nprocs > 45 )); do echo -n "."; sleep 1; nprocs=`ps auxw|grep $string | wc -l`; done
10 }
11
12 label=$1
13 # boolean parameters:
14 if ! [ $label ]; then echo "no label!"; exit 1; fi
15 if echo "$@" | grep ' \-\-interpolate' ; then interpolate=interpolate; else interpolate=; fi
16 if echo "$@" | grep ' \-\-delete' ; then delete=delete; else delete=; fi
17 if echo "$@" | grep ' \-\-fakes' ; then fakes=fakes; else fakes=; fi
18 if echo "$@" | grep ' \-\-ptvars' ; then ptvars=ptvars; else ptvars=; fi
19 if echo "$@" | grep ' \-\-multiclass' ; then multiclass=multiclass; else multiclass=; fi
20 if echo "$@" | grep ' \-\-multisigs' ; then multisigs=multisigs; else multisigs=; fi
21 if echo "$@" | grep ' \-\-condor' ; then condor=condor; else condor=; fi
22 if echo "$@" | grep ' \-\-pt4l' ; then pt4l=pt4l; else pt4l=; fi
23 if echo "$@" | grep ' \-\-m4l' ; then m4l=m4l; else m4l=; fi
24 if echo "$@" | grep ' \-\-fourTwoX' ; then fourTwoX=fourTwoX; else fourTwoX=; fi
25 # parameters with args:
26 window=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-window' | grep -v "\-\-window"`; if ! [ $window ]; then window=1; fi
27 NTrees=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-NTrees' | grep -v "\-\-NTrees"`
28 NNodesMax=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-NNodesMax' | grep -v "\-\-NNodesMax"`
29 Shrinkage=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-Shrinkage' | grep -v "\-\-Shrinkage"`
30 nCuts=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-nCuts' | grep -v "\-\-nCuts"`
31 nMax=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-nMax' | grep -v "\-\-nMax"`
32
33 if echo $label | grep 2011 &>/dev/null; then era2011=era2011; else era2011=; fi
34 mHfile=Angles/data/mHs.conf
35 #if [ $era2011 ]; then
36 # mHfile=Angles/data/mHs-f11.conf
37 #else
38 # mHfile=Angles/data/mHs-s12.conf
39 #fi
40
41 exe=$PWD/Angles/bin/trainAngles.exe
42 if [ $fourTwoX ]; then
43 exe=$PWD/Angles/bin/trainAngles_42x.exe
44 fi
45 resultLabel=jetinfo
46 inputdir=/scratch/dkralph/MitHzz4l_028/Selection/root/$resultLabel
47
48 echo "Training $label"
49 echo " resultLabel: $resultLabel"
50 echo " interpolate: $interpolate"
51 echo " window: $window"
52 echo " fakes: $fakes"
53 echo " era2011: $era2011"
54 echo " ptvars: $ptvars"
55 echo " multiclass: $multiclass"
56 echo " multisigs: $multisigs"
57
58 while read line; do
59 if echo $line | grep '^#' &> /dev/null; then continue; fi
60 if echo $line | grep '^\^' &> /dev/null; then continue; fi
61
62 # skip the samples that don't exist if we're interpolating...
63 haveMCdkr=`echo $line | awk '{print $8}'`
64 if [ "$haveMCdkr" == "0" ] && ! [ $interpolate ]; then continue; fi
65
66 mH=`echo $line | awk '{print $3}'`
67 # if [ "$mH" != "125" ]; then continue; fi
68 echo $mH
69 # set low and high values of mass window
70 if (( window == 0 )); then
71 wL=0
72 wH=1000
73 elif (( window == 1 )); then
74 wL=`echo $line | awk '{print $4}'`
75 wH=`echo $line | awk '{print $5}'`
76 elif (( window == 2 )); then
77 wL=`echo $line | awk '{print $11}'`
78 wH=`echo $line | awk '{print $12}'`
79 elif (( window == 3 )); then
80 wL=`echo $line | awk '{print $13}'`
81 wH=`echo $line | awk '{print $14}'`
82 fi
83
84 # take events from these two masses to interpolate
85 mH_lo_dkr=`echo $line | awk '{print $9}'`
86 mH_hi_dkr=`echo $line | awk '{print $10}'`
87
88 config=$PWD/Angles/data/tmp/trainAngles-$label-$mH-$mH_lo_dkr-$mH_hi_dkr.config
89
90 if [ $era2011 ]; then
91 sigStrFirst=f11-h
92 sigStrSecond=zz4l-gf-v14b-bp
93 bkgs='f11-zz4e-powheg-v14b-bp f11-zz4m-powheg-v14b-bp f11-zz2e2m-powheg-v14b-bp'
94 if [ $fakes ]; then
95 bkgs="$bkgs fakes-r11-histat fakes-r12-histat";
96 fi
97 else
98 sigStrFirst=s12-h
99 sigStrSecond=zz4l-gf-v2-dkr
100 # # lo is good up to wH = 155-160 or so
101 # # med is good from wL = 115 to wH = 220 or so
102 # if [ "`echo "$wH < 155" | bc -l`" == "1" ]; then
103 # bkgs='s12-zz4e-lo-dkr s12-zz4m-lo-dkr s12-zz2e2m-lo-dkr s12-zz4e-lo-v2-dkr s12-zz4m-lo-v2-dkr s12-zz2e2m-lo-v2-dkr'
104 # elif [ "`echo "$wH < 220" | bc -l`" == "1" ]; then
105 # bkgs='s12-zz4e-med-dkr s12-zz4m-med-dkr s12-zz2e2m-med-dkr'
106 # else
107 # bkgs='s12-zz4e-powheg-v9 s12-zz4m-powheg-v9 s12-zz2e2m-powheg-v9'
108 # fi
109 bkgs='s12-zz4e-pu-dkr s12-zz4m-pu-dkr s12-zz2e2m-pu-dkr'
110 if [ $fakes ]; then
111 bkgs="$bkgs fakes-r12-histat fakes-r11-histat";
112 fi
113 fi
114
115 rm -f $config
116 if [ $NTrees ]; then echo "^NTrees $NTrees" >> $config; fi
117 if [ $NNodesMax ]; then echo "^NNodesMax $NNodesMax" >> $config; fi
118 if [ $Shrinkage ]; then echo "^Shrinkage $Shrinkage" >> $config; fi
119 if [ $nCuts ]; then echo "^nCuts $nCuts" >> $config; fi
120 if [ $nMax ]; then echo "^nMax $nMax" >> $config; fi
121 echo "^inputdir $inputdir" >> $config # not used at the moment...
122 if [ $multiclass ]; then echo "^multiclass multiclass" >> $config; fi
123 if [ $multisigs ]; then echo "^multisigs multisigs" >> $config; fi
124 if [ $multisigs ]; then
125 if (( mH != 125 )); then continue; fi
126 echo "sig 1 $inputdir/s12-x125zz4l-0m-v9/merged.root $mH" >> $config
127 echo "sig2 1 $inputdir/s12-x125zz4l-0p-v9/merged.root $mH" >> $config
128 # echo "sig3 1 $inputdir/s12-x125zz4l-2p-v9/merged.root $mH" >> $config
129 elif [ $interpolate ] && [ "$haveMCdkr" == "0" ]; then
130 echo " interpolating with: $mH_lo_dkr $mH_hi_dkr"
131 test=`echo "($wL < $mH_lo_dkr - 4) || ( $wH > $mH_hi_dkr + 4 )" | bc -l`
132 if [ "$test" == "0" ]; then echo -e "\nmass window ($wL,$wH) too narrow for this interpolation!\n"; exit 1; fi
133 echo "sig -1 $inputdir/$sigStrFirst${mH_lo_dkr}$sigStrSecond/merged.root $mH_lo_dkr" >> $config
134 echo "sig -1 $inputdir/$sigStrFirst${mH_hi_dkr}$sigStrSecond/merged.root $mH_hi_dkr" >> $config
135 else
136 echo "sig 1 $inputdir/$sigStrFirst${mH}$sigStrSecond/merged.root $mH" >> $config
137 mH_lo_dkr=0
138 mH_hi_dkr=0
139 fi
140 for bkg in $bkgs; do
141 echo "bkg 1 $inputdir/$bkg/merged.root -1" >> $config
142 done
143
144 if [ $m4l ]; then
145 varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2:pt4l:y4l:Z1pt:Z2pt:zzdotz1:zzdotz2:dphi1:dphi2:m4l
146 elif [ $ptvars ]; then
147 varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2:pt4l:y4l:Z1pt:Z2pt:zzdotz1:zzdotz2:dphi1:dphi2
148 elif [ $pt4l ]; then
149 varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2:pt4l
150 else
151 varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2
152 fi
153
154 outputdir=/scratch/dkralph/MitHzz4l_028/Angles/root/training/$label
155 mkdir -p $outputdir/logs
156 outputfile=$outputdir/hzz4lBDT.${mH}.root
157 weightfile=$outputdir/weights/hzz4l_mH${mH}_BDTG.weights.xml
158 if [ $delete ]; then rm -vf $outputfile $weightfile; fi
159 if [ -s $outputfile ] && [ -s $weightfile ]; then echo " already there..."; continue; fi
160 args="$exe $config $outputfile hzz4l_mH${mH} $varstring ${mH} ${wL} ${wH} $mH_lo_dkr $mH_hi_dkr"
161 if [ $condor ]; then
162 ./scripts/submit.sh $args --output $outputfile
163 else
164 cd $outputdir
165 # $args
166 $args &> $outputdir/logs/hzz4lBDT.${mH}.txt &
167 cd $OLDPWD
168 fi
169
170 sleep 0.2
171 limit_procs `basename $exe`
172
173 done < $mHfile
174
175 #while ps | grep `basename $exe | sed 's/\([a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]\).*/\1/'` &> /dev/null; do
176 # echo "still running... "
177 # sleep 0.5
178 #done
179
180 #mkdir -p ./Angles/root/training/$label/weights/
181 #mv -v ./weights/* ./Angles/root/training/$label/weights/