1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
#!/bin/bash
#set -o verbose
EXPECTED_ARGS=6
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` repository name process card Nevents RandomSeed "
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"
echo "Example: ./create_lhe_powheg.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 1000 1212"
exit 1
fi
echo " ______________________________________ "
echo " Running Powheg "
echo " ______________________________________ "
repo=${1}
echo "%MSG-POWHEG repository = $repo"
name=${2}
echo "%%MSG-POWHEG name = $name"
process=${3}
echo "%MSG-POWHEG process = $process"
cardinput=${4}
echo "%MSG-POWHEG location of the card = $cardinput"
nevt=${5}
echo "%MSG-POWHEG number of events requested = $nevt"
rnum=${6}
echo "%MSG-POWHEG random seed used for the run = $rnum"
ncpu=${7}
echo "%MSG-POWHEG thread count requested = $ncpu (ignored)"
seed=$rnum
file="events"
# Release to be used to define the environment and the compiler needed
export PRODHOME=`pwd`
export RELEASE=${CMSSW_VERSION}
export WORKDIR=`pwd`
# Get the input card
wget --no-check-certificate http://cms-project-generators.web.cern.ch/cms-project-generators/${cardinput} -O powheg.input
card="$WORKDIR/powheg.input"
# initialize the CMS environment
scram project -n ${name} CMSSW ${RELEASE} ; cd ${name} ; mkdir -p work ; cd work
eval `scram runtime -sh`
# force the f77 compiler to be the CMS defined one
#ln -s `which gfortran` f77
#ln -s `which gfortran` g77
export PATH=`pwd`:${PATH}
# FastJet and LHAPDF
#fastjet-config comes with the paths used at build time.
#we need this to replace with the correct paths obtained from scram tool info fastjet
newinstallationdir=`scram tool info fastjet | grep FASTJET_BASE |cut -d "=" -f2`
cp ${newinstallationdir}/bin/fastjet-config ./fastjet-config.orig
oldinstallationdir=`cat fastjet-config.orig | grep installationdir | head -n 1 | cut -d"=" -f2`
sed -e "s#${oldinstallationdir}#${newinstallationdir}#g" fastjet-config.orig > fastjet-config
chmod +x fastjet-config
#same for lhapdf
newinstallationdirlha=`scram tool info lhapdf | grep LHAPDF_BASE |cut -d "=" -f2`
cp ${newinstallationdirlha}/bin/lhapdf-config ./lhapdf-config.orig
oldinstallationdirlha=`cat lhapdf-config.orig | grep prefix | head -n 1 | cut -d"=" -f2`
sed -e "s#prefix=${oldinstallationdirlha}#prefix=${newinstallationdirlha}#g" lhapdf-config.orig > lhapdf-config
chmod +x lhapdf-config
#svn checkout --username anonymous --password anonymous svn://powhegbox.mib.infn.it/trunk/POWHEG-BOX
# # retrieve the wanted POWHEG-BOX from the official repository
wget --no-check-certificate http://cms-project-generators.web.cern.ch/cms-project-generators/${repo}/${name}.tar.gz -O ${name}.tar.gz
tar xzf ${name}.tar.gz
#remove from Powheg the LENOCC function which is already defined in LHAPDF library
patch POWHEG-BOX/cernroutines.f <<EOF
*** POWHEG-BOX/cernroutines_orig.f Wed Mar 14 11:48:14 2012
--- POWHEG-BOX/cernroutines.f Wed Mar 14 11:48:29 2012
***************
*** 790,815 ****
! c# 10 "lenocc.F" 2
! FUNCTION LENOCC (CHV)
! C
! C CERN PROGLIB# M507 LENOCC .VERSION KERNFOR 4.21 890323
! C ORIG. March 85, A.Petrilli, re-write 21/02/89, JZ
! C
! C- Find last non-blank character in CHV
!
! CHARACTER CHV*(*)
!
! N = LEN(CHV)
!
! DO 17 JJ= N,1,-1
! IF (CHV(JJ:JJ).NE.' ') GO TO 99
! 17 CONTINUE
! JJ = 0
!
! 99 LENOCC = JJ
! RETURN
! END
c# 1 "mtlset.F"
c# 1 "<built-in>"
c# 1 "<command line>"
--- 790,815 ----
! ccccccc# 10 "lenocc.F" 2
! cccccc FUNCTION LENOCC (CHV)
! ccccccC
! ccccccC CERN PROGLIB# M507 LENOCC .VERSION KERNFOR 4.21 890323
! ccccccC ORIG. March 85, A.Petrilli, re-write 21/02/89, JZ
! ccccccC
! ccccccC- Find last non-blank character in CHV
! cccccc
! cccccc CHARACTER CHV*(*)
! cccccc
! cccccc N = LEN(CHV)
! cccccc
! cccccc DO 17 JJ= N,1,-1
! cccccc IF (CHV(JJ:JJ).NE.' ') GO TO 99
! cccccc 17 CONTINUE
! cccccc JJ = 0
! cccccc
! cccccc 99 LENOCC = JJ
! cccccc RETURN
! cccccc END
c# 1 "mtlset.F"
c# 1 "<built-in>"
c# 1 "<command line>"
EOF
cd POWHEG-BOX/${process}
mv Makefile Makefile.orig
cat Makefile.orig | sed -e "s#STATIC[ \t]*=[ \t]*-static#STATIC=-dynamic#g" | sed -e "s#PDF[ \t]*=[ \t]*native#PDF=lhapdf#g"> Makefile
echo "LIBS+=-lz -lstdc++" >> Makefile
LHA_BASE="`readlink -f "$LHAPATH/../../../"`"
#slc5_amd64_gcc462/external/lhapdf/5.8.5 has a bug. if this version is used, replace it by 5.8.5-cms:
if [ `basename $LHA_BASE` == "5.8.5" ]
then
LHA_BASE="`echo "$LHA_BASE" | sed 's@slc5_amd64_gcc462/external/lhapdf/5.8.5@slc5_amd64_gcc462/external/lhapdf/5.8.5-cms@'`"
fi
LHA_BASE_OLD="`$LHA_BASE/bin/lhapdf-config --prefix`"
cat > lhapdf-config-wrap <<EOF
#!/bin/bash
"$LHA_BASE/bin/lhapdf-config" "\$@" | sed "s|$LHA_BASE_OLD|$LHA_BASE|g"
EOF
chmod a+x lhapdf-config-wrap
make LHAPDF_CONFIG="`pwd`/lhapdf-config-wrap" pwhg_main
mkdir workdir
cd workdir
cat ${card} | sed -e "s#SEED#${seed}#g" | sed -e "s#NEVENTS#${nevt}#g" > powheg.input
cat powheg.input
../pwhg_main &> log_${process}_${seed}.txt
#remove the spurious random seed output that is non LHE standard
cat pwgevents.lhe | grep -v "Random number generator exit values" > ${file}_final.lhe
ls -l ${file}_final.lhe
pwd
cp ${file}_final.lhe ${WORKDIR}/.
#cp ${file}_final.lhe ${WORKDIR}/${file}_final.lhe
#cp ${file}_final.lhe ${WORKDIR}/output.lhe
echo "Output ready with log_${process}_${seed}.txt and ${file}_final.lhe at `pwd` and $WORKDIR"
echo "End of job on " `date`
exit 0;
|