Fork me on GitHub

Version 8 (modified by mselvaggi, 13 months ago) (diff)


Student Project BND - Spa September 2019


To successfully run this tutorial the following prerequisite packages should be installed:

  • gfortran/gcc/tcl:

For linux users gcc/tcl should be already installed. For Mac users you should install XCode.

  • ROOT:

can be downloaded from Go on latest release, and download a version under "Binary distributions".

  • MadGraph5

a version of MG5 can be downloaded here:

  • Delphes

start from here:

  • Pythia8:

following instructions from here (or using the Pythia8 installation in MadGraph):

0) Download data sample

From the Delphes main directory, download the pseudo-data file data.root :

wget -O data.root

1) Access information in the ROOT file

Open the ROOT file (ignore the various warnings) and visualize its content via the TBrowser.

root -l data.root
TBrowser t;

Open the Delphes Tree and then Event branch (by double-clicking). How many events are in this dataset? Likewise explore the Tree content by looking at other branches.

Non trivial information can also be plotted from the command line.

TFile *f = TFile::Open("data.root");
TBrowser browser;

Some information is not directly accessible from the browser interface but can nevertheless be access via command line. Every Delphes object has a 4-vector (called P4()) member of type TLorentzVector (see here for documentation:

So for example to plot the magnitude of the 3-momenta of the jets, or the jet invariant mass:


In order to perform an event-loop with a more sophisticated event selection you will have to write a small python macro. This macro takes as input the data.root and produce an output file that contains a couple of histograms. Copy paste inside a file called, and run it via the command python histograms.root. The histograms.root file can then be browsed as done before with the data file.

# example event loop macro
#!/usr/bin/env python

import sys
import ROOT

if len(sys.argv) < 2:
  print " Usage: python data.root histograms.root"


  ROOT.gInterpreter.Declare('#include "classes/SortableObject.h"')
  ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"')
  ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"')

inputFile = sys.argv[1]
outputFile = sys.argv[2]

# Create chain of root trees
chain = ROOT.TChain("Delphes")

# Create object of class ExRootTreeReader
treeReader = ROOT.ExRootTreeReader(chain)
numberOfEntries = treeReader.GetEntries()

# Get pointers to branches used in this analysis
branchMuon = treeReader.UseBranch("Muon")
branchJet = treeReader.UseBranch("Jet")

# Book histograms
histMuonMultiplicity = ROOT.TH1F("histMuonMultiplicity", "M_{recoil} [GeV]", 60, 100.0, 160.0)

ptot = ROOT.TLorentzVector(0.,0.,0.,240.)
# Loop over all events
for entry in range(0, numberOfEntries):
  # Load selected branches with data from specified event

  # If event contains at least 2 muons
  if branchMuon.GetEntries() > 1:

    mu1 = branchMuon.At(0)
    mu2 = branchMuon.At(1)

    pll = mu1.P4() + mu2.P4()
    ph = ptot - pll


out_root = ROOT.TFile(outputFile,"RECREATE")

Attachments (2)

Download all attachments as: .zip