# based on example from Herwig++ 2.4.2 distribution:
#   share/Herwig++/TVT.in

# rungen.sh uses the following command to insert PPCollider.in snippet
#%beamsetup71%

# Run options:
cd /Herwig/Generators
set LHCGenerator:NumberOfEvents 100000
set LHCGenerator:RandomNumberGenerator:Seed 588
set LHCGenerator:DebugLevel 9
set LHCGenerator:PrintEvent 1
set LHCGenerator:MaxErrors 100000

# redirect all log output to stdout
set LHCGenerator:UseStdout true

# do output to a HepMC file
cd /Herwig/Generators
insert LHCGenerator:AnalysisHandlers 0 /Herwig/Analysis/HepMCFile
set /Herwig/Analysis/HepMCFile:PrintEvent 1000000
set /Herwig/Analysis/HepMCFile:Format GenEvent
set /Herwig/Analysis/HepMCFile:Filename /shared/tmp/tmp.F8EFRxI2Yc/generator.hepmc
# set /Herwig/Analysis/HepMCFile:Units GeV_mm


# Beam parameters:
set LHCGenerator:EventHandler:LuminosityFunction:Energy 1800
set LHCGenerator:EventHandler:BeamA /Herwig/Particles/p+
set LHCGenerator:EventHandler:BeamB /Herwig/Particles/pbar-
set LHCGenerator:MaxErrors -1


# Drell-Yan Z/gamma process:
cd /Herwig/MatrixElements
insert SimpleQCD:MatrixElements[0] MEqq2gZ2ff

# Select only electron channel
#set MEqq2gZ2ff:Process Electron


# Set cuts
# Use this for hard leading-jets in a certain pT window
set /Herwig/Cuts/JetKtCut:MinKT 0*GeV        # minimum jet pT
set /Herwig/Cuts/JetKtCut:MaxKT 1800*GeV        # maximum jet pT

# Use this for lepton pair invariant mass in a certain window
set /Herwig/Cuts/MassCut:MinM 50*GeV        # min inv. mass of lep. pair
set /Herwig/Cuts/MassCut:MaxM 130*GeV        # max inv. mass of lep. pair


# Make particles with c*tau > 10 mm stable:
set /Herwig/Decays/DecayHandler:MaxLifeTime 10*mm
set /Herwig/Decays/DecayHandler:LifeTimeOption Average


# tune 'UE-MMHT' parameters: -------------------
#%tuneFile%
# 9 Jan 2018: adapted/copied from
# https://herwig.hepforge.org/tutorials/mpi/tunes.html#herwig-7-1-tunes
# by P. Skands

# MPI energy extrapolation settings
set /Herwig/UnderlyingEvent/MPIHandler:EnergyExtrapolation Power
set /Herwig/UnderlyingEvent/MPIHandler:ReferenceScale 7000.*GeV
set /Herwig/UnderlyingEvent/MPIHandler:Power 0.366
set /Herwig/UnderlyingEvent/MPIHandler:pTmin0 4.39*GeV

# Energy-independent MPI parameters
# Colour reconnection settings
set /Herwig/Hadronization/ColourReconnector:ColourReconnection Yes
set /Herwig/Hadronization/ColourReconnector:ReconnectionProbability 0.4276
# Colour Disrupt settings
set /Herwig/Partons/RemnantDecayer:colourDisrupt 0.798
# inverse hadron radius
set /Herwig/UnderlyingEvent/MPIHandler:InvRadius 2.30

# ---------------------------------------------


set /Herwig/UnderlyingEvent/MPIHandler:IdenticalToUE -1

# Run generator
cd /Herwig/Generators
saverun generator LHCGenerator