Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Public Attributes | Private Member Functions | List of all members
Herwig7ConfigMerging.Hw7ConfigMerging Class Reference

Configuration class for Matchbox runs with Herwig7. More...

Inheritance diagram for Herwig7ConfigMerging.Hw7ConfigMerging:
Collaboration diagram for Herwig7ConfigMerging.Hw7ConfigMerging:

Public Member Functions

def __init__ (self, genSeq, runArgs, run_name="Herwig", beams="pp")
 Initialize a generator configuration object for the Matchbox run mode. More...
 
def local_pre_commands (self)
 
def local_post_commands (self)
 
def run (self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True)
 High-level function for triggering the process setup and the event generation. More...
 
def do_build (self, integration_jobs)
 Atomic steering function for doing the build step alone. More...
 
def do_integrate (self, integration_job)
 Atomic steering function for doing one specific integration job. More...
 
def do_mergegrids (self, integration_jobs, gridpack=None)
 Atomic steering function for combining the integration grids and possibly creating a gridpack. More...
 
def do_run (self, gridpack=None, cleanup_herwig_scratch=True)
 Atomic steering function for possibly unpacking a gridpack and generating events. More...
 
def sampler_commands (self, bin_sampler="CellGridSampler", initial_points=10000, n_iterations=1, remapper_points=50000, exploration_steps=4, exploration_points=500)
 Configure the sampler. More...
 
def merging_weight (self, htPower=0, maxPtPower=0, onlyColoured="No")
 

Public Attributes

 beams
 provide variables initialized by the parent class More...
 

Private Member Functions

def __configure (self)
 

Detailed Description

Configuration class for Matchbox runs with Herwig7.

Example JobOptions are available in examples/Matchbox and tests/athenaMatchbox/jobOptions.

Process Setup and Generator Configuration

To use the Matchbox run mode of Herwig7 load the corresponding modules and add Herwig7 to the generator sequence

from Herwig7_i.Herwig7_iConf import Herwig7
from Herwig7_i.Herwig7ConfigMatchbox import Hw7ConfigMatchbox
genSeq += Herwig7()

You may specify details of the run a la

# Provide config information
evgenConfig.generators += ["Herwig7"]
evgenConfig.tune = "MMHT2014"
evgenConfig.description = "Herwig7 Zee sample with CT10 ME PDF and MMHT2014 PS and UE tune"
evgenConfig.keywords = ["SM","Z","electron"]
evgenConfig.contact = ["Your Name (your.name@cern.ch)"]

You can initialize a generator configuration object with

# initialize generator configuration object
generator = Hw7ConfigMatchbox(genSeq, runArgs, run_name="HerwigMatchbox", beams="pp")

Please see the constructor for more information on the arguments.

You can use the functions me_alphas_commands, me_pdf_commands and tune_commands from Herwig7Config::Hw7Config to configure the strong coupling and the PDFs for the hard process and the parton shower and underlying event tunes, e.g.

# configure generator
generator.me_pdf_commands(order="NLO", name="CT10")
generator.tune_commands()

You can add direct Herwig7 commands like this

generator.add_commands("""
# Model assumptions
read Matchbox/StandardModelLike.in
# Set the hard process
set /Herwig/MatrixElements/Matchbox/Factory:OrderInAlphaS 0
set /Herwig/MatrixElements/Matchbox/Factory:OrderInAlphaEW 2
do /Herwig/MatrixElements/Matchbox/Factory:Process p p -> e+ e-
# Cut selection (see the documentation for more options)
set /Herwig/Cuts/ChargedLeptonPairMassCut:MinMass 60*GeV
set /Herwig/Cuts/ChargedLeptonPairMassCut:MaxMass 120*GeV
# Scale choice (see the documentation for more options)
cd /Herwig/MatrixElements/Matchbox
set Factory:ScaleChoice /Herwig/MatrixElements/Matchbox/Scales/LeptonPairMassScale
# Matching and shower selection
read Matchbox/MCatNLO-DefaultShower.in
# Choose a flavour scheme
read Matchbox/FiveFlavourScheme.in
""")

