ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/DistributedModelCalculations/ShapeLimits/CreateModel.sh
Revision: 1.5
Committed: Thu May 17 20:01:40 2012 UTC (12 years, 11 months ago) by buchmann
Content type: application/x-sh
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +54 -44 lines
Log Message:
general overhaul of the createmodel script; instead of actually creating a model (nomen non est omen) we use the datacard directly as input for the combination tool; we also redefine the temp directory (which is now the temporary working directory); removed full cls computation (is now done via ShapeLimit)

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