~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to Template/NLO/MCatNLO/Scripts/MCatNLO_MadFKS_HERWIG6.Script

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
# finds out architecture name, defines system files, and construct
 
3
# the relevant directory for run, if not present. If the architecture
 
4
# cannot be figured out, defines ./Run as working directory, and use 
 
5
# sun as system file -- it should work in most of the cases
 
6
function architecture {
 
7
PATH=".:""$PATH"
 
8
thisdir=`pwd`
 
9
homedir=$HOME
 
10
case `uname` in
 
11
Linux*) ARCHNAME=LinuxHW ; DBGFLAG='DEBUG=-ggdb' ; EXTRA='EXTRAOBJ=linux.o' ;
 
12
        EXMAKE=make ; CPOPT=pu ;;
 
13
OSF*)  ARCHNAME=AlphaHW ; DBGFLAG='DEBUG=-g' ; EXTRA='EXTRAOBJ=alpha.o' ;
 
14
       EXMAKE=gmake ; CPOPT=p ;;
 
15
Sun*) ARCHNAME=SunHW ; DBGFLAG='DEBUG=-g' ; EXTRA='EXTRAOBJ=sun.o' ;
 
16
      EXMAKE=gmake ; CPOPT=p ;;
 
17
Darwin*) ARCHNAME=DarwinHW ; DBGFLAG='DEBUG=-g' ; EXTRA='EXTRAOBJ=sun.o' ;
 
18
         EXMAKE=make ; CPOPT=p ;;
 
19
*) ARCHNAME=RunHW ; DBGFLAG='DEBUG=-g' ; EXTRA='EXTRAOBJ=sun.o' ;;
 
20
esac
 
21
#
 
22
}
 
23
 
 
24
# $? is the value of last executed command. A call to this function
 
25
# after a failure will cause the program to quit the script
 
26
function teststatus {
 
27
rc=$?
 
28
if [ 0 = $rc ]
 
29
then
 
30
:
 
31
else
 
32
echo $* did not succeed, exit status=$rc 
 
33
exit $rc
 
34
fi
 
35
}
 
36
 
 
37
# returns a string which identifies the target
 
38
# for the Makefile
 
39
function getSTRmake {
 
40
stringmake=MadFKS
 
41
}
 
42
 
 
43
# utility function for dothelinks
 
44
function stripextension {
 
45
echo $1 | sed "s/\..*\$//"
 
46
}
 
47
 
 
48
# utility function for dothelinks
 
49
function capitalize {
 
50
echo $1 | sed "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/"
 
51
}
 
52
 
 
53
# creates logical links for the PDF grid files. By P. Nason
 
