PYTHIA  8.311
Public Types | Public Member Functions | List of all members
LHAupMadgraph Class Reference

A derived class from LHAup which generates events with MadGraph 5. More...

#include <LHAMadgraph.h>

Inheritance diagram for LHAupMadgraph:
LHAup

Public Types

enum  Stage { Auto, Configure, Generate, Launch }
 Types of MadGraph stages.
 

Public Member Functions

 LHAupMadgraph (Pythia *pythiaIn, bool matchIn=true, string dirIn="madgraphrun", string exeIn="mg5_aMC")
 Constructor.
 
 ~LHAupMadgraph ()
 
bool readString (string line, Stage stage=Auto)
 Read a MadGraph command string. More...
 
void addCard (string src, string dst)
 Add a MadGraph configuration card to be used. More...
 
void setEvents (int eventsIn)
 Set the number of events to generate per run. More...
 
bool setSeed (int seedIn, int runsIn=30081)
 Set the random seed and maximum runs. More...
 
void setJets (int jetsIn)
 Set the maximum number of jets produced by MadGraph. More...
 
bool setInit ()
 Set the initialization information. More...
 
bool setEvent (int=0)
 Set the event information. More...
 
bool execute (string line)
 Execute a system command. More...
 
bool configure ()
 Write the MadGraph configuration. More...
 
bool generate ()
 Run the generate stage of MadGraph. More...
 
bool launch ()
 Run the launch stage of MadGraph. More...
 
bool run (int eventsIn, int seedIn=-1)
 Run MadGraph.
 
bool reader (bool init)
 Create the LHEF reader. More...
 
void errorMsg (string messageIn)
 Print a message the first few times. Insert in database. More...
 
- Public Member Functions inherited from LHAup
virtual ~LHAup ()
 Destructor.
 
void setPtr (Info *infoPtrIn)
 Set pointers.
 
virtual void newEventFile (const char *)
 Method to be used for LHAupLHEF derived class.
 
virtual bool fileFound ()
 
virtual bool useExternal ()
 
int idBeamA () const
 Give back info on beams.
 
int idBeamB () const
 
double eBeamA () const
 
double eBeamB () const
 
int pdfGroupBeamA () const
 
int pdfGroupBeamB () const
 
int pdfSetBeamA () const
 
int pdfSetBeamB () const
 
int strategy () const
 Give back weight strategy.
 
int sizeProc () const
 Give back info on processes.
 
int idProcess (int proc) const
 
double xSec (int proc) const
 
double xErr (int proc) const
 
double xMax (int proc) const
 
double xSecSum () const
 
double xErrSum () const
 
void listInit ()
 Print the initialization info; useful to check that setting it worked. More...
 
int idProcess () const
 Give back process number, weight, scale, alpha_em, alpha_s.
 
double weight () const
 
double scale () const
 
double alphaQED () const
 
double alphaQCD () const
 
int sizePart () const
 Give back info on separate particle.
 
int id (int part) const
 
int status (int part) const
 
int mother1 (int part) const
 
int mother2 (int part) const
 
int col1 (int part) const
 
int col2 (int part) const
 
double px (int part) const
 
double py (int part) const
 
double pz (int part) const
 
double e (int part) const
 
double m (int part) const
 
double tau (int part) const
 
double spin (int part) const
 
double scale (int part) const
 
int id1 () const
 Give back info on flavour and x values of hard-process initiators.
 
int id2 () const
 
double x1 () const
 
double x2 () const
 
bool pdfIsSet () const
 Optional: give back info on parton density values of event.
 
int id1pdf () const
 
int id2pdf () const
 
double x1pdf () const
 
double x2pdf () const
 
double scalePDF () const
 
double pdf1 () const
 
double pdf2 () const
 
bool scaleShowersIsSet () const
 Optional: give back info on parton shower scales.
 
double scaleShowers (int i) const
 
void listEvent ()
 Print the info; useful to check that reading an event worked. More...
 
virtual bool skipEvent (int nSkip)
 
virtual bool openLHEF (string fileNameIn)
 Four routines to write a Les Houches Event file in steps. More...
 
virtual bool closeLHEF (bool updateInit=false)
 Write end of a Les Houches Event File and close it. More...
 
bool initLHEF ()
 Write initialization information to a Les Houches Event File. More...
 
bool eventLHEF (bool verbose=true)
 
string getFileName () const
 Get access to the Les Houches Event file name.
 

Additional Inherited Members

- Protected Member Functions inherited from LHAup
 LHAup (int strategyIn=3)
 Constructor. Sets default to be that events come with unit weight.
 
