#PBS -N tr21030_413 #PBS -q medium5 #PBS -S /bin/bash #PBS -l cput=6:00:00,walltime=6:00:00 #PBS -j oe -m e -M r.stdenis@physics.gla.ac.uk # env source ~cdfsoft/cdf2.shrc setup cdfsoft2 6.1.6.m setup root v5_26_00 -q GCC_3_4_6 -f Linux+2.6 cd /home/stdenis/hww_1fb/hwwcdf6.1.6.mv5_18v1_16 srt_setup -a # setup neurobayes setup neurobayes_expert # # Switches determining what portions to run # GenerateTrainingTrees=1 Use2StepsInTreeGenerationAndTraining=1 ComputeTMVA=0 DoTraining=1 Dotemplates=1 Dostackedplots=1 Dostackedinput=1 Dofit=1 separateHiggsSignals=0 # # Run from the job directory to avoid stepping on other jobs # cd /data/cdf04/stdenis/batch/run21030/job413 rm -f /data/cdf04/stdenis/batch/run21030/job413/tr413.log # # If we are to train with NB, Determine if the server is up # if((${DoTraining}==1)); then if((${ComputeTMVA}!=1)); then ping -c 1 ppepc23.physics.gla.ac.uk; let x=0; if ((x!=0)); then echo ppepc23.physics.gla.ac.uk bad; exit 1 else echo ppepc23.physics.gla.ac.uk ok at start of job; fi fi fi # # If the trees are to be made, make them # # Do tree generation for training in a separate step if desired # if(((${Use2StepsInTreeGenerationAndTraining}==1)) && ((${GenerateTrainingTrees}==1))); then Computentp /data/cdf04/stdenis/batch/run21030/job413/steerComputentp.txt > Computentp175.log 2>&1 fi # # If the training is to be done, do it # if((${DoTraining}==1)); then if((${ComputeTMVA}==1)); then # Do training.Also generate trees if not doing this in 2 steps if(((${GenerateTrainingTrees}==1)) && ((${Use2StepsInTreeGenerationAndTraining}!=1))); then NNAnaMain 175 413 -1 /data/cdf04/stdenis/batch/run21030/job413/steer.txt /data/cdf04/stdenis/batch/run21030/varset.txt TheTree:NNInput TrainingTree:/data/cdf04/stdenis/batch/run21030/job413/steerComputentp.txt:/data/cdf04/stdenis/batch/run21030/job413/trees/NNInputs_175.root > /data/cdf04/stdenis/batch/run21030/job413/tr413.log 2>&1 else NNAnaMain 175 413 -1 /data/cdf04/stdenis/batch/run21030/job413/steer.txt /data/cdf04/stdenis/batch/run21030/varset.txt TheTree:NNInput /data/cdf04/stdenis/batch/run21030/job413/trees/NNInputs_175.root > /data/cdf04/stdenis/batch/run21030/job413/tr413.log 2>&1 fi # echo "listing after running NNAnaMain" ls echo "Done listing" # # Make the plots # echo "Make plots" /home/stdenis/hww_1fb/hwwcdf6.1.6.mv5_18v1_16/GlaNtp/NNAna/scripts/plotTMVAResults.sh 175 21030 413 Run21030Job413 TMVA413_175_-1.root echo "Plots Done" # # test area to do the templates # move weights first mv weights/TMVTEST413_175_-1.root_H6AONN5MEMLP.weights.txt /data/cdf04/stdenis/batch/run21030/job413/weights/ mv -f weights/TMVTEST413_175_-1.root_H6AONN5MEMLP.class.C /data/cdf04/stdenis/batch/run21030/job413/weights/ mkdir -p /data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v121030 echo "Moving weights" echo "In directory" /data/cdf04/stdenis/batch/run21030/job413 ls -al weights cp -f weights/* /data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v121030/ cp -u /data/cdf04/stdenis/batch/run21030/job413/steer.txt /data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v121030/. > /dev/null 2>&1 else /data/cdf04/stdenis/batch/train_nb.sh stdenis srv004 run21030job413 /data/cdf04/stdenis/batch/run21030/job413 /data/cdf04/stdenis/batch/run21030/job413/trees/NNInputs_175.root 175 >train_nb.log 2>&1 if [ $? -ne 0 ] then echo "NeuroBayes training failed" exit 1 fi fi fi if ((${Dotemplates==1})); then # now the templates # this is a stripped down process1run.sh echo "making templates from /data/cdf04/stdenis/batch/run21030/job413" mkdir -p /data/cdf04/stdenis/batch/run21030/templatesBl97_v100 inbase=/data/cdf04/stdenis/Hww/hwwucsdtuple/NTP_v21_r5-main-var1/BaseMllInv/thin3/HWW175 if [ -e ${inbase} ]; then filelist=`ls ${inbase}/*.root` else echo "Directory ${inbase} does not exist" exit 1 fi mkdir -p /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175 mkdir -p /data/cdf04/stdenis/batch/run21030/templatesBl97_v101/HWW175 if [ -e /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/templates_out175.log ]; then rm /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/templates_out175.log fi for f in $filelist do # # Doctor the fixweight if required # g=`basename $f` FixWeight=1.0 if [ -e /data/cdf04/stdenis/batch/run21030/job413/FixWeightFilev21_r3.txt ]; then factorline=`cat /data/cdf04/stdenis/batch/run21030/job413/FixWeightFilev21_r3.txt | grep $g` if [ "$factorline" != "" ]; then FixWeight=`echo $factorline | awk '{print $2}'` fi fi echo "file = ${g} and FixWeight= ${FixWeight}" templatesteerFlat=${g}_templateFlat.txt cat /data/cdf04/stdenis/batch/run21030/job413/steerFlatReaderTMVA.txt | sed "s/FixWeight=1.0/FixWeight=${FixWeight}/g" > ${templatesteerFlat} templatesteertouse=${g}_templatesteer.txt cat /data/cdf04/stdenis/batch/run21030/job413/steerTemplate.txt | sed "s/steerFlatReaderTMVA.txt/${templatesteerFlat}/g" > ${templatesteertouse} echo "Process ${f} with template ${templatesteertouse} and fixweight = ${FixWeight}" >> /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/templates_out175.log infile=`basename $f` runFlatPlotter ${templatesteertouse} $f >> /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/templates_out175.log 2>&1 mv stackoutput.root /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/UCSDnt_${infile}_175_00000000_99999999_ana.root done echo "Templates Done">> /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/templates_out175.log fi # # Create the histlist # # If we are to separate the Higgs signals, then we should do that here # if((${separateHiggsSignals}==1)); then cat /data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./histlist-fb59-ntp-nolr-v18-175.txt | sed "s/7 UCSDnt_ntp_ZH/ UCSDnt_ntp_ZH/g" | sed "s/7 UCSDnt_ntp_WH/ UCSDnt_ntp_WH/g" | sed "s/7 UCSDnt_ntp_VBF/ UCSDnt_ntp_VBF/g" > localhistlist.txt else cp /data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./histlist-fb59-ntp-nolr-v18-175.txt localhistlist.txt fi # but only include the required Higgs signals if [ "" != "" ]; then for hproc in ; do cat localhistlist.txt | grep -v $hproc > localhistlist2.txt mv localhistlist2.txt localhistlist.txt done fi # # Get rid of any files that don't exist # while read line do filetotest=/data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/`echo $line | awk '{print $2}'` if [ -e $filetotest ]; then echo $line >> localhistlist2.txt else echo $line >> localhistlistExcludedLines.txt fi done < localhistlist.txt mv localhistlist2.txt localhistlist.txt # # define the local hist list # export localhistlist=${PWD}/localhistlist.txt # # Also create a localhist that has the channels summed on # if [ -f /data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./histlist-fb59-ntp-nolr-v18-175-allchan.txt ]; then # Check file exists and is a regular file if((${separateHiggsSignals}==1)); then cat /data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./histlist-fb59-ntp-nolr-v18-175-allchan.txt | sed "s/7 UCSDnt_ntp_ZH/ UCSDnt_ntp_ZH/g" | sed "s/7 UCSDnt_ntp_WH/ UCSDnt_ntp_WH/g" | sed "s/7 UCSDnt_ntp_VBF/ UCSDnt_ntp_VBF/g" > localhistlist_allchan.txt else cp /data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./histlist-fb59-ntp-nolr-v18-175-allchan.txt localhistlist_allchan.txt fi if [ "" != "" ]; then for hproc in ; do cat localhistlist_allchan.txt | grep -v $hproc > localhistlist2.txt mv localhistlist2.txt localhistlist_allchan.txt done fi export localhistlist_allchan=${PWD}/localhistlist_allchan.txt # # Get rid of any files that don't exist # while read line do filetotest=/data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/`echo $line | awk '{print $2}'` if [ -e $filetotest ]; then echo $line >> localhistlist2.txt fi done < localhistlist_allchan.txt mv localhistlist2.txt localhistlist_allchan.txt else export localhistlist_allchan="None" fi # # make stacked plots if ((${Dostackedplots}==1)); then let ipass=1 while((ipass<=2)); do if((ipass==1)); then myhistlist=${localhistlist} mystackoutdir=/data/cdf04/stdenis/batch/run21030/stacked/Bl97_v100 mystacksteer=/data/cdf04/stdenis/batch/run21030/job413/stackSteer.txt else myhistlist=${localhistlist_allchan} mystackoutdir=/data/cdf04/stdenis/batch/run21030/stacked/Bl97_v101 mystacksteer=/data/cdf04/stdenis/batch/run21030/job413/stackSteerSum.txt fi if [ "${myhistlist}" == "None" ]; then echo "Skipping Stacked Plots from /data/cdf04/stdenis/batch/run21030/job413 for pass ${ipass} since myhistlist is none" else echo "Making Stacked Plots from /data/cdf04/stdenis/batch/run21030/job413 for pass ${ipass}" # mkdir -p $mystackoutdir FlatStackMain /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/ \ ${myhistlist} \ ${mystackoutdir}/Stack175-run21030_1_${ipass}.root \ ${mystacksteer} \ /data/cdf04/stdenis/batch/run21030/job413/SysSetLowMll3.txt \ 175 0.6 1.0 \ /home/stdenis/hww_1fb/hwwcdf6.1.6.mv5_18v1_16/Hww/HwwFit/root/RealTitles.txt None > FlatStack1_out_175_${ipass}.log 2>&1 mv FlatStack_0.eps ${mystackoutdir}/Stack175-run21030_0_1_${ipass}.eps mv Rescaled.root ${mystackoutdir}/Rescaled175-run21030_1_${ipass}.root mv ZInsert.root ${mystackoutdir}/ZInsert175-run21030_1_${ipass}.root mv RescaledZInsert.root ${mystackoutdir}/RescaledZInsert175-run21030_1_${ipass}.root mv FlatStackstack.root ${mystackoutdir}/FlatStackstack175-run21030_1_${ipass}.root # FlatStackMain /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/ \ ${myhistlist} \ ${mystackoutdir}/Stack175-run21030_2_${ipass}.root \ ${mystacksteer} \ /data/cdf04/stdenis/batch/run21030/job413/SysSetLowMll3.txt \ 175 0.8 1.0 \ /home/stdenis/hww_1fb/hwwcdf6.1.6.mv5_18v1_16/Hww/HwwFit/root/RealTitles.txt None > FlatStack2_out_175_${ipass}.log 2>&1 mv FlatStack_0.eps ${mystackoutdir}/Stack175-run21030_0_2_${ipass}.eps mv Rescaled.root ${mystackoutdir}/Rescaled175-run21030_2_${ipass}.root mv ZInsert.root ${mystackoutdir}/ZInsert175-run21030_2_${ipass}.root mv RescaledZInsert.root ${mystackoutdir}/RescaledZInsert175-run21030_2_${ipass}.root mv FlatStackstack.root ${mystackoutdir}/FlatStackstack175-run21030_2_${ipass}.root # # Convert histos to gif files # cd ${mystackoutdir} convert Stack175-run21030_0_1_${ipass}.eps Stack175-run21030_0_1_${ipass}.gif convert Stack175-run21030_0_2_${ipass}.eps Stack175-run21030_0_2_${ipass}.gif cd - fi let ipass=ipass+1 done fi if ((${Dostackedinput==1})); then let ipass=1 while((ipass<=2)); do if((ipass==1)); then mystackinputoutdir=/data/cdf04/stdenis/batch/run21030/stackedinput/Bl97_v100 mytemplateoutdir=/data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175 sumprefix= else mystackinputoutdir=/data/cdf04/stdenis/batch/run21030/stackedinput/Bl97_v101 mytemplateoutdir=/data/cdf04/stdenis/batch/run21030/templatesBl97_v101/HWW175 sumprefix=Sum # Sum the templates and make the new template dir # mkdir -p /data/cdf04/stdenis/batch/run21030/templatesBl97_v101/HWW175 echo "ColumnParameter Channel 1 HISB=0:LOSB=1" > steersumhist.txt echo "Making SumHist" for f in `ls /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175`; do SumHist steersumhist.txt /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/${f} \ /data/cdf04/stdenis/batch/run21030/templatesBl97_v101/HWW175/${f} > /data/cdf04/stdenis/batch/run21030/job413/SumHist.log done fi echo "Making Stacked Input Plots from /data/cdf04/stdenis/batch/run21030/job413 on pass ${ipass}" mkdir -p ${mystackinputoutdir} if [ -e /data/cdf04/stdenis/batch/run21030/job413/StackInputConditionList.txt ]; then # # The input stack condition is the same name as th steering file and forms the name of the output # directory # for InputStackCondition in `cat /data/cdf04/stdenis/batch/run21030/job413/StackInputConditionList.txt`; do myInputStackCondition=${sumprefix}${InputStackCondition} stackinputsteer=/data/cdf04/stdenis/batch/run21030/job413/${myInputStackCondition}.txt # outdest=${mystackinputoutdir}/StackInput/HWW175/${myInputStackCondition} mkdir -p $outdest tmvafile=/data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v17324/TMVTEST400_160_-1.root DisplayFlatStackedInput ${tmvafile} \ ${mytemplateoutdir}/ \ ${outdest}/InputStack175-run21030 \ ${stackinputsteer} \ /data/cdf04/stdenis/batch/run21030/job413/SysSetLowMll3.txt 175 > ${outdest}/aaastackjob175.log 2>&1 done else echo "Unable to find stack input condition file: /data/cdf04/stdenis/batch/run21030/job413/StackInputConditionList.txt. No stack input made" return 1 fi let ipass=ipass+1 done fi # now the fit # if ((${Dofit}==1)); then # # Determine if the summed or unsummed templates are to be used. # let FitST=0 export fithistlist=${localhistlist} if ((FitST==1)); then export fithistlist=${localhistlist_allchan}; fi # echo "Do Fit" fitdest=/data/cdf04/stdenis/batch/run21030/templatesBl97_v100/fit/out_1 fitwdir=/data/cdf04/stdenis/batch/run21030/templatesBl97_v100/fit/input_1/HWW175 fitlog=out_175.log mkdir -p ${fitdest} mkdir -p ${fitwdir} cd ${fitdest} rm -f LRWW_21030_175.root* rm -f ${fitlog} cd ${fitwdir} date > ${fitlog} echo `pwd` > ${fitlog} ####################### #Determine if shapes are to be used. If so, copy files in # # let ns1=`cat /data/cdf04/stdenis/batch/run21030/job413/steerfitLRHWW.txt | grep UseShape=1| wc -l` let ns2=`cat /data/cdf04/stdenis/batch/run21030/job413/steerfitLRHWW.txt | grep UseShapeMean=1| wc -l` let ns=ns1+ns2 echo "ns= ${ns} ns1= ${ns1} ns2= ${ns2}" >> ${fitlog} hlistsuffix=`basename ${fithistlist}` if((ns>0)); then # Want shapes echo "Want Shapes" >> ${fitlog} export hlist=histlist-fb59-ntp-nolr-v18-175.txt if ((FitST==1)); then export hlist=histlist-fb59-ntp-nolr-v18-175-allchan.txt ; fi # Get the list of systematics sysnamefile=/data/cdf04/stdenis/batch/run21030/job413/SysNamesLowMll3.txt cat ${sysnamefile} | while read sysline do sysname=`echo ${sysline} | awk '{print $4}' | awk -F: '{print $2}'` echo "Check sysname= ${sysname}">> ${fitlog} fpos=/data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./ShapePos_${sysname}_${hlist} echo "Check for fpos=${fpos}">> ${fitlog} if [ -f ${fpos} ]; then fposlocal=ShapePos_${sysname}_${hlistsuffix} echo "Got file. Copy ${fpos} ${fposlocal}">>${fitlog} cp ${fpos} ${fposlocal} fi fneg=/data/cdf04/stdenis/batch/histlist/v21_nolr_tmva/./ShapeNeg_${sysname}_${hlist} echo "Check for fneg=${fneg}">> ${fitlog} if [ -f ${fneg} ]; then fneglocal=ShapeNeg_${sysname}_${hlistsuffix} echo "Got file. Copy ${fneg} ${fneglocal}">>${fitlog} cp ${fneg} ${fneglocal} fi done fi cp ${fithistlist} . ####################### # Perform Fit # Fit ${hlistsuffix} \ /data/cdf04/stdenis/batch/run21030/templatesBl97_v100/HWW175/ \ /data/cdf04/stdenis/batch/run21030/job413/SysSetLowMll3.txt \ /data/cdf04/stdenis/batch/run21030/job413/steerfitLRHWW.txt 175 >> ${fitlog} 2>&1 ####################### date >> ${fitlog} mv * ${fitdest} fi #