Please see the Herwig7 tutorial page for in-depth information on the different settings and have a look at Herwig7ConfigMatchbox::Hw7ConfigMatchbox and Herwig7Config::Hw7Config to see if there are convenience functions that accomplish the task provided in the interface already.

Integration and Event Generation

To trigger the actual running of Herwig7 in Athena please end the JobOptions with

# run the generator
generator.run()

More specifically, the run() function triggers the creation of the Herwig7 input file and the preparation of the run (i.e. the Herwig [build, integrate, mergegrids] sequence). This means, that no Herwig7 settings should be modified after calling the run() function because the changed settings would not be applied during the event generation.

Cleanup After the Event Generation

By default the folder Herwig-scratch which created by Herwig7 and contains the process libraries and several other files (e.g. integration grids) will be cleaned up and deleted after the event generation in order to save disk space. You can prevent this with:

# run the generator
generator.run(cleanup_herwig_scratch=True)

Parallel Integration

Machine-local parallelization of the integration can be achieved with

# run the generator
generator.run(integration_jobs=2)

Generate_tf.py comes with the command line parameter --generatorJobNumber that can be used to specify the number of integration jobs dynamically, instead of fixing it in the JobOptions

# run the generator
generator.run(integration_jobs=runArgs.generatorJobNumber)

Gridpacks

A gridpack can be created with

# run the generator
generator.run(gridpack="gridpack.tar.gz")

The JobOptions can be run in athena with a command such as

Generate_tf.py --jobConfig=MC15.999999.H7_MB_Int_Zee_MCatLO_QTilde_H7_UE_MMHT2014.py --runNumber=999999 --ecmEnergy=13000 --randomSeed=12011988 --maxEvents=100 --outputEVNTFile=evgen.root

If you have previously created a gridpack called gridpack.tar.gz and want to generate events from it, specify the name of the compressed gridpack using the --inputGenConfFile command line parameter, e.g.

Generate_tf.py --jobConfig=MC15.999999.H7_MB_Int_Zee_MCatLO_QTilde_H7_UE_MMHT2014.py --inputGenConfFile=gridpack.tar.gz --runNumber=999999 --ecmEnergy=13000 --randomSeed=12011988 --maxEvents=100 --outputEVNTFile=evgen.root

Full Flexibility and Batch-Parallel Integration

The --generatorRunMode command line argument for Generate_tf.py can be used to put in place a very fine-grained control over the various steps that happen before the event generation.

In the following example this is combined with the creation and use of a gridpack. This, however, doesn't have to be done and can be left out.

if runArgs.generatorRunMode == 'build':
# use the --generatorJobNumber command line parameter to dynamically
# specify the total number of parallel integration jobs
generator.do_build(integration_jobs=runArgs.generatorJobNumber)
elif runArgs.generatorRunMode == 'integrate':
# use the --generatorJobNumber command line parameter to dynamically
# specify which specific integration job is to be run
generator.do_integrate(runArgs.generatorJobNumber)
elif runArgs.generatorRunMode == 'mergegrids':
# combine integration grids and prepare a gridpack
# use the --generatorJobNumber command line parameter to dynamically
# specify the total number of parallel integration jobs
generator.do_mergegrids(integration_jobs=runArgs.generatorJobNumber, gridpack="gridpack.tar.gz")
elif runArgs.generatorRunMode == 'run':
# generate events using the specified gridpack
generator.do_run(gridpack="gridpack.tar.gz")

Please note that for the do_build() function the same caveat applies as for the run() function: The Herwig7 generator configuration should not be modified afterwards in the job options as the new settings would not be applied in the event generation.

Note
Currently the build, the integration and the mergegrids steps have to run in the same directory which means that the files written by athena will be re-created and overwritten. In one of the next releases Herwig7 will bring infrastructure to re-use Herwig-scratch folders from a different location which will allow for a full batch parallelization of the integration in athena.

Definition at line 210 of file Herwig7ConfigMerging.py.

Constructor & Destructor Documentation

◆ __init__()