void setBeamA (int idIn, double eIn, int pdfGroupIn=0, int pdfSetIn=0)
 Input beam info.
 
void setBeamB (int idIn, double eIn, int pdfGroupIn=0, int pdfSetIn=0)
 
void setStrategy (int strategyIn)
 Input process weight strategy.
 
void addProcess (int idProcIn, double xSecIn=1., double xErrIn=0., double xMaxIn=1.)
 Input process info.
 
void setXSec (int iP, double xSecIn)
 Possibility to update some cross section info at end of run.
 
void setXErr (int iP, double xErrIn)
 
void setXMax (int iP, double xMaxIn)
 
void setProcess (int idProcIn=0, double weightIn=1., double scaleIn=0., double alphaQEDIn=0.0073, double alphaQCDIn=0.12)
 Input info on the selected process. More...
 
void addParticle (LHAParticle particleIn)
 Input particle info, one particle at the time.
 
void addParticle (int idIn, int statusIn=0, int mother1In=0, int mother2In=0, int col1In=0, int col2In=0, double pxIn=0., double pyIn=0., double pzIn=0., double eIn=0., double mIn=0., double tauIn=0., double spinIn=9., double scaleIn=-1.)
 
void setIdX (int id1In, int id2In, double x1In, double x2In)
 Input info on flavour and x values of hard-process initiators.
 
void setPdf (int id1pdfIn, int id2pdfIn, double x1pdfIn, double x2pdfIn, double scalePDFIn, double pdf1In, double pdf2In, bool pdfIsSetIn)
 Optionally input info on parton density values of event.
 
void setScaleShowers (double scaleIn1, double scaleIn2=0.)
 Optionally input info on parton shower starting scale; two for DPS.
 
bool setInitLHEF (istream &is, bool readHeaders=false)
 Three routines for LHEF files, but put here for flexibility. More...
 
bool setNewEventLHEF (istream &is)
 
bool setOldEventLHEF ()
 Make current event information read in by setNewEventLHEF. More...
 
istream * openFile (const char *fn, ifstream &ifs)
 
void closeFile (istream *&is, ifstream &ifs)
 
void setInfoHeader (const string &key, const string &val)
 
- Protected Attributes inherited from LHAup
InfoinfoPtr
 Pointer to various information on the generation.
 
LoggerloggerPtr
 
int nupSave
 Event properties from LHEF files, for repeated use.
 
int idprupSave
 
double xwgtupSave
 
double scalupSave
 
double aqedupSave
 
double aqcdupSave
 
double xSecSumSave
 
double xErrSumSave
 
vector< LHAParticleparticlesSave
 
bool getPDFSave
 
bool getScale
 
bool getScaleShowers
 
int id1InSave
 
int id2InSave
 
int id1pdfInSave
 
int id2pdfInSave
 
double x1InSave
 
double x2InSave
 
double x1pdfInSave
 
double x2pdfInSave
 
double scalePDFInSave
 
double pdf1InSave
 
double pdf2InSave
 
double scaleShowersInSave [2]
 
string fileName
 File to which to write Les Houches Event File information.
 
fstream osLHEF
 
char dateNow [12]
 
char timeNow [9]
 
- Static Protected Attributes inherited from LHAup
static const double CONVERTMB2PB = 1e9
 Allow conversion from mb to pb. More...
 

Detailed Description

A derived class from LHAup which generates events with MadGraph 5.

This class automatically generates hard processes with MadGraph 5 and aMC, reads in the LHEF file output, and performs matching (if requested). For tree-level generation MLM matching is performed while FxFx is used for aMC generation. The user can send commands to MadGraph via the readString method. Any string begining with "configure " is used for the initial MadGraph configuration with "configure " stripped from the begining. In general, only the process and run settings need to be provided. Run settings must begin with " set" (note the leading space). The output and launch commands, random seed, and shower choice are automatically handled. For example, the following will produce di-muon events from 13 TeV proton proton collisions at NLO in QCD: readString("generate p p > mu+ mu- [QCD]") The number of events generated per MadGraph run is controlled by setEvents, while the random seed is controlled by setSeed. The maximum number of jets produced by MadGraph (needed for matching) is automatically determined but can be manually specified with setJets. In general these methods should not be needed; for further details see the method documentation. Events are generated with MadGraph utilizing the "gridpack" method for MadGraph 5:

https:///cp3.irmp.ucl.ac.be/projects/madgraph/wiki/GridDevelopment

and an eqivalent method for aMC:

https:///answers.launchpad.net/mg5amcnlo/+question/243268

