ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/DistributedModelCalculations/ShapeLimits/CreateModel.sh
Revision: 1.3
Committed: Fri Apr 27 07:09:25 2012 UTC (13 years ago) by buchmann
Content type: application/x-sh
Branch: MAIN
Changes since 1.2: +9 -1 lines
Log Message:
Added error detection to CreateModel.sh

File Contents

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