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 {
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' ;;
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
32
echo $* did not succeed, exit status=$rc
37
# returns a string which identifies the target
43
# utility function for dothelinks
44
function stripextension {
45
echo $1 | sed "s/\..*\$//"
48
# utility function for dothelinks
50
echo $1 | sed "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/"
53
# creates logical links for the PDF grid files. By P. Nason
57
for i in ${PDFPATH}/*.dat ${PDFPATH}/*.tbl
62
name=`stripextension $name`
65
*mrs*|grpol|grvdm|lac1|pion[1-3]) name=`capitalize $name`;;
67
if [ ! -L $thisdir/$name ] || [ ! $thisdir/$name -ef $i ]
69
ln -sf $i $thisdir/$name
73
for i in ${PDFPATH}/a02.*
78
if [ ! -L $thisdir/$name ] || [ ! $thisdir/$name -ef $i ]
80
ln -sf $i $thisdir/$name
87
# creates logical links for LHAPDF, and replaced PDF group name (unused
88
# by LHAPDF) with a LHAPDF-specific string
91
FREEZE|freeze) PDFGROUP=LHAPDF ;;
92
EXTRAPOLATE|extrapolate) PDFGROUP=LHAEXT ;;
93
*) echo "no such option; failure in linklhapdf" ; exit 1 ;;
95
source ../Source/fj_lhapdf_opts
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
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 ]
113
echo "Event file" $EVTDIR/$EVT_NAMEF "not found: quitting"
118
if [ "$PDFCODE" -ne 0 ]
123
cp -f $LHAPDFPATH"/lib/libLHAPDF.a" `pwd`"/lib"
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
131
elif [ "$PDFCODE" -eq 0 ]
136
# the following is dummy
140
echo 'Invalid PDFCODE' $PDFCODE
144
whichpdflib $PDFLIBRARY
146
nameextralib "$EXTRALIBS"
147
pathextralib "$EXTRAPATHS"
148
pathextralibdyn "$EXTRAPATHS"
149
pathextraincl "$INCLUDEPATHS"
153
read -a HWUTIA <<< "$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"
168
if [ "$LD_LIBRARY_PATH" = "" ]
170
LD_LIBRARY_PATH="$ExtraPathsDyn"
172
if [ "$ExtraPathsDyn" != "" ]
174
LD_LIBRARY_PATH="$ExtraPathsDyn"":""$LD_LIBRARY_PATH"
179
NLO) echo "NLO must be computed with MadFKS"; exit 1 ;;
180
MC) if [ $UsedPdfLib = "PDFLIB" ]
182
EXEC_NAMEF="HW_EXE_PDFLIB"
183
elif [ $UsedPdfLib = "THISLIB" ]
185
EXEC_NAMEF="HW_EXE_DEFAULT"
186
elif [ $UsedPdfLib = "LHAPDF" ]
188
EXEC_NAMEF="HW_EXE_LHAPDF"
189
if [ $UsedLhaPdf = "lhasta" ]
191
LIBSLHA="$LIBSLHA""$LHALIBPATH""/lib/libLHAPDF.a"
193
LIBSMAKE="$LIBSMAKE"" -lLHAPDF -lstdc++"
194
LIBSMAKEP="$LIBSMAKEP"" -L$LHALIBPATH""/lib/"
195
if [ "$LD_LIBRARY_PATH" = "" ]
197
LD_LIBRARY_PATH="$LHALIBPATH""/lib/"
199
LD_LIBRARY_PATH="$LHALIBPATH""/lib/:""$LD_LIBRARY_PATH"
203
echo "fatal error in compile"; exit 1
205
*) echo "do not know what to do in function compile" ; exit 1 ;;
207
export LD_LIBRARY_PATH
211
EXEC_NAME=$stringmake$EXEC_NAMEF
214
EXEC_NAME="$EXEC_NAMEF"
216
EXEC_NAMEFF="$EXEPREFIX""$EXEC_NAMEF"
217
rm -f $thisdir/$EXEC_NAMEFF
219
# creates a temporary directory to produce the executable, eventually moved
220
# back to running directory
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" ]
236
\mv $EXEC_NAME $EXEC_NAMEFF
238
if [ -f $thisdir/$EXEC_NAMEFF ]
240
echo "Executable already present: quitting"
243
\mv $EXEC_NAMEFF $thisdir/$EXEC_NAMEFF
244
chmod 744 $thisdir/$EXEC_NAMEFF
245
find . -name "*".o -exec \cp -"$CPOPT" {} $thisdir/ \;
247
\rm -r $thisdir/$TMPDIRNAME
249
teststatus Compilation
252
# foolproof utility function, to be called by the user
257
# wrapper for the functions which run and compile MC codes
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" ]
266
echo "Error! HERWIG6 Script called with MCMODE not equal to HERWIG6"
275
if (( $(bc <<< "$B_MASS < 0.0") )); then BMASSHW=$BMASS; fi
276
if (( $(bc <<< "$B_MASS >= 0.0") )); then BMASSHW=$B_MASS; fi
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";
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";
287
# Check the previous!
292
whichpdflib $PDFLIBRARY
293
if [ $UsedPdfLib = "THISLIB" ]
296
elif [ $UsedPdfLib = "LHAPDF" ]
302
echo "***** All parameters read from event file $EVT_NAMEF"
303
echo "***** Now ready for showering" $NEVENTS "events with $MC_TYPE "
309
# compiles and runs the MC
310
function runMCMadFKS {
311
ifile="$FPREFIX"MCinput
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
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)
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
363
eval arr_elem='$'DM_$i
364
if [ "$arr_elem" != "" ]
366
arr=("${arr[@]}" "$arr_elem")
371
cat <<EOF >> ./$ifile
372
$numDM ! Number of decay modes set by user
374
for DM in "${arr[@]}"
378
num_of_part=$(echo ${#DM[@]})
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
386
cat <<EOF >> ./$ifile
387
$EVENT_NORM ! Event weights are normalized to sun or average to the cross section
390
mv $EXEC_NAMEFF MCATNLO_$MCMODE'_EXE'
391
mv $ifile MCATNLO_$MCMODE'_input'
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 {
398
DEFAULT|default) pdftype=0 ;;
399
EXTPDF|extpdf) pdftype=1 ;;
400
*) echo "error in whichherpdf: no such option" ; exit 1 ;;
404
# checks that the value given to PDFLIBRAY in input is meaningful
405
function whichpdflib {
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 ;;
414
# checks that the value given to LHALINK in input is meaningful
415
function whichlhapdf {
417
STATIC|static) UsedLhaPdf=lhasta ;;
418
DYNAMIC|dynamic) UsedLhaPdf=lhadyn ;;
419
*) echo "no such option for LHAPDF; failure in whichlhapdf" ; exit 1 ;;
423
# prepends -l to library names
424
function nameextralib {
429
ExtraLibs=`echo $ExtraLibs | sed "s/ / -l/g"`
430
ExtraLibs="-l""$ExtraLibs"
434
# prepends -L to library paths
435
function pathextralib {
440
ExtraPaths=`echo $ExtraPaths | sed "s/ / -L/g"`
441
ExtraPaths="-L""$ExtraPaths"
445
# separate library names with columns
446
function pathextralibdyn {
448
ilen3=${#ExtraPathsDyn}
451
ExtraPathsDyn=`echo $ExtraPathsDyn | sed "s/ /:/g"`
455
# prepends -I to include paths
456
function pathextraincl {
461
ExtraIncl=`echo $ExtraIncl | sed "s/ / -I/g"`
462
ExtraIncl="-I""$ExtraIncl"