Consequently the run directory ("madgraphrun" by default) does not need to be deleted between independent runs with the same configuration (excluding random seeds). Indeed, keeping the directory significantly speeds the generation process, particularly for NLO generation with aMC as the grid initialization can be skipped after the initial run.

Constructor & Destructor Documentation

Destructor: Print error statistics before exiting. Printing code basically copied from Info class.

Header.

Loop over all messages

Message printout.

Done.

Member Function Documentation

void addCard ( string  src,
string  dst 
)

Add a MadGraph configuration card to be used.

In general, MadGraph should be configured via the readString method. However, there are some cases where the user might wish to provide an entire configuration card, e.g. setting BSM model space. This method allows the user to provide a source card, src, which is then copied to <MadGraph run="" directory>="">/Cards/dst. These cards are copied before any MadGraph processes are launched.

bool configure ( )

Write the MadGraph configuration.

If not overridden, the MadGraph configuration is set to prevent the output from being opened in a web-browser and stop MadGraph updates.

void errorMsg ( string  messageIn)
inline

Print a message the first few times. Insert in database.

Recover number of times message occured. Also inserts new string.

Print message the first few times.

bool execute ( string  line)

Execute a system command.

Note: The functions below have been made public to ease the generation of Python bindings. protected:

bool generate ( )

Run the generate stage of MadGraph.

The final command of "output <dir> -f -nojpeg\n" is automatically set, if not overridden. MadGraph is then run and the output is checked. Finally, the configuration is updated and the type of run, MadGraph or aMC, is determined.

Write the user settings to the generate configuration file.

Run MadGraph and check output.

Update configuration.

Copy over any user provided configuration cards.

bool launch ( )

Run the launch stage of MadGraph.

The first command "launch ..." is automatically set, and depends on whether aMC is being used.

Open the launch configuration file and write the settings.

Write the user settings.

Fix aMC linking.

Run MadGraph and create run scripts.

bool reader ( bool  init)

Create the LHEF reader.

Check valid LHE file.

Determine the cross-section (if needed).

Set the info.

bool readString ( string  line,
Stage  stage = Auto 
)

Read a MadGraph command string.

If the stage is set to Auto, commands beginning with " set" are used in the launch stage (these must begin with a single space to differentiate from generate stage set commands), commands begining with "configure" are used in the configuration stage, and all remaining commands (excluding output and launch) are used in the generate stage. Output, launch, seed, and shower commands are automatically handled. If the user wishes to override commands, then the stage can be specified. This will prevent any automatically generated commands from being used for that stage. This should only be done if the user understands what additional commands are needed. The system MadGraph configuration will be used if the configuration stage is overridden by the user and only blank commands have been passed. This is accomplished via readString("", LHAupMadgraph::Configure).

bool setEvent ( int  = 0)
virtual

Set the event information.

Run setEvent from the LHEF object and launch MadGraph if failed.

Read the event from the LHEF object.

Implements LHAup.

void setEvents ( int  eventsIn)

Set the number of events to generate per run.

Set the number of events to generate per MadGraph run, the default is 10000.

bool setInit ( )
virtual

Set the initialization information.

If shower matching has been requested, then the matching is also set up depending on the type of MadGraph output.

Initialize MadGraph.

Set up matching if requested.

Load the MadGraph parameters.

Extract maximum number of jets.

Common settings.

aMC settings.

MLM tree-level MadGraph settings.

Set the matching hook.

Create the LHEF LHAup object and run setInit.

Implements LHAup.

void setJets ( int  jetsIn)

Set the maximum number of jets produced by MadGraph.

Set the number maximum number of jets generated by MadGraph.

If negative (default of -1) then the number of jets is determined automatically. This is the maximum number of jets produced at leading order.

bool setSeed ( int  seedIn,
int  runsIn = 30081 
)

Set the random seed and maximum runs.

Set the random seed and maximum allowed runs.

If the random seed is negative (default of -1), then the MadGraph seed is taken as the Pythia parameter "Random:seed", which must be greater than 0. If the maximum number of allowed runs is exceeded (default of 30081) an error is thrown. The seed for a MadGraph run is set as: (random seed - 1) * (maximum runs) + (number of runs) + 1 MadGraph can only handle random seeds up to 30081 * 30081. So, with this strategy, one can generate Pythia jobs with seeds from 1 to 30081, with each job running MadGraph less than 30081 times, and ensure a fully statistically independent sample. If more than 30081 jobs are needed, then the maximum allowed runs can be lowered accordingly, and if need be, setEvents can be used to increase the number of events generated per run.


The documentation for this class was generated from the following file: