9 from .
import Herwig7Config
as hw7Config
10 from .
import Herwig7Control
as hw7Control
11 from .
import Herwig7Utils
as hw7Utils
61 def __init__(self, genSeq, runArgs, run_name="Herwig", beams="pp"):
64 if beams
not in [
"EE",
"EP" ,
"PP"]:
65 raise RuntimeError(hw7Utils.ansi_format_error(
"Parameter 'beams' must be one of the following: ['EE', 'EP' , 'PP']"))
68 super(Hw7ConfigLHEF, self).
__init__(genSeq, runArgs, run_name)
79 ## ============================================
80 ## Local Pre-Commands from Herwig7ConfigLHEF.py
81 ## ============================================
83 # > no local pre-commands at the moment
90 ## =============================================
91 ## Local Post-Commands from Herwig7ConfigLHEF.py
92 ## =============================================
94 saverun {} /Herwig/Generators/EventGenerator
108 self.default_commands += self.beam_commands()
109 self.default_commands += self.random_seed_commands()
111 if not self.set_printout_commands:
112 self.default_commands += self.printout_commands()
113 if not self.set_physics_parameter_commands:
114 self.default_commands += self.physics_parameter_commands()
115 if not self.set_technical_parameter_commands:
116 self.default_commands += self.technical_parameter_commands()
121 raise RuntimeError(hw7Utils.ansi_format_error(
"Please do not use both 'lhef_mg5amc_commands()' and 'lhef_powhegbox_commands()' at the same time!"))
123 raise RuntimeError(hw7Utils.ansi_format_error(
"Please use either 'lhef_mg5amc_commands()' or 'lhef_powhegbox_commands()' in the JobOptions!"))
134 def __lhef_commands(self, lhe_filename="events.lhe", me_pdf_order="NLO", usespin=True, usepwghlhereader=False, pwg_reader = "powheg", pwg_reader_lib="libpowhegHerwig.so"):
136 if me_pdf_order
not in [
"LO",
"NLO"]:
137 raise RuntimeError(hw7Utils.ansi_format_error(
"Herwig7ConfigLHEF.py:__lhef_commands: Parameter 'me_pdf_order' must either be 'LO' or 'NLO'!"))
139 if lhe_filename.endswith(
".tar.gz"):
140 lhe_filename = lhe_filename.replace(
".tar.gz",
".events")
141 if not os.path.isfile(lhe_filename):
142 raise RuntimeError(hw7Utils.ansi_format_error(
"Herwig7ConfigLHEF.py:__lhef_commands: Could not find decompressed LHE file '{}'!".
format(lhe_filename)))
144 momentum_treatment =
""
146 if self.
beams ==
"EE":
147 momentum_treatment =
"Accept"
148 elif self.
beams ==
"EP":
149 momentum_treatment =
"RescaleEnergy"
151 ## Set the PDF for the LHE reader
152 # set /Herwig/EventHandlers/LHEReader:PDFA /Herwig/Partons/Hard{MEPDFOrder}PDF
153 """.
format(MEPDFOrder = me_pdf_order)
154 elif self.
beams ==
"PP":
155 momentum_treatment =
"RescaleEnergy"
157 ## Set the PDF for the LHE reader
158 # set /Herwig/EventHandlers/LHEReader:PDFA /Herwig/Partons/Hard{MEPDFOrder}PDF
159 # set /Herwig/EventHandlers/LHEReader:PDFB /Herwig/Partons/Hard{MEPDFOrder}PDF
160 """.
format(MEPDFOrder = me_pdf_order)
162 pwg_reader_lib =
"library "+pwg_reader_lib
165 ## ----------------------------
166 ## Read in Events from LHE File
167 ## ----------------------------
169 ## Create the Handler and Reader
170 library LesHouches.so
171 create ThePEG::LesHouchesEventHandler /Herwig/EventHandlers/LHEHandler
173 create ThePEG::{PwgReader}LesHouchesFileReader /Herwig/EventHandlers/LHEReader
176 set /Herwig/EventHandlers/LHEReader:FileName {FileName}
178 ## Setup LHE event handler and LHE reader
179 set /Herwig/Generators/EventGenerator:EventHandler /Herwig/EventHandlers/LHEHandler
180 insert /Herwig/EventHandlers/LHEHandler:LesHouchesReaders 0 /Herwig/EventHandlers/LHEReader
181 set /Herwig/EventHandlers/LHEHandler:PartonExtractor /Herwig/Partons/{Beams}Extractor
182 set /Herwig/EventHandlers/LHEHandler:CascadeHandler /Herwig/Shower/ShowerHandler
183 set /Herwig/EventHandlers/LHEHandler:HadronizationHandler /Herwig/Hadronization/ClusterHadHandler
184 set /Herwig/EventHandlers/LHEHandler:DecayHandler /Herwig/Decays/DecayHandler
185 set /Herwig/EventHandlers/LHEHandler:WeightNormalization CrossSection
186 set /Herwig/EventHandlers/LHEHandler:WeightOption VarNegWeight
187 set /Herwig/EventHandlers/LHEReader:IncludeSpin {IncludeSpin}
188 set /Herwig/EventHandlers/LHEReader:MomentumTreatment {MomentumTreatment}
189 set /Herwig/EventHandlers/LHEReader:AllowedToReOpen No
191 ## Parton shower settings
192 set /Herwig/Shower/ShowerHandler:MaxPtIsMuF Yes
193 set /Herwig/Shower/ShowerHandler:RestrictPhasespace Yes
194 # treatment of wide angle radiation
195 set /Herwig/Shower/PartnerFinder:PartnerMethod Random
196 set /Herwig/Shower/PartnerFinder:ScaleChoice Partner
198 ## Don't use any cuts on LHE files
199 create ThePEG::Cuts /Herwig/Cuts/NoCuts
200 set /Herwig/EventHandlers/LHEReader:Cuts /Herwig/Cuts/NoCuts
203 """.
format(FileName = lhe_filename,
204 PwgReaderLib = pwg_reader_lib
if usepwghlhereader
else "",
205 PwgReader = pwg_reader
if usepwghlhereader
else "",
207 IncludeSpin =
"Yes" if usespin
else "No",
208 MomentumTreatment = momentum_treatment,
209 BeamCommands = beam_commands)
233 if me_pdf_order
not in [
"LO",
"NLO"]:
234 raise RuntimeError(hw7Utils.ansi_format_error(
"Herwig7ConfigLHEF.py:lhef_mg5amc_commands: Parameter 'me_pdf_order' must either be 'LO' or 'NLO'!"))
241 ## Commands specific to showering of events produced with MG5_aMC@NLO
242 set /Herwig/Shower/KinematicsReconstructor:ReconstructionOption General
243 set /Herwig/Shower/KinematicsReconstructor:InitialInitialBoostOption LongTransBoost
244 set /Herwig/Shower/KinematicsReconstructor:InitialStateReconOption Rapidity
245 set /Herwig/Shower/ShowerHandler:SpinCorrelations No
249 if os.environ[
'HERWIG7VER'].startswith(
'7.1'):
250 self.command +=
"""set /Herwig/Shower/KinematicsReconstructor:FinalStateReconOption Default"""
286 def lhef_powhegbox_commands(self, lhe_filename="events.lhe", me_pdf_order="NLO", usespin=True, usepwhglhereader=False, pwg_reader = "powheg", pwg_reader_lib="libpowhegHerwig.so"):
288 if me_pdf_order
not in [
"LO",
"NLO"]:
289 raise RuntimeError(hw7Utils.ansi_format_error(
"Herwig7ConfigLHEF.py:lhef_powhegbox_commands: Parameter 'me_pdf_order' must either be 'LO' or 'NLO'!"))
293 self.
__lhef_commands(lhe_filename, me_pdf_order, usespin, usepwhglhereader, pwg_reader, pwg_reader_lib)