Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:22

0001 #!/bin/bash
0002 grep "LINESHAPE EFFICIENCY:" *.out > tmp.txt
0003 cat tmp.txt | sed "s|.out:LINESHAPE EFFICIENCY||g" > parsed_lineshape.txt
0004 grep "qMisID EFFICIENCY:" *.out > tmp.txt
0005 cat tmp.txt | sed "s|.out:qMisID EFFICIENCY||g" > parsed_qmisid.txt
0006 grep "LINESHAPE EFFICIENCY:" *.out.mc > tmp.txt
0007 cat tmp.txt | sed "s|.out.mc:LINESHAPE EFFICIENCY||g" > parsed_lineshape.txt.mc
0008 grep "qMisID EFFICIENCY:" *.out.mc > tmp.txt
0009 cat tmp.txt | sed "s|.out.mc:qMisID EFFICIENCY||g" > parsed_qmisid.txt.mc
0010 grep "LINESHAPE EFFICIENCY:" *.out.mc.truth > tmp.txt
0011 cat tmp.txt | sed "s|.out.mc.truth:LINESHAPE EFFICIENCY||g" > parsed_lineshape.txt.mc.truth
0012 grep "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   pass: chi2/dof=" *.out >tmp.txt
0013 cat tmp.txt | sed "s|.out:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   pass: chi2/dof=||g" > parsed_passing_chi2.txt
0014 grep "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   fail: chi2/dof=" *.out >tmp.txt
0015 cat tmp.txt | sed "s|.out:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   fail: chi2/dof=||g" > parsed_failing_chi2.txt
0016 
0017 
0018 grep "(+" *.out > tmp.txt
0019 cat tmp.txt | sed "s|.out:Floating Parameter  InitialValue    FinalValue (+HiError,-LoError)    GblCorr.||g" > parsed_minos0.txt
0020 grep "LINESHAPE SIGNAL" *.out > tmp.txt
0021 cat tmp.txt | sed "s|.out:LINESHAPE SIGNAL pass, fail=||g" > parsed_nSignal.txt
0022 grep "LINESHAPE BKG" *.out > tmp.txt
0023 cat tmp.txt | sed "s|.out:LINESHAPE BKG pass, fail=||g" > parsed_nBkg.txt
0024 
0025 
0026 grep "LINESHAPE SIGNAL" *.out.mc > tmp.txt
0027 cat tmp.txt | sed "s|.out.mc:LINESHAPE SIGNAL pass, fail=||g" > parsed_nSignal.txt.mc
0028 
0029 grep "LINESHAPE SIGNAL" *.out.mc.truth > tmp.txt
0030 cat tmp.txt | sed "s|.out.mc.truth:LINESHAPE SIGNAL pass, fail=||g" > parsed_nSignal.txt.mc.truth
0031 
0032 
0033 ### OK now we have all effs dumped to the txt files -- from here we want to produce a table
0034 arrayLength=35
0035 effArray_type[$arrayLength]=0
0036 effArray_lineshape[$arrayLength]=0
0037 effArray_qmisid[$arrayLength]=0
0038 effArray_lineshape_mc[$arrayLength]=0
0039 effArray_qmisid_mc[$arrayLength]=0
0040 effArray_lineshape_mc_truth[$arrayLength]=0
0041 effArray_lineshape_stat[$arrayLength]=0
0042 effArray_qmisid_stat[$arrayLength]=0
0043 effArray_lineshape_syst[$arrayLength]=0
0044 effArray_qmisid_syst[$arrayLength]=0
0045 effArray_qmisid_mc_syst[$arrayLength]=0
0046 
0047 passChi2[$arrayLength]=0
0048 failChi2[$arrayLength]=0
0049 
0050 passSig[$arrayLength]=0
0051 failSig[$arrayLength]=0
0052 passBkg[$arrayLength]=0
0053 failBkg[$arrayLength]=0
0054 
0055 passSig_mc[$arrayLength]=0
0056 failSig_mc[$arrayLength]=0
0057 
0058 passSig_mc_truth[$arrayLength]=0
0059 failSig_mc_truth[$arrayLength]=0
0060 
0061 
0062 
0063 i=0
0064 exec<parsed_lineshape.txt
0065 while read line; do
0066 echo $line > tmp0.txt
0067 effArray_type[$i]=`awk '{print $1}' tmp0.txt`
0068 effArray_lineshape[$i]=`awk '{print $2}' tmp0.txt`
0069 effArray_lineshape_stat[$i]=`awk '{print $4}' tmp0.txt`
0070 #echo ${effArray_type[$i][0]} ${effArray_lineshape[$i][0]} ${effArray_lineshape_stat[$i]} 
0071 i=$(($i+1))
0072 done
0073 
0074 
0075 i=0
0076 exec<parsed_lineshape.txt.mc
0077 while read line; do
0078 echo $line > tmp0.txt
0079 effArray_lineshape_mc[$i]=`awk '{print $2}' tmp0.txt`
0080 i=$(($i+1))
0081 done
0082 
0083 i=0
0084 exec<parsed_lineshape.txt.mc.truth
0085 while read line; do
0086 echo $line > tmp0.txt
0087 effArray_lineshape_mc_truth[$i]=`awk '{print $2}' tmp0.txt`
0088 i=$(($i+1))
0089 done
0090 
0091 
0092 i=0
0093 exec<parsed_qmisid.txt
0094 while read line; do
0095 echo $line > tmp0.txt
0096 effArray_qmisid[$i]=`awk '{print $2}' tmp0.txt`
0097 effArray_qmisid_stat[$i]=`awk '{print $4}' tmp0.txt`
0098 effArray_qmisid_syst[$i]=`awk '{print $6}' tmp0.txt`
0099 i=$(($i+1))
0100 done
0101 
0102 i=0
0103 exec<parsed_qmisid.txt.mc
0104 while read line; do
0105 echo $line > tmp0.txt
0106 effArray_qmisid_mc[$i]=`awk '{print $2}' tmp0.txt`
0107 effArray_qmisid_mc_syst[$i]=`awk '{print $6}' tmp0.txt`
0108 i=$(($i+1))
0109 done
0110 
0111 
0112 i=0
0113 exec<parsed_passing_chi2.txt
0114 while read line; do
0115 echo $line > tmp0.txt
0116 passChi2[$i]=`awk '{print $2}' tmp0.txt`
0117 i=$(($i+1))
0118 done
0119 
0120 i=0
0121 exec<parsed_failing_chi2.txt
0122 while read line; do
0123 echo $line > tmp0.txt
0124 failChi2[$i]=`awk '{print $2}' tmp0.txt`
0125 i=$(($i+1))
0126 done
0127 
0128 i=0
0129 exec<parsed_nSignal.txt
0130 while read line; do
0131 echo $line > tmp0.txt
0132 passSig[$i]=`awk '{print $2}' tmp0.txt`
0133 failSig[$i]=`awk '{print $5}' tmp0.txt`
0134 i=$(($i+1))
0135 done
0136 
0137 i=0
0138 exec<parsed_nBkg.txt
0139 while read line; do
0140 echo $line > tmp0.txt
0141 passBkg[$i]=`awk '{print $2}' tmp0.txt`
0142 failBkg[$i]=`awk '{print $5}' tmp0.txt`
0143 i=$(($i+1))
0144 done
0145 
0146 
0147 i=0
0148 exec<parsed_nSignal.txt.mc
0149 while read line; do
0150 echo $line > tmp0.txt
0151 passSig_mc[$i]=`awk '{print $2}' tmp0.txt`
0152 failSig_mc[$i]=`awk '{print $5}' tmp0.txt`
0153 i=$(($i+1))
0154 done
0155 
0156 i=0
0157 exec<parsed_nSignal.txt.mc.truth
0158 while read line; do
0159 echo $line > tmp0.txt
0160 passSig_mc_truth[$i]=`awk '{print $2}' tmp0.txt`
0161 failSig_mc_truth[$i]=`awk '{print $5}' tmp0.txt`
0162 i=$(($i+1))
0163 done
0164 
0165 
0166 
0167 
0168 
0169 ### OK -- now go all info we need
0170 mv efficiencyTable.txt efficiencyTable_old.txt
0171 echo "type                         line           line_stat        mc       mc_truth        qmisid         qmisid_stat      qmisid_syst      qmisid_mc      qmisid_mc_syst" >> efficiencyTable.txt
0172 i=0
0173 while [ $i -lt $arrayLength ]; do
0174 foo=${#effArray_type[$i]}
0175 add=$((25-$foo)) 
0176 x=""
0177 j=0
0178 #echo add is $add
0179 while [ $j -lt $add ]; do
0180 #x=`echo "$x + 1" | bc`
0181 x=`echo "$x-"`
0182 #echo x is $x
0183 j=$(($j+1))
0184 done
0185 x=`echo "$x :"`
0186 if [[ ${effArray_type[$i]} = *gsf* ]]; then
0187     echo ${effArray_type[$i]}  $x    ${effArray_lineshape[$i]} "     "     ${effArray_lineshape_stat[$i]} "     "     ${effArray_lineshape_mc[$i]} "     "     ${effArray_lineshape_mc_truth[$i]} >> efficiencyTable.txt
0188 elif [[ ${effArray_type[$i]} = *plus* ]]; then
0189 echo ${effArray_type[$i]}  $x    ${effArray_lineshape[$i]} "     "     ${effArray_lineshape_stat[$i]} "     "     ${effArray_lineshape_mc[$i]} "     "     ${effArray_lineshape_mc_truth[$i]}   >> efficiencyTable.txt
0190 elif [[ ${effArray_type[$i]} = *minus* ]]; then
0191 echo ${effArray_type[$i]}  $x    ${effArray_lineshape[$i]} "     "     ${effArray_lineshape_stat[$i]} "     "     ${effArray_lineshape_mc[$i]} "     "     ${effArray_lineshape_mc_truth[$i]}   >> efficiencyTable.txt
0192 else 
0193 echo ${effArray_type[$i]}  $x    ${effArray_lineshape[$i]} "     "     ${effArray_lineshape_stat[$i]} "     "     ${effArray_lineshape_mc[$i]} "     "     ${effArray_lineshape_mc_truth[$i]} "     "     ${effArray_qmisid[$i]} "     "    ${effArray_qmisid_stat[$i]} "     "     ${effArray_qmisid_syst[$i]} "     "     ${effArray_qmisid_mc[$i]} "     "     ${effArray_qmisid_mc_syst[$i]}   >> efficiencyTable.txt
0194 fi
0195 i=$(($i+1))  
0196 done
0197 
0198 
0199 
0200 
0201 
0202 mv efficiencyTable_MC.txt efficiencyTable_MC_old.txt
0203 echo "type                         mc             mc_truth       mc_pass_integral         mc_fail_integral      mc_truth_pass_integral      mc_truth_fail_integral" >> efficiencyTable_MC.txt
0204 i=0
0205 while [ $i -lt $arrayLength ]; do
0206 foo=${#effArray_type[$i]}
0207 add=$((25-$foo)) 
0208 x=""
0209 j=0
0210 #echo add is $add
0211 while [ $j -lt $add ]; do
0212 #x=`echo "$x + 1" | bc`
0213 x=`echo "$x-"`
0214 #echo x is $x
0215 j=$(($j+1))
0216 done
0217 x=`echo "$x :"`
0218 echo ${effArray_type[$i]}  $x    ${effArray_lineshape_mc[$i]} "     "     ${effArray_lineshape_mc_truth[$i]} "     "     ${passSig_mc[$i]} "                 "    ${failSig_mc[$i]} "                "     ${passSig_mc_truth[$i]} "                    "     ${failSig_mc_truth[$i]}   >> efficiencyTable_MC.txt
0219 
0220 i=$(($i+1))  
0221 done
0222 
0223 
0224 
0225 
0226 
0227 
0228 mv detailedTable.txt detailedTable_old.txt
0229 echo "type                        eff             stat             chi2_pass      chi2_fail      sig_pass      bkg_pass      sig_fail      bkg_fail    fVars_pass      fvars_errors_pass           fVars_fail       fVars_errors_fail" > detailedTable.txt
0230 i=0
0231 echo "arrayLength= " $arrayLength
0232 #while [ $i -lt 7 ]; do
0233 while [ $i -lt $arrayLength ]; do
0234 foo=${#effArray_type[$i]}
0235 add=$((25-$foo))
0236 x=""
0237 j=0
0238 while [ $j -lt $add ]; do
0239 x=`echo "$x-"`
0240 j=$(($j+1))
0241 done
0242 x=`echo "$x :"`
0243 echo -n ${effArray_type[$i]}  $x    ${effArray_lineshape[$i]} "     "     ${effArray_lineshape_stat[$i]} "     "  ${passChi2[$i]}   "     "  ${failChi2[$i]} "     "  ${passSig[$i]}   "     "  ${passBkg[$i]} "     "  ${failSig[$i]}   "     "  ${failBkg[$i]} >> detailedTable.txt
0244 
0245 ###now throw in the minos errors for the floating variables
0246 pass_par[5]=0
0247 pass_err[5]=0
0248 fail_par[5]=0
0249 fail_err[5]=0
0250 
0251 pass_par[0]=" "
0252 pass_err[0]=" "
0253 fail_par[0]=" "
0254 fail_err[0]=" "
0255 
0256 pass_par[1]=" "
0257 pass_err[1]=" "
0258 fail_par[1]=" "
0259 fail_err[1]=" "
0260 
0261 pass_par[2]=" "
0262 pass_err[2]=" "
0263 fail_par[2]=" "
0264 fail_err[2]=" "
0265 
0266 pass_par[3]=" "
0267 pass_err[3]=" "
0268 fail_par[3]=" "
0269 fail_err[3]=" "
0270 
0271 pass_par[4]=" "
0272 pass_err[4]=" "
0273 fail_par[4]=" "
0274 fail_err[4]=" "
0275 
0276 
0277 nPassPar=0
0278 nFailPar=0
0279 j=0
0280 exec<parsed_minos0.txt
0281 while read line; do
0282 #echo $line > tmp1.txt
0283 echo $line | sed "s|.out||g"  > tmp0.txt
0284 type=`awk '{print $1}' tmp0.txt`
0285 #echo $type ${effArray_type[$i]}
0286 if [[ $type = ${effArray_type[$i]} ]]; then
0287     what=`awk '{print $2}' tmp0.txt`
0288     #echo $what $j
0289     if [[ $what != *Float* ]]; then
0290         
0291         if [[ $j -eq 1 ]]; then 
0292             pass_err[$nPassPar]=`awk '{print $5}' tmp0.txt`
0293             pass_par[$nPassPar]=`awk '{print $2}' tmp0.txt`
0294             nPassPar=$(($nPassPar+1)) 
0295             #echo "yeah" $nPassPar
0296         elif [[ $j -eq 2 ]]; then
0297             fail_err[$nFailPar]=`awk '{print $5}' tmp0.txt`
0298             fail_par[$nFailPar]=`awk '{print $2}' tmp0.txt`
0299             nFailPar=$(($nFailPar+1))
0300             #echo "yeahF" $nFailPar
0301         fi
0302     else
0303         j=$(($j+1))
0304     fi
0305 fi    
0306 ###now finally print the minos errors for the floating variables
0307 done
0308 j=0
0309 #echo "npasspar failpar= " $nPassPar " " $nFailPar
0310 if [ $nPassPar -gt $nFailPar ]; then
0311     echo "    " ${pass_par[0]} "         " ${pass_err[0]}   "     "  ${fail_par[0]}   "            "    ${fail_err[0]}    >>  detailedTable.txt
0312     j=$(($j+1))
0313     while [ $j -lt $nPassPar ]; do  
0314         echo "                                                                                                                                                " ${pass_par[$j]} "         " ${pass_err[$j]}   "     "  ${fail_par[$j]}   "            "    ${fail_err[$j]}    >>  detailedTable.txt
0315         j=$(($j+1))
0316     done
0317 else
0318     echo "    " ${pass_par[0]} "         " ${pass_err[0]}   "     "  ${fail_par[0]}   "            "    ${fail_err[0]}    >>  detailedTable.txt
0319     j=$(($j+1))
0320     while [ $j -lt $nFailPar ];do
0321         echo "                                                                                                                                                " ${pass_par[$j]} "         " ${pass_err[$j]}   "      "  ${fail_par[$j]}   "            "    ${fail_err[$j]}    >>  detailedTable.txt
0322         j=$(($j+1))
0323     done
0324 fi    
0325 i=$(($i+1))  
0326 echo "i= " $i
0327 done
0328 
0329 #get rid of pesky commas
0330 #mv detailedTable.txt tmp.txt
0331 #cat tmp.txt | sed "s|,||g" >detailedTable.txt