~maddevelopers/mg5amcnlo/3.0.2-alpha0

« back to all changes in this revision

Viewing changes to Template/bin/run_pythia

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 pythia on the unweighted_events.dat
 
4
#
 
5
#  Usage: run_pythia [pydir [para/serial [run_name]]]
 
6
#  where pydir is the path to the pythia executable
 
7
 
 
8
if [ "$1" != "" ]
 
9
then
 
10
  pydir=$1
 
11
else
 
12
  pydir=../../pythia-pgs/src
 
13
fi
 
14
 
 
15
p=$2
 
16
run=$3
 
17
main=`pwd`
 
18
 
 
19
if [ "$4" != "" ]
 
20
then
 
21
  ERAdir=$4
 
22
else
 
23
  ERAdir=../../ExRootAnalysis
 
24
fi
 
25
 
 
26
if [ ! -e ../Cards/pythia_card.dat ]; then
 
27
  echo "No pythia_card.dat found. Quitting..."
 
28
  exit
 
29
fi
 
30
 
 
31
echo $$ >> ../myprocid
 
32
 
 
33
if [ "$run" != "" ]; then
 
34
  if [ ! -e ${run}_unweighted_events.lhe.gz ]; then
 
35
    echo "No file  ${run}_unweighted_events.lhe.gz. Quitting..."
 
36
    exit
 
37
  fi
 
38
  echo gunzip ${run}_unweighted_events.lhe.gz
 
39
  gunzip -c ${run}_unweighted_events.lhe.gz > unweighted_events.lhe
 
40
  echo Running Pythia
 
41
fi
 
42
 
 
43
# shower and hadronize event through Pythia
 
44
 
 
45
echo " " >> ../Cards/pythia_card.dat
 
46
echo "      LHAPATH=$pydir/PDFsets" >> ../Cards/pythia_card.dat
 
47
export PDG_MASS_TBL=$pydir/mass_width_2004.mc
 
48
rm -f pythia.log > /dev/null
 
49
rm -f pythia.err > /dev/null
 
50
rm -f pythia.out > /dev/null
 
51
 
 
52
if [ "$p" = "1" ]; 
 
53
then 
 
54
echo '#!/bin/bash' > pythia.pbs
 
55
echo "export PDG_MASS_TBL=$pydir/mass_width_2004.mc;cd $main;$pydir/pythia;touch pythia.out" >> pythia.pbs
 
56
chmod u+x pythia.pbs
 
57
qsub -N pythia_run -e pythia.err -o pythia.log -V -q madgraph pythia.pbs >> ../running_jobs
 
58
while [ ! -e pythia.out ]
 
59
do
 
60
  sleep 5
 
61
done
 
62
rm -f pythia.pbs
 
63
else
 
64
$pydir/pythia >& pythia.log
 
65
fi
 
66
 
 
67
if [[ -e pythia.err ]];then
 
68
  cat pythia.err
 
69
fi
 
70
 
 
71
if [ "$run" != "" ]; then
 
72
  if [ -e pythia_events.hep ]; then
 
73
    if [ -x $pydir/hep2lhe ]; then
 
74
      echo "Creating Pythia LHE File" > ../status
 
75
      echo "Creating Pythia LHE File"
 
76
      ../bin/gen_crossxhtml-pl $run
 
77
      ../bin/run_hep2lhe $pydir $p  
 
78
    fi
 
79
    if [[ -x $ERAdir/ExRootLHEFConverter && -e pythia_events.lhe ]]; then
 
80
      echo "Creating Pythia LHE Root File" > ../status
 
81
      echo "Creating Pythia LHE Root File"
 
82
      ../bin/gen_crossxhtml-pl $run
 
83
      $ERAdir/ExRootLHEFConverter pythia_events.lhe ${run}_pythia_lhe_events.root
 
84
    fi
 
85
    echo Storing files
 
86
    echo Storing Pythia files > ../status
 
87
    ../bin/gen_crossxhtml-pl $run
 
88
    mv -f pythia_events.hep ${run}_pythia_events.hep
 
89
    gzip -f ${run}_pythia_events.hep
 
90
    mv -f pythia.log ${run}_pythia.log
 
91
# pythia_card.dat
 
92
   if [ -e ../Cards/pythia_card.dat ] ; then 
 
93
      echo "<MGPythiaCard>" >>${run}_banner.txt
 
94
      cat ../Cards/pythia_card.dat   >> ${run}_banner.txt
 
95
      echo "</MGPythiaCard>" >>${run}_banner.txt
 
96
   fi
 
97
  fi
 
98
  if [ -e events.tree ]; then
 
99
    mv -f events.tree ${run}_events.tree
 
100
    gzip -f ${run}_events.tree
 
101
    mv -f xsecs.tree ${run}_xsecs.tree
 
102
    mv -f beforeveto.tree ${run}_beforeveto.tree
 
103
    gzip -f ${run}_beforeveto.tree
 
104
  fi
 
105
  if [ -e pythia_events.lhe ]; then
 
106
    echo \<LesHouchesEvents version=\"1.0\"\> > temp.lhe
 
107
    echo \<\!-- >> temp.lhe
 
108
    cat ${run}_banner.txt >> temp.lhe
 
109
    sed /'<LesHouchesEvents version=\"1.0\">'/s//'-->'/ pythia_events.lhe >> temp.lhe
 
110
    rm -f pythia_events.lhe
 
111
    mv -f temp.lhe ${run}_pythia_events.lhe
 
112
    gzip -f ${run}_pythia_events.lhe
 
113
  fi
 
114
  rm -f unweighted_events.lhe  
 
115
fi