-
Notifications
You must be signed in to change notification settings - Fork 8
/
submitLimits.sh
206 lines (173 loc) · 6.95 KB
/
submitLimits.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
DATACARD=$1
MASS=$2
OUTFILENAME=$3
BKG=$4
SIGWS=$5
JOBLOGFILES="myout.txt myerr.txt"
# OUTFILES=""
DBG=2
SEUSERSUBDIR=""
SEOUTFILES=""
HN_NAME=`whoami`
USER_SRM_HOME="srm://t3se01.psi.ch:8443/srm/managerv2?SFN=/pnfs/psi.ch/cms/trivcat/store/user"
TOPWORKDIR=/scratch/`whoami`
JOBDIR=submitlimits-$JOB_ID
#CMSSW_DIR="/mnt/t3nfs01/data01/shome/thaarres/EXOVVAnalysisRunII/LimitCode/CMSSW_7_1_5"
CMSSW_DIR="/mnt/t3nfs01/data01/shome/dschafer/CMSSW_7_4_7"
BASEDIR=`pwd`
LOGDIRNAME=${BASEDIR}/${JOBDIR}
OUTDIR=${BASEDIR}/${JOBDIR}
#mkdir ${OUTDIR}
############ BATCH QUEUE DIRECTIVES ##############################
# Lines beginning with #$ are used to set options for the SGE
# queueing system (same as specifying these options to the qsub
# command
# Job name (defines name seen in monitoring by qstat and the
# job script's stderr/stdout names)
#$ -N interpolateAll_job
### Specify the queue on which to run
#$ -q short.q
# Change to the current working directory from which the job got
# submitted (will also result in the job report stdout/stderr being
# written to this directory)
#$ -cwd
# here you could change location of the job report stdout/stderr files
# if you did not want them in the submission directory
#$ -o $OUTDIR
#$ -e $OUTDIR
#################################################################
##### MONITORING/DEBUG INFORMATION ###############################
DATE_START=`date +%s`
echo "Job started at " `date`
cat <<EOF
################################################################
## QUEUEING SYSTEM SETTINGS:
HOME=$HOME
USER=$USER
JOB_ID=$JOB_ID
JOB_NAME=$JOB_NAME
HOSTNAME=$HOSTNAME
TASK_ID=$TASK_ID
QUEUE=$QUEUE
EOF
echo "################################################################"
if test 0"$DBG" -gt 0; then
echo "######## Environment Variables ##########"
env
echo "################################################################"
fi
##### SET UP WORKDIR AND ENVIRONMENT ######################################
STARTDIR=`pwd`
WORKDIR=$TOPWORKDIR/$JOBDIR
RESULTDIR=$STARTDIR/$JOBDIR
if test x"$SEUSERSUBDIR" = x; then
SERESULTDIR=$USER_SRM_HOME/$HN_NAME/$JOBDIR
else
SERESULTDIR=$USER_SRM_HOME/$HN_NAME/$SEUSERSUBDIR
fi
if test -e "$WORKDIR"; then
echo "ERROR: WORKDIR ($WORKDIR) already exists! Aborting..." >&2
exit 1
fi
mkdir -p $WORKDIR
if test ! -d "$WORKDIR"; then
echo "ERROR: Failed to create workdir ($WORKDIR)! Aborting..." >&2
exit 1
fi
cd $WORKDIR
cat <<EOF
################################################################
## JOB SETTINGS:
STARTDIR=$STARTDIR
WORKDIR=$WORKDIR
RESULTDIR=$RESULTDIR
SERESULTDIR=$SERESULTDIR
EOF
###########################################################################
## YOUR FUNCTIONALITY CODE GOES HERE
# set up CMS environment
# do to: write submission script like this :
#qsub -q all.q submitLimits.sh CMS_jj_qZ_2000_13TeV_CMS_jj_qZHP 2000 CMS_jj_2000_qZ_13TeV_CMS_jj_qZHP_asymptoticCLs_new.root CMS_jj_bkg_qV_13TeV CMS_jj_qZ_2000_13TeV
#RUNSCRIPT=${BASEDIR}/combine
INFILE=${BASEDIR}/${INPUT}
source $VO_CMS_SW_DIR/cmsset_default.sh
cd $CMSSW_DIR/src
eval `scramv1 runtime -sh`
if test $? -ne 0; then
echo "ERROR: Failed to source scram environment" >&2
exit 1
fi
cd $WORKDIR
# copy needed files:
mkdir datacards
mkdir workspaces
cp /mnt/t3nfs01/data01/shome/dschafer/CMSSW_7_4_7/src/DijetCombineLimitCode/datacards/${DATACARD}.txt datacards/
cp /mnt/t3nfs01/data01/shome/dschafer/CMSSW_7_4_7/src/DijetCombineLimitCode/workspaces/${SIGWS}.root workspaces/
cp /mnt/t3nfs01/data01/shome/dschafer/CMSSW_7_4_7/src/DijetCombineLimitCode/workspaces/${BKG}.root workspaces/
cd datacards
#echo "input: ${INPUT}" >> myout.txt 2>>myerr.txt
echo "datacard: ${DATACARD}" >> myout.txt 2>>myerr.txt
#combine datacards/CMS_jj_altBulkWW_2000_13TeV_CMS_jj_WWHP.txt -M Asymptotic -v2 -m 2000 -n BulkWW_M2000_alt --rMax 100 --rMin 0.000001
echo "combine ${DATACARD}.txt -M Asymptotic -m ${MASS} -n test --rMax 100 --rMin 0.000001" >> myout.txt 2>>myerr.txt
echo "mv higgsCombineTest.Asymptotic.mH${MASS}.root ${OUTFILENAME}" >> myout.txt 2>>myerr.txt
combine ${DATACARD}.txt -M Asymptotic -m ${MASS} -n test --rMax 100 --rMin 0.000001 >> myout.txt 2>>myerr.txt
mv higgs*.root /mnt/t3nfs01/data01/shome/dschafer/CMSSW_7_4_7/src/DijetCombineLimitCode/test/${OUTFILENAME} >> myout.txt 2>>myerr.txt
mv myerr.txt ../
mv myout.txt ../
#### RETRIEVAL OF OUTPUT FILES AND CLEANING UP ############################
cd $WORKDIR
if test 0"$DBG" -gt 0; then
echo "########################################################"
echo "############# Working directory contents ###############"
echo "pwd: " `pwd`
ls -Rl
echo "########################################################"
echo "YOUR OUTPUT WILL BE MOVED TO $RESULTDIR"
echo "########################################################"
fi
if test x"$JOBLOGFILES" != x; then
mkdir -p $RESULTDIR
if test ! -e "$RESULTDIR"; then
echo "ERROR: Failed to create $RESULTDIR ...Aborting..." >&2
exit 1
fi
for n in $JOBLOGFILES; do
if test ! -e $WORKDIR/$n; then
echo "WARNING: Cannot find output file $WORKDIR/$n. Ignoring it" >&2
else
cp -a $WORKDIR/$n $RESULTDIR/$n
if test $? -ne 0; then
echo "ERROR: Failed to copy $WORKDIR/$n to $RESULTDIR/$n" >&2
fi
fi
done
fi
if test x"$OUTFILES" != x; then
if test 0"$DBG" -ge 2; then
srmdebug="-v"
fi
for n in $OUTFILES; do
if test ! -e $WORKDIR/$n; then
echo "WARNING: Cannot find output file $WORKDIR/$n. Ignoring it" >&2
else
cp -a $WORKDIR/$n $OUTDIR/$n
if test $? -ne 0; then
echo "ERROR: Failed to copy $WORKDIR/$n to $OUTDIR/$n" >&2
fi
fi
done
fi
echo "Cleaning up $WORKDIR"
rm -rf $WORKDIR
rm -rf $LOGDIRNAME/$JOBDIR
mv $STARTDIR/$JOBDIR $LOGDIRNAME/.
###########################################################################
DATE_END=`date +%s`
RUNTIME=$((DATE_END-DATE_START))
echo "################################################################"
echo "Job finished at " `date`
echo "Wallclock running time: $RUNTIME s"
cd ${BASEDIR}
mv interpolateAll_job.o$JOB_ID interpolateAll_job.e$JOB_ID $LOGDIRNAME/.
exit 0