From e23dc773525fd27103a74c1f2f3a7bb15465fc8c Mon Sep 17 00:00:00 2001 From: Roberto Covarelli Date: Wed, 6 Sep 2017 11:08:04 +0200 Subject: [PATCH] Important pdf fix --- bin/Powheg/run_pwg.py | 28 +++++++++++++++++++-------- bin/Powheg/runcmsgrid_powheg.sh | 4 ++++ bin/Powheg/runcmsgrid_powhegjhugen.sh | 4 ++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/bin/Powheg/run_pwg.py b/bin/Powheg/run_pwg.py index 00b0c6ec6499..4a53f074648c 100755 --- a/bin/Powheg/run_pwg.py +++ b/bin/Powheg/run_pwg.py @@ -38,7 +38,8 @@ def prepareJob(tag, i, folderName) : filename = folderName+'/run_' + tag + '.sh' f = open(filename, 'w') - f.write('#!/bin/bash \n\n') + f.write('#!/bin/bash \n') + f.write('fail_exit() { echo "$@" 1>&2; exit 1; } \n\n') f.write('echo "Start of job on " `date`\n\n') @@ -265,7 +266,7 @@ def runSingleXgrid(parstage, xgrid, folderName, nEvents, powInputName, seed, pro #runCommand ('bsub -J ' + jobID + ' -u pippopluto -q ' + QUEUE + ' < ' + jobname, 1, TESTING == 0) # ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -def runGetSource(parstage, xgrid, folderName, powInputName, process, tagName) : +def runGetSource(parstage, xgrid, folderName, powInputName, process, noPdfCheck, tagName) : # parstage, xgrid are strings! print 'Getting and compiling POWHEG source...' @@ -279,6 +280,7 @@ def runGetSource(parstage, xgrid, folderName, powInputName, process, tagName) : # f.write('export process='+rootfolder+'\n\n') f.write('export cardInput='+powInputName+'\n\n') f.write('export process='+process+'\n\n') + f.write('export noPdfCheck='+noPdfCheck+'\n\n') f.write('export WORKDIR='+os.getcwd()+'\n\n') f.write( ''' @@ -314,6 +316,16 @@ def runGetSource(parstage, xgrid, folderName, powInputName, process, tagName) : cp -p ../${cardInput} powheg.input fi +# enforce standard pdfs? +grep "306000" powheg.input >> teststandpdf.txt +if ! [ -s teststandpdf.txt ] ; then + if [ $noPdfCheck == '0' ] ; then + rm -f teststandpdf.txt + fail_exit "WARNING: The input card provided does not have the standard 2017 PDF (NNPDF31 NNLO, 306000). Either change the card or run again with -d 1 to ignore this message. Exiting now..." + fi +fi +rm -f teststandpdf.txt + if [ -s ../JHUGen.input ]; then cp -p ../JHUGen.input JHUGen.input fi @@ -810,9 +822,7 @@ def createTarBall(parstage, folderName, prcName, keepTop, seed, scriptName) : grep -q "xgriditeration" powheg.input; test $? -eq 0 || printf "\\nxgriditeration 1\\n" >> powheg.input sed -i "s/^pdfreweight.*/pdfreweight 0/g" powheg.input -# enforce standard pdfs -sed -i "s/^lhans1.*/lhans1 306000/g" powheg.input -sed -i "s/^lhans2.*/lhans2 306000/g" powheg.input + # turn into single run mode sed -i "s/^manyseeds.*/#manyseeds 1/g" powheg.input @@ -971,6 +981,7 @@ def runhnnlo(folderName, njobs, QUEUE): parser.add_option('-s', '--rndSeed' , dest="rndSeed", default= '42', help='Starting random number seed [42]') parser.add_option('-m', '--prcName' , dest="prcName", default= 'DMGG', help='POWHEG process name [DMGG]') parser.add_option('-k', '--keepTop' , dest="keepTop", default= '0', help='Keep the validation top draw plots [0]') + parser.add_option('-d', '--noPdfCheck' , dest="noPdfCheck", default= '0', help='If 1, deactivate automatic PDF check [0]') # args = parser.parse_args () (args, opts) = parser.parse_args(sys.argv) @@ -1067,6 +1078,7 @@ def runhnnlo(folderName, njobs, QUEUE): print "\t argument '-s', '--rndSeed' , default= '42'" print "\t argument '-m', '--prcName' , default= 'DMGG'" print "\t argument '-k', '--keepTop' , default= '0'" + print "\t argument '-d', '--noPdfCheck' , default= '0'" print "" exit() @@ -1109,7 +1121,7 @@ def runhnnlo(folderName, njobs, QUEUE): prepareJob(tagName, '', '.') runGetSource(args.parstage, args.xgrid, args.folderName, - powInputName, args.prcName, tagName) + powInputName, args.prcName, args.noPdfCheck, tagName) if QUEUE == '': print 'Direct compiling... \n' @@ -1156,7 +1168,7 @@ def runhnnlo(folderName, njobs, QUEUE): prepareJob(tagName, '', '.') runGetSource(args.parstage, args.xgrid, args.folderName, - powInputName, args.prcName, tagName) + powInputName, args.prcName, args.noPdfCheck, tagName) os.system('sed -i "s/^numevts.*/numevts '+args.numEvents+'/" '+ args.folderName+'/powheg.input') @@ -1180,7 +1192,7 @@ def runhnnlo(folderName, njobs, QUEUE): prepareJob(tagName, '', '.') runGetSource(args.parstage, args.xgrid, args.folderName, - powInputName, args.prcName, tagName) + powInputName, args.prcName, args.noPdfCheck, tagName) runSingleXgrid(args.parstage, args.xgrid, args.folderName, args.numEvents, powInputName, args.rndSeed, diff --git a/bin/Powheg/runcmsgrid_powheg.sh b/bin/Powheg/runcmsgrid_powheg.sh index 78cc61b11a71..86f989597151 100755 --- a/bin/Powheg/runcmsgrid_powheg.sh +++ b/bin/Powheg/runcmsgrid_powheg.sh @@ -154,6 +154,10 @@ cat pwgevents.lhe | grep -v "Random number generator exit values" > ${file}_fina xmllint --noout ${file}_final.lhe > /dev/null 2>&1; test $? -eq 0 || fail_exit "xmllint integrity check failed on pwgevents.lhe" +grep "> NaN" ${file}_final.lhe; test $? -ne 0 || fail_exit "Weights equal to NaN found, there must be a problem in the reweighting" + +grep ">0.00000E+00" ${file}_final.lhe; test $? -ne 0 || fail_exit "Weights equal to 0 found, there must be a problem in the reweighting" + ls -l ${file}_final.lhe sed -i 's/Input file powheg.input contained:/Process: '$process'\nInput file powheg.input contained:/g' ${file}_final.lhe pwd diff --git a/bin/Powheg/runcmsgrid_powhegjhugen.sh b/bin/Powheg/runcmsgrid_powhegjhugen.sh index 5f6fdde98288..a333b3fba60f 100755 --- a/bin/Powheg/runcmsgrid_powhegjhugen.sh +++ b/bin/Powheg/runcmsgrid_powhegjhugen.sh @@ -153,6 +153,10 @@ cat pwgevents.lhe | grep -v "Random number generator exit values" > ${file}_fina xmllint --noout ${file}_final.lhe > /dev/null 2>&1; test $? -eq 0 || fail_exit "xmllint integrity check failed on pwgevents.lhe" +grep "> NaN" ${file}_final.lhe; test $? -ne 0 || fail_exit "Weights equal to NaN found, there must be a problem in the reweighting" + +grep ">0.00000E+00" ${file}_final.lhe; test $? -ne 0 || fail_exit "Weights equal to 0 found, there must be a problem in the reweighting" + ls -l ${file}_final.lhe sed -i 's/Input file powheg.input contained:/Process: '$process'\nInput file powheg.input contained:/g' ${file}_final.lhe pwd