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
Herwig7ConfigMatchbox.Hw7ConfigMatchbox Class Reference

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

Inheritance diagram for Herwig7ConfigMatchbox.Hw7ConfigMatchbox:
Collaboration diagram for Herwig7ConfigMatchbox.Hw7ConfigMatchbox:

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, integrate=False)
 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, alpha=0.8, grid_divisions=48)
 Configure the sampler. More...
 

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 211 of file Herwig7ConfigMatchbox.py.

Constructor & Destructor Documentation

◆ __init__()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.__init__ (   self,
  genSeq,
  runArgs,
  run_name = "Herwig",
  beams = "pp" 
)

Initialize a generator configuration object for the Matchbox run mode.

Definition at line 215 of file Herwig7ConfigMatchbox.py.

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

Member Function Documentation

◆ __configure()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.__configure (   self)
private

Definition at line 279 of file Herwig7ConfigMatchbox.py.

279  def __configure(self):
280 
281 
282 
283  self.default_commands += self.energy_commands()
284  self.default_commands += self.random_seed_commands()
285 
286  if not self.set_printout_commands:
287  self.default_commands += self.printout_commands()
288  if not self.set_physics_parameter_commands:
289  self.default_commands += self.physics_parameter_commands()
290  if not self.set_technical_parameter_commands:
291  self.default_commands += self.technical_parameter_commands()
292 
293 

◆ do_build()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.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 328 of file Herwig7ConfigMatchbox.py.

328  def do_build(self, integration_jobs):
329  self.__configure()
330  hw7Control.do_build(self, integration_jobs)
331  hw7Control.do_abort()
332 

◆ do_integrate()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.do_integrate (   self,
  integration_job 
)

Atomic steering function for doing one specific integration job.

Todo:
provide info about the range

Definition at line 335 of file Herwig7ConfigMatchbox.py.

335  def do_integrate(self, integration_job):
336  hw7Control.do_integrate(self.run_name, integration_job)
337  hw7Control.do_abort()
338 

◆ do_mergegrids()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.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 344 of file Herwig7ConfigMatchbox.py.

344  def do_mergegrids(self, integration_jobs, gridpack=None):
345  hw7Control.do_mergegrids(self.run_name, integration_jobs)
346  if gridpack:
347  hw7Control.do_compress_gridpack(self.run_name, gridpack)
348  hw7Control.do_abort()
349 

◆ do_run()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.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 355 of file Herwig7ConfigMatchbox.py.

355  def do_run(self, gridpack=None, cleanup_herwig_scratch=True):
356  if gridpack:
357  hw7Control.do_uncompress_gridpack(gridpack)
358  hw7Control.do_run(self, cleanup_herwig_scratch)
359 
360 

◆ local_post_commands()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.local_post_commands (   self)

Definition at line 267 of file Herwig7ConfigMatchbox.py.

267  def local_post_commands(self):
268 
269  return """
270 ## =================================================
271 ## Local Post-Commands from Herwig7ConfigMatchbox.py
272 ## =================================================
273 
274 do /Herwig/MatrixElements/Matchbox/Factory:ProductionMode
275 saverun {} /Herwig/Generators/EventGenerator
276 """.format(self.run_name)
277 
278 

◆ local_pre_commands()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.local_pre_commands (   self)

Definition at line 227 of file Herwig7ConfigMatchbox.py.

227  def local_pre_commands(self):
228 
229  # try to locate the MG5_aMC@NLO installation
230  try:
231  MG5aMC_path = os.environ['MADPATH']
232  except KeyError:
233  raise RuntimeError("MADPATH environment variable not set")
234  if not os.path.isfile(os.path.join(MG5aMC_path, 'bin', 'mg5_aMC')):
235  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)))
236 
237  try:
238  OpenLoops_path= os.environ['OPENLOOPSPATH']
239  except KeyError:
240  raise RuntimeError("OPENLOOPSPATH environment variable not set")
241  if not os.path.isdir(os.path.join(OpenLoops_path, "proclib")):
242  athMsgLog.warn(hw7Utils.ansi_format_warning("The OpenLoops process libraries can't be found from $OPENLOOPS_PATH = {}".format(OpenLoops_path)))
243 
244  return """
245 ## ================================================
246 ## Local Pre-Commands from Herwig7ConfigMatchbox.py
247 ## ================================================
248 
249 ## Fixing interface locations for MadGraph
250 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:BinDir {0}
251 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:DataDir {1}
252 set /Herwig/MatrixElements/Matchbox/Amplitudes/MadGraph:MadgraphPrefix {2}
253 
254 ##Fixing interface locations of Openloops
255 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsLibs {3}
256 set /Herwig/MatrixElements/Matchbox/Amplitudes/OpenLoops:OpenLoopsPrefix {4}
257 
258 read snippets/Matchbox.in
259 read snippets/{4}Collider.in
260 """.format(hw7Control.herwig7_bin_path,
261  hw7Control.herwig7_share_path,
262  MG5aMC_path,
263  os.path.join(OpenLoops_path,"proclib"),
264  OpenLoops_path)
265 
266 

◆ run()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.run (   self,
  integration_jobs = 1,
  gridpack = None,
  cleanup_herwig_scratch = True,
  integrate = False 
)

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 309 of file Herwig7ConfigMatchbox.py.

309  def run(self, integration_jobs=1, gridpack=None, cleanup_herwig_scratch=True, integrate=False):
310 
311  self.__configure()
312 
313  if gridpack:
314  hw7Control.matchbox_run_gridpack(self, integration_jobs, gridpack, cleanup_herwig_scratch, integrate)
315  else:
316  hw7Control.matchbox_run(self, integration_jobs, cleanup_herwig_scratch)
317 
318 

◆ sampler_commands()

def Herwig7ConfigMatchbox.Hw7ConfigMatchbox.sampler_commands (   self,
  bin_sampler = "CellGridSampler",
  initial_points = 10000,
  n_iterations = 1,
  remapper_points = 50000,
  exploration_steps = 4,
  exploration_points = 500,
  alpha = 0.8,
  grid_divisions = 48 
)

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 378 of file Herwig7ConfigMatchbox.py.

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

Member Data Documentation

◆ beams

Herwig7ConfigMatchbox.Hw7ConfigMatchbox.beams

provide variables initialized by the parent class

Definition at line 224 of file Herwig7ConfigMatchbox.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