1 |
buchmann |
1.1 |
#!/bin/bash
|
2 |
|
|
|
3 |
|
|
if [ $# -lt 2 ]; then
|
4 |
|
|
echo "This script is called automatically when trying to compute limits using shapes. it is called as follows:"
|
5 |
|
|
echo " $0 (directory where datacard & histo root file are stored) (name of datacard, usually susydatacard.txt)"
|
6 |
|
|
fi
|
7 |
|
|
|
8 |
buchmann |
1.2 |
echo -e "Have been supplied with the following arguments \n $1 \n $2 \n $3"
|
9 |
buchmann |
1.4 |
ORIGDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
10 |
|
|
|
11 |
buchmann |
1.1 |
cd ~/final_production_2011/CMSSW_4_2_8/src/HiggsAnalysis/
|
12 |
|
|
origscramarch=$SCRAM_ARCH
|
13 |
|
|
origbase=$CMSSW_BASE
|
14 |
|
|
export SCRAM_ARCH=slc5_amd64_gcc434
|
15 |
|
|
cd
|
16 |
|
|
cd /shome/buchmann/final_production_2011/CMSSW_4_2_8/src/
|
17 |
|
|
eval `scram ru -sh`
|
18 |
|
|
echo "Ready to create model file"
|
19 |
|
|
cd $1
|
20 |
|
|
python /shome/buchmann/final_production_2011/CMSSW_4_2_8/src/HiggsAnalysis/CombinedLimit/scripts/text2workspace.py $2 -b -o $1/model.root
|
21 |
|
|
if [ $? -gt 0 ]; then
|
22 |
|
|
echo "SOMETHING FAILED"
|
23 |
buchmann |
1.2 |
failures=$4
|
24 |
buchmann |
1.1 |
if [ -e $failures ]; then
|
25 |
|
|
echo "~~~~ THIS IS THE FIRST FAILURE"
|
26 |
|
|
failures=0;
|
27 |
|
|
fi
|
28 |
|
|
|
29 |
|
|
if [ $failures -lt 4 ]; then
|
30 |
|
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Going to retry (failures so far: $failures)"
|
31 |
|
|
let "failures = failures + 1"
|
32 |
|
|
cd $ORIGDIR
|
33 |
buchmann |
1.2 |
bash $0 $1 $2 $3 $failures
|
34 |
buchmann |
1.1 |
exit
|
35 |
|
|
else
|
36 |
|
|
echo "There's something totally wrong ..."
|
37 |
|
|
exit -1
|
38 |
|
|
fi
|
39 |
|
|
|
40 |
|
|
else
|
41 |
|
|
echo "Success";
|
42 |
|
|
fi
|
43 |
|
|
|
44 |
|
|
ls -ltrh $1
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
echo " ~~~~~~~~~~~~~ "
|
49 |
|
|
echo " LIMIT COMPUTATION "
|
50 |
|
|
echo " ~~~~~~~~~~~~~ "
|
51 |
|
|
|
52 |
|
|
#$CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/model.root -t500 -s2
|
53 |
|
|
|
54 |
buchmann |
1.2 |
#$CMSSW_BASE/bin/$SCRAM_ARCH/combine -M HybridNew --frequentist --testStat LHC $1/model.root -H ProfileLikelihood
|
55 |
buchmann |
1.1 |
|
56 |
|
|
echo "Ready to run limit!"
|
57 |
buchmann |
1.4 |
|
58 |
|
|
modelsource="model.root"
|
59 |
|
|
if [[ $5 -gt 0 ]]; then
|
60 |
|
|
modelsource="susydatacard.txt"
|
61 |
|
|
fi
|
62 |
|
|
|
63 |
buchmann |
1.2 |
if [[ $3 -gt 1 ]]; then
|
64 |
|
|
echo "Asymptotic is $3 (0) therefore doing FULL LIMITS"
|
65 |
|
|
# command="$CMSSW_BASE/bin/$SCRAM_ARCH/combine -M HybridNew -t1 --frequentist --testStat LHC $1/model.root -H ProfileLikelihood"
|
66 |
buchmann |
1.4 |
command="$CMSSW_BASE/bin/$SCRAM_ARCH/combine -M HybridNew --rule CLs --testStat LHC -H ProfileLikelihood --freq -T 1000 -i 8 --saveHybridResult --saveToys -v 1 -s 0 $1/${modelsource} "
|
67 |
buchmann |
1.2 |
else
|
68 |
|
|
if [[ $3 -lt 1 ]]; then
|
69 |
|
|
echo "Asymptotic is $3 (0) therefore doing ASYMPTOTIC LIMITS"
|
70 |
buchmann |
1.4 |
command="$CMSSW_BASE/bin/$SCRAM_ARCH/combine -M Asymptotic -t1 $1/${modelsource} -H ProfileLikelihood"
|
71 |
buchmann |
1.2 |
else
|
72 |
|
|
echo "Asymptotic is $3 (0) therefore doing ASYMPTOTIC LIMITS but WITH initial guess"
|
73 |
buchmann |
1.4 |
command="$CMSSW_BASE/bin/$SCRAM_ARCH/combine -M Asymptotic -t1 $1/${modelsource} -H ProfileLikelihood"
|
74 |
buchmann |
1.2 |
fi
|
75 |
|
|
fi
|
76 |
|
|
|
77 |
buchmann |
1.1 |
echo "Going to run $command"
|
78 |
buchmann |
1.3 |
#time eval $command 3>&1 >&2 2>&3 3>&- | tee $1/log.txt
|
79 |
|
|
time eval $command 2>&1 | tee $1/log.txt
|
80 |
buchmann |
1.1 |
echo "Done running limits"
|
81 |
buchmann |
1.3 |
errorsencountered=`cat $1/log.txt | grep nan | wc -l`
|
82 |
|
|
echo "DURING LIMIT COMPUTATOIN, AN ERROR LOG HAS BEEN WRITTEN TO $1/errorlog.txt which contains $errorsencountered not-a-value's"
|
83 |
|
|
if [[ $errorsencountered -gt 20 ]]; then
|
84 |
|
|
# something is seriously wrong, there's no point in continuing
|
85 |
|
|
exit -1
|
86 |
|
|
fi
|
87 |
|
|
|
88 |
buchmann |
1.1 |
outfile="INVALID"
|
89 |
|
|
echo `pwd`
|
90 |
|
|
for i in `ls -ltrh | grep root | grep ombine | awk '{ print $9 }'`; do
|
91 |
|
|
outfile=$i
|
92 |
|
|
done
|
93 |
|
|
if [[ $outfile == *INVALID* ]]; then
|
94 |
|
|
echo "THERE WAS NO OUTPUT FROM THE LIMIT COMPUTATION ..."
|
95 |
|
|
ls -ltrh
|
96 |
|
|
exit -1
|
97 |
|
|
fi
|
98 |
|
|
|
99 |
|
|
g++ $ORIGDIR/ReadAndSave.C -o ReadAndSave.exec `root-config --glibs --cflags`
|
100 |
|
|
|
101 |
buchmann |
1.2 |
if [[ $3 -gt 1 ]]; then
|
102 |
|
|
startfile=$outfile
|
103 |
|
|
outfile="allmerged.root"
|
104 |
buchmann |
1.4 |
$CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/${modelsource} -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.16
|
105 |
|
|
$CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/${modelsource} -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.025
|
106 |
|
|
$CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/${modelsource} -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.5
|
107 |
|
|
$CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/${modelsource} -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.84
|
108 |
|
|
$CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/${modelsource} -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.975
|
109 |
|
|
hadd $outfile higgs*.root
|
110 |
buchmann |
1.2 |
fi
|
111 |
|
|
|
112 |
buchmann |
1.1 |
./ReadAndSave.exec $1/$outfile $1/ShapeDropletResult.txt
|
113 |
|
|
|
114 |
|
|
rm ReadAndSave.exec
|
115 |
|
|
|
116 |
|
|
echo "$ORIGDIR/ReadAndSave.exec $1/$outfile $1/ShapeDropletResult.txt"
|
117 |
|
|
echo "Stored the droplet in $1/ShapeDropletResult.txt"
|
118 |
|
|
|
119 |
|
|
|
120 |
buchmann |
1.2 |
|
121 |
buchmann |
1.1 |
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
origscramarch=$SCRAM_ARCH
|
126 |
|
|
export SCRAM_ARCH=$origscramarch
|
127 |
|
|
cd $origbase
|
128 |
|
|
eval `scram ru -sh`
|