So Chigusa
So Chigusa
So Chigusa

Install and simulate with Madgraph

Latest update: 2022-08-18

Tips on how to introduce, use, and solve problems about Madgraph

Latest update: 2022-08-18

Tips on how to introduce, use, and solve problems about Madgraph


First of all, edit the global setting in input/mg5_configuration.txt such that the automatic browser opening is disabled:

 automatic_html_opening = False

Next, install all the necessary dependencies as

 install boost
 install lhapdf6
 install zlib
 install hepmc
 install pythia8

How to use

If Madgraph requires other dependencies when executing the code, I often hit enter without any thoughts. Here are some examples of the workflow.

  1. LO Drell-Yan
 p = p b b~
 generate p p > e+ e-
 output pp2ee
  1. NLO Drell-Yan
 import model sm-no_b_mass
 generate p p > e+ e- [QCD]
 output pp2eeNLO

(2022/8/18) Delphes on Mac OS 11, 12

I encountered the following error when I tried to install Delphes on Mac (arm) OS 12.

>> Building
clang: error: no such file or directory: ''
make: *** [] Error 1

According to this Q&A, this error is caused by <Delphes installation>/doc/Makefile.arch only compatible with Mac OS <= 10.

This error is realized with Delphes downloaded as


while there is no such error for the newest version obtained with

git clone

So I recommend to use the latter. When you would like to work with MadGraph -> Delphes workflow, Madgraph tries to use Delphes downloaded in the former method and gives som errors. You should first escape from ./bin/mg5_aMC and replace the file Makefile.arch in <MadGraph installation>/Delphes/doc/ to the one included in the newest version of Delphes and manually redo make. It makes you compile Delphes successfully and now the workflow can be used with no problem.

(2019/6/26) jet matching

Depending on the version of Madgraph, maybe, you should edit run_card.dat when you would like to perform the jet matching.

1 = ickkw            ! 0 no matching, 1 MLM

The help document further tells us that the option 2 corresponds to the CKKW matching. These options forces Madgraph to calculate the hard process for a sufficiently large phase space that has a sizable overlap with the phase space covered by the parton shower calculation. After the parton showering, we can obtain the correct cross section after the jet matching.

(2019/4/26) Use the interpreter for repeated calculation etc

For example, if you would like to launch the process several times with some given names, you should prepare a text file named, e.g., launch_several_times.txt, with the content

launch pp2gogo2 -n 6TeV_0
launch pp2gogo2 -n 6TeV_1
launch pp2gogo2 -n 6TeV_2

Then you can execute it with

./bin/mg5_aMC launch_several_times.txt

to obtain the three results.

(2019/04/21) Change default values of the model parameters

For exmample, if you would like to consider the b-quark PDF in the SM, the b quark should be massless for the consistency of the calculation, so you should first

import model SM-no_b_mass

This command uses the content of **MG5**/model/sm/restrict_no_b_mass.dat as param_card.dat. Similarly, for example, if you would like to use an anomally-mediated symmetry breaking with some given gravitino mass etc as a benchmark point used by default, you can copy your param_card.dat to, e.g., **MG5**/model/MSSM_SLHA2/restrict_AMSB.dat, and use it with

import model MSSM_SLHA2-AMSB

In the preparation of the param_card.dat, it is also convenient to use the command such as

compute_widths n2 go --body_decay=2.0025

to compute the decay width of the given particles. After executing this command, a file param_card.dat is generated in the model directory that includes the computed decay widths.

(2018/11/20) User defined cuts

If you would like to define a new cut variable and condition used at the stage of the event generation, one way is to directly edit the fortran source file of Madgraph. Each process has the file SubProcesses/cuts.f; just edit it as


      do i=1,nexternal          ! loop over all external particles
         if(istatus(i).eq.1 .and. ! final state particle
     &        (ipdg(i).eq.12 .or. ipdg(i).eq.14 .or. ipdg(i).eq.16)) then ! neutrino
            do j=1,nexternal       ! loop over all external particles
               if (is_a_lp(j)) then ! l+
                  if (2d0 * sqrt(p(1,i)**2+p(2,i)**2) * sqrt(p(1,j)**2+p(2,j)**2)
     &                 - 2d0*(p(1,i)*p(1,j)+p(2,i)*p(2,j))
     &                 .lt. 480d0**2) then ! transverse mass cut at 480GeV


The above example puts a cut on the transverse mass between the lepton and neutrino in the final state. Note that a too strong cut can cause a problem related to the precision of the Monte Carlo integration. See here for further discussions.

(2018/08/24) aMCatNLOError : Some tests failed, run cannot continue

You can identify the test that ends up with the error by carefully reading the error messages. In my case, the Soft / Collinear test was failed, that lead me to look inside SubProcesses/test_soft_col_limits.f. This Q&A told me that the existence of many different energy scales would enlarge the numerical instability and tend to cause this kind of problem. I solved this problem by loosing the test condition by editing the fortran source as

      parameter       (max_fail=(LARGE ENOUGH VALUE))

(2018/08/19) Use systematics module

In order to use the systematics module for the estimation of various systematic errors, you need the python interface of LHAPDF. I encountered a problem with "unkonwn library" with the default LHAPDF, so manually reinstalled it. Correspondingly, I had to edit input/mg5_configuration.txt to set the LHAPDF path as

lhapdf = /usr/local/bin/lhapdf-config

and reinstalled pythia just in case.

Before launching the process, you need to edit run_card.dat as

 lhapdf = pdlabel ! PDF set
 True   = reweight_scale ! Reweight to get scale variation using the
 True   = reweight_pdf ! Reweight to get PDF uncertainty. Should be a
 True   = store_rwgt_info ! Store info for reweighting in LHE file
 systematics = systematics_program
 ['--mur=0.5,1,2', '--muf=0.5,1,2', '--pdf=errorset'] = systematics_arguments ! see:

This gives you the estimation of errors associated with the choice of renormalization scales and PDFs.

Share this post: