Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:49

0001 #!/bin/bash
0002 
0003 #set -o verbose
0004 EXPECTED_ARGS=10
0005 
0006 if [ $# -ne $EXPECTED_ARGS ]
0007 then
0008     echo "Usage: `basename $0` repository name process card preCompiled createTarball tarballRepository tarballName Nevents RandomSeed "
0009     echo "process names are: Dijet Zj WW hvq WZ  W_ew-BW Wbb Wj VBF_Hgg_H W Z  Wp_Wp_J_J VBF_Wp_Wp ZZ"  
0010     echo "Example: ./create_lhe_powheg_all.sh slc5_ia32_gcc434/powheg/V1.0/src powhegboxv1.0_Jan2012 Z slc5_ia32_gcc434/powheg/V1.0/8TeV_Summer12/DYToEE_M-20_8TeV-powheg/v1/DYToEE_M-20_8TeV-powheg.input false true slc5_amd64_gcc462/8TeV/powheg Z 1000 1212" 
0011     exit 1
0012 fi
0013 
0014 echo "   ______________________________________     "
0015 echo "         Running Powheg                       "
0016 echo "   ______________________________________     "
0017 
0018 repo=${1}
0019 echo "%MSG-POWHEG repository = $repo"
0020 
0021 name=${2} 
0022 echo "%%MSG-POWHEG name = $name"
0023 
0024 process=${3}
0025 echo "%MSG-POWHEG process = $process"
0026 
0027 cardinput=${4}
0028 echo "%MSG-POWHEG location of the card = $cardinput"
0029 
0030 precompile=${5}
0031 echo "%MSG-POWHEG Precompiled or not   = $precompile"
0032 
0033 createTarball=${6}
0034 echo "%MSG-POWHEG create tarball or not   = $createTarball"
0035 
0036 tarballRepo=${7}
0037 echo "%MSG-POWHEG tarball repository = $tarballRepo"
0038 
0039 tarball=${8}
0040 echo "%MSG-POWHEG tar ball file name = $tarball"
0041 
0042 nevt=${9}
0043 echo "%MSG-POWHEG number of events requested = $nevt"
0044 
0045 rnum=${10}
0046 echo "%MSG-POWHEG random seed used for the run = $rnum"
0047 
0048 ncpu=${11}
0049 echo "%MSG-POWHEG thread count requested = $ncpu (ignored)"
0050 
0051 seed=$rnum
0052 file="events"
0053 # Release to be used to define the environment and the compiler needed
0054 export PRODHOME=`pwd`
0055 export RELEASE=${CMSSW_VERSION}
0056 export WORKDIR=`pwd`
0057 
0058 # Get the input card
0059 wget --no-check-certificate http://cms-project-generators.web.cern.ch/cms-project-generators/${cardinput} -O powheg.input
0060 card="$WORKDIR/powheg.input"
0061 
0062 # initialize the CMS environment 
0063 scram project -n ${name} CMSSW ${RELEASE} ; cd ${name} ; mkdir -p work ; cd work
0064 eval `scram runtime -sh`
0065 
0066 # force the f77 compiler to be the CMS defined one
0067 #ln -s `which gfortran` f77
0068 #ln -s `which gfortran` g77
0069 export PATH=`pwd`:${PATH}
0070 
0071 # FastJet and LHAPDF
0072 #fastjet-config comes with the paths used at build time.
0073 #we need this to replace with the correct paths obtained from scram tool info fastjet
0074 
0075 newinstallationdir=`scram tool info fastjet | grep FASTJET_BASE |cut -d "=" -f2`
0076 cp ${newinstallationdir}/bin/fastjet-config ./fastjet-config.orig
0077 
0078 oldinstallationdir=`cat fastjet-config.orig | grep installationdir | head -n 1 | cut -d"=" -f2`
0079 sed -e "s#${oldinstallationdir}#${newinstallationdir}#g" fastjet-config.orig > fastjet-config 
0080 chmod +x fastjet-config
0081 
0082 #same for lhapdf
0083 newinstallationdirlha=`scram tool info lhapdf | grep LHAPDF_BASE |cut -d "=" -f2`
0084 cp ${newinstallationdirlha}/bin/lhapdf-config ./lhapdf-config.orig
0085 oldinstallationdirlha=`cat lhapdf-config.orig | grep prefix | head -n 1 | cut -d"=" -f2`
0086 sed -e "s#prefix=${oldinstallationdirlha}#prefix=${newinstallationdirlha}#g" lhapdf-config.orig > lhapdf-config
0087 chmod +x lhapdf-config
0088 
0089 #svn checkout --username anonymous --password anonymous svn://powhegbox.mib.infn.it/trunk/POWHEG-BOX
0090 # # retrieve the wanted POWHEG-BOX from the official repository 
0091 
0092 if [ "$precompile" == "false" ];
0093 then 
0094     echo "Compile during the run"
0095 
0096     wget --no-check-certificate http://cms-project-generators.web.cern.ch/cms-project-generators/${repo}/${name}.tar.gz  -O ${name}.tar.gz
0097     tar xzf ${name}.tar.gz
0098 
0099 #remove from Powheg the LENOCC function which is already defined in LHAPDF library
0100     patch POWHEG-BOX/cernroutines.f <<EOF
0101 *** POWHEG-BOX/cernroutines_orig.f      Wed Mar 14 11:48:14 2012
0102 --- POWHEG-BOX/cernroutines.f   Wed Mar 14 11:48:29 2012
0103 ***************
0104 *** 790,815 ****
0105   
0106   
0107   
0108 ! c# 10 "lenocc.F" 2
0109 !       FUNCTION LENOCC (CHV)
0110 ! C
0111 ! C CERN PROGLIB# M507    LENOCC          .VERSION KERNFOR  4.21  890323
0112 ! C ORIG. March 85, A.Petrilli, re-write 21/02/89, JZ
0113 ! C
0114 ! C-    Find last non-blank character in CHV
0115 ! 
0116 !       CHARACTER    CHV*(*)
0117 ! 
0118 !       N = LEN(CHV)
0119 ! 
0120 !       DO 17  JJ= N,1,-1
0121 !       IF (CHV(JJ:JJ).NE.' ') GO TO 99
0122 !    17 CONTINUE
0123 !       JJ = 0
0124 ! 
0125 !    99 LENOCC = JJ
0126 !       RETURN
0127 !       END
0128   c# 1 "mtlset.F"
0129   c# 1 "<built-in>"
0130   c# 1 "<command line>"
0131 --- 790,815 ----
0132   
0133   
0134   
0135 ! ccccccc# 10 "lenocc.F" 2
0136 ! cccccc      FUNCTION LENOCC (CHV)
0137 ! ccccccC
0138 ! ccccccC CERN PROGLIB# M507    LENOCC          .VERSION KERNFOR  4.21  890323
0139 ! ccccccC ORIG. March 85, A.Petrilli, re-write 21/02/89, JZ
0140 ! ccccccC
0141 ! ccccccC-    Find last non-blank character in CHV
0142 ! cccccc
0143 ! cccccc      CHARACTER    CHV*(*)
0144 ! cccccc
0145 ! cccccc      N = LEN(CHV)
0146 ! cccccc
0147 ! cccccc      DO 17  JJ= N,1,-1
0148 ! cccccc      IF (CHV(JJ:JJ).NE.' ') GO TO 99
0149 ! cccccc   17 CONTINUE
0150 ! cccccc      JJ = 0
0151 ! cccccc
0152 ! cccccc   99 LENOCC = JJ
0153 ! cccccc      RETURN
0154 ! cccccc      END
0155   c# 1 "mtlset.F"
0156   c# 1 "<built-in>"
0157   c# 1 "<command line>"
0158 
0159 EOF
0160 
0161     cd POWHEG-BOX/${process}
0162 
0163     mv Makefile Makefile.orig
0164     cat Makefile.orig | sed -e "s#STATIC[ \t]*=[ \t]*-static#STATIC=-dynamic#g" | sed -e "s#PDF[ \t]*=[ \t]*native#PDF=lhapdf#g"> Makefile
0165     echo "LIBS+=-lz -lstdc++" >> Makefile
0166 
0167 
0168     LHA_BASE="`readlink -f "$LHAPATH/../../../"`"
0169 
0170 #slc5_amd64_gcc462/external/lhapdf/5.8.5 has a bug. if this version is used, replace it by 5.8.5-cms:
0171     if [ `basename $LHA_BASE` == "5.8.5" ]
0172     then  
0173         LHA_BASE="`echo "$LHA_BASE" | sed 's@slc5_amd64_gcc462/external/lhapdf/5.8.5@slc5_amd64_gcc462/external/lhapdf/5.8.5-cms@'`"
0174     fi
0175 
0176     LHA_BASE_OLD="`$LHA_BASE/bin/lhapdf-config --prefix`"
0177     cat > lhapdf-config-wrap <<EOF
0178 #!/bin/bash
0179 "$LHA_BASE/bin/lhapdf-config" "\$@" | sed "s|$LHA_BASE_OLD|$LHA_BASE|g"
0180 EOF
0181     chmod a+x lhapdf-config-wrap
0182 
0183     make LHAPDF_CONFIG="`pwd`/lhapdf-config-wrap" pwhg_main
0184 
0185     if [ "$createTarball" == "true" ]
0186     then
0187         rm -rf testrun*
0188         rm -rf Docs
0189         rm -rf .svn 
0190         rm -rf obj
0191         rm -rf *.f
0192         cd ..
0193         tar chvzf ${tarball}.tar.gz ${process}
0194         cp -p ${tarball}.tar.gz ${WORKDIR}/.
0195         cd ${process}
0196     fi
0197 
0198 else if [ "$precompile" == "true" ];
0199 then
0200     echo "Using a precompiled tar ball $tarball.tar.gz"
0201 #    wget --no-check-certificate http://cms-project-generators.web.cern.ch/cms-project-generators/${tarballRepo}/${tarball}.tar.gz
0202     fn-fileget -c `cmsGetFnConnect frontier://smallfiles` ${tarballRepo}/${tarball}.tar.gz || true
0203 
0204     if [[ -e ./${tarball}.tar.gz ]]; then
0205         tar xvzf ${tarball}.tar.gz
0206         cd ${process}
0207     else
0208         echo "Error! The tar ball $tarball.tar.gz does not exist!"
0209         exit 1
0210     fi
0211 fi
0212 fi
0213 
0214 
0215 mkdir workdir
0216 cd workdir
0217 cat ${card} | sed -e "s#SEED#${seed}#g" | sed -e "s#NEVENTS#${nevt}#g" > powheg.input
0218 cat powheg.input
0219 ../pwhg_main &> log_${process}_${seed}.txt
0220 #remove the spurious random seed output that is non LHE standard 
0221 cat pwgevents.lhe | grep -v "Random number generator exit values" > ${file}_final.lhe
0222 ls -l ${file}_final.lhe
0223 pwd
0224 cp ${file}_final.lhe ${WORKDIR}/.
0225 #cp ${file}_final.lhe ${WORKDIR}/${file}_final.lhe
0226 #cp ${file}_final.lhe ${WORKDIR}/output.lhe
0227 
0228 echo "Output ready with log_${process}_${seed}.txt and ${file}_final.lhe at `pwd` and $WORKDIR"
0229 echo "End of job on " `date`
0230 exit 0;