diff --git a/run/SimExamples/HepMC_HERWIG7/LHC.in b/run/SimExamples/HepMC_HERWIG7/LHC.in new file mode 100644 index 0000000000000..ef3641bf7b174 --- /dev/null +++ b/run/SimExamples/HepMC_HERWIG7/LHC.in @@ -0,0 +1,49 @@ +# -*- ThePEG-repository -*- +################################################################################ +# This file contains our best tune to UE data from ATLAS at 7 TeV. More recent +# tunes and tunes for other centre-of-mass energies as well as more usage +# instructions can be obtained from this Herwig wiki page: +# http://projects.hepforge.org/herwig/trac/wiki/MB_UE_tunes +# The model for soft interactions and diffractions is explained in +# [S. Gieseke, P. Kirchgaesser, F. Loshaj, arXiv:1612.04701] +################################################################################ + +read snippets/PPCollider.in + +################################################## +# Technical parameters for this run +################################################## +cd /Herwig/Generators +################################################## +# LHC physics parameters (override defaults here) +################################################## +set EventGenerator:EventHandler:LuminosityFunction:Energy 13600.0 + +# Minimum Bias +read snippets/MB.in + +# Recommended set of parameters for MB/UE runs + +set /Herwig/Hadronization/ColourReconnector:ReconnectionProbability 0.5 +set /Herwig/UnderlyingEvent/MPIHandler:pTmin0 3.502683 +set /Herwig/UnderlyingEvent/MPIHandler:InvRadius 1.402055 +set /Herwig/UnderlyingEvent/MPIHandler:Power 0.416852 +set /Herwig/Partons/RemnantDecayer:ladderPower -0.08 +set /Herwig/Partons/RemnantDecayer:ladderNorm 0.95 + +################################################## +# Analyses +################################################## +## Hepmc file creation +create ThePEG::HepMCFile /Herwig/Analysis/HepMC HepMCAnalysis.so +set /Herwig/Analysis/HepMC:PrintEvent 10 +set /Herwig/Analysis/HepMC:Format GenEvent +set /Herwig/Analysis/HepMC:Units GeV_mm +set /Herwig/Analysis/HepMC:Filename herwig.hepmc +insert /Herwig/Generators/EventGenerator:AnalysisHandlers 0 /Herwig/Analysis/HepMC + + +################################################## +# Save run for later usage with 'Herwig run' +################################################## +saverun LHC EventGenerator \ No newline at end of file diff --git a/run/SimExamples/HepMC_HERWIG7/README.md b/run/SimExamples/HepMC_HERWIG7/README.md new file mode 100755 index 0000000000000..6366c1f076672 --- /dev/null +++ b/run/SimExamples/HepMC_HERWIG7/README.md @@ -0,0 +1,25 @@ + + +The usage of HERWIG7 with the O2 machinery is presented in this short manual. +The example generates HEPMC3 data using the Herwig executable and then +reads the data via the hepmc generator defined in o2-sim. + +# Files description + +Two files are provided in the folder: +- **runo2sim.sh** → allows the generation of events using o2-sim +- **LHC.in** → example input file for the configuration of the HERWIG generator + +## runo2sim.sh + +The script works after loading any O2sim version containing HERWIG7 as a package (dependence of AliGenO2). + +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: +- **-m , --more** → feeds the simulation with advanced parameters provided to the configuration key flags +- **-n , --nevents** → changes the number of events in the .in file or gets the one in the file if no events are provided +- **-i , --input** → .in filename for HERWIG7 configuration +- **-j , --jobs** → sets the number of workers (2 jobs by default) +- **-e , --ecm** → sets the center-of-mass energy in the input file +- **-h , --help** → prints usage instructions \ No newline at end of file diff --git a/run/SimExamples/HepMC_HERWIG7/runo2sim.sh b/run/SimExamples/HepMC_HERWIG7/runo2sim.sh new file mode 100755 index 0000000000000..536a47de01d5c --- /dev/null +++ b/run/SimExamples/HepMC_HERWIG7/runo2sim.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash +# +# This is a simple simulation example on how to generate HEPMC3 data from +# HERWIG7 and run an ALICE simulation using the o2-sim executable +# In the script we assume that the .run file has the same name of the input file, so change it accordingly. +# This script works only with AliGenO2 version containing the HERWIG7 generator + +# HERWIG7 and O2 must be loaded +set -x +if [ ! "${HERWIG_ROOT}" ]; then + echo "This needs HERWIG7 loaded; alienv enter ..." + exit 1 +fi + +[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 2 + +NEV=-1 +more="" +input="LHC" +eCM=-1 +JOBS=2 + +usage() +{ + cat </dev/stderr + exit 3 + ;; + esac + shift +done + +echo "Input file: $input" + +if [ ! -f $input.in ]; then + echo "Error: Input file $input.in not found" + exit 4 +else + if grep -Fq "saverun" $input.in; then + sed -i "/saverun/c\saverun $input EventGenerator" $input.in + else + echo "saverun $input EventGenerator" >> $input.in + fi +fi + +# Set number of events to write in HepMC in input file +if [ ! $NEV -eq -1 ]; then + echo "Setting number of events to $NEV" + if grep -Fq "PrintEvent" $input.in; then + sed -i "/PrintEvent/c\set /Herwig/Analysis/HepMC:PrintEvent $NEV" $input.in + else + echo "set /Herwig/Analysis/HepMC:PrintEvent $NEV" >> $input.in + fi +else + echo "Number of events not set, checking input file..." + if grep -Fq "PrintEvent" $input.in; then + NEV=$(grep -F "PrintEvent" $input.in | awk '{print $3}') + echo "Number of events set to $NEV" + else + echo "Error: Number of events not set in HERWIG7" + exit 5 + fi +fi + +# Set ECM + +if [ ! $eCM -eq -1 ]; then + echo "Setting eCM to $eCM" + if grep -Fq "Energy" $input.in; then + sed -i "/Energy/c\set EventGenerator:EventHandler:LuminosityFunction:Energy $eCM" $input.in + else + echo "set EventGenerator:EventHandler:LuminosityFunction:Energy $eCM" >> $input.in + fi +else + echo "Energy not set, checking input file..." + if grep -Fq "Energy" $input.in; then + eCM=$(grep -F "Energy" $input.in | awk '{print $3}') + echo "Energy set to $eCM" + else + echo "Error: eCM not set in HERWIG7" + exit 6 + fi +fi + +# Generating events using HERWIG7 +Herwig read --repo=${HERWIG_ROOT}/share/Herwig/HerwigDefaults.rpo $input.in +Herwig run -N $NEV $input.run + +# Starting simulation with o2-sim +o2-sim -j $JOBS -n ${NEV} -g hepmc \ + --configKeyValues "GeneratorFileOrCmd.fileNames=herwig.hepmc;${more}"