54
function dothelinks {
 
55
if [ -d $PDFPATH ]
 
56
then
 
57
for i in ${PDFPATH}/*.dat ${PDFPATH}/*.tbl
 
58
do
 
59
if [ -f $i ]
 
60
then
 
61
name=`basename $i`
 
62
name=`stripextension $name`
 
63
case $name in
 
64
mrst200*) ;;
 
65
*mrs*|grpol|grvdm|lac1|pion[1-3]) name=`capitalize $name`;;
 
66
esac
 
67
if [ ! -L $thisdir/$name ] || [ ! $thisdir/$name -ef $i ]
 
68
then
 
69
ln -sf $i $thisdir/$name
 
70
fi
 
71
fi
 
72
done
 
73
for i in ${PDFPATH}/a02.*
 
74
do
 
75
if [ -f $i ]
 
76
then
 
77
name=`basename $i`
 
78
if [ ! -L $thisdir/$name ] || [ ! $thisdir/$name -ef $i ]
 
79
then
 
80
ln -sf $i $thisdir/$name
 
81
fi
 
82
fi
 
83
done
 
84
fi
 
85
}
 
86
 
 
87
# creates logical links for LHAPDF, and replaced PDF group name (unused
 
88
# by LHAPDF) with a LHAPDF-specific string
 
89
function linklhapdf {
 
90
case $LHAOFL in
 
91
FREEZE|freeze) PDFGROUP=LHAPDF ;;
 
92
EXTRAPOLATE|extrapolate) PDFGROUP=LHAEXT ;;
 
93
*) echo "no such option; failure in linklhapdf" ; exit 1 ;;
 
94
esac
 
95
source ../Source/fj_lhapdf_opts
 
96
}    
 
97
 
 
98
# creates the executable for NLO and MC; the entry of the function
 
99
# is either NLO or MC, depending on which executable one wants to obtain;
 
100
# PDFLIB or private PDF library is linked, depending on the value of
 
101
# the parameter UsedPdfLib, which is set by the function whichpdflib.
 
102
# Extra libraries are listed in the shell variable EXTRALIBS; do NOT
 
103
# remove the double quotes in the call to nameextralib, otherwise only
 
104
# the first library of the list is taken
 
105
function compile {
 
106
architecture
 
107
 
 
108
EVTDIR=`pwd`"/../Events"
 
109
# stops if event file is not in the /Events folder
 
110
EVT_NAMEF="$EVPREFIX"
 
111
if [ ! -f $EVTDIR/$EVT_NAMEF ]
 
112
then
 
113
  echo "Event file" $EVTDIR/$EVT_NAMEF "not found: quitting"
 
114
  exit 1
 
115
fi
 
116
 
 
117
 
 
118
if [ "$PDFCODE" -ne 0 ]
 
119
then
 
120
  HERPDF='EXTPDF'
 
121
  PDFLIBRARY='LHAPDF'
 
122
  UsedPdfLib='LHAPDF'
 
123
  cp -f $LHAPDFPATH"/lib/libLHAPDF.a" `pwd`"/lib"
 
124
  LHALIBPATH=`pwd`
 
125
  LHALINK=DYNAMIC
 
126
  if [ "$PDFCODE" -gt 0 ]; then LHAOFL=FREEZE; fi
 
127
  if [ "$PDFCODE" -gt 1 ]; then PDFSET=$PDFCODE; fi
 
128
  if [ "$PDFCODE" -lt 0 ]; then LHAOFL=EXTRAPOLATE; fi
 
129
  if [ "$PDFCODE" -lt -1 ]; then PDFSET=$((PDFCODE*-1)); fi
 
130
  linklhapdf
 
131
elif [ "$PDFCODE" -eq 0 ]
 
132
then
 
133
  HERPDF='DEFAULT'
 
134
  PDFLIBRARY='THISLIB'
 
135
  UsedPdfLib='THISLIB'
 
136
# the following is dummy
 
137
  LHALINK=DYNAMIC
 
138
  LHAOFL=FREEZE
 
139
else
 
140
  echo 'Invalid PDFCODE' $PDFCODE
 
141
  exit 1
 
142
fi
 
143
 
 
144
whichpdflib $PDFLIBRARY
 
145
whichlhapdf $LHALINK
 
146
nameextralib "$EXTRALIBS"
 
147
pathextralib "$EXTRAPATHS"
 
148
pathextralibdyn "$EXTRAPATHS"
 
149
pathextraincl "$INCLUDEPATHS"
 
150
EXEC_NAME=
 
151
EXEC_NAMEF=
 
152
EXEC_NAMEFF=
 
153
read -a HWUTIA <<< "$HWUTI"
 
154
HWUTI=
 
155
for i in "${HWUTIA[@]}"; do HWUTI+=`pwd`"/objects/$i "; done
 
156
HWUTIMAKE="HWUTI="$HWUTI
 
157
HERWGMAKE="HERWIGVER="$HERWIGVER
 
158
LIBSMAKE="EXTRALIBS="$ExtraLibs
 
159
LIBSMAKEP="EXTRAPATHS="$ExtraPaths
 
160
INCLMAKE="INCLOPTION="$ExtraIncl
 
161
INCDIRMK="INCDIR="`pwd`"/include"
 
162
COMSRCMK="COMSRC="`pwd`"/srcCommon"
 
163
ANASRCMK="ANADIR="`pwd`"/HWAnalyzer"
 
164
OBJDIRMK="OBJDIR="`pwd`"/objects"
 
165
HWSSRCMK="HWSDIR=""$HWPATH"
 
166
EVTDIR=`pwd`"/../Events"
 
167
 
 
168
if [ "$LD_LIBRARY_PATH" = "" ]
 
169
then
 
170
  LD_LIBRARY_PATH="$ExtraPathsDyn"
 
171
else
 
172
  if [ "$ExtraPathsDyn" != "" ]
 
173
  then
 
174
    LD_LIBRARY_PATH="$ExtraPathsDyn"":""$LD_LIBRARY_PATH"
 
175
  fi
 
176
fi
 
177
LIBSLHA="LHALIB="
 
178
case $1 in
 
179
NLO) echo "NLO must be computed with MadFKS"; exit 1 ;;
 
180
MC) if [ $UsedPdfLib = "PDFLIB" ]
 
181
     then
 
182
       EXEC_NAMEF="HW_EXE_PDFLIB"
 
183
     elif [ $UsedPdfLib = "THISLIB" ]
 
184
     then
 
185
       EXEC_NAMEF="HW_EXE_DEFAULT"
 
186
     elif [ $UsedPdfLib = "LHAPDF" ]
 
187
     then
 
188
       EXEC_NAMEF="HW_EXE_LHAPDF"
 
189
       if [ $UsedLhaPdf = "lhasta" ]
 
190
       then
 
191
         LIBSLHA="$LIBSLHA""$LHALIBPATH""/lib/libLHAPDF.a"
 
192
       else
 
193
         LIBSMAKE="$LIBSMAKE"" -lLHAPDF -lstdc++"
 
194
         LIBSMAKEP="$LIBSMAKEP"" -L$LHALIBPATH""/lib/"
 
195
         if [ "$LD_LIBRARY_PATH" = "" ]
 
196
         then
 
197
           LD_LIBRARY_PATH="$LHALIBPATH""/lib/"
 
198
         else
 
199
           LD_LIBRARY_PATH="$LHALIBPATH""/lib/:""$LD_LIBRARY_PATH"
 
200
         fi
 
201
       fi
 
202
     else
 
203
       echo "fatal error in compile"; exit 1
 
204
     fi ;;
 
205
*) echo "do not know what to do in function compile" ; exit 1 ;;
 
206
esac
 
207
export LD_LIBRARY_PATH
 
208
if [ $1 = "NLO" ]
 
209
then
 
210
  getSTRmake
 
211
  EXEC_NAME=$stringmake$EXEC_NAMEF
 
212
elif [ $1 = "MC" ]
 
213
then
 
214
  EXEC_NAME="$EXEC_NAMEF"
 
215
fi
 
216
EXEC_NAMEFF="$EXEPREFIX""$EXEC_NAMEF"
 
217
rm -f $thisdir/$EXEC_NAMEFF
 
218
 
 
219
# creates a temporary directory to produce the executable, eventually moved
 
220
# back to running directory
 
221
CURRDATE=`date`
 
222
TMPDIRNAME=`echo $CURRDATE | cut -d" " -f1`
 
223
TMPDIRNAME=$TMPDIRNAME`echo $CURRDATE | cut -d" " -f2`
 
224
TMPDIRNAME=$TMPDIRNAME`echo $CURRDATE | cut -d" " -f3`
 
225
TMPDIRNAME=$TMPDIRNAME`echo $CURRDATE | cut -d" " -f4`
 
226
TMPDIRNAME=$EXEPREFIX$TMPDIRNAME
 
227
mkdir "$thisdir/$TMPDIRNAME"
 
228
(cd $thisdir/$TMPDIRNAME ;\
 
229
 $EXMAKE -f $thisdir/Makefile_MadFKS $EXTRA "$HWUTIMAKE" "$HERWGMAKE" \
 
230
 "$LIBSLHA" "$LIBSMAKE" "$LIBSMAKEP" "$INCLMAKE" \
 
231
 "$INCDIRMK" "$COMSRCMK" "$ANASRCMK" "$HWSSRCMK" \
 
232
 "$OBJDIRMK" $EXEC_NAME
 
233
 VPATH=$thisdir/:$thisdir/objects/:$HWPATH:$LHALIBPATH/lib/ ;\
 
234
 if [ "$EXEC_NAME" != "$EXEC_NAMEFF" ] 
 
235
 then
 
236
   \mv $EXEC_NAME $EXEC_NAMEFF
 
237
 fi ;\
 
238
 if [ -f $thisdir/$EXEC_NAMEFF ]
 
239
 then
 
240
   echo "Executable already present: quitting"
 
241
   exit 1
 
242
 else
 
243
   \mv $EXEC_NAMEFF $thisdir/$EXEC_NAMEFF
 
244
   chmod 744 $thisdir/$EXEC_NAMEFF
 
245
   find . -name "*".o -exec \cp -"$CPOPT" {} $thisdir/ \;
 
246
   cd $thisdir
 
247
   \rm -r $thisdir/$TMPDIRNAME
 
248
 fi)
 
249
teststatus Compilation
 
250
}
 
251
 
 
252
# foolproof utility function, to be called by the user
 
253
function compileMC {
 
254
compile MC
 
255
}
 
256
 
 
257
# wrapper for the functions which run and compile MC codes
 
258
function runMC {
 
259
compile MC
 
260
 
 
261
#put MCMODE to upper case
 
262
MCMODE=`echo $MCMODE | tr '[a-z]' '[A-Z]' `
 
263
# Check correspondence between MCMODE and what written in the event file
 
264
if [ $MCMODE != "HERWIG6" ]
 
265
then
 
266
  echo "Error! HERWIG6 Script called with MCMODE not equal to HERWIG6"
 
267
  exit 1
 
268
fi
 
269
 
 
270
 
 
271
UMASSHW=$UMASS
 
272
DMASSHW=$DMASS
 
273
SMASSHW=$SMASS
 
274
CMASSHW=$CMASS
 
275
if (( $(bc <<< "$B_MASS <  0.0") )); then BMASSHW=$BMASS; fi
 
276
if (( $(bc <<< "$B_MASS >= 0.0") )); then BMASSHW=$B_MASS; fi
 
277
GMASSHW=$GMASS
 
278
 
 
279
if [ $BEAM1 == 1 ]; then PART1="P"; elif [ $BEAM1 == -1 ]; then PART1="PBAR";
 
280
elif [ $BEAM1 == 0 ]; then PART1="E+"; elif [ $BEAM1 == 2 ]; then PART1="N";
 
281
elif [ $BEAM1 == -2 ]; then PART1="NBAR"; else echo "Unrecognized incoming beam 1";
 
282
exit 1; fi
 
283
if [ $BEAM2 == 1 ]; then PART2="P"; elif [ $BEAM2 == -1 ]; then PART2="PBAR";
 
284
elif [ $BEAM2 == 0 ]; then PART2="E-"; elif [ $BEAM2 == 2 ]; then PART2="N";
 
285
elif [ $BEAM2 == -2 ]; then PART2="NBAR"; else echo "Unrecognized incoming beam 2";
 
286
exit 1; fi
 
287
# Check the previous!
 
288
 
 
289
whichherpdf $HERPDF
 
290
if [ $pdftype = 1 ]
 
291
then
 
292
  whichpdflib $PDFLIBRARY
 
293
  if [ $UsedPdfLib = "THISLIB" ]
 
294
  then
 
295
    dothelinks
 
296
  elif [ $UsedPdfLib = "LHAPDF" ]
 
297
  then
 
298
    linklhapdf
 
299
  fi
 
300
fi
 
301
echo " "
 
302
echo "*****   All parameters read from event file $EVT_NAMEF"
 
303
echo "*****   Now ready for showering" $NEVENTS "events with $MC_TYPE "
 
304
echo " "
 
305
runMCMadFKS
 
306
teststatus runMC
 
307
}
 
308
 
 
309
# compiles and runs the MC
 
310
function runMCMadFKS {
 
311
ifile="$FPREFIX"MCinput
 
312
if [ -f ./$ifile ]
 
313
then
 
314
\rm ./$ifile 
 
315
fi
 
316
 
 
317
cat <<EOF > ./$ifile 
 
318
 '$SCRTCH$EVPREFIX'               ! event file
 
319
  $NEVENTS                        ! number of events
 
320
  $pdftype                        ! 0->Herwig PDFs, 1 otherwise
 
321
 '$PART1'  '$PART2'               ! hadron types
 
322
  $beammom1 $beammom2               ! beam momenta
 
323
  $LHSOFT                         ! Underlying event on (.TRUE.) or off (.FALSE.)
 
324
  $MODBOS_1 $MODBOS_2             ! Gauge boson decay modes
 
325
EOF
 
326
if [ $pdftype = 1 ]
 
327
then
 
328
cat <<EOF >> ./$ifile
 
329
 '$PDFGROUP'                      ! PDF group (1)
 
330
  $PDFSET                         ! PDF id number (1)
 
331
 '$PDFGROUP'                      ! PDF group (2)
 
332
  $PDFSET                         ! PDF id number (2)
 
333
EOF
 
334
fi
 
335
cat <<EOF >> ./$ifile
 
336
  $LAMBDAHERW                     ! Lambda_5, < 0 for default
 
337
  $ZMASS $ZWIDTH                  ! M_Z, Gamma_Z
 
338
  $WMASS $WWIDTH                  ! M_W, Gamma_W
 
339
  $TMASS $TWIDTH                  ! M_top, Gamma_top
 
340
  $HGGMASS $HGGWIDTH              ! M_H, Ga_H
 
341
  $UMASSHW $DMASSHW $SMASSHW $CMASSHW $BMASSHW $GMASSHW ! quark and gluon masses
 
342
  $MAXPR_HW                       ! Number of events to be printed out
 
343
  $ERR_FR_HW                      ! Tolerated fraction of errors
 
344
  $B_STABLE_HW                    ! .TRUE. if it is single-top production
 
345
  $IS_BB_HW                       ! .TRUE. if it is b-bbar production
 
346
  $RNDEVSEED1_HW $RNDEVSEED2_HW   ! First and second random seeds (0 0 for default)
 
347
  $PI_STABLE_HW                   ! .TRUE. if one wants Pi0 stable
 
348
  $WP_STABLE_HW                   ! .TRUE. if one wants W+ stable
 
349
  $WM_STABLE_HW                   ! .TRUE. if one wants W- stable
 
350
  $Z_STABLE_HW                    ! .TRUE. if one wants Z0 stable
 
351
  $TAUP_STABLE_HW                 ! .TRUE. if one wants tau+ stable
 
352
  $TAUM_STABLE_HW                 ! .TRUE. if one wants tau- stable
 
353
  $MUP_STABLE_HW                  ! .TRUE. if one wants mu+ stable
 
354
  $MUM_STABLE_HW                  ! .TRUE. if one wants mu- stable
 
355
  $H_STABLE_HW                    ! .TRUE. if one wants Higgs stable
 
356
EOF
 
357
 
 
358
arr=()
 
359
numDM=0
 
360
iDM=0
 
361
for i in {1..99}
 
362
do
 
363
 eval arr_elem='$'DM_$i
 
364
 if [ "$arr_elem" != "" ]
 
365
 then
 
366
  arr=("${arr[@]}" "$arr_elem")
 
367
 fi
 
368
done
 
369
 
 
370
numDM=${#arr[@]}
 
371
cat <<EOF >> ./$ifile
 
372
  $numDM                          ! Number of decay modes set by user
 
373
EOF
 
374
for DM in "${arr[@]}"
 
375
do
 
376
 let "iDM+=1"
 
377
 DM=( $DM )
 
378
 num_of_part=$(echo ${#DM[@]})
 
379
 let "num_of_part-=6"
 
380
cat <<EOF >> ./$ifile
 
381
  $num_of_part                    ! Number of bodies for new decay mode $iDM of $numDM
 
382
  ${DM[@]}                        ! Decay mode $iDM of $numDM
 
383
EOF
 
384
done
 
385
 
 
386
cat <<EOF >> ./$ifile
 
387
  $EVENT_NORM     ! Event weights are normalized to sun or average to the cross section
 
388
EOF
 
389
 
 
390
mv $EXEC_NAMEFF MCATNLO_$MCMODE'_EXE'
 
391
mv $ifile MCATNLO_$MCMODE'_input'
 
392
}
 
393
 
 
394
# this function set the parameter pdftype according to the value 
 
395
# of HERPDF (the entry of this function) given in input
 
396
function whichherpdf {
 
397
case $1 in
 
398
DEFAULT|default) pdftype=0 ;;
 
399
EXTPDF|extpdf) pdftype=1 ;;
 
400
*) echo "error in whichherpdf: no such option" ; exit 1 ;;
 
401
esac
 
402
}
 
403
 
 
404
# checks that the value given to PDFLIBRAY in input is meaningful
 
405
function whichpdflib {
 
406
case $1 in
 
407
THISLIB|thislib) UsedPdfLib=THISLIB ;;
 
408
PDFLIB|pdflib) UsedPdfLib=PDFLIB ;;
 
409
LHAPDF|lhapdf) UsedPdfLib=LHAPDF ;;
 
410
*) echo "no such library for PDFS; failure in whichpdflib" ; exit 1 ;;
 
411
esac
 
412
}
 
413
 
 
414
# checks that the value given to LHALINK in input is meaningful
 
415
function whichlhapdf {
 
416
case $1 in
 
417
STATIC|static) UsedLhaPdf=lhasta ;;
 
418
DYNAMIC|dynamic) UsedLhaPdf=lhadyn ;;
 
419
*) echo "no such option for LHAPDF; failure in whichlhapdf" ; exit 1 ;;
 
420
esac
 
421
}
 
422
 
 
423
# prepends -l to library names
 
424
function nameextralib {
 
425
ExtraLibs="$1"
 
426
ilen1=${#ExtraLibs}
 
427
if [ $ilen1 -ne 0 ]
 
428
then
 
429
  ExtraLibs=`echo $ExtraLibs | sed "s/ / -l/g"`
 
430
  ExtraLibs="-l""$ExtraLibs"
 
431
fi
 
432
}
 
433
 
 
434
# prepends -L to library paths
 
435
function pathextralib {
 
436
ExtraPaths="$1"
 
437
ilen2=${#ExtraPaths}
 
438
if [ $ilen2 -ne 0 ]
 
439
then
 
440
  ExtraPaths=`echo $ExtraPaths | sed "s/ / -L/g"`
 
441
  ExtraPaths="-L""$ExtraPaths"
 
442
fi
 
443
}
 
444
 
 
445
# separate library names with columns
 
446
function pathextralibdyn {
 
447
ExtraPathsDyn="$1"
 
448
ilen3=${#ExtraPathsDyn}
 
449
if [ $ilen3 -ne 0 ]
 
450
then
 
451
  ExtraPathsDyn=`echo $ExtraPathsDyn | sed "s/ /:/g"`
 
452
fi
 
453
}
 
454
 
 
455
# prepends -I to include paths
 
456
function pathextraincl {
 
457
ExtraIncl="$1"
 
458
ilen4=${#ExtraIncl}
 
459
if [ $ilen4 -ne 0 ]
 
460
then
 
461
  ExtraIncl=`echo $ExtraIncl | sed "s/ / -I/g"`
 
462
  ExtraIncl="-I""$ExtraIncl"
 
463
fi
 
464
}