~maddevelopers/mg5amcnlo/3.0.2-alpha0

« back to all changes in this revision

Viewing changes to Template/bin/gridrun

Added Template and HELAS into bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
#  This runs survey,refine,unweight_events, one after the other
 
4
#  
 
5
#   First we need to get into the main directory
 
6
#
 
7
#
 
8
#  Usage: grid_run
 
9
#
 
10
 
 
11
if [[  ! -d ./bin  ]]; then
 
12
    cd ../
 
13
    if [[ ! -d ./bin ]]; then
 
14
        echo "Error: it must be executed from the main, or bin directory"
 
15
        exit
 
16
    fi
 
17
fi
 
18
#
 
19
#  Now let shell know where to find important executables
 
20
#
 
21
main=`pwd`
 
22
dirbin=$main/bin
 
23
pydir=$main/../pythia-pgs/src
 
24
pgsdir=$pydir
 
25
ERAdir=$main/../ExRootAnalysis
 
26
MAdir=$main/../MadAnalysis
 
27
webbin=$dirbin
 
28
td=$main/../td
 
29
web=0
 
30
 
 
31
echo $$ >> myprocid
 
32
 
 
33
#if ( "$1" == "" ) then
 
34
#    echo 'Number of unweighted events. This is ingnored and read from run_card.dat ' 
 
35
#    set a  = $< 
 
36
#else
 
37
#    set a = $1
 
38
#endif
 
39
 
 
40
#if [[  "$1" == ""  ]]; then
 
41
#    echo 'Enter 1 for parallel 0 for serial run' 
 
42
#     read p 
 
43
#else
 
44
#     p=$1
 
45
#fi
 
46
p=0
 
47
n=MadEvent
 
48
#if [[  $p -gt 0 ]]; then
 
49
#   if [[  "$2" == ""  ]]; then
 
50
#    echo 'Enter name for jobs on pbs queue'
 
51
#       read n
 
52
#   else
 
53
#       n=$2
 
54
#   fi
 
55
#   if [[  "$3" == ""  ]]; then
 
56
#       echo 'Enter run name'
 
57
#       read t
 
58
#   else
 
59
#       t=$3
 
60
#   fi
 
61
#else
 
62
#   if [[  "$2" == ""  ]]; then
 
63
#      echo 'Enter run name'
 
64
#      read t
 
65
       t=GridRun
 
66
#   else
 
67
#      t=$2
 
68
#   fi
 
69
#fi
 
70
#set t = TeV2
 
71
if [[  "$4" -ne ""  ]]; then
 
72
    web=1
 
73
    webbin="$MADGRAPH_BASE/MG_ME/WebBin"
 
74
    pydir="$webbin/pythia-pgs"
 
75
    pgsdir=$pydir
 
76
    ERAdir="$MADGRAPH_BASE/MG_ME/ExRootAnalysis"
 
77
    MAdir="$MADGRAPH_BASE/MG_ME/MadAnalysis"
 
78
    td="$MADGRAPH_BASE/MG_ME/td"
 
79
    touch Online
 
80
fi
 
81
date
 
82
a=`awk '/^[^#].*=.*gevents/{print $1}' Cards/grid_card.dat`
 
83
echo Generating $a events
 
84
 
 
85
echo 'restoring default data...'
 
86
$dirbin/restore_data default
 
87
echo '...default data restored.'
 
88
#
 
89
#  Check if run already exists. If so, store run w/ new name
 
90
#  and remove old run before starting.
 
91
#
 
92
 
 
93
if [[  -e status  ]]; then
 
94
  rm status
 
95
fi
 
96
if [[  -e error  ]]; then
 
97
  rm error
 
98
fi
 
99
touch RunWeb
 
100
#echo "Cleaning directories" > status
 
101
#$dirbin/gen_crossxhtml-pl $t
 
102
#$dirbin/clean
 
103
touch survey
 
104
#echo "Starting jobs" > status
 
105
#$dirbin/gen_crossxhtml-pl $t
 
106
#$dirbin/survey $p $n $t
 
107
if [[  -e error  ]]; then
 
108
  cat error
 
109
  date
 
110
  cp -f error status
 
111
  rm survey
 
112
  rm RunWeb
 
113
  $dirbin/gen_crossxhtml-pl $t
 
114
  $dirbin/gen_cardhtml-pl
 
115
  exit
 
116
fi
 
117
mv survey refine
 
118
#
 
119
#  Changes for gen_grid_job don't need refine
 
120
#
 
121
$dirbin/refine4grid $a $p $n 1 $t
 
122
mv refine refine2
 
123
rm -f refine2
 
124
#
 
125
#  Now collect the events
 
126
#
 
127
echo "Combining Events" >& status
 
128
echo "Combining Events" 
 
129
$dirbin/gen_crossxhtml-pl $t
 
130
pushd ./Source > /dev/null
 
131
# make ../bin/combine_events
 
132
popd > /dev/null
 
133
pushd SubProcesses > /dev/null
 
134
$dirbin/run_combine $p
 
135
mv events.lhe ../Events/
 
136
mv unweighted_events.lhe ../Events/
 
137
popd > /dev/null
 
138
#
 
139
#  do the banner
 
140
#
 
141
cd ./Events
 
142
echo "putting the banner"
 