def Herwig7ConfigMerging.Hw7ConfigMerging.__init__ (   self,
  genSeq,
  runArgs,
  run_name = "Herwig",
  beams = "pp" 
)

Initialize a generator configuration object for the Matchbox run mode.

Definition at line 214 of file Herwig7ConfigMerging.py.

214  def __init__(self, genSeq, runArgs, run_name="Herwig", beams="pp"):
215 
216  beams = beams.upper()
217  if beams not in ["EE", "EP", "PP"]:
218  raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'beams' must be one of the following ['EE', 'EP', 'PP']!"))
219 
220 
221  super(Hw7ConfigMerging, self).__init__(genSeq, runArgs, run_name)
222 
223  self.beams = beams
224 
225 

Member Function Documentation

◆ __configure()

def Herwig7ConfigMerging.Hw7ConfigMerging.__configure (   self)
private

Definition at line 284 of file Herwig7ConfigMerging.py.

284  def __configure(self):
285 
286 
287 
288  self.default_commands += self.energy_commands()
289  self.default_commands += self.random_seed_commands()
290 
291  if not self.set_printout_commands:
292  self.default_commands += self.printout_commands()
293  if not self.set_physics_parameter_commands:
294  self.default_commands += self.physics_parameter_commands()
295  if not self.set_technical_parameter_commands:
296  self.default_commands += self.technical_parameter_commands()
297 
298 

◆ do_build()

def Herwig7ConfigMerging.Hw7ConfigMerging.do_build (   self,
  integration_jobs 
)

Atomic steering function for doing the build step alone.

Parameters
[in]integration_jobsNumber of integration jobs to be prepared
Warning
Please do not modify the generator configuration in the job options after calling the do_build() function as the modified settings would not be applied in the event generation

Definition at line 333 of file Herwig7ConfigMerging.py.

333  def do_build(self, integration_jobs):
334  self.__configure()
335  hw7Control.do_build(self, integration_jobs)
336  hw7Control.do_abort()
337 

◆ do_integrate()

def Herwig7ConfigMerging.Hw7ConfigMerging.do_integrate (   self,
  integration_job 
)

Atomic steering function for doing one specific integration job.

Todo:
provide info about the range

Definition at line 340 of file Herwig7ConfigMerging.py.

340  def do_integrate(self, integration_job):
341  hw7Control.do_integrate(self.run_name, integration_job)
342  hw7Control.do_abort()
343 

◆ do_mergegrids()

def Herwig7ConfigMerging.Hw7ConfigMerging.do_mergegrids (   self,
  integration_jobs,
  gridpack = None 
)

Atomic steering function for combining the integration grids and possibly creating a gridpack.

Parameters
[in]integration_jobsNumber of integration jobs
[in]gridpackName of the gridpack to be created. No gridpack is created if the parameter is not specified.

Definition at line 349 of file Herwig7ConfigMerging.py.

349  def do_mergegrids(self, integration_jobs, gridpack=None):
350  hw7Control.do_mergegrids(self.run_name, integration_jobs)
351  if gridpack:
352  hw7Control.do_compress_gridpack(self.run_name, gridpack)
353  hw7Control.do_abort()
354 

◆ do_run()

def Herwig7ConfigMerging.Hw7ConfigMerging.do_run (   self,
  gridpack = None,
  cleanup_herwig_scratch = True 
)

Atomic steering function for possibly unpacking a gridpack and generating events.

Parameters
[in]gridpackName of the gridpack to be used. No gridpack is used if the parameter is not specified.
[in]cleanup_herwig_scratchRemove the Herwig-scratch folder after event generation to save disk space

Definition at line 360 of file Herwig7ConfigMerging.py.

360  def do_run(self, gridpack=None, cleanup_herwig_scratch=True):
361  if gridpack:
362  hw7Control.do_uncompress_gridpack(gridpack)
363  hw7Control.do_run(self, cleanup_herwig_scratch)
364 
365 

◆ local_post_commands()

def Herwig7ConfigMerging.Hw7ConfigMerging.local_post_commands (   self)

Definition at line 272 of file Herwig7ConfigMerging.py.

272  def local_post_commands(self):
273 
274  return """
275 ## =================================================
276 ## Local Post-Commands from Herwig7ConfigMerging.py
277 ## =================================================
278 
279 do /Herwig/Merging/MergingFactory:ProductionMode
280 saverun {} /Herwig/Generators/EventGenerator
281 """.format(self.run_name)
282 
283 

◆ local_pre_commands()

def Herwig7ConfigMerging.Hw7ConfigMerging.local_pre_commands (   self)

Definition at line 226 of file Herwig7ConfigMerging.py.

226  def local_pre_commands(self):
227 
228  # try to locate the MG5_aMC@NLO installation
229  try:
230  MG5aMC_path = os.environ['MADPATH']
231  except KeyError:
232  raise RuntimeError("MADPATH environment variable not set")
233  if not os.path.isfile(os.path.join(MG5aMC_path, 'bin', 'mg5_aMC')):
234  athMsgLog.warn(hw7Utils.ansi_format_warning("The MadGraph5_aMC@NLO installation can't be found from $MADPATH = {}, so don't be surprised if your run crashes in you are using matrix elements from MG5_aMC@NLO in Herwig7 / Matchbox. Please ensure that the location exists, that you have permissions to access it and that it contains the executable 'bin/mg5_aMC'".format(MG5aMC_path)))
235 
236  try:
237  OpenLoops_path= os.environ['OPENLOOPSPATH']
238  except KeyError:
239  raise RuntimeError("OPENLOOPSPATH environment variable not set")
240  if not os.path.isdir(os.path.join(OpenLoops_path, "proclib")):
241  athMsgLog.warn(hw7Utils.ansi_format_warning("The OpenLoops process libraries can't be found from $OPENLOOPSPATH = {}".format(OpenLoops_path)))
242 
243 
244 
245  return """
246 ## ================================================
247 ## Local Pre-Commands from Herwig7ConfigMerging.py
248 ## ================================================
249 
250 ## Fixing interface locations for MadGraph
251 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
252 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
253 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
254 
255 ##Fixing interface locations of Openloops
256 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {4}
257 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {5}
258 
259 # Currently the Dipole Snippet is broken (reads to the Rivet interface which we don't build)
260 # For now manually copy all the relevant settings in
261 read snippets/DipoleMerging.in
262 read snippets/{3}Collider.in
263 read Merging/Merging-Dipole-FactorCMWSchemeTune.in
264 read Merging/FactorCMWScheme.in
265 """.format(hw7Control.herwig7_bin_path,
266  hw7Control.herwig7_share_path,
267  MG5aMC_path,
268  self.beams,
269  os.path.join(OpenLoops_path,"proclib"),
270  OpenLoops_path)
271 

◆ merging_weight()

def Herwig7ConfigMerging.Hw7ConfigMerging.merging_weight (   self,
  htPower = 0,
  maxPtPower = 0,
  onlyColoured = "No" 
)

Definition at line 410 of file Herwig7ConfigMerging.py.

410  def merging_weight(self, htPower=0, maxPtPower=0, onlyColoured="No"):
411  if onlyColoured not in ["Yes","No"]:
412  raise RuntimeError(hw7Utils.ansi_format_error("OnlyColoured must be Yes or No"))
413 
414  self.commands+="""
415 ##Merging Weighter for better phase space coverage
416 set /Herwig/Merging/MPreWeight:HTPower {}
417 set /Herwig/Merging/MPreWeight:MaxPTPower {}
418 set /Herwig/Merging/MPreWeight:OnlyColoured {}
419 """.format(htPower,maxPtPower,onlyColoured)
420 

◆ run()

def Herwig7ConfigMerging.Hw7ConfigMerging.run (   self,
  integration_jobs = 1,
  gridpack = None,
  cleanup_herwig_scratch = True 
)

High-level function for triggering the process setup and the event generation.

Parameters
[in]integration_jobsNumber of threads for machine-local parallelization of the integration
[in]gridpackName of the gridpack that possibly is to be created (after the integration) or to be used (for the event generation). No gridpack is created or used if the parameter is not specified. If you have created a gridpack and would like to generate events from it, please pass the name of the gridpack to the Generate_tf.py command using the --inputGenConfFile command line argument
[in]cleanup_herwig_scratchRemove the Herwig-scratch folder after event generation to save disk space
Warning
Please do not modify the generator configuration in the job options after calling the run() function as the modified settings would not be applied in the event generation

Definition at line 314 of file Herwig7ConfigMerging.py.

314  def run(self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True):
315 
316  self.__configure()
317 
318  if gridpack:
319  hw7Control.matchbox_run_gridpack(self, integration_jobs, gridpack, cleanup_herwig_scratch)
320  else:
321  hw7Control.matchbox_run(self, integration_jobs, cleanup_herwig_scratch)
322 
323 

◆ sampler_commands()

def Herwig7ConfigMerging.Hw7ConfigMerging.sampler_commands (   self,
  bin_sampler = "CellGridSampler",
  initial_points = 10000,
  n_iterations = 1,
  remapper_points = 50000,
  exploration_steps = 4,
  exploration_points = 500 
)

Configure the sampler.

Warning
Please be very careful when modifying the sampler settings and ensure that the statistics in the integration phase is sufficient to provide an adequate phase space sampling and setup. The total cross section estimated after the integration is output before the event generation, please watch out for the corresponding lines beginning with
Py:Herwig7Utils      INFO Calculating cross section after integration

If the statistical uncertainty on this estimated total cross section is larger than 0.2% a warning is printed, encouraging you to consider increasing the statistics of the integration.

Definition at line 383 of file Herwig7ConfigMerging.py.

383  def sampler_commands(self, bin_sampler="CellGridSampler",
384  initial_points=10000, n_iterations=1, remapper_points=50000,
385  exploration_steps=4, exploration_points=500):
386 
387  bin_samplers = ["CellGridSampler", "MonacoSampler", "FlatBinSampler"]
388 
389  if bin_sampler not in bin_samplers:
390  raise RuntimeError(hw7Utils.ansi_format_error("Parameter 'bin_sampler' must be one of {}!".format(bin_samplers)))
391 
392  self.commands += """
393 ## Sampler Configuration
394 set /Herwig/Samplers/Sampler:BinSampler /Herwig/Samplers/{}
395 set /Herwig/Samplers/Sampler:BinSampler:InitialPoints {}
396 set /Herwig/Samplers/Sampler:BinSampler:NIterations {}
397 set /Herwig/Samplers/Sampler:BinSampler:RemapperPoints {}
398 """.format(bin_sampler, initial_points, n_iterations, remapper_points)
399 
400  if bin_sampler == "CellGridSampler":
401  self.commands += """
402 set /Herwig/Samplers/CellGridSampler:ExplorationSteps {}
403 set /Herwig/Samplers/CellGridSampler:ExplorationPoints {}
404 """.format(exploration_steps, exploration_points)
405 
406  if bin_sampler == "MonacoSampler":
407  self.commands += """
408 read snippets/MonacoSampler.in"""
409 

Member Data Documentation

◆ beams

Herwig7ConfigMerging.Hw7ConfigMerging.beams

provide variables initialized by the parent class

Definition at line 223 of file Herwig7ConfigMerging.py.


The documentation for this class was generated from the following file:
Herwig7Control.do_integrate
def do_integrate(run_name, integration_job)
Do the integrate step for one specific integration job.
Definition: Herwig7Control.py:196
Herwig7Control.do_build
def do_build(gen_config, integration_jobs)
Do the build step.
Definition: Herwig7Control.py:178
vtune_athena.format
format
Definition: vtune_athena.py:14
Herwig7Control.do_mergegrids
def do_mergegrids(run_name, integration_jobs)
This function provides the mergegrids step.
Definition: Herwig7Control.py:209
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
Herwig7
Interface to athena.
Definition: Herwig7.h:129
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Herwig7Control.do_run
def do_run(gen_config, cleanup_herwig_scratch=True)
Definition: Herwig7Control.py:273