diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/createCard.sh b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/createCard.sh new file mode 100644 index 000000000000..d86157289eeb --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/createCard.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +for mass in 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 160 180 200 250 300 350 400 450 500 600 700 800 900 1000 1100 1200 1400 1600 1800 2000 2300 2600 2900 3200 3500; +do + for hdampmode in "" 1 2; + do + for hfactmode in "" 1 2; + do + if (( $(echo $mass'<'145 | bc -l) )); + then + width=0.0041 + elif (( $(echo $mass'<'605 | bc -l) )); then + width=0.1 + elif (( $(echo $mass'<'2005 | bc -l) )); then + width=1.0 + else + width=2.0 + fi + +#setup.sh 1: mass 2: channel: incl, t, b or tb # Combinations are (contrib-scale): incl-t/b/tb, t-t, b-b, tb-tb, t-tb, b-tb (!!!now t only) 3. width depending on mass 4.hfactmode + ./setup.sh $mass t $width $hfactmode; + done; + done; +done; diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/scales-higgs-mass-scan.dat b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/scales-higgs-mass-scan.dat new file mode 100644 index 000000000000..2695dbee04d2 --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/scales-higgs-mass-scan.dat @@ -0,0 +1,97 @@ +60 33 8 4 +65 35 9 5 +70 36 10 5 +75 37 11 6 +80 38 12 6 +85 39 13 6 +90 40 13 6 +95 41 14 7 +100 42 14 7 +105 43 15 8 +110 44 16 8 +115 46 17 8 +120 47 17 8 +125 48 18 9 +130 50 18 9 +135 51 19 10 +140 52 19 10 +150 55 21 11 +160 58 22 11 +170 61 23 12 +180 64 24 13 +190 67 26 14 +200 71 27 14 +210 75 28 15 +220 80 29 16 +230 92 30 17 +240 103 31 18 +250 108 32 18 +260 111 34 19 +270 112 35 20 +280 112 36 21 +290 112 37 22 +300 111 38 23 +310 108 39 23 +320 105 40 24 +330 101 41 25 +340 95 42 26 +350 87 43 26 +360 82 44 25 +370 82 46 25 +380 81 47 24 +390 81 48 24 +400 81 49 23 +410 82 50 23 +420 83 51 23 +430 85 52 22 +440 86 53 21 +450 87 53 21 +460 89 54 20 +470 91 55 19 +480 92 56 19 +490 94 57 18 +500 96 58 17 +510 97 59 16 +520 99 60 15 +530 101 61 14 +540 102 62 12 +550 104 63 11 +560 106 64 10 +570 107 65 8 +580 109 66 5 +590 111 67 2 +600 113 68 6 +610 115 69 8 +620 117 70 10 +630 119 71 12 +640 121 72 14 +650 127 73 16 +660 129 74 17 +670 131 75 19 +680 133 76 21 +690 135 77 22 +700 137 78 24 +710 139 79 25 +720 141 79 27 +730 143 80 28 +740 146 81 30 +750 148 82 32 +760 150 83 33 +770 152 84 35 +780 154 85 44 +790 156 86 45 +800 158 87 46 +900 180 95 65 +1000 202 103 279 +1100 223 113 277 +1200 243 122 275 +1400 284 138 282 +1500 305 147 287 +1600 324 154 292 +1800 362 171 305 +2000 398 189 318 +2300 451 213 340 +2600 502 237 358 +2900 547 260 381 +3200 589 282 404 +3500 640 306 425 diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/scripts/scales-higgs-mass-scan.dat b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/scripts/scales-higgs-mass-scan.dat new file mode 120000 index 000000000000..bb510960cb0b --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/scripts/scales-higgs-mass-scan.dat @@ -0,0 +1 @@ +../scales-higgs-mass-scan.dat \ No newline at end of file diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/setup.sh b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/setup.sh new file mode 100755 index 000000000000..630b3c7f9491 --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/CardSpace/setup.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +export VO_CMS_SW_DIR=/cvmfs/cms.cern.ch +source $VO_CMS_SW_DIR/cmsset_default.sh + +mass=${1} +contrib=${2} # t-only +width=${3} +hdampmode=${4} +hfactmode=${5} + +# set hfact depending on mass and contrib +#e.g, for h125 t = 48, b = 18, t+b = 9 +hfact=9 + +inline=$(cat scripts/scales-higgs-mass-scan.dat | grep -P "^${mass}\t") +if [ "$inline" == "" ]; then + echo "Error: There are no hfact damping scales for your chosen mass point, exiting." + exit +fi +stringarray=($inline) +if [ "${contrib}" == "t" ]; then + hfact=${stringarray[1]} +elif [ "${contrib}" == "b" ]; then + hfact=${stringarray[2]} +elif [ "${contrib}" == "tb" ]; then + hfact=${stringarray[3]} +else + echo "Error: Your chosen contribution must can only be t, b, tb, exiting" + exit +fi + +if [ "${hfactmode}" == 1 ]; then hfact=`awk "BEGIN {print 2*${hfact}}"`; fi +if [ "${hfactmode}" == 2 ]; then hfact=`awk "BEGIN {print 0.5*${hfact}}"`; fi + +echo "hfact set to: " $hfact + +workdir=$PWD/../ +template=$workdir/gg_H_2HDM_template/ +massdir=$workdir/m${mass}_${contrib} + +if [[ "${hfactmode}" == 1 ]]; then massdir=$workdir/m${mass}_${contrib}_hfactUp; fi +if [[ "${hfactmode}" == 2 ]]; then massdir=$workdir/m${mass}_${contrib}_hfactDown; fi + +echo "creating directories" +mkdir -p $massdir +echo "Copying files:" +cp -v $template/pwg-rwl.dat $massdir +cp -v $template/ggH_mssm.input-* $massdir +cp -v $template/JHUGen.input $massdir +cp -rv $template/lib $massdir + +sed -i "s/XHMASSX/${mass}/g" $massdir/ggH_mssm.input-* +sed -i "s/XHWIDTHX/${width}/g" $massdir/ggH_mssm.input-* +sed -i "s/XHFACTX/${hfact}/g" $massdir/ggH_mssm.input-* +sed -i "s/XHDAMPX/${hdamp}/g" $massdir/ggH_mssm.input-* + +# tanb = 15 for h and A +# tanb = 50 for H +# alpha always pi/4 + +tanb=15 +echo tanb set to ${tanb} + +sed -i "s/XTANBX/${tanb}/g" $massdir/ggH_mssm.input-* +sed -i "s/XALPHAX/0.785398163397448/g" $massdir/ggH_mssm.input-* + +sed -i "s/XNOBOTX/1/g" $massdir/ggH_mssm.input-* +sed -i "s/XNOTOPX/0/g" $massdir/ggH_mssm.input-* + +mv $massdir/ggH_mssm.input-base $massdir/ggH_mssm.input diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/ggH_mssm.input-base b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/ggH_mssm.input-base new file mode 100644 index 000000000000..45312510cd8f --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/ggH_mssm.input-base @@ -0,0 +1,103 @@ +numevts NEVENTS ! number of events to be generated +ih1 1 ! hadron 1 (1 for protons, -1 for antiprotons) +ih2 1 ! hadron 2 (1 for protons, -1 for antiprotons) +ebeam1 6800 ! energy of beam 1 +ebeam2 6800 ! energy of beam 2 + +! To be set only if using LHA pdfs +lhans1 325300 ! pdf set for hadron 1 (LHA numbering) +lhans2 325300 ! pdf set for hadron 2 (LHA numbering) + +! To be set only if using different pdf sets for the two incoming hadrons +! QCDLambda5 0.25 ! for not equal pdf sets + +! Parameters to allow or not the use of stored data +use-old-grid 1 ! if 1 use old grid if file pwggrids.dat is present (<> 1 regenerate) +use-old-ubound 1 ! if 1 use norm of upper bounding function stored in pwgubound.dat, if present; <> 1 regenerate + +ncall1 100000 ! number of calls for initializing the integration grid +itmx1 1 ! number of iterations for initializing the integration grid +ncall2 100000 ! number of calls for computing the integral and finding upper bound +itmx2 5 ! number of iterations for computing the integral and finding upper bound +nubound 200000 ! number of bbarra calls to setup norm of upper bounding function +foldcsi 2 ! number of folds on csi integration +foldy 5 ! number of folds on y integration +foldphi 2 ! number of folds on phi integration +icsimax 1 ! <= 100, number of csi subdivision when computing the upper bounds +iymax 1 ! <= 100, number of y subdivision when computing the upper bounds +xupbound 2d0 ! increase upper bound for radiation generation + +! OPTIONAL PARAMETERS + +# renscfact 1 ! (default 1d0) ren scale factor: muren = muref * renscfact +# facscfact 1 ! (default 1d0) fac scale factor: mufact = muref * facscfact +# ptsupp 0d0 ! (default 0d0) mass param for Born suppression factor (generation cut) If < 0 suppfact = 1 +# bornonly 1 ! (default 0) if 1 do Born only +# smartsig 0 ! (default 1) remember equal amplitudes (0 do not remember) +# withsubtr 0 ! (default 1) subtract real counterterms (0 do not subtract) +# withdamp 1 ! (default 0, do not use) use Born-zero damping factor +# ptsqmin 0.8 ! (default 0.8 GeV) minimum pt for generation of radiation +# charmthr 1.5 ! (default 1.5 GeV) charm treshold for gluon splitting +# bottomthr 5.0 ! (default 5.0 GeV) bottom treshold for gluon splitting +testplots 1 ! (default 0, do not) do NLO and PWHG distributions +# testsuda 1 ! (default 0, do not test) test Sudakov form factor +# radregion 1 ! (default all regions) only generate radiation in the selected singular region +# charmthrpdf 1.5 ! (default 1.5 GeV) pdf charm treshold +# bottomthrpdf 5.0 ! (default 5.0 GeV) pdf bottom treshold +withnegweights 1 ! use negative weights + +runningscale 1 ! 0 = scales equal to the Higgs pole mass; 1 = scales equal to the Higgs virtuality; + ! 2 = scales equal to the Higgs pole mass for Born-like configuration and to the transverse mass for real emission contribution +# When using 2 uncomment the following option +# btlscalereal 1 + +iseed SEED ! initialize random number sequence +maxseeds 4999 +manyseeds 0 ! Used to perform multiple runs with different random + ! seeds in the same directory. + ! If set to 1, the program asks for an integer j; + ! The file pwgseeds.dat at line j is read, and the + ! integer at line j is used to initialize the random + ! sequence for the generation of the event. + ! The event file is called pwgevents-'j'.lhe + +# iupperisr 1 ! (default 1) choice of ISR upper bounding functional form +# iupperfsr 2 ! (default 2) choice of FSR upper bounding functional form + +! GGF_H production: +! **** Mandatory parameters for ALL models **** +zerowidth 1 ! Control if the Higgs boson is to be produced on-shell or not: 1 = On-Shell; 0 = Off-shell with Breit-Wigner +bwshape 1 ! BW shape; 1 = running width; 0 = fixed width +ew 0 ! ew = 0 disable EW corrections - ew = 1 enable EW corrections +fastew 1 ! mass sampling of ew corrections +gfermi 0.116637D-04 ! GF +hdecaymode -1 ! PDG code for first decay product of the higgs + ! -1 no decay + ! 0 all decay channels open + ! 1-6 d dbar, u ubar,..., t tbar + ! 7-9 e+ e-, mu+ mu-, tau+ tau- + ! 10 W+W- + ! 11 ZZ + ! 12 gamma gamma +masswindow 10d0 !(default 10d0) number of widths around hmass in the BW for an off-shell Higgs boson +scheme 0 ! Mass renormalization scheme: 0 = OS (Default); 1 = MSBAR; 2 = DRBAR +topmass 172.5 ! top quark mass +bottommass 4.75d0 ! bottom quark mass - if defined it enables the bottom quark +!charmmass 1.5d0 ! char quark mass - if defined it enables the charm quark +! Optional +hdecaywidth 0 ! If equals to 1 read total decay width from HDECAY sm.br2 file +! 2HDM parameters +2HDMtype 2 +alpha XALPHAXd0 ! 0.785398163397448d0 + +higgstype 1 ! 1:h, 2:H, 3:A +hmass XHMASSXd0 +hwidth XHWIDTHXd0 +tanb XTANBXd0 +hfact XHFACTX +nobot XNOBOTX +notop XNOTOPX + +storeinfo_rwgt 1 ! store info for reweighting events +compute_rwgt 0 ! store info for reweighting events +pdfreweight 1 diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.a b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.a new file mode 100644 index 000000000000..76acf741582c Binary files /dev/null and b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.a differ diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.la b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.la new file mode 100755 index 000000000000..6e680a2361ed --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.la @@ -0,0 +1,41 @@ +# libchaplin.la - a libtool library file +# Generated by ltmain.sh (GNU libtool) 2.2.6b Debian-2.2.6b-2ubuntu3 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libchaplin.so.0' + +# Names of this library. +library_names='libchaplin.so.0.0.0 libchaplin.so.0 libchaplin.so' + +# The name of the static archive. +old_library='libchaplin.a' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs='' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libchaplin. +current=0 +age=0 +revision=0 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/vols/cms/dw515/ggh_mc/ggh-mssm/m125/CMSSW_10_2_3/src/powheg_new/CMSSW_9_3_0/src/genproductions/bin/Powheg/my_ggH/POWHEG-BOX/gg_H_2HDM/chaplin-1.2/../lib' diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.so.0 b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.so.0 new file mode 100755 index 000000000000..6e8ac728e61a Binary files /dev/null and b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.so.0 differ diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.so.0.0.0 b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.so.0.0.0 new file mode 100755 index 000000000000..6e8ac728e61a Binary files /dev/null and b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/lib/libchaplin.so.0.0.0 differ diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/pwg-rwl.dat b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/pwg-rwl.dat new file mode 100644 index 000000000000..d863e730f6ef --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/gg_H_2HDM_template/pwg-rwl.dat @@ -0,0 +1,49 @@ + + + lhapdf=90900 renscfact=1d0 facscfact=1d0 + lhapdf=90900 renscfact=1d0 facscfact=2d0 + lhapdf=90900 renscfact=1d0 facscfact=0.5d0 + lhapdf=90900 renscfact=2d0 facscfact=1d0 + lhapdf=90900 renscfact=2d0 facscfact=2d0 + lhapdf=90900 renscfact=2d0 facscfact=0.5d0 + lhapdf=90900 renscfact=0.5d0 facscfact=1d0 + lhapdf=90900 renscfact=0.5d0 facscfact=2d0 + lhapdf=90900 renscfact=0.5d0 facscfact=0.5d0 + lhapdf=90900 renscfact=0.25d0 facscfact=0.25d0 + lhapdf=90900 renscfact=0.5d0 facscfact=0.25d0 + lhapdf=90900 renscfact=0.25d0 facscfact=0.5d0 + + + lhapdf=90900 + lhapdf=90901 + lhapdf=90902 + lhapdf=90903 + lhapdf=90904 + lhapdf=90905 + lhapdf=90906 + lhapdf=90907 + lhapdf=90908 + lhapdf=90909 + lhapdf=90910 + lhapdf=90911 + lhapdf=90912 + lhapdf=90913 + lhapdf=90914 + lhapdf=90915 + lhapdf=90916 + lhapdf=90917 + lhapdf=90918 + lhapdf=90919 + lhapdf=90920 + lhapdf=90921 + lhapdf=90922 + lhapdf=90923 + lhapdf=90924 + lhapdf=90925 + lhapdf=90926 + lhapdf=90927 + lhapdf=90928 + lhapdf=90929 + lhapdf=90930 + + diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/pdfweights_new.patch b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/pdfweights_new.patch new file mode 100644 index 000000000000..27eabc89738a --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/pdfweights_new.patch @@ -0,0 +1,63 @@ +--- POWHEG-BOX/include/pwhg_lhrwgt.h 2015-01-30 09:54:31.845227920 +0100 ++++ ../roberto/POWHEG-BOX/include/pwhg_lhrwgt.h 2015-02-18 14:29:12.772549580 +0100 +@@ -2,7 +2,7 @@ + + c Maximum number of weights + integer lhrwgt_maxnheader +- parameter (lhrwgt_maxnheader=200) ++ parameter (lhrwgt_maxnheader=400) + integer lhrwgt_max_header_columns + parameter ( lhrwgt_max_header_columns=200) + character * (lhrwgt_max_header_columns) +--- ../my_testNNLOPS2/POWHEG-BOX/rwl_weightlists.f 2018-09-04 10:13:18.000000001 +0200 ++++ POWHEG-BOX/rwl_weightlists.f 2018-11-22 10:37:02.000000001 +0100 +@@ -558,6 +558,8 @@ + call nextword(jpos,iv,jv) + c No key found + if(iv>lb) goto 998 ++c for NNLOPS ++ if(buf(iv:jv) == 'combines') goto 998 + if(buf(iv:jv) == 'default') then + c In this case we do not expect a value + val = 0 +--- POWHEG-BOX/lhefwrite.f 2021-12-15 15:46:15.000000001 +0100 ++++ ../boh/POWHEG-BOX/lhefwrite.f 2021-12-15 15:47:45.000000001 +0100 +@@ -7,6 +7,7 @@ + include 'pwhg_rad.h' + include 'pwhg_flg.h' + include 'pwhg_lhrwgt.h' ++ include 'pwhg_pdf.h' + integer nlf + real * 8 version + common/cversion/version +@@ -50,8 +51,13 @@ + endif + call pwhg_io_write(nlf,'') + c write(nlf,'(a)') '' +- write(buffer,110) idbmup(1),idbmup(2),ebmup(1),ebmup(2), ++ if(pdfsup(1).ne.-1 .and. pdfsup(2).ne.-1) then ++ write(buffer,110) idbmup(1),idbmup(2),ebmup(1),ebmup(2), + 1 pdfgup(1),pdfgup(2),pdfsup(1),pdfsup(2),idwtup,nprup ++ else ++ write(buffer,110) idbmup(1),idbmup(2),ebmup(1),ebmup(2), ++ 1 0,0,pdf_ndns1,pdf_ndns2,idwtup,nprup ++ endif + call pwhg_io_write(nlf,trim(buffer)) + do 100 ipr=1,nprup + write(buffer,120) xsecup(ipr),xerrup(ipr),xmaxup(ipr), +@@ -99,6 +105,7 @@ + & vtimup(i),spinup(i) + call pwhg_io_write(nlf,trim(buffer)) + 200 continue ++ if(flg_pdfreweight) call lhefwritepdfrw(nlf) + if(flg_reweight .or. flg_rwl) then + call lhefwriteevrw(nlf) + if(flg_rwl) then +@@ -111,7 +118,6 @@ + c write(nlf,'(a)')'' + endif + endif +- if(flg_pdfreweight) call lhefwritepdfrw(nlf) + if(flg_debug) call lhefwritextra(nlf) + call pwhg_io_write(nlf,'') + c write(nlf,'(a)')'' diff --git a/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/runcmsgrid_powheg.sh b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/runcmsgrid_powheg.sh new file mode 100644 index 000000000000..a6358a4909c8 --- /dev/null +++ b/bin/Powheg/production/Run3/13p6TeV/gg_H_2HDM_13p6TeV/runcmsgrid_powheg.sh @@ -0,0 +1,602 @@ +#!/bin/bash + +fail_exit() { echo "$@"; exit 1; } + +# #set -o verbose +# EXPECTED_ARGS=3 + +# if [ $# -ne $EXPECTED_ARGS ] +# then + # echo "Usage: `basename $0` Nevents RandomSeed cpu" + # echo "Example: `basename $0` 1000 1212 cpu" + # exit 1 +# fi + +echo " ______________________________________ " +echo " Running Powheg " +echo " ______________________________________ " + +nevt=${1} +echo "%MSG-POWHEG number of events requested = $nevt" + +rnum=${2} +echo "%MSG-POWHEG random seed used for the run = $rnum" + +ncpu=${3} +echo "%MSG-POWHEG number of cputs for the run = $ncpu" + + +LHEWORKDIR=`pwd` + +use_gridpack_env=true +if [ -n "$4" ] + then + use_gridpack_env=$4 +fi + +if [ "$use_gridpack_env" = true ] + then + if [ -n "$5" ] + then + scram_arch_version=${5} + else + scram_arch_version=SCRAM_ARCH_VERSION_REPLACE + fi + echo "%MSG-POWHEG SCRAM_ARCH version = $scram_arch_version" + + if [ -n "$6" ] + then + cmssw_version=${6} + else + cmssw_version=CMSSW_VERSION_REPLACE + fi + echo "%MSG-POWHEG CMSSW version = $cmssw_version" + export VO_CMS_SW_DIR=/cvmfs/cms.cern.ch + source $VO_CMS_SW_DIR/cmsset_default.sh + + eval `scramv1 unsetenv -sh` + # Make a directory that doesn't overlap + if [ ! -d $CMSSW_BASE ] && [[ $PWD == ${CMSSW_BASE}/* ]]; then + base=`basename $PWD` + cd ${CMSSW_BASE}/.. + if [ ! -d $base ]; then + mkdir $base + cd $base + fi + fi + + + export SCRAM_ARCH=${scram_arch_version} + scramv1 project CMSSW ${cmssw_version} + cd ${cmssw_version}/src + eval `scramv1 runtime -sh` +fi +cd $LHEWORKDIR + +seed=$rnum +file="cmsgrid" + +process="PROCESS" + +# Release to be used to define the environment and the compiler needed +export WORKDIR=`pwd` + +# LHAPDF setup +LHAPDFCONFIG=`echo "$LHAPDF_DATA_PATH/../../bin/lhapdf-config"` +#if lhapdf6 external is available then above points to lhapdf5 and needs to be overridden +LHAPDF6TOOLFILE=$CMSSW_BASE/config/toolbox/$SCRAM_ARCH/tools/available/lhapdf6.xml +if [ -e $LHAPDF6TOOLFILE ]; then + LHAPDFCONFIG=`cat $LHAPDF6TOOLFILE | grep " powheg.input + +# Check if the powheg.input file contains the proper settings to calculate weights + +produceWeights="false" + +grep -q "storeinfo_rwgt 1" powheg.input ; test $? -eq 0 || produceWeights="false" +grep -q "pdfreweight 1" powheg.input ; test $? -eq 0 || produceWeights="false" +grep -q "first runx" powheg.input ; test $? -ne 0 || produceWeights="true" + +if [ "$process" = "Z_ew-BMNNPV" ] || [ "$process" = "W_ew-BMNNP" ]; then + # Photos matching removes weights, so we will calculate them afterwards + sed -i '/rwl_file/d' powheg.input +fi + +# Check if we are running with the "manyseeds" option +manyseeds="false" +grep -qFx "manyseeds 1" powheg.input ; test $? -ne 0 || manyseeds="true" + +if [ "$manyseeds" == "true" ]; then + if [ "$produceWeights" == "true" ]; then + fail_exit "Error: not implemented" + fi + + # With "manyseeds", powheg reads the seed from pwgseeds.dat + echo $seed > pwgseeds.dat + + # Powheg expects the index of the seed to use as an command line argument + # Since we dont actually use the parallelization functionality of Powheg, + # we just write one seed to pwgseeds.dat and always pick seed 1 + cat powheg.input + ../pwhg_main iwhichseed=1 2>&1 | tee log_${process}_${seed}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + # Rename the produced LHE file to be what the rest of the script expects + mv pwgevents-0001.lhe pwgevents.lhe + +else + cat powheg.input + ../pwhg_main 2>&1 | tee log_${process}_${seed}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + +fi + + +if [ "${process}" == "X0jj" ]; then + # now run reweighting for X0jj process + # also need to modify powheg.input inbetween these calls + cp powheg.input powheg.input.noweight + sed -nir '/compute_rwgt/!p;$acompute_rwgt 1' powheg.input + + # sm weight + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''sm_weight'\''' powheg.input + sed -nir '/MGcosa/!p;$aMGcosa 1d0' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_sm.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # ps weight + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''ps_weight'\''' powheg.input + sed -nir '/MGcosa/!p;$aMGcosa 0d0' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_ps.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # mm weight + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''mm_weight'\''' powheg.input + sed -nir '/MGcosa/!p;$aMGcosa -0.707107d0' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_mm.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe +fi + +if [ "${process}" == "gg_H_2HDM" ]; then + # now run reweighting for gg_H_2HDM process + # also need to modify powheg.input inbetween these calls + cp powheg.input powheg.input.noweight + sed -nir '/compute_rwgt/!p;$acompute_rwgt 1' powheg.input + + # rweight h tb + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''h_tb'\''' powheg.input + sed -nir '/notop/!p;$anotop 0' powheg.input + sed -nir '/nobot/!p;$anobot 0' powheg.input + sed -nir '/higgstype/!p;$ahiggstype 1' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_h_tb.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # rweight h t-only + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''h_t'\''' powheg.input + sed -nir '/notop/!p;$anotop 0' powheg.input + sed -nir '/nobot/!p;$anobot 1' powheg.input + sed -nir '/higgstype/!p;$ahiggstype 1' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_h_t.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # rweight h b-only + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''h_b'\''' powheg.input + sed -nir '/notop/!p;$anotop 1' powheg.input + sed -nir '/nobot/!p;$anobot 0' powheg.input + sed -nir '/higgstype/!p;$ahiggstype 1' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_h_b.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # rweight A tb + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''A_tb'\''' powheg.input + sed -nir '/notop/!p;$anotop 0' powheg.input + sed -nir '/nobot/!p;$anobot 0' powheg.input + sed -nir '/higgstype/!p;$ahiggstype 3' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_A_tb.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # rweight A t-only + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''A_t'\''' powheg.input + sed -nir '/notop/!p;$anotop 0' powheg.input + sed -nir '/nobot/!p;$anobot 1' powheg.input + sed -nir '/higgstype/!p;$ahiggstype 3' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_A_t.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # rweight A b-only + sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''A_b'\''' powheg.input + sed -nir '/notop/!p;$anotop 1' powheg.input + sed -nir '/nobot/!p;$anobot 0' powheg.input + sed -nir '/higgstype/!p;$ahiggstype 3' powheg.input + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_A_b.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents-rwgt.lhe pwgevents.lhe + + # # rweight H tb + # sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''H_tb'\''' powheg.input + # sed -nir '/notop/!p;$anotop 0' powheg.input + # sed -nir '/nobot/!p;$anobot 0' powheg.input + # sed -nir '/higgstype/!p;$ahiggstype 2' powheg.input + # sed -nir '/tanb/!p;$atanb 50' powheg.input + # ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_H_tb.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + # mv pwgevents-rwgt.lhe pwgevents.lhe + + # # rweight H t-only + # sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''H_t'\''' powheg.input + # sed -nir '/notop/!p;$anotop 0' powheg.input + # sed -nir '/nobot/!p;$anobot 1' powheg.input + # sed -nir '/higgstype/!p;$ahiggstype 2' powheg.input + # sed -nir '/tanb/!p;$atanb 50' powheg.input + # ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_H_t.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + # mv pwgevents-rwgt.lhe pwgevents.lhe + + # # rweight H b-only + # sed -nir '/lhrwgt_id/!p;$alhrwgt_id '\''H_b'\''' powheg.input + # sed -nir '/notop/!p;$anotop 1' powheg.input + # sed -nir '/nobot/!p;$anobot 0' powheg.input + # sed -nir '/higgstype/!p;$ahiggstype 2' powheg.input + # sed -nir '/tanb/!p;$atanb 50' powheg.input + # ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_H_b.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + # mv pwgevents-rwgt.lhe pwgevents.lhe + +fi + +if [ "$produceWeightsNNLO" == "true" ]; then + echo -e "\ncomputing weights for NNLOPS\n" + mv pwgevents.lhe fornnlops + cp ../nnlopsreweighter.input . + cp ../HNNLO-11.top . + cp ../HNNLO-22.top . + cp ../HNNLO-0505.top . + ../nnlopsreweighter + mv fornnlops.nnlo pwgevents.lhe +fi + +sed -e "/#new weight/d" -e "//d" -e "//d" pwgevents.lhe > pwgevents.lhe.tmp +mv pwgevents.lhe.tmp pwgevents.lhe +if [[ $(grep -c "> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " mass=${MASS} " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + if [ "$process" == "Zj" ]; then + echo "Zmass ${MASS}" >> powheg.input + echo "psZmass ${PSMASS}" >> powheg.input + elif [ "$process" == "Wj" ]; then + echo "Wmass ${MASS}" >> powheg.input + echo "psWmass ${PSMASS}" >> powheg.input + fi + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_mass_${MASS}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + done + # Width + for WIDTH in ${WIDTHS[@]} + do + echo -e "\n doing width ${WIDTH}\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + echo "rwl_file '-'" >> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " width=${WIDTH} " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + if [ "$process" == "Zj" ]; then + echo "Zwidth ${WIDTH}" >> powheg.input + elif [ "$process" == "Wj" ]; then + echo "Wwidth ${WIDTH}" >> powheg.input + fi + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_width_${WIDTH}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + done + # Q0 + QS=(2.0 1.0 0.5 0.0) + for Q in ${QS[@]} + do + echo -e "\n doing Q0 ${Q}\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + sed -i '/Q0/d' powheg.input + echo "rwl_file '-'" >> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " Q0=${Q} " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo "Q0 ${Q}" >> powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_q0_${Q}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + done + # largeptscales + echo -e "\n doing largeptscales 1\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + sed -i '/largeptscales/d' powheg.input + echo "rwl_file '-'" >> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " largeptscales=1 " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo "largeptscales 1" >> powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_largeptscales_1.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + # sin2theta + if [ "$process" == "Zj" ]; then + SINW2S=(0.23151 0.23154 0.23157 0.2230 0.2300 0.2305 0.2310 0.2315 0.2320 0.2325 0.2330) + for SINW2 in ${SINW2S[@]} + do + echo -e "\n doing sthw2 ${SINW2}\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + echo "rwl_file '-'" >> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " sthw2=${SINW2} " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo "sthw2 ${SINW2}" >> powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_sinw2_${SINW2}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + done + fi + # CKM + if [ "$process" == "Wj" ]; then + echo -e "\n doing CKM Cabibbo\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + echo "rwl_file '-'" >> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " ckm_cabibbo=1 " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + sed -i "s/CKM_Vud .*/CKM_Vud 0.975d0/g" powheg.input + sed -i "s/CKM_Vus .*/CKM_Vus 0.222d0/g" powheg.input + sed -i "s/CKM_Vub .*/CKM_Vub 1d-10/g" powheg.input + sed -i "s/CKM_Vcd .*/CKM_Vcd 0.222d0/g" powheg.input + sed -i "s/CKM_Vcs .*/CKM_Vcs 0.975d0/g" powheg.input + sed -i "s/CKM_Vcb .*/CKM_Vcb 1d-10/g" powheg.input + sed -i "s/CKM_Vtd .*/CKM_Vtd 1d-10/g" powheg.input + sed -i "s/CKM_Vts .*/CKM_Vts 1d-10/g" powheg.input + sed -i "s/CKM_Vtb .*/CKM_Vtb 1d0/g" powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_ckm_cabibbo.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + + + echo -e "\n doing CKM diagonal\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + echo "rwl_file '-'" >> powheg.input + echo "rwl_add 1" >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + echo " ckm_diagonal=1 " >> powheg.input + echo "" >> powheg.input + echo "" >> powheg.input + sed -i "s/CKM_Vud .*/CKM_Vud 1.000/g" powheg.input + sed -i "s/CKM_Vus .*/CKM_Vus 1d-10/g" powheg.input + sed -i "s/CKM_Vub .*/CKM_Vub 1d-10/g" powheg.input + sed -i "s/CKM_Vcd .*/CKM_Vcd 1d-10/g" powheg.input + sed -i "s/CKM_Vcs .*/CKM_Vcs 1.000/g" powheg.input + sed -i "s/CKM_Vcb .*/CKM_Vcb 1d-10/g" powheg.input + sed -i "s/CKM_Vtd .*/CKM_Vtd 1d-10/g" powheg.input + sed -i "s/CKM_Vts .*/CKM_Vts 1d-10/g" powheg.input + sed -i "s/CKM_Vtb .*/CKM_Vtb 1.000/g" powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}_ckm_diagonal.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + mv pwgevents-rwgt.lhe pwgevents.lhe + + counter=$(( counter + 1 )) + fi +fi + +if [ "$process" = "Z_ew-BMNNPV" ] || [ "$process" = "W_ew-BMNNP" ]; then + ../main-PHOTOS-lhef 2>&1 | tee logphotos_${process}_${seed}.txt; test $? -eq 0 || fail_exit "main-PHOTOS-lhef: exit code not 0" + mv pwgevents.lhe pwgevents_nophotos.lhe + mv pwgevents_photos.lhe pwgevents.lhe + + echo -e "\n doing rwl\n" + cp powheg.input.noweight powheg.input + sed -i '/rwl_file/d' powheg.input + echo "rwl_file 'pwg-rwl.dat'" >> powheg.input + echo "rwl_add 1" >> powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + mv pwgevents.lhe pwgevents_photos.lhe + mv pwgevents-rwgt.lhe pwgevents.lhe +fi + +if [ "$produceWeights" == "true" ]; then + + echo " ______________________________________ " + echo " Running HV_ew reweight " + echo " ______________________________________ " + + cp pwgfullgrid-reg-00*.dat pwgfullgrid-reg.dat + echo "rwl_add 1" >> powheg.input + echo "rwl_group_events 2000" >> powheg.input + echo "lhapdf6maxsets 50" >> powheg.input + echo "rwl_file 'pwg-rwl.dat'" >> powheg.input + echo "rwl_format_rwgt 1" >> powheg.input + sed -i -e "s#select_EW#\#select_EW#g" powheg.input + echo "select_EW_virt 1" >> powheg.input + + ../pwhg_main 2>&1 | tee logrew_${process}_${seed}.txt; test $? -eq 0 || fail_exit "pwhg_main error: exit code not 0" + + cat pwgevents-rwgt.lhe | grep -v "Random number generator exit values" > ${file}_final.lhe +else + cat pwgevents.lhe | grep -v "Random number generator exit values" > ${file}_final.lhe +fi + +rm -rf powheg.input* + +echo -e "\n finished computing weights ..\n" + +xmllint --stream --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" + +# uncomment to avoid problems in production as whole job would fail and problem traced back to neg. PDFs +# 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 + +if [ -s pwgstat.dat ]; then + mv pwgstat.dat pwg-stat.dat +fi + +if [ -s pwg-stat.dat ]; then + if [ "$process" = "b_bbar_4l" ] || [ "$process" = "HWJ_ew" ] || [ "$process" = "HW_ew" ] || [ "$process" = "HZJ_ew" ] || [ "$process" = "HZ_ew" ]; then + XSECTION=`tac pwg-stat.dat | grep total\ total | awk '{ print $(NF-2) }'` + XSECUNC=` tac pwg-stat.dat | grep total\ total | awk '{ print $(NF) }'` + else + XSECTION=`tac pwg-stat.dat | grep -m1 in\ pb | awk '{ print $(NF-2) }'` + XSECUNC=` tac pwg-stat.dat | grep -m1 in\ pb | awk '{ print $(NF) }'` + fi + head=`cat cmsgrid_final.lhe | grep -in "" | sed "s@:@ @g" | awk '{print $1+1}' | tail -1` + tail=`wc -l cmsgrid_final.lhe | awk -v tmp="$head" '{print $1-2-tmp}'` + tail -${tail} cmsgrid_final.lhe > cmsgrid_final.lhe_tail + head -${head} cmsgrid_final.lhe > cmsgrid_final.lhe_F + proclin=`expr $head + 1` + proc=`sed -n -e ${proclin}p cmsgrid_final.lhe | awk '{print $4}'` + echo " "$XSECTION" "$XSECUNC" 1.00000000000E-00 "$proc >> cmsgrid_final.lhe_F + echo "" >> cmsgrid_final.lhe_F + cat cmsgrid_final.lhe_tail >> cmsgrid_final.lhe_F + mv cmsgrid_final.lhe_F cmsgrid_final.lhe +fi +#Replace the negative so pythia will work +sed "s@-1000021@ 1000022@g" cmsgrid_final.lhe > cmsgrid_final.lhe_F1 +sed "s@1000021@1000022@g" cmsgrid_final.lhe_F1 > cmsgrid_final.lhe +cp ${file}_final.lhe ${WORKDIR}/. + +echo "Output ready with ${file}_final.lhe at $WORKDIR" +echo "End of job on " `date` +exit 0; +