ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/DistributedModelCalculations/ShapeLimits/CreateModel.sh
Revision: 1.2
Committed: Wed Apr 25 13:34:44 2012 UTC (13 years ago) by buchmann
Content type: application/x-sh
Branch: MAIN
Changes since 1.1: +30 -7 lines
Log Message:
Added initial guess of limits and additional expected limits

File Contents

# User Rev Content
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.1 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 buchmann 1.2 failures=$4
23 buchmann 1.1 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 buchmann 1.2 bash $0 $1 $2 $3 $failures
33 buchmann 1.1 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 buchmann 1.2 #$CMSSW_BASE/bin/$SCRAM_ARCH/combine -M HybridNew --frequentist --testStat LHC $1/model.root -H ProfileLikelihood
54 buchmann 1.1
55     echo "Ready to run limit!"
56 buchmann 1.2 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 buchmann 1.1 echo "Going to run $command"
71     time eval $command
72     echo "Done running limits"
73     outfile="INVALID"
74     echo `pwd`
75     for i in `ls -ltrh | grep root | grep ombine | awk '{ print $9 }'`; do
76     outfile=$i
77     done
78     if [[ $outfile == *INVALID* ]]; then
79     echo "THERE WAS NO OUTPUT FROM THE LIMIT COMPUTATION ..."
80     ls -ltrh
81     exit -1
82     fi
83    
84     g++ $ORIGDIR/ReadAndSave.C -o ReadAndSave.exec `root-config --glibs --cflags`
85    
86 buchmann 1.2 if [[ $3 -gt 1 ]]; then
87     startfile=$outfile
88     outfile="allmerged.root"
89     $CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/model.root -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.16
90     $CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/model.root -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.025
91     $CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/model.root -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.5
92     $CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/model.root -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.84
93     $CMSSW_BASE/bin/$SCRAM_ARCH/combine $1/model.root -M HybridNew --freq --grid=$startfile --expectedFromGrid 0.975
94     hadd $outfile *.root
95     fi
96    
97 buchmann 1.1 ./ReadAndSave.exec $1/$outfile $1/ShapeDropletResult.txt
98    
99     rm ReadAndSave.exec
100    
101     echo "$ORIGDIR/ReadAndSave.exec $1/$outfile $1/ShapeDropletResult.txt"
102     echo "Stored the droplet in $1/ShapeDropletResult.txt"
103    
104    
105 buchmann 1.2
106 buchmann 1.1
107    
108    
109    
110     origscramarch=$SCRAM_ARCH
111     export SCRAM_ARCH=$origscramarch
112     cd $origbase
113     eval `scram ru -sh`