--
LauraBarrancoNavarro - 2019-04-15
Generate tW scattering signal samples with MadGraph5 _aMC@NLO in lxplus
This twiki will guide you into the process of generating signal (and some backgrounds) samples for the tW scattering process using
MadGraph5 _aMC@NLO in lxplus.
Signal and background processes
Section based on
arXiv:1511.03674v2.
The scattering of top quarks with
W,
Z and Higgs boson is described by the following lagrangian:
where, according to the SM, all couplings are 1 except c_RR, which banishes.
BSM effects modifyint the couplings of the top and bottom to the
W,
Z and Higgs with respect to the SM can be parameterized by operators of dim-6:
where the couplings accompanying the dim-6 operators are related to the couplings in the SM Lagrangian as:
We are going to focus on the couplings of the top quark to the
Z boson, both because they have an impact on the scattering processes and because they are weakly constrained by direct measurements.
The couplings we are considering are then:
The collider process of interest is
pp → t\bar{t}Wj, which arises at O(g_s,(g_w)^3) in the gauge couplings and we will call it (ttWj)_EW from now on. An example of feynman diagram of a signal process is shown below.
The main irreducible background is the ttW+jets production at order ^3 in the strong coupling, as shown in the following diagram. This process will be called (ttWj)_QCD from now on.
Downloading and installing MadGraph5 _aMC@NLO in lxplus
ssh -Y USERNAME@lxplus6.cern.ch
- On a fresh terminal tab, secure-copy the tar file you just downloaded to you desired working directory in afs
scp MG5_aMC_v2.6.5.tar.gz USERNAME@lxplus.cern.ch:/afs/cern.ch/work/l/USERNAME/
- Go to your lxplus session and setup your environment:
setupATLAS
lsetup "root 6.14.04-x86_64-slc6-gcc62-opt"
- Now untar the file you copied before
tar -zxvf MG5_aMC_v2.6.5.tar.gz
- You can test if it is working by trying to run it:
cd MG5_aMC_v2_6_5
./bin/mg5_aMC
- If it worked, try installing some packages that you will need later:
MG5_aMC>install MadAnalysis5
MG5_aMC>install pythia8
MG5_aMC>install Delphes
- If you are not familiar with MadGraph, type "tutorial" and follow the instructions for a nice introduction.
Downloading and installing SMETFsim package
SMEFTsim (
arXiv:1709.06493) is a package which provides a complete
FeynRules implementation of the B-conserving dim-6 Lagrangian in the Warsaw basis.
This reference also gives a nice overview on the operators implemented in the package.
- Go to https://feynrules.irmp.ucl.ac.be/wiki/SMEFT and download the pre-exported UFO files (at the bottom of the page) for the flavor-general SMEFTsim model A and scheme m_W
- Secure-copy the tar file in your working directory, under MG5_aMC_v2_6_6/models
scp SMEFTsim_A_general_MwScheme_UFO_v2.tar.gz lbarranc@lxplus.cern.ch:/afs/cern.ch/work/l/lbarranc/MG5_aMC_v2_6_5/models/
- Go to your lxplus session and untar de file
tar -zxvf SMEFTsim_A_general_MwScheme_UFO_v2.tar.gz
- Try running MadGraph and exporting the model to test that everything went right
./bin/mg5_aMC
MG5_aMC>import model SMEFTsim_A_general_MwScheme_UFO_v2-SMlimit
Generating the SM signal sample
In the last command, the last part of the line, "-SMlimit", enables the usage of the SMEFTsim package with the SM constrains, i.e., sets the Wilson coefficients of the dim-6 operators to zero. You can see the card used in "MG5_aMC_v2_6_5/models/SMEFTsim_A_general_MwScheme_UFO_v2/restrict_SMlimit.dat"
Creating scripts
Instead of typing the commands on the interactive
MadGraph session, it is more useful to write them in a script.
- Create a directory to store the different scripts
mkdir scripts
cd scripts
- Create a file for the SM signal sample at 13 TeV
vi SM_signal_13TeV.txt
- and copy the following lines:
##########################################
# MADGRAPH SCRIPT #
##########################################
# SM Settings using SMEFTsim-setA package
#-----------------------------------------
# Multiparticle W = W+ and W-
define w w+ w-
# Import UFO model with SM restriction (use Mw scheme and fully general flavor assumption)
import model SMEFTsim_A_general_MwScheme_UFO_v2-SMlimit
#Generate the ttWj process with QED=3 and QCD=1 (this is our signal)
# NP=1 means SM + signal + interference
generate p p > t t~ w j QED=3 QCD=1 NP=0
# Save the output on a directory named SM_signal_13TeV
output SM_signal_13TeV
# Launch events
launch SM_signal_13TeV
# Modify the run card
set nevents 50000 # Change number of events
set ebeam1 6500.0 # Change beam energies to 13 TeV
set ebeam2 6500.0 # Change beam energies to 13 TeV
launch SM_signal_13TeV -i
print_results --path=./SM_signal_13TeV.txt --format=short #This will save the cross-section in a txt file
- Go back to the main folder and run MadGraph with this script
cd ..
./bin/mg5_aMC scripts/SM_signal_13TeV.txt
If the previous step went well, when it finishes you'll have, in the main folder, a txt file named "SM_signal_13TeV.txt". The file lists the run_name, the tag, the cross section in picobarns, its error and the generated number of events.
In addition, you'll have a new directory named "SM_signal_13TeV"
Generating new physics signal samples
In this case, instead of using the SM restriction, we will create a restriction card for each signal sample we want to create.
The first signal sample we want to create is for \Delta_R = 1. This is equivalent to set C_\phi_u^(33) to 4.9.
- Copy the SM restriction card into a new restriction card where we will change this coupling
cd /models/SMEFTsim_A_general_MwScheme_UFO_v2
cp restrict_SMlimit.dat restrict_SMlimit_CR4p9.dat
- Open the file restrict_SMlimit_CR4p9.dat, find the line that contains "cHuAbs33" and replace the value "1.000000e-99" by "0.490000e+01"
You can check the equivalence between the EFT couplings and their names inside the restriction cards in
This reference.
- Create a new script to implement the changes
cd ../../scripts
vi CR_4p9_signal_13TeV.txt
- Paste the following lines
##########################################
# MADGRAPH SCRIPT #
##########################################
# CR4p9 Settings using SMEFTsim-setA package
#-----------------------------------------
# Multiparticle W = W+ and W-
define w w+ w-
# Import UFO model with \Delta_R = 1 restriction (use Mw scheme and fully general flavor assumption)
import model SMEFTsim_A_general_MwScheme_UFO_v2-SMlimit_CR4p9
#Generate the ttWj process with QED=3 and QCD=1 (this is our signal)
# NP=1 means SM + signal + interference
generate p p > t t~ w j QED=3 QCD=1 NP=1
# Save the output on a directory named CR4p9_signal_13TeV
output CR4p9_signal_13TeV
# Launch events
launch CR4p9_signal_13TeV
# Modify the run card
set nevents 50000 # Change number of events
set ebeam1 6500.0 # Change beam energies to 13 TeV
set ebeam2 6500.0 # Change beam energies to 13 TeV
launch CR4p9_signal_13TeV -i
print_results --path=./CR4p9_signal_13TeV.txt --format=short #This will save the cross-section in a txt file
Generating background samples
As stated before, the main irreducible background is the ttW+jets production at order ^3 in the strong coupling. To generate a sample of this background, just copy and paste the SM script into a new script and change the order of the interactions to
generate p p > t t~ w j QED=1 QCD=3 NP=0
Simulating parton shower and detector reconstruction
Parton shower simulation
Pythia [
arXiv:1410.3012] is a tool to evolve the generated events from the hard-scattering process to the multi-particle final state (including ISR/FSR, parton showering and hadronisation among others). It runs over the "unweighted_events.lhe.gz" created by
MadGraph and stored in the Events folder. To run it, do the following
cd SM_signal_13TeV
./bin/madevent
- From inside the interactive session do
SM_signal_13TeV>pythia8 run_01
To run only pythia8 and with default settings, type 0 twice when prompted. The output of pythia will be stored in a file called "tag_1_pythia8_events.hepmc.gz" under the Events folder.
Detector simulation
The final step of the simulation is to run the detector simulation. For that, we will use Delphes [
arXiv:1307.6346]. For this, got to the Delphes folder in the main
MadGraph folder.
- First, you need to unzip the Pythia output
gunzip ../SM_signal_13TeV/Events/run_01/tag_1_pythia8_events.hepmc.gz
- Now, you can run Delphes with the following command
./DelphesHepMC cards/delphes_card_CMS.tcl SM_signal_13TeV.root ../SM_signal_13TeV/Events/run_01/tag_1_pythia8_events.hepmc
- The syntax of the command is the following
./DelphesHepMC DELPHES_CONFIG_CARD OUTPUT_ROOT_FILE_NAME INPUT_HEPMC_FILE
A root file containing a tree with all the events at reconstruction level will be created as "Delphes/OUTPUT_ROOT_FILE_NAME".
Bonus track
Run everything in one go
In the previous example, we run everything in separate steps. While this is useful to run tests and to save time when debugging the different steps, it is also possible to run the three steps from a single config file. To do that, you can edit the script file in the following way:
##########################################
# MADGRAPH SCRIPT #
##########################################
# SM Settings using SMEFTsim-setA package
#-----------------------------------------
# Multiparticle W = W+ and W-
define w w+ w-
# Import UFO model with SM restriction (use Mw scheme and fully general flavor assumption)
import model SMEFTsim_A_general_MwScheme_UFO_v2-SMlimit
#Generate the ttWj process with QED=3 and QCD=1 (this is our signal)
# NP=1 means SM + signal + interference
generate p p > t t~ w j QED=3 QCD=1 NP=0
# Save the output on a directory named SM_signal_13TeV
output SM_signal_13TeV
# Launch events
launch SM_signal_13TeV
# Set Pythia on
shower = ON
# Set detector simulation on
detector = ON
# Use CMS (Default is ATLAS)
/afs/cern.ch/work/l/lbarranc/MG5_aMC_v2_6_5/SM_signal_13TeV/Cards/delphes_card_CMS.dat
# Modify the run card
set nevents 50000 # Change number of events
set ebeam1 6500.0 # Change beam energies to 13 TeV
set ebeam2 6500.0 # Change beam energies to 13 TeV
launch SM_signal_13TeV -i
print_results --path=./SM_signal_13TeV.txt --format=short
Multi-run
It is recommended not to generate more than 100k events per run. The multi-run command runs sequentially several number of runs, which is equivalent to run generate_events multiple times. When running with multi-run though, the random seed is different for each run and the lhe files are combined into a single run. To to do this, you need to replace in your script the line that launches the generation by
# Launch events
launch SM_signal_13TeV -i
multi_run 10
This will run the generation 10 times with the number of events specified in the script file in each run, so you'll end up with 10xnevents. The output of each of the runs will be stored unther the Events folder in subfolders names "run_01_N" and the merged unweighted files will be stored in run_01 directory.
To run the detector simulation, you will need to unzip all the pythia files from each run and pass all of them in the command line, for example:
./DelphesHepMC DELPHES_CONFIG_CARD OUTPUT_ROOT_FILE_NAME INPUT_HEPMC_FILE_1 INPUT_HEPMC_FILE_2 INPUT_HEPMC_FILE_3 ...
Signal reweighting
As seen in the previous sections of the twiki, the different stages of the simulation ar independent from each other. Moreover, when going through the examples it is easy to realise that the parton shower and detector reconstruction stages are the slowest ones. One possibility to overcome this issue is to generate large samples under a SM hypothesis and then change the weight of each event in the sample to deform the probability functions associated to the parton-level events in the phase space to account for an alternative theory or benchmark point.
MadGraph implements different ways of performing the reweighting and more details can be read in
arXiv:1607.00763
To run the reweighting, we first need to export $PYTHONDIR as the path the folder above the bin and lib folder:
echo "export PYTHONDIR=/afs/cern.ch/sw/lcg/external/Python/2.7.3/x86_64-slc6-gcc48-opt" >> $HOME/.bashrc
Then update $PYTHONPATH and $LD_LIBRARY_PATH:
<code>echo "export PYTHONPATH=$PYTHONPATH:$ROOTSYS/lib" >> $HOME/.bashrc</code>
<code>echo "export LD_LIBRARY_PATH=$ROOTSYS/lib:$PYTHONDIR/lib:$LD_LIBRARY_PATH:/opt/rh/python27/root/usr/lib64" >> $HOME/.bashrc</code>
Since we want to change the model, we need to point
MadGraph to a valid param_card for the new model. The param card is updated when running
MadGraph with a specified restriction card. We can copy the param_card that was created when we generated the new physics signal sample:
cp CR4p9_signal_13TeV/Cards/param_card.dat models/SMEFTsim_A_general_MwScheme_UFO_v2/param_card_CR4p9.dat
We now run
MadGraph interactively:
./bin/mg5_aMC
define w w+ w-
import model SMEFTsim_A_general_MwScheme_UFO_v2-SMlimit
generate p p > t t~ w j QED=3 QCD=1 NP=1
output SM_signal_13TeV_rwt
launch SM_signal_13TeV_rwt
Note that this time we specified "NP=1". This won't have an effect since we are implementing the SM restriction card, but will avoid problems when running the reweighting (i.e., we don't need to change the process, only the model).
We will be asked to switch the programs we want to run. We will the reweight on:
reweight=ON
We will then modify the run card to specify the number of events:
set nevents 50000 # Change number of events
And the reweighing card by pressing "3", and we will copy the following lines:
change model SMEFTsim_A_general_MwScheme_UFO_v2-SMlimit_CR4p9
launch
/PATH_TO_MADGRAPH//SMEFTsim_A_general_MwScheme_UFO_v2/param_card_CR4p9.dat
This will generate an "unweighed_events" file which will include an additional "rewight" tree with the information about the reweighting.
Analysing the output
Read unweighted_events.lhe file
(You might need centos7)
To create a root file from the lhe file, we need to install
ExRootAnalysis. To do that, we first need to add the following lines to our ~/.bashrc files:
export ROOTSYS=/usr
export PATH=$PATH:$ROOTSYS/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ROOTSYS/lib
Now we can run
MadGraph and install
ExRootAnalysis:
./bin/mg5_aMC
install ExRootAnalysis
To run it, we first unzip the lhe file:
gunzip SM_signal_13TeV_rwt/Events/run_01/unweighted_events.lhe.gz
sdsdf
ExRootAnalysis /ExRootLHEFConverter SM_signal_13TeV_rwg/Events/run_01/unweighted_events.lhe SM_signal_13TeV_rwg/Events/run_01/unweighted_events.root
Preselection
Plots and tables