You are here: Foswiki>Computing Web>Tier3WebHome>MadEvent (revision 34)EditAttach
Madevent is a package derived from MadGraph (which is quite stable and has been around for a long time). It produces events according to SM and BSM processes at the parton level, but also interfaces with Pythia. This isn't new. What is unique is that this can all be originated from a web interface.

The web page is:

Detailed instructions from Reinhard, May 24, 2007:

To get started, you should get registered on the registration web page. That will generate a username-password for you which you need to produce any processes.

Then go to the "Generate Process" page and start playing around with it. You can look at the example processes that it provides for you, for

example uu~>dd~ as the input process. You can look at many other example processes as well, for example an electroweak one: ud~>e+ve. To generate something Tevatron or LHC related, you would use pp as the input particles, for example pp>e+ve. Once you enter this you'll see that there are more Feynman diagrams that can produce this process. (Note that as far as madgraph is concerned, p and p contain the same partons.)

After you click "Generate Process", the program will take a little while and then direct you to a page for this process. If you click on the "Process Information" link you get to see all of the relevant processes and links to all of the Feynman diagrams.

Play with these a little bit, and enter different processes that you can think of to get an idea. Examples that I can think of are pp>tt~ or including decays: pp>tt~>bb~w+w-.

Two processes you should look at are the two single top ones: pb>tj, which is t-channel single top quark production, and pp>tb~, which is s-channel single top quark production.

For these last two, you should not only look at the Feynman diagrams but also produce events. Here's how to do that: The button "Code Download" allows you to download a .tar.gz file that does some event generation. Download it. Untar it and follow the instructions in the README file to run it. You should edit the Cards/run_card.dat file and adjust the following parameters:
# Collider type and energy                                           *
        1     = lpp1  ! beam 1 type (0=NO PDF)
       -1     = lpp2  ! beam 2 type (0=NO PDF)
      980     = ebeam1  ! beam 1 energy in GeV
      980     = ebeam2  ! beam 2 energy in GeV 

If you are on one of the Fermilab machines, then you will need to do a "setup D0RunII" in order to get the compiler set up before you generate events. If you are anywhere else in the world, the compiler should already be set up properly. Run the ./bin/generate_events script. You should run serial and give a reasonable name, and then you just wait for events to be generated.

