#PBS -N tr20744_400 #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=0 ComputeTMVA=0 DoTraining=0 Dotemplates=1 Dostackedplots=0 Dostackedinput=1 Dofit=0 separateHiggsSignals=0 # # Run from the job directory to avoid stepping on other jobs # cd /data/cdf04/stdenis/batch/run20744/job400 rm -f /data/cdf04/stdenis/batch/run20744/job400/tr400.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 ; let x=0; if ((x!=0)); then echo bad; exit 1 else echo 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/run20744/job400/steerComputentp.txt > Computentp160.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 160 400 -1 /data/cdf04/stdenis/batch/run20744/job400/steer.txt /data/cdf04/stdenis/batch/run20744/varset.txt TheTree:NNInput TrainingTree:/data/cdf04/stdenis/batch/run20744/job400/steerComputentp.txt:/data/cdf04/stdenis/batch/run20744/job400/trees/NNInputs_160.root > /data/cdf04/stdenis/batch/run20744/job400/tr400.log 2>&1 else NNAnaMain 160 400 -1 /data/cdf04/stdenis/batch/run20744/job400/steer.txt /data/cdf04/stdenis/batch/run20744/varset.txt TheTree:NNInput /data/cdf04/stdenis/batch/run20744/job400/trees/NNInputs_160.root > /data/cdf04/stdenis/batch/run20744/job400/tr400.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 160 20744 400 Run20744Job400 TMVA400_160_-1.root echo "Plots Done" # # test area to do the templates # move weights first mv weights/TMVTEST400_160_-1.root_H6AONN5MEMLP.weights.txt /data/cdf04/stdenis/batch/run20744/job400/weights/ mv -f weights/TMVTEST400_160_-1.root_H6AONN5MEMLP.class.C /data/cdf04/stdenis/batch/run20744/job400/weights/ mkdir -p /data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v120744 echo "Moving weights" echo "In directory" /data/cdf04/stdenis/batch/run20744/job400 ls -al weights cp -f weights/* /data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v120744/ cp -u /data/cdf04/stdenis/batch/run20744/job400/steer.txt /data/cdf04/stdenis/hww_1fb/hwwcdf6.1.6.mh/Hww/HwwUtil/weights/MENNWeights/v120744/. > /dev/null 2>&1 else /data/cdf04/stdenis/batch/train_nb.sh /data/cdf04/stdenis/batch/run20744/job400 /data/cdf04/stdenis/batch/run20744/job400/trees/NNInputs_160.root 160 >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/run20744/job400" mkdir -p /data/cdf04/stdenis/batch/run20744/templatesBl97_v100 inbase=/data/cdf04/stdenis/Hww/hwwucsdtuple/NTP_v21_r3-main-var1/BaseMllInv/thin3/HWW160 if [ -e ${inbase} ]; then filelist=`ls ${inbase}/*.root` else echo "Directory ${inbase} does not exist" exit 1 fi mkdir -p /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160 mkdir -p /data/cdf04/stdenis/batch/run20744/templatesBl97_v101/HWW160 if [ -e /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/templates_out160.log ]; then rm /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/templates_out160.log fi for f in $filelist do # # Doctor the fixweight if required # g=`basename $f` FixWeight=1.0 if [ -e /data/cdf04/stdenis/batch/run20744/job400/FixWeightFilev21_r3.txt ]; then factorline=`cat /data/cdf04/stdenis/batch/run20744/job400/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/run20744/job400/steerFlatReaderTMVA.txt | sed "s/FixWeight=1.0/FixWeight=${FixWeight}/g" > ${templatesteerFlat} templatesteertouse=${g}_templatesteer.txt cat /data/cdf04/stdenis/batch/run20744/job400/steerTemplate.txt | sed "s/steerFlatReaderTMVA.txt/${templatesteerFlat}/g" > ${templatesteertouse} echo "Process ${f} with template ${templatesteertouse} and fixweight = ${FixWeight}" >> /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/templates_out160.log infile=`basename $f` runFlatPlotter ${templatesteertouse} $f >> /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/templates_out160.log 2>&1 mv stackoutput.root /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160/UCSDnt_${infile}_160_00000000_99999999_ana.root done echo "Templates Done">> /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/templates_out160.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-160.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-160.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/run20744/templatesBl97_v100/HWW160/`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-160-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-160-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-160-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/run20744/templatesBl97_v100/HWW160/`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/run20744/stacked/Bl97_v100 mystacksteer=/data/cdf04/stdenis/batch/run20744/job400/stackSteer.txt else myhistlist=${localhistlist_allchan} mystackoutdir=/data/cdf04/stdenis/batch/run20744/stacked/Bl97_v101 mystacksteer=/data/cdf04/stdenis/batch/run20744/job400/stackSteerSum.txt fi if [ "${myhistlist}" == "None" ]; then echo "Skipping Stacked Plots from /data/cdf04/stdenis/batch/run20744/job400 for pass ${ipass} since myhistlist is none" else echo "Making Stacked Plots from /data/cdf04/stdenis/batch/run20744/job400 for pass ${ipass}" # mkdir -p $mystackoutdir FlatStackMain /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160/ \ ${myhistlist} \ ${mystackoutdir}/Stack160-run20744_1_${ipass}.root \ ${mystacksteer} \ /data/cdf04/stdenis/batch/run20744/job400/SysSetLowMll3.txt \ 160 0.89 1.2 \ /home/stdenis/hww_1fb/hwwcdf6.1.6.mv5_18v1_16/Hww/HwwFit/root/RealTitles.txt None > FlatStack1_out_160_${ipass}.log 2>&1 mv FlatStack_0.eps ${mystackoutdir}/Stack160-run20744_0_1_${ipass}.eps mv Rescaled.root ${mystackoutdir}/Rescaled160-run20744_1_${ipass}.root mv ZInsert.root ${mystackoutdir}/ZInsert160-run20744_1_${ipass}.root mv RescaledZInsert.root ${mystackoutdir}/RescaledZInsert160-run20744_1_${ipass}.root mv FlatStackstack.root ${mystackoutdir}/FlatStackstack160-run20744_1_${ipass}.root # FlatStackMain /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160/ \ ${myhistlist} \ ${mystackoutdir}/Stack160-run20744_2_${ipass}.root \ ${mystacksteer} \ /data/cdf04/stdenis/batch/run20744/job400/SysSetLowMll3.txt \ 160 1.05 1.22 \ /home/stdenis/hww_1fb/hwwcdf6.1.6.mv5_18v1_16/Hww/HwwFit/root/RealTitles.txt None > FlatStack2_out_160_${ipass}.log 2>&1 mv FlatStack_0.eps ${mystackoutdir}/Stack160-run20744_0_2_${ipass}.eps mv Rescaled.root ${mystackoutdir}/Rescaled160-run20744_2_${ipass}.root mv ZInsert.root ${mystackoutdir}/ZInsert160-run20744_2_${ipass}.root mv RescaledZInsert.root ${mystackoutdir}/RescaledZInsert160-run20744_2_${ipass}.root mv FlatStackstack.root ${mystackoutdir}/FlatStackstack160-run20744_2_${ipass}.root # # Convert histos to gif files # cd ${mystackoutdir} convert Stack160-run20744_0_1_${ipass}.eps Stack160-run20744_0_1_${ipass}.gif convert Stack160-run20744_0_2_${ipass}.eps Stack160-run20744_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/run20744/stackedinput/Bl97_v100 mytemplateoutdir=/data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160 sumprefix= else mystackinputoutdir=/data/cdf04/stdenis/batch/run20744/stackedinput/Bl97_v101 mytemplateoutdir=/data/cdf04/stdenis/batch/run20744/templatesBl97_v101/HWW160 sumprefix=Sum # Sum the templates and make the new template dir # mkdir -p /data/cdf04/stdenis/batch/run20744/templatesBl97_v101/HWW160 echo "ColumnParameter Channel 1 HISB=0:LOSB=1" > steersumhist.txt echo "Making SumHist" for f in `ls /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160`; do SumHist steersumhist.txt /data/cdf04/stdenis/batch/run20744/templatesBl97_v100/HWW160/${f} \ /data/cdf04/stdenis/batch/run20744/templatesBl97_v101/HWW160/${f} > /data/cdf04/stdenis/batch/run20744/job400/SumHist.log done fi echo "Making Stacked Input Plots from /data/cdf04/stdenis/batch/run20744/job400 on pass ${ipass}" mkdir -p ${mystackinputoutdir} if [ -e /data/cdf04/stdenis/batch/run20744/job400/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/run20744/job400/StackInputConditionList.txt`; do myInputStackCondition=${sumprefix}${InputStackCondition} stackinputsteer=/data/cdf04/stdenis/batch/run20744/job400/${myInputStackCondition}.txt # outdest=${mystackinputoutdir}/StackInput/HWW160/${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}/InputStack160-run20744 \ ${stackinputsteer} \ /data/cdf04/stdenis/batch/run20744/job400/SysSetLowMll3.txt 160 > ${outdest}/aaastackjob160.log 2>&1 done else echo "Unable to find stack input condition file: /data/cdf04/stdenis/batch/run20744/job400/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/run20744/templatesBl97_v100/fit/out_1 fitwdir=/data/cdf04/stdenis/batch/run20744/templatesBl97_v100/fit/input_1/HWW160 fitlog=out_160.log mkdir -p ${fitdest} mkdir -p ${fitwdir} cd ${fitdest} rm -f LRWW_20744_160.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/run20744/job400/steerfitLRHWW.txt | grep UseShape=1| wc -l` let ns2=`cat /data/cdf04/stdenis/batch/run20744/job400/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-160.txt if ((FitST==1)); then export hlist=histlist-fb59-ntp-nolr-v18-160-allchan.txt ; fi # Get the list of systematics sysnamefile=/data/cdf04/stdenis/batch/run20744/job400/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/run20744/templatesBl97_v100/HWW160/ \ /data/cdf04/stdenis/batch/run20744/job400/SysSetLowMll3.txt \ /data/cdf04/stdenis/batch/run20744/job400/steerfitLRHWW.txt 160 >> ${fitlog} 2>&1 ####################### date >> ${fitlog} mv * ${fitdest} fi #