Skip to content

Commit 516303f

Browse files
jackal1-66sawenzel
authored andcommitted
Example to run HERWIG7 with o2-sim
1 parent eaeee05 commit 516303f

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- ThePEG-repository -*-
2+
################################################################################
3+
# This file contains our best tune to UE data from ATLAS at 7 TeV. More recent
4+
# tunes and tunes for other centre-of-mass energies as well as more usage
5+
# instructions can be obtained from this Herwig wiki page:
6+
# http://projects.hepforge.org/herwig/trac/wiki/MB_UE_tunes
7+
# The model for soft interactions and diffractions is explained in
8+
# [S. Gieseke, P. Kirchgaesser, F. Loshaj, arXiv:1612.04701]
9+
################################################################################
10+
11+
read snippets/PPCollider.in
12+
13+
##################################################
14+
# Technical parameters for this run
15+
##################################################
16+
cd /Herwig/Generators
17+
##################################################
18+
# LHC physics parameters (override defaults here)
19+
##################################################
20+
set EventGenerator:EventHandler:LuminosityFunction:Energy 13600.0
21+
22+
# Minimum Bias
23+
read snippets/MB.in
24+
25+
# Recommended set of parameters for MB/UE runs
26+
27+
set /Herwig/Hadronization/ColourReconnector:ReconnectionProbability 0.5
28+
set /Herwig/UnderlyingEvent/MPIHandler:pTmin0 3.502683
29+
set /Herwig/UnderlyingEvent/MPIHandler:InvRadius 1.402055
30+
set /Herwig/UnderlyingEvent/MPIHandler:Power 0.416852
31+
set /Herwig/Partons/RemnantDecayer:ladderPower -0.08
32+
set /Herwig/Partons/RemnantDecayer:ladderNorm 0.95
33+
34+
##################################################
35+
# Analyses
36+
##################################################
37+
## Hepmc file creation
38+
create ThePEG::HepMCFile /Herwig/Analysis/HepMC HepMCAnalysis.so
39+
set /Herwig/Analysis/HepMC:PrintEvent 10
40+
set /Herwig/Analysis/HepMC:Format GenEvent
41+
set /Herwig/Analysis/HepMC:Units GeV_mm
42+
set /Herwig/Analysis/HepMC:Filename herwig.hepmc
43+
insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/HepMC
44+
45+
46+
##################################################
47+
# Save run for later usage with 'Herwig run'
48+
##################################################
49+
saverun LHC EventGenerator
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!-- doxy
2+
\page refrunSimExamplesHepMC_HERWIG7 Example HepMC_HERWIG7
3+
/doxy -->
4+
5+
The usage of HERWIG7 with the O2 machinery is presented in this short manual.
6+
The example generates HEPMC3 data using the Herwig executable and then
7+
reads the data via the hepmc generator defined in o2-sim.
8+
9+
# Files description
10+
11+
Two files are provided in the folder:
12+
- **runo2sim.sh** &rarr; allows the generation of events using o2-sim
13+
- **LHC.in** &rarr; example input file for the configuration of the HERWIG generator
14+
15+
## runo2sim.sh
16+
17+
The script works after loading any O2sim version containing HERWIG7 as a package (dependence of AliGenO2).
18+
19+
If no parameters are provided, the script will run with default values (energy and nEvents provided in the LHC.in file), but few flags are available to change the settings on-the-fly:
20+
- **-m , --more** &rarr; feeds the simulation with advanced parameters provided to the configuration key flags
21+
- **-n , --nevents** &rarr; changes the number of events in the .in file or gets the one in the file if no events are provided
22+
- **-i , --input** &rarr; .in filename for HERWIG7 configuration
23+
- **-j , --jobs** &rarr; sets the number of workers (2 jobs by default)
24+
- **-e , --ecm** &rarr; sets the center-of-mass energy in the input file
25+
- **-h , --help** &rarr; prints usage instructions
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This is a simple simulation example on how to generate HEPMC3 data from
4+
# HERWIG7 and run an ALICE simulation using the o2-sim executable
5+
# In the script we assume that the .run file has the same name of the input file, so change it accordingly.
6+
# This script works only with AliGenO2 version containing the HERWIG7 generator
7+
8+
# HERWIG7 and O2 must be loaded
9+
set -x
10+
if [ ! "${HERWIG_ROOT}" ]; then
11+
echo "This needs HERWIG7 loaded; alienv enter ..."
12+
exit 1
13+
fi
14+
15+
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 2
16+
17+
NEV=-1
18+
more=""
19+
input="LHC"
20+
eCM=-1
21+
JOBS=2
22+
23+
usage()
24+
{
25+
cat <<EOF
26+
Usage: $0 [OPTIONS]
27+
28+
Options:
29+
30+
-m,--more CONFIG More configurations ($more)
31+
-n,--nevents EVENTS Number of events ($nev)
32+
-i,--input INPUT Options file fed to HERWIG7 ($input)
33+
-j,--jobs JOBS Number of jobs ($JOBS)
34+
-e,--ecm ENERGY Center-of-Mass energy
35+
-h,--help Print these instructions
36+
-- Rest of command line sent to o2-sim
37+
38+
COMMAND must be quoted if it contains spaces or other special
39+
characters
40+
41+
Below follows the help output of o2-sim
42+
43+
EOF
44+
}
45+
46+
if [ "$#" -lt 2 ]; then
47+
echo "Running with default values"
48+
fi
49+
50+
while test $# -gt 0 ; do
51+
case $1 in
52+
-m|--more) more="$2" ; shift ;;
53+
-n|--nevents) NEV=$2 ; shift ;;
54+
-i|--input) input=$2 ; shift ;;
55+
-j|--jobs) JOBS=$2 ; shift ;;
56+
-e|--ecm) eCM=$2 ; shift ;;
57+
-h|--help) usage; o2-sim --help full ; exit 0 ;;
58+
--) shift ; break ;;
59+
*) echo "Unknown option '$1', did you forget '--'?" >/dev/stderr
60+
exit 3
61+
;;
62+
esac
63+
shift
64+
done
65+
66+
echo "Input file: $input"
67+
68+
if [ ! -f $input.in ]; then
69+
echo "Error: Input file $input.in not found"
70+
exit 4
71+
else
72+
if grep -Fq "saverun" $input.in; then
73+
sed -i "/saverun/c\saverun $input EventGenerator" $input.in
74+
else
75+
echo "saverun $input EventGenerator" >> $input.in
76+
fi
77+
fi
78+
79+
# Set number of events to write in HepMC in input file
80+
if [ ! $NEV -eq -1 ]; then
81+
echo "Setting number of events to $NEV"
82+
if grep -Fq "PrintEvent" $input.in; then
83+
sed -i "/PrintEvent/c\set /Herwig/Analysis/HepMC:PrintEvent $NEV" $input.in
84+
else
85+
echo "set /Herwig/Analysis/HepMC:PrintEvent $NEV" >> $input.in
86+
fi
87+
else
88+
echo "Number of events not set, checking input file..."
89+
if grep -Fq "PrintEvent" $input.in; then
90+
NEV=$(grep -F "PrintEvent" $input.in | awk '{print $3}')
91+
echo "Number of events set to $NEV"
92+
else
93+
echo "Error: Number of events not set in HERWIG7"
94+
exit 5
95+
fi
96+
fi
97+
98+
# Set ECM
99+
100+
if [ ! $eCM -eq -1 ]; then
101+
echo "Setting eCM to $eCM"
102+
if grep -Fq "Energy" $input.in; then
103+
sed -i "/Energy/c\set EventGenerator:EventHandler:LuminosityFunction:Energy $eCM" $input.in
104+
else
105+
echo "set EventGenerator:EventHandler:LuminosityFunction:Energy $eCM" >> $input.in
106+
fi
107+
else
108+
echo "Energy not set, checking input file..."
109+
if grep -Fq "Energy" $input.in; then
110+
eCM=$(grep -F "Energy" $input.in | awk '{print $3}')
111+
echo "Energy set to $eCM"
112+
else
113+
echo "Error: eCM not set in HERWIG7"
114+
exit 6
115+
fi
116+
fi
117+
118+
# Generating events using HERWIG7
119+
Herwig read --repo=${HERWIG_ROOT}/share/Herwig/HerwigDefaults.rpo $input.in
120+
Herwig run -N $NEV $input.run
121+
122+
# Starting simulation with o2-sim
123+
o2-sim -j $JOBS -n ${NEV} -g hepmc \
124+
--configKeyValues "GeneratorFileOrCmd.fileNames=herwig.hepmc;${more}"

0 commit comments

Comments
 (0)