1 |
#!/bin/sh
|
2 |
alias grep='grep --color=auto'
|
3 |
|
4 |
#limit_procs() {
|
5 |
# string=`echo $1 | sed 's/\(..............\).*/\1/'`
|
6 |
# nprocs=`ps | grep $string | wc -l`
|
7 |
# while (( $nprocs > 45 )); do echo -n "."; sleep 1; nprocs=`ps auxw|grep $string | wc -l`; done
|
8 |
#}
|
9 |
|
10 |
label=$1
|
11 |
if echo "$@" | grep ' \-\-interpolate' ; then interpolate=interpolate; echo "interpolate: $interpolate"; else interpolate=; fi
|
12 |
if echo "$@" | grep ' \-\-delete' ; then delete=delete; echo " delete: $delete"; else delete=; fi
|
13 |
if echo "$@" | grep ' \-\-ptvars' ; then ptvars=ptvars; echo " ptvars: $ptvars"; else ptvars=; fi
|
14 |
if echo "$@" | grep ' \-\-pt4l' ; then pt4l=pt4l; echo " pt4l: $pt4l"; else pt4l=; fi
|
15 |
if echo "$@" | grep ' \-\-condor' ; then condor=condor; echo " condor: $condor"; else condor=; fi
|
16 |
if echo "$@" | grep ' \-\-check' ; then check=check; echo " check: $check"; else check=; fi
|
17 |
if echo "$@" | grep ' \-\-makeMela' ; then makeMela=--makeMela; echo " makeMela: $makeMela"; else makeMela=; fi
|
18 |
if echo "$@" | grep ' \-\-multiclass' ; then multiclass=--multiclass; echo " multiclass: $multiclass"; else multiclass=; fi
|
19 |
if echo "$@" | grep ' \-\-multisigs' ; then multisigs=--multisigs; echo " multisigs: $multisigs"; else multisigs=; fi
|
20 |
if echo "$@" | grep ' \-\-flattree' ; then flattree=--flattree; echo " flattree: $flattree"; else flattree=; fi
|
21 |
if echo "$@" | grep ' \-\-withPtY' ; then withPtY=--withPtY; echo " withPtY: $withPtY"; else withPtY=; fi
|
22 |
window=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-window' | grep -v "\-\-window"`; if ! [ $window ]; then window=1; fi
|
23 |
spinWeightLabel=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-spinWeightLabel' | grep -v "\-\-spinWeightLabel"`; if ! [ $spinWeightLabel ]; then spinWeightLabel=; fi
|
24 |
if echo "$@" | grep ' \-\-weightLabel' ; then
|
25 |
weightLabel=`echo $@ | sed 's/[ ][ ]*/\n/g' | grep -A1 '\-\-weightLabel' | grep -v "\-\-weightLabel"`
|
26 |
else
|
27 |
weightLabel=$label
|
28 |
fi
|
29 |
if echo $label | grep 2011; then
|
30 |
era2011=era2011;
|
31 |
eraArg="--era 2011"
|
32 |
else
|
33 |
era2011=
|
34 |
eraArg="--era 2012"
|
35 |
fi
|
36 |
|
37 |
mHfile=Angles/data/mHs.conf
|
38 |
|
39 |
condor_q -l &>/tmp/dkralph/condor_q-cache.txt
|
40 |
|
41 |
if ! [ $label ]; then echo "no label..."; exit 1; fi
|
42 |
#if ! [ $interpolate ]; then echo "no interpolation specified..."; exit 1; fi
|
43 |
LD_LIBRARY_PATH=/afs/cern.ch/cms/slc5_amd64_gcc434/external/boost/1.44.0-cms3/lib/:${LD_LIBRARY_PATH}
|
44 |
|
45 |
resultLabel=hcp
|
46 |
exe=$PWD/Angles/bin/fillBdtTree.exe
|
47 |
baseDir=/afs/cern.ch/work/d/dkralph/MitHzz4l/Angles/root/training
|
48 |
outdirBase=$baseDir/$label
|
49 |
weightDir=$baseDir/$weightLabel/weights
|
50 |
spinWeightDir=$baseDir/$spinWeightLabel/weights
|
51 |
inputdir=/afs/cern.ch/work/d/dkralph/MitHzz4l/Selection/root/$resultLabel
|
52 |
|
53 |
echo "Adding branches: $label"
|
54 |
echo " resultLabel: $resultLabel"
|
55 |
echo " window: $window"
|
56 |
echo " interpolate: $interpolate"
|
57 |
echo " era2011: $era2011"
|
58 |
echo " makeMela: $makeMela"
|
59 |
echo " ptvars: $ptvars"
|
60 |
|
61 |
echo -e "\n\nHEY ---> add mueg dsets back in <--- \n\n"
|
62 |
while read -u 7 line; do
|
63 |
if echo $line | grep '^#' &> /dev/null; then continue; fi
|
64 |
if echo $line | grep '^\^' &> /dev/null; then continue; fi
|
65 |
|
66 |
mH=`echo $line | awk '{print $3}'`
|
67 |
if [ $multisigs ] && (( mH != 125 )); then continue; fi
|
68 |
|
69 |
# skip the samples that don't exist if we're not interpolating...
|
70 |
if [ "`echo $line | awk '{print $1}'`" == "1" ]; then haveMC2011=1; else haveMC2011=; fi
|
71 |
if [ "`echo $line | awk '{print $2}'`" == "1" ]; then haveMC2012=1; else haveMC2012=; fi
|
72 |
if ! [ $haveMC2011 ] && ! [ $haveMC2012 ] && ! [ $interpolate ]; then continue; fi
|
73 |
|
74 |
# if [ "$mH" != "125" ]; then continue; fi
|
75 |
# set low and high values of mass window
|
76 |
if (( window == 0 )); then
|
77 |
wL=0
|
78 |
wH=1000
|
79 |
elif (( window == 1 )); then
|
80 |
wL=`echo $line | awk '{print $4}'`
|
81 |
wH=`echo $line | awk '{print $5}'`
|
82 |
elif (( window == 2 )); then
|
83 |
wL=`echo $line | awk '{print $11}'`
|
84 |
wH=`echo $line | awk '{print $12}'`
|
85 |
elif (( window == 3 )); then
|
86 |
wL=`echo $line | awk '{print $13}'`
|
87 |
wH=`echo $line | awk '{print $14}'`
|
88 |
fi
|
89 |
|
90 |
echo "${mH}, window: $wL,$wH"
|
91 |
|
92 |
if [ $ptvars ]; then
|
93 |
varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2:pt4l:y4l:Z1pt:Z2pt:zzdotz1:zzdotz2:dphi1:dphi2
|
94 |
elif [ $pt4l ]; then
|
95 |
varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2:pt4l
|
96 |
else
|
97 |
varstring=costheta1:costheta2:costhetastar:Phi:Phi1:mZ1:mZ2
|
98 |
fi
|
99 |
|
100 |
mH_lo=`echo $line | awk '{print $6}'`
|
101 |
mH_hi=`echo $line | awk '{print $7}'`
|
102 |
|
103 |
classes="gfH qqZZ lljj ggZZ data"
|
104 |
# classes="gfH qqZZ data"
|
105 |
if [ $multisigs ]; then classes="$classes 0m 0p 2p"; fi
|
106 |
for class in $classes; do # qqH
|
107 |
output=$outdirBase/$class/BDT.$class.${mH}.root
|
108 |
|
109 |
# only fill bkgs and data if signal will come from the other era
|
110 |
if [ "$class" == "gfH" ] && ! [ $interpolate ]; then
|
111 |
if [ $era2011 ] && ! [ $haveMC2011 ]; then echo " skipping nonexistent gfH"; continue; fi
|
112 |
if ! [ $era2011 ] && ! [ $haveMC2012 ]; then echo " skipping nonexistent gfH"; continue; fi
|
113 |
fi
|
114 |
|
115 |
mkdir -p `dirname $output`
|
116 |
if [ $delete ]; then rm -vf $output; fi
|
117 |
if grep $output /tmp/dkralph/condor_q-cache.txt &>/dev/null; then
|
118 |
echo " $class already running..."
|
119 |
continue;
|
120 |
elif [ -s $output ] && (( `wc -c $output | awk '{print $1}'` > 1000 )); then
|
121 |
echo " $class already there... "
|
122 |
if [ $check ]; then
|
123 |
if root -b -l -q $output 2>&1 | grep 'probably not closed'; then
|
124 |
# echo " -----> delete?"
|
125 |
# read
|
126 |
# if [ "$REPLY" == "y" ]; then
|
127 |
echo -n " "; rm -vf $output
|
128 |
# fi
|
129 |
fi
|
130 |
continue
|
131 |
fi
|
132 |
else
|
133 |
config=Angles/data/tmp/fillBdtTree-$label-$mH-$mH_lo-$mH_hi-$class.config
|
134 |
|
135 |
if [ $era2011 ]; then
|
136 |
sigStrFirst=f11-h
|
137 |
sigStrSecond=zz4l-gf-v14b-bp
|
138 |
qqZZsets='f11-zz4e-powheg-v14b-bp f11-zz4m-powheg-v14b-bp f11-zz2e2m-powheg-v14b-bp'
|
139 |
datums='r11a-del-j16-v1-bp r11a-dmu-j16-v1-bp r11b-del-j16-v1-bp r11b-dmu-j16-v1-bp'
|
140 |
fakeSets='fakes-r11'
|
141 |
ggZZsets='f11-ggzz2l2l-v14b-bp f11-ggzz4l-v14b-bp'
|
142 |
else
|
143 |
sigStrFirst=s12-h
|
144 |
sigStrSecond=zz4l-gf-v7a
|
145 |
qqZZsets='s12-zz4e-powheg-v7a s12-zz4m-powheg-v7a s12-zz2e2m-powheg-v7a'
|
146 |
# datums='r12a-del-pr-v1 r12a-dmu-pr-v1 r12b-del-pr-v1 r12b-dmu-pr-v1'
|
147 |
datums='r12a-del-j13-v1 r12a-dmu-j13-v1 r12b-del-j13-v1 r12b-dmu-j13-v1'
|
148 |
fakeSets='fakes-r12'
|
149 |
ggZZsets='f11-ggzz2l2l-v14b-bp f11-ggzz4l-v14b-bp'
|
150 |
fi
|
151 |
|
152 |
echo "^ntupledir $inputdir" > $config # not used at the moment
|
153 |
if [ $spinWeightLabel ]; then
|
154 |
echo "^spinWeightFile $spinWeightDir/hzz4l_mH${mH}_BDTG.weights.xml" >> $config
|
155 |
fi
|
156 |
if [ "$class" == "gfH" ]; then
|
157 |
if [ "$haveMC2011" == "0" ] && [ "$haveMC2012" == "0" ] && [ $interpolate ]; then
|
158 |
echo "gfH 1 $inputdir/$sigStrFirst$mH_lo$sigStrSecond/merged.root $mH_lo" >> $config # NOTE: it's a '1' here b/c I added another weight in the event loop in makeBDTTree.cc
|
159 |
echo "gfH 1 $inputdir/$sigStrFirst$mH_hi$sigStrSecond/merged.root $mH_hi" >> $config
|
160 |
else
|
161 |
echo "gfH 1 $inputdir/$sigStrFirst$mH$sigStrSecond/merged.root $mH" >> $config
|
162 |
mH_lo=0
|
163 |
mH_hi=0
|
164 |
fi
|
165 |
elif [ "$class" == "qqZZ" ]; then for qqZZset in $qqZZsets; do echo "qqZZ 1 $inputdir/$qqZZset/merged.root -1" >> $config; done
|
166 |
elif [ "$class" == "lljj" ]; then for fakeSet in $fakeSets; do echo "lljj 1 $inputdir/$fakeSet/merged.root -1" >> $config; done
|
167 |
elif [ "$class" == "ggZZ" ]; then for ggZZset in $ggZZsets; do echo "ggZZ 1 $inputdir/$ggZZset/merged.root -1" >> $config; done
|
168 |
elif [ "$class" == "data" ]; then for dat in $datums; do echo "data 1 $inputdir/$dat/merged.root -1" >> $config; done
|
169 |
elif [ "$class" == "0m" ]; then echo "gfH 1 $inputdir/s12-x125zz4l-0m-v9/merged.root $mH" >> $config
|
170 |
elif [ "$class" == "0p" ]; then echo "gfH 1 $inputdir/s12-x125zz4l-0p-v9/merged.root $mH" >> $config
|
171 |
elif [ "$class" == "2p" ]; then echo "gfH 1 $inputdir/s12-x125zz4l-2p-v9/merged.root $mH" >> $config
|
172 |
fi
|
173 |
if ! [ "$class" == "gfH" ] && ! [ "$class" == "qqH" ]; then mH_lo=0; mH_hi=0; fi
|
174 |
args="$exe --inputfile $config --output $output --weightfile $weightDir/hzz4l_mH${mH}_BDTG.weights.xml --varstring $varstring --wL $wL --wH $wH --mH_lo $mH_lo --mH_hi $mH_hi $makeMela $multiclass $flattree $multisigs $eraArg $withPtY"
|
175 |
if hostname | grep lx &>/dev/null; then
|
176 |
outLog=`echo $output | sed 's/\.root/\.out/' | sed 's@/dkralph/@/dkralph/logs/@'`
|
177 |
errLog=`echo $output | sed 's/\.root/\.err/' | sed 's@/dkralph/@/dkralph/logs/@'`
|
178 |
else
|
179 |
outLog=`echo $output | sed 's/\.root/\.out/' | sed 's@/temp/dkralph/@/scratch/dkralph/logs/@'`
|
180 |
errLog=`echo $output | sed 's/\.root/\.err/' | sed 's@/temp/dkralph/@/scratch/dkralph/logs/@'`
|
181 |
fi
|
182 |
mkdir -p `dirname $outLog`
|
183 |
if [ $condor ]; then
|
184 |
echo " ---> submitting $class"
|
185 |
if hostname | grep lx &>/dev/null; then
|
186 |
bsub -cwd $PWD -q 1nh -oo $outLog -eo $errLog $PWD/scripts/run_condor.sh $args
|
187 |
else
|
188 |
./scripts/submit.sh $args
|
189 |
fi
|
190 |
# ./scripts/submit.sh $args
|
191 |
else
|
192 |
echo " ---> running $class"
|
193 |
$args 1>$outLog 2>$errLog &
|
194 |
fi
|
195 |
fi
|
196 |
sleep .02
|
197 |
$HOME/bin/limit_procs `basename $exe`
|
198 |
done
|
199 |
echo ""
|
200 |
done 7< $mHfile
|