File indexing completed on 2024-04-06 12:13:49
0001
0002
0003
0004
0005 echo " ______________________________________ "
0006 echo " Running Madgraph5 "
0007 echo " ______________________________________ "
0008
0009 repo=${1}
0010 echo "%MSG-MG5 repository = $repo"
0011
0012 name=${2}
0013 echo "%MSG-MG5 gridpack = $name"
0014
0015 decay=${3}
0016 echo "%MSG-MG5 run decay = $decay"
0017
0018 replace=${4}
0019 echo "%MSG-MG5 replace = $replace"
0020
0021 process=${5}
0022 echo "%MSG-MG5 process = $process"
0023
0024 maxjetflavor=${6}
0025 echo "%MSG-MG5 maxjetflavor = $maxjetflavor"
0026
0027 qcut=${7}
0028 echo "%MSG-MG5 qcut = $qcut"
0029
0030 minmax_jet=${8}
0031 echo "%MSG-MG5 minmax_jet = $minmax_jet"
0032
0033 min_jets=${9}
0034 max_jets=${10}
0035 echo "%MSG-MG5 min/max jet multiplicity = $min_jets / $max_jets"
0036
0037 nevt=${11}
0038 echo "%MSG-MG5 number of events requested = $nevt"
0039
0040 rnum=${12}
0041 echo "%MSG-MG5 random seed used for the run = $rnum"
0042
0043 ncpu=${13}
0044 echo "%MSG-MG5 thread count requested = $ncpu (ignored)"
0045
0046 if [[ -d madevent ]]
0047 then
0048 echo 'madevent directory found'
0049 echo 'Setting up the environment'
0050 rm -rf madevent
0051 fi
0052 mkdir madevent; cd madevent
0053
0054
0055 fn-fileget -c `cmsGetFnConnect frontier://smallfiles` ${repo}/${name}_tarball.tar.gz
0056
0057
0058
0059 tar xzf ${name}_tarball.tar.gz ; rm -f ${name}_tarball.tar.gz ;
0060
0061
0062 ln -sf `which gfortran` f77
0063 ln -sf `which gfortran` g77
0064 PATH=`pwd`:${PATH}
0065
0066
0067 run_card_seed=`awk 'BEGIN{FS=" = iseed"}/iseed/{print $1}' Cards/run_card.dat`
0068 echo "run_card_seed = ${run_card_seed}"
0069 sed -i -e "s#${run_card_seed}.*.= iseed#${rnum} = iseed#g" Cards/run_card.dat
0070 new_run_card_seed=`awk 'BEGIN{FS=" = iseed"}/iseed/{print $1}' Cards/run_card.dat`
0071 echo "new_run_card_seed = ${new_run_card_seed}"
0072
0073
0074 run_card_nevents=`awk 'BEGIN{FS=" = nevents"}/nevents/{print $1}' Cards/run_card.dat`
0075 echo "run_card_nevents = ${run_card_nevents}"
0076 sed -i -e "s#${run_card_nevents}.*.= nevents#${nevt} = nevents#g" Cards/run_card.dat
0077 new_run_card_nevents=`awk 'BEGIN{FS=" = nevents"}/nevents/{print $1}' Cards/run_card.dat`
0078 echo "new_run_card_nevents = ${new_run_card_nevents}"
0079
0080
0081 version=`cat MGMEVersion.txt | grep -c "1.4"`
0082
0083
0084 bin/generate_events 0 ${name}
0085 cd ../
0086
0087 file="${name}_unweighted_events"
0088 if [ "$version" -eq "0" ] ; then
0089 mv madevent/Events/${file}.lhe.gz ./
0090 fi
0091
0092 if [ "$version" -eq "1" ] ; then
0093 mv madevent/Events/${name}/unweighted_events.lhe.gz ${file}.lhe.gz
0094 fi
0095
0096 if [ ! -f ${file}.lhe.gz ]; then
0097 echo "%MSG-MG5 events.lhe.gz file is not in the same folder with run.sh script, abort !!! "
0098 exit
0099 fi
0100
0101 cp ${file}.lhe.gz ${file}_orig.lhe.gz
0102 gzip -d ${file}.lhe.gz
0103
0104
0105
0106
0107
0108 echo " ______________________________________ "
0109 echo " post processing started "
0110 echo " ______________________________________ "
0111
0112 echo
0113 if [ -f ${file}.lhe ] ; then
0114 seed=`awk 'BEGIN{FS=" = iseed "}/iseed/{print $1}' ${file}.lhe`
0115 number_event=`grep -c "</event>" ${file}.lhe`
0116 fi
0117
0118 if [ $seed -eq $rnum ] ;then
0119 echo "GSEED :$seed"
0120 if [ $number_event -eq $nevt ] ;then
0121 echo "NEVENT : $nevt "
0122 else
0123 echo "%MSG-MG5 Error: The are less events ( $number_event ) Post Production is cancelled."
0124
0125 exit 1
0126 fi
0127 else
0128 echo "%MSG-MG5 Error: Seed numbers doesnt match ( $seed )"
0129 exit 1
0130 fi
0131
0132
0133
0134
0135
0136
0137
0138 if [ "${decay}" == true ] ; then
0139
0140 echo "%MSG-MG5 Running DECAY..."
0141 bm=`grep -c "# MB" ${file}.lhe`
0142 zero=0;
0143 if [ $bm -eq $zero ] ;then
0144 sed 's/ 5 0.000000 # b : 0.0/ 5 4.800000 # b/' ${file}.lhe > ${file}_in.lhe ; rm -f ${file}.lhe
0145 fi
0146
0147 if [ $bm -gt $zero ] ;then
0148 sed 's/5 0.000000e+00 # MB/5 4.800000e+00 # MB/g' ${file}.lhe > ${file}_in.lhe ; rm -f ${file}.lhe
0149 fi
0150
0151 for (( i = 1; i <=2; i++)) ; do
0152 if [ -f ${file}.lhe ] ; then
0153 mv ${file}.lhe ${file}_in.lhe
0154 fi
0155 madevent/bin/decay < madevent/bin/decay_$i\.in
0156 done
0157 fi
0158
0159
0160
0161
0162 cat > replace_card1.dat <<EOF
0163
0164
0165
0166 11:11 13 15
0167 -12: -12 -14 -16
0168 -11:-11 -13 -15
0169 12: 12 14 16
0170 done
0171 EOF
0172
0173 if [ ${replace} == true ] ; then
0174 echo "%MSG-MG5 Runnig REPLACE..."
0175 if [ -f ${file}.lhe ] ; then
0176 mv ${file}.lhe ${file}_in.lhe
0177 fi
0178 perl madevent/bin/replace.pl ${file}_in.lhe ${file}.lhe < replace_card1.dat
0179 fi
0180
0181
0182
0183 if [[ ${process} == wjets || ${process} == zjets ]] ; then
0184 echo "%MSG-MG5 process V+jets"
0185 python madevent/bin/mgPostProcv2.py -o ${file}_qcut${qcut}_mgPostv2.lhe -m -w -j ${maxjetflavor} -q ${qcut} -e 5 -s ${file}.lhe
0186 fi
0187
0188
0189 if [ ${process} == qcd ] ; then
0190 echo "%MSG-MG5 process QCD"
0191 python madevent/bin/mgPostProcv2.py -o ${file}_qcut${qcut}_mgPostv2.lhe -q ${qcut} -j ${maxjetflavor} -e 5 -s ${file}.lhe
0192 fi
0193
0194
0195 if [ ${process} == ttbar ] ; then
0196 echo "%MSG-MG5 process ttbar"
0197 python madevent/bin/mgPostProcv2.py -o ${file}_qcut${qcut}_mgPostv2.lhe -m -w -t -j ${maxjetflavor} -q ${qcut} -e 5 -s ${file}.lhe
0198 sed -i -e '/Rnd seed/d' -e '/MC partial width/d' -e '/Number of Events/d' -e '/Max wgt/d' -e '/Average wgt/d' -e '/Integrated weight/d' ${file}_qcut${qcut}_mgPostv2.lhe
0199 fi
0200
0201
0202
0203
0204
0205 if [ $minmax_jet == true ] ;then
0206
0207 sed -i "s/ [0-9]* = minjets ! Smallest number of additional light flavour jets/ $min_jets = minjets ! Smallest number of additional light flavour jets/g" \
0208 ${file}_qcut${qcut}_mgPostv2.lhe
0209 sed -i "s/ [0-9]* = maxjets ! Largest number (inclusive ktMLM matching multipl.)/ $max_jets = maxjets ! Largest number (inclusive ktMLM matching multipl.)/g" \
0210 ${file}_qcut${qcut}_mgPostv2.lhe
0211 fi
0212
0213 mv ${file}_qcut${qcut}_mgPostv2.lhe ${file}_final.lhe
0214
0215
0216 ls -l
0217 echo
0218
0219 exit 0