143
$dirbin/put_banner events.lhe
 
144
$dirbin/put_banner unweighted_events.lhe
 
145
 
 
146
#
 
147
#  Create root file
 
148
#
 
149
 
 
150
 
 
151
if [[ (-x $ERAdir/ExRootLHEFConverter) && (-e unweighted_events.lhe) ]]; then
 
152
    echo "Creating Root File" >& ../status
 
153
    $dirbin/gen_crossxhtml-pl $t
 
154
    $ERAdir/ExRootLHEFConverter unweighted_events.lhe unweighted_events.root
 
155
fi
 
156
 
 
157
#if ((-x $ERAdir/ExRootMain) && (-e unweighted_events.root) && (-e ../Cards/plot_card.dat)) then
 
158
#    echo "Creating Root Plots" >& ../status
 
159
#    $dirbin/gen_crossxhtml-pl $t
 
160
#    mkdir $t
 
161
#    cd $t
 
162
#    echo "../unweighted_events.root" > events.list
 
163
#    $dirbin/plot $ERAdir > plot.log
 
164
#    cd ..
 
165
#    $dirbin/plot_page-pl $t
 
166
#endif
 
167
if [[ (-x $MAdir/plot_events) && (-e unweighted_events.lhe) && (-e ../Cards/plot_card.dat) ]]; then
 
168
    echo "Creating Plots" >& ../status
 
169
    $dirbin/gen_crossxhtml-pl $t
 
170
    mkdir $t
 
171
    cd $t
 
172
    echo "../unweighted_events.lhe" > events.list
 
173
    $dirbin/plot $MAdir $td > plot.log
 
174
    cd ..
 
175
    $dirbin/plot_page-pl $t
 
176
fi
 
177
 
 
178
exit
 
179
#
 
180
#  Below is for Pythia runs...
 
181
#
 
182
$dirbin/store $t
 
183
$dirbin/gen_crossxhtml-pl $t
 
184
 
 
185
#
 
186
#  Run Pythia and PGS on events
 
187
#
 
188
 
 
189
# Compile pythia if not there
 
190
if [[ !(-x $pydir/pythia) && (-d $pydir) && (-e ../Cards/pythia_card.dat) ]]; then
 
191
    pushd $pydir > /dev/null
 
192
    echo "No pythia executable - running make"
 
193
    make
 
194
    popd > /dev/null
 
195
fi
 
196
 
 
197
if [[ (-x $pydir/pythia) && (-e ../Cards/pythia_card.dat) ]]; then
 
198
    gunzip -c ${t}_unweighted_events.lhe.gz > unweighted_events.lhe
 
199
    echo "Running Pythia" >& ../status
 
200
    $dirbin/gen_crossxhtml-pl $t
 
201
# shower and hadronize event through Pythia
 
202
    echo "Running pythia..."
 
203
#    qsub -v pydir=$pydir $dirbin/run_pythia >> ../running_jobs
 
204
    $dirbin/run_pythia $pydir $p  
 
205
fi
 
206
 
 
207
if [[ (-x $pydir/hep2lhe) && (-e ../Cards/pythia_card.dat) && (-e pythia_events.hep) ]]; then
 
208
    echo "Creating Pythia LHE File" >& ../status
 
209
    $dirbin/gen_crossxhtml-pl $t
 
210
    $dirbin/run_hep2lhe $pydir $p  
 
211
fi
 
212
 
 
213
if [[ (-x $ERAdir/ExRootLHEFConverter) && (-e pythia_events.lhe) ]]; then
 
214
    echo "Creating Pythia LHE Root File" >& ../status
 
215
    $dirbin/gen_crossxhtml-pl $t
 
216
    $ERAdir/ExRootLHEFConverter pythia_events.lhe pythia_lhe_events.root
 
217
fi
 
218
 
 
219
# Compile pgs if not there
 
220
if [[ !(-x $pgsdir/pgs) && (-d $pgsdir) && (-e ../Cards/pgs_card.dat) ]]; then
 
221
    pushd $pgsdir > /dev/null
 
222
    echo "No pgs executable - running make"
 
223
    make
 
224
    popd > /dev/null
 
225
fi
 
226
 
 
227
if [[ (-x $pgsdir/pgs) && (-e ../Cards/pgs_card.dat) ]]; then
 
228
    echo "Running PGS" >& ../status
 
229
    $dirbin/gen_crossxhtml-pl $t
 
230
    # now pass the event to a detector simulator and reconstruct objects
 
231
    echo "Running PGS..."
 
232
#    qsub -v pgsdir=$pgsdir $dirbin/run_pgs >> ../running_jobs
 
233
    $dirbin/run_pgs $pgsdir $p
 
234
fi
 
235
#
 
236
 
 
237
if [[ (-x $ERAdir/ExRootLHCOlympicsConverter) && (-e pgs_events.lhco) ]]; then
 
238
    echo "Creating PGS Root File" >& ../status
 
239
    $dirbin/gen_crossxhtml-pl $t
 
240
    $ERAdir/ExRootLHCOlympicsConverter pgs_events.lhco pgs_events.root
 
241
fi
 
242
 
 
243
cd ../
 
244
echo " " >& status
 
245
$dirbin/gen_cardhtml-pl
 
246
date