Then when you have an output file, you can use the web interface again to produce a root file and decay the top quark. Go to the "Tools" -> "Decay Interface" page. Browse to the Events/*_unweighted_events.lhe.gz file and load it. Select that you do want root output. Since your two single top files have a top quark in them, select the decay t > b ve e+. Then click on "Upload & Decay". After a while you'll get a page with links, one of which is the root file. Download the root file.

Download the ExRootAnalysis package from the "Downloads" tab. Follow the instructions to produce the library and then run the simple macro given in the Readme file at in order to produce your first histograms.

Once you have a histogram of jetPT and Mass as in the example macro we should talk again.

These instructions are quite long and it is likely that I missed something somewhere. There are also many steps involving topics you probably aren't familiar yet, and this is supposed to be a learning experience. Let me know if you get stuck or if you have any questions.

Emily Johnson has done a study of single top with CDF-style cuts.

-- ChipBrock - 24 May 2007 -- ReinhardSchwienhorst - 10 Sep 2007

Instructions for New Users of MadEvent and ROOT by Andrew Chegwidden and Jacob Parsons, 3 Aug 2011:

We've created these instructions as a starting point for any student using MadEvent. The scope of these instructions is limited to generating a ROOT file from MadEvent, performing cuts, and creating histograms from code.

They are meant as a starting point from which one can develop a more in-depth analysis of SM and BSM processes at the parton level.

Getting Started and Output Code Generation

The first step in the process is signing up for an account at Once your account is established you can begin to generate your processes. You have a choice of what model you want MadEvent to follow as well as the process you wish to study. There is a decent list of examples and formats in a link next to the input field. Our initial study focused on the production of the W Boson together with the top quark (p p > w- t). Once you've input your desired process you'll need to select your desired p and j definitions. Our study required p to stand for all possible quarks (the last line of the drop down menu).

Clicking submit will send you to a page where you can download the output code. You will get the appropriate Feynman diagram if it worked properly.

On this page you can download the the output code as a "tar" file which you can use the command line "tar -xzf" to unpack it.

Changing Attributes, Generating Events, Decay Interface, and ROOT Output File

Once the files are unpacked the user has the ability to change certain attributes before you generate events as well as see what the cross sections . In our analysis we changed the beam energies in the ~/Cards/run_card.dat file (lines 38 and 39) to better represent what's coming out of the LHC.

# Number of events and rnd seed                                      *
  10000       = nevents ! Number of unweighted events requested 
      0       = iseed   ! rnd seed (0=assigned automatically=default))
# Collider type and energy                                           *
        1     = lpp1  ! beam 1 type (0=NO PDF)
        1     = lpp2  ! beam 2 type (0=NO PDF)
     3500     = ebeam1  ! beam 1 energy in GeV
     3500     = ebeam2  ! beam 2 energy in GeV

Other cards can be manipulated as the user sees fits. We did not make any other changes for this analysis.

Once the user has made his changes he can generate events from the command line by "./bin/generate_events". We ran a serial run because the calculations were so short. In some instances the ~Cards/param_card.dat file may need to be edited. If this is the case you can utilize MadEvent's calculators under the Tools heading. One should use this tool as opposed to doing the editing by hand.

Once the events have been generated a locally produced output "LHE" file will be created. If a decay is requested this LHE file can be uploaded to the MadEvent site under Tools-->Decay Interface. You'll need to upload the locally produced LHE file and request a SM model decay. If you only want to look at one decay and would like a ROOT output then just click Upload & Decay. If, however, you would like to further decay the events then you will need to perform multiple decays on successive LHE files.

Once you've finished running the decay process you can download the final ROOT file which you can analyze and use to generate various histograms.

Process Information and Results & Feynman Diagrams

Once the tar file has been unpacked and events have been generated an html file is created in the directory called index.html. This file is what is called the "MadEvent Card"on the website. It is specific to the process which the user has inputted. Opening up the file yields links to other files within the directory (it is important to not rename or move files once the code has been unpacked).

Below is an example of an index.html file (links on the page are local directory links)

Clicking on the "Process Information Link" will send the user to a page which shows which processes and subprocesses yield the production of a W- boson and top quark. The user should recall that he told MadEvent that the p (proton) definition should include gluons and the up, down, bottom, and strange quarks/anti-quarks. The strange and bottom quark/anti-quarks are obviously virtual particles which are referred to as the "quark sea" or "sea quarks." The production of the W- boson and top quark does not stem from any processes dealing with virtual particles. Other products such as the production of ttbar are produced as a result of virtual particle interactions. The user can see this for himself by completing the whole procedure again with the p p > t t~ input process.

This page also has links to the Feynman diagrams. Below is the postscript diagrams for the g b > w- t process.

The user can see that these two Feynman diagrams correspond to the g b > w- t and b g > w- t subprocesses shown on the Process Information page.

Also on the Process Information page is a link to the proc_card_mg5.dat file which gives an overview of the model, input process, and p/j definitions requested by the user.

Results and Event Database

From the index.html file the user can navigate to the Results and Event Database page. This page shows the total cross section for the process as well as the run name, information on the collider, and the number of events generated. Clicking on the "results" link sends the user to a page which again shows the user the total cross section. The P0_gb_wmt link navigates the user to the Feyman diagrams (two in this case as a result of two subprocesses). Clicking on the link under the Cross Sect lets the user see the cross section of the two subprocesses.

Generating Histograms From Code

Specific histograms can be created by utilizing c++ code to create macros. This is most easily done by utilizing the ROOT command line to open up the ROOT file. Once open, use the .ls command to view the list of trees within the ROOT file. Usually there are only 1 or 2 trees within the file. Use the MakeClass command on the tree you want to work on (for example, one of the trees we found using .ls was called "LHEF", so we entered "LHEF->MakeClass("myMacro")" where "myMacro" is the name you choose to give the .h/.C files outputted by the process. In this example the files myMacro.h and myMacro.C will be created automatically). The .h file's purpose is to associate the raw data of the root file with variables the user can work with, the .C file is used to loop through each event containing these variables. After spending some time figuring out the internal structure of these files, the user can edit them to create histograms specific to desired particles/properties/cuts/etc.

An additional file (with extension .C) must be created from scratch. In this file, an object of the class defined in the .h/.C files must be created and the Loop function defined in the original .C file must be applied to the object. Make sure that all four files (the original root file, the auto-generated .h/.C files, and the final .C file) are in the same directory and then execute the final .C file as a macro in ROOT. The attached files take the input root file and generates a histogram of electron transverse momentum. The attached files have specific comments embedded in the code:

  • myMacro.h: Associate raw data with defined variables

Any number of histograms can be generated using this code as a format. Additionally, users can make cuts and loop over all events.

One such histogram which the user may be interested in creating is the MET (missing transverse energy). Neutrinos pass right through a real detector leaving missing energy. This missing energy can be calculated. MadEvent, which is an ideal detector simulator, tracks these neutrinos. The user could utilize 4-vectors to determine the transverse energy of these neutrinos within MadEvent which would be missing within a real detector.

Once you become familiar with utilizing the computational advantages of MadEvent and developing ROOT macros you can begin to filter out any background which may obsure the specific process you wish to study.

In MadEvent the user asks the program to create events involving only one process with subsequent decays into a final state. Our initial study concentrated on the production of a W Boson together with a top quark (W- t) with a final state consisting of two leptons (electron and positron), two electron neutrinos, and one jet. Other processes may leave very similar final states. Consider the production of a top quark along with a top anti-quark (ttbar). If both W Bosons (W+ from top quark decay and W- from top anti-quark decay) decay into leptons and neutrinos (dileptonic channel) then the final state is exactly the same as the W- t process except for the presence of another jet (the hadronization of the bbar which came from the tbar decay). Producing the same histograms for the ttbar process would allow the user to look for possible differences between the two processes and may allow the user to subtract out the background (the ttbar process). All of this is transparent within MadEvent but not a physical detector. Herein lies MadEvent's usefulness.

Histograms and Source Code by Andrew Chegwidden and Jacob Parsons, 1 Aug 2011:

Below we present our source code for our initial analysis of single top production in the W-t channel. While the W-t process has numerous backgrounds associated with it, we chose to only focus on the ttbar background. We have chosen not to include our histograms in this TWiki because it is much easier to upload changes in code than it is to upload all new histograms. If the user wishes to view the histograms he/she must download the "Pre.root" file as well as copy and past the code into an editor. It is important to note that the file names should not be changed. Once all files are saved in a common directory the user should use the following terminal commands:

bash-3.2$ cd foldername
bash-3.2$ root WTEx.C
root [0] .q
bash-3.2$ root WTOutput.root
bash-3.2$ TBrowser tb

This will open up the TBrowser where the user can view, manipulate, and save any histogram

***Insert Code Here****

In this code the user can create any cut he desires utilizing a boolean statement. Typically the statement will be something like "if this quantity of this particle is greater than this number, then...." Within this if statement is where the user should fill his histograms. If the statement returns a "false" then the histogram will not be filled with that event. The user should keep in mind that MadEvent is a truth simulator and has information on where each individual particle came from and is able to separate the final and intermediate state particles exactly (very unlike an actual detector).

While we will not present the many nuances of our code here in this forum we would like to make the reader aware of one important facet. Once the user has run the LHE file through the Decay Interface on the MadGraph website, the output root file labels each particle with a status. This status, which is read as a number, correpsponds to whether the particle is an initial, intermediate, or final state particle. When making cuts it may be important to implement cuts only on certain status numbers. We present an example below:

Cuts on Particles
When defining a jet the user should require that the final state quarks should have energy greater than 25GeV. However, as the user can see from the Feynman diagrams of the g b > w- t process (see above for directions to these diagrams), there is a bottom quark in the initial state. It is the initial interaction of a bottom quark and a gluon that gave rise to all the data. There is also a bottom quark as a final state. It is this final state bottom quark to which we wish to apply the cuts. If the user naively inputs the statement "if bottom quark PT is greater than 25Gev...." he will accidently make cuts on the initial state bottom quark as well as the final state bottom quark.

ROOT identifies initial particles (in this case the bottom quark and gluon) as having a status number of -1. Intermediate particles (in this case the W &, W+ bosons and the top quark as having a status number of 2. Final state particles (in this case the leptons and neutrinos) as having a status number of 1.

So the user needs to be cognizant of where in the interaction/decay chain he wishes to make cuts and utilize the "Particle.Status" variable to implement those cuts.

-- AndrewChegwidden - 3 Aug 2011 -- JakeParsons - 3 Aug 2011
Topic attachments
I Attachment Action Size Date Who Comment
Histograms_Lime_2.pdfpdf Histograms_Lime_2.pdf manage 128.5 K 27 Jul 2011 - 18:55 AndrewChegwidden  
Histograms_Lime_3.pdfpdf Histograms_Lime_3.pdf manage 431.4 K 27 Jul 2011 - 18:55 AndrewChegwidden  
Histograms_Lime_4.pdfpdf Histograms_Lime_4.pdf manage 249.5 K 27 Jul 2011 - 18:56 AndrewChegwidden  
Lime.rootroot Lime.root manage 100.2 K 27 Jul 2011 - 18:55 AndrewChegwidden Output ROOT file to be run in ROOT
LimeClass.CC LimeClass.C manage 9.2 K 27 Jul 2011 - 18:54 AndrewChegwidden Loop through each event
LimeClass.hh LimeClass.h manage 12.1 K 27 Jul 2011 - 18:54 AndrewChegwidden Associate raw data with defined variables
LimeEx.CC LimeEx.C manage 0.2 K 27 Jul 2011 - 18:54 AndrewChegwidden Executable to be run in ROOT
LimePre.rootroot LimePre.root manage 5937.5 K 27 Jul 2011 - 18:55 AndrewChegwidden Input ROOT file from MadEvent
WTFeynmanDiagrams.psps manage 12.9 K 03 Aug 2011 - 17:52 AndrewChegwidden W-t Feynman Diagrams
index.htmlhtml index.html manage 1.9 K 03 Aug 2011 - 18:31 AndrewChegwidden MadEvent Card for W-t Process
input.rootroot input.root manage 5937.5 K 12 Jul 2011 - 20:29 AndrewChegwidden Input ROOT file from MadEvent
myMacro.CC myMacro.C manage 2.3 K 12 Jul 2011 - 20:30 AndrewChegwidden Loop through each event
myMacro.hh myMacro.h manage 8.7 K 12 Jul 2011 - 20:29 AndrewChegwidden Associate raw data with defined variables
myMacroEx.CC myMacroEx.C manage 0.5 K 12 Jul 2011 - 20:30 AndrewChegwidden Executable to be run in ROOT
Edit | Attach | Print version | History: r46 | r35 < r34 < r33 < r32 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r34 - 04 Aug 2011, AndrewChegwidden

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback