Skip to content

Commit

Permalink
Merge pull request #416 from sarahgaiser/wab_gen_update
Browse files Browse the repository at this point in the history
adding MG5 WAB generator
  • Loading branch information
mgignac authored Dec 13, 2024
2 parents 4c1ca17 + 9c0043c commit 81c21da
Show file tree
Hide file tree
Showing 402 changed files with 208,200 additions and 12 deletions.
4 changes: 4 additions & 0 deletions examples/wab_gen_mg5/.hpsmc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Job]
dry_run = False
enable_file_chaining = True
check_output_files = False
1 change: 1 addition & 0 deletions examples/wab_gen_mg5/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm -rf scratch output &> /dev/null
17 changes: 17 additions & 0 deletions examples/wab_gen_mg5/job.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"run_number": 14185,
"bunches": 1000,
"nevents": 1000,
"seed": 123,
"run_params": "3pt74",
"target_thickness": 0.002,
"beam_energy": 3740.0,
"num_electrons": 1500,
"target_z": 0.0,
"output_files": {
"WAB_unweighted_events.lhe.gz": "wab_unweighted_3pt74_1.lhe.gz",
"WAB_unweighted_events_rot.stdhep": "wab_unweighted_3pt74_rot_1.stdhep"
},
"output_dir": "output",
"job_id": 1
}
16 changes: 16 additions & 0 deletions examples/wab_gen_mg5/job.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"run_number": {{ run_number }},
"bunches": {{ bunches }},
"nevents": {{ nevents }},
"seed": {{ 110001 + job_id }},
"run_params": "{{ run_params }}",
"target_thickness": {{ target_thickness }},
"beam_energy": {{ beam_energy }},
"num_electrons": {{ num_electrons }},
"target_z": {{ target_z }},
"output_files": {
"WAB_unweighted_events.lhe.gz": "wab_unweighted_{{ run_params }}_{{ job_id }}.lhe.gz",
"WAB_unweighted_events_rot.stdhep": "wab_unweighted_{{ run_params }}_rot_{{ job_id }}.stdhep"
},
"output_dir": "output"
}
1 change: 1 addition & 0 deletions examples/wab_gen_mg5/mkjobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hps-mc-job-template -j 1 -r 10 -a vars.json job.json.tmpl jobs.json
6 changes: 6 additions & 0 deletions examples/wab_gen_mg5/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#/bin/bash
#SBATCH --ntasks=1
#SBATCH --time=6:00:00
#SBATCH --job-name=examples

hps-mc-job run -d $PWD/scratch wab_gen_mg5 job.json
10 changes: 10 additions & 0 deletions examples/wab_gen_mg5/vars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"run_number": [14185],
"bunches": [10000],
"nevents": [10000],
"run_params": ["3pt74"],
"target_thickness": [0.002],
"beam_energy": [3740.00],
"num_electrons": [1500],
"target_z": [0.0]
}
10 changes: 10 additions & 0 deletions examples/wab_gen_mg5/wab_gen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
WAB generation and sampling {#wabgensample}
===========================

This is an example of how to use wab_gen_sample_job.py. The job generates wab events using MadGraph5 and transforms the output from lhe to stdhep to then rotate the events into beam coordinates.

#### Job parameters
There are no special run parameters that need to be set for this job other than the general ones discussed on the [examples main page](@ref examples).

#### Job template
This example includes a job template. The variables used in this template mostly have the same name and meaning as the job parameters above. Their values are set in `vars.json`.
14 changes: 7 additions & 7 deletions examples/wab_gen_sample/job.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"nevents": 1000,
"run_params": "3pt7",
"run_params": "3pt74",
"target_thickness": 0.002,
"beam_energy": 3700.00,
"beam_energy": 3740.00,
"num_electrons": 1500,
"param_card": "MG_mini_WAB/AP_6W_XSec2_HallB/Cards/param_card.dat",
"seed": 7614876,
"seed": 123,
"output_files": {
"wab_unweighted_events.stdhep": "wab_unweighted_events_3pt7_1.stdhep",
"wab_unweighted_events_rot.stdhep": "wab_unweighted_events_3pt7_rot_1.stdhep",
"wab_unweighted_events_rot_sampled.stdhep": "wab_unweighted_events_3pt7_rot_sampled_1.stdhep"
"wab_unweighted_events.stdhep": "wab_unweighted_events_3pt74_1.stdhep",
"wab_unweighted_events_rot.stdhep": "wab_unweighted_events_3pt74_rot_1.stdhep",
"wab_unweighted_events_rot_sampled.stdhep": "wab_unweighted_events_3pt74_rot_sampled_1.stdhep"
},
"output_dir": "output/2019/",
"output_dir": "output",
"job_id": 1
}
7 changes: 3 additions & 4 deletions examples/wab_gen_sample/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/scl enable devtoolset-8 -- /bin/bash
#/bin/bash
#SBATCH --ntasks=1
#SBATCH --time=24:00:00
#SBATCH --partition=shared
#SBATCH --time=6:00:00
#SBATCH --job-name=examples

hps-mc-job run -d $PWD/scratch wab_gen_sample job.json
hps-mc-job run -d $PWD/scratch $PWD/wab_gen_sample_job.py job.json
32 changes: 32 additions & 0 deletions examples/wab_gen_sample/wab_gen_sample_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""!
@file wab_gen_sample_job.py
Python script for generating sampled WAB events in StdHep format from an input LHE file.
The output events can be used as input to 'merge_job.py' with a beam StdHep file to for creating a
wab-beam sample file.
"""

from hpsmc.generators import MG5
from hpsmc.tools import BeamCoords, MergePoisson
from hpsmc.generators import StdHepConverter

job.description = 'WAB gen and sampling'

## generate tritrig in MG5
mg = MG5(name="WAB")

# check that at least 80% of the requested events were generated or fail the job
# check = LHECount(minevents=params.nevents*0.8, inputs=["wab_unweighted_events.lhe.gz"])
## Convert wab events to stdhep
cnv = StdHepConverter(inputs=mg.output_files(), outputs=['wab_events.stdhep'])

## Rotate WAB events into beam coordinates
rot = BeamCoords()

## Sample wabs using poisson distribution, calculating mu from provided cross section
sample = MergePoisson(input_filter='wab',
input_files=['wab_unweighted_events_rot.stdhep'],
output_files=['wab_unweighted_events_rot_sampled.stdhep'],
xsec=7.55e10)

## Add components -> add check and sample as needed
job.add([mg, cnv])
20 changes: 20 additions & 0 deletions generators/madgraph5/src/WAB/Cards/.delphes_trigger.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#TRIGGER CARD # DO NOT REMOVE THIS IS A TAG!

# list of trigger algorithms
# trigger_name >> algorithm #comments
Inclusive electron >> ELEC1_PT: '29'
di-electron >> ELEC1_PT: '17' && ELEC2_PT: '17'
Inclusive Photon >> GAMMA1_PT: '80'
di-Photon >> GAMMA1_PT: '40' && GAMMA2_PT: '25'
Inclusive muon >> MUON1_PT: '19'
di-muon >> MUON1_PT: '7' && MUON2_PT: '7'
Taujet and ETmis >> TAU1_PT: '86' && ETMIS_PT: '65'
di-Taujets >> TAU1_PT: '59' && TAU2_PT: '59'
Jet and ETmis >> JET1_PT: '180' && ETMIS_PT: '123'
Taujet and electron >> TAU1_PT: '45' && ELEC1_PT: '19'
Taujet and muon >> TAU1_PT: '40' && ELEC1_PT: '15'
Inclusive b-jet >> Bjet1_PT: '237'
Inclusive 1 jet >> JET1_PT: '657'
Inclusive 3 jets >> JET1_PT: '247' && JET2_PT: '247' && JET3_PT: '247'
Inclusive 4 jets >> JET1_PT: '113' && JET2_PT: '113' && JET3_PT: '113' && JET4_PT: '113'

203 changes: 203 additions & 0 deletions generators/madgraph5/src/WAB/Cards/.plot_card.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
#**************************************************************************
# Card for MadAnalysis *
# *
# This file is used to set the classes and options for *
# the MadAnalysis program. *
# *
# *
# Some comments about the classes *
# 1. Plots are for classes of particles. *
# 2. Each particle is identified by its PDG code. *
# 3. Classes names are arbitrary (4 symbols max, no spaces allowed). *
# 4. Particles in the same class will be ordered with the 'ordering *
# function' in the file in_func.f. *
# 5. Classes can be added/edited/removed at will, and given a name *
# that will then appear in the plots. *
# 6. A particle can be put in one class only. Putting a particle in *
# two or more classes can lead to double counting of events. *
# 7. The class name mET is missing Energy and its name is reserved. *
# If used, it must be put last in the classes list below. *
# 8. If events contain particles not belonging to an existing class, *
# a new class will automatically be generated. *
# 9. For LHCO events the PDG code 21 is assigned to a jet (not *
# b-tagged), 5 to a b-tagged jet and 12 to missing ET. *
# *
# *
# Some comments about the cuts *
# 1. In the file kin_func.f the functions on which cuts can be applied *
# are given. *
# 2. The syntax is as follows. *
# etmin 1 3 30d0 *
# means that from the first class the Et of the first three particles *
# has to be greater than 30 GeV. *
# *
# etmissmin 20d0 *
# means that there must be at least 20 GeV of missing Et *
# *
# dRmin 2 1 4 3 3d0 *
# means that the distance between the first particle in the second *
# class and the first three particles in the fourth class has to be *
# greater than 3. *
# *
# ptmax 1 3 10d0 *
# ptmax 1 2 15d0 *
# means that the maximum pt of the third particle in the first class *
# has to smaller than 10 GeV, and the first two particles of this *
# class has to be smaller than 15 GeV *
# 3. The ordering of the particles within a class can be set with the *
# 'ordering function' in the file kin_func.f. *
# 4. For all the 'min' cuts, an event will be thrown away if the particle *
# does not exist. On the other hand, for all the 'max' cuts the cut *
# will be ignored if the particle does not exist *
# (Only dRij is an exception, for which it is the other way around) *
# *
# *
# *
# Some comments about the plotting options *
# 1. In the file kin_func.f the functions can be found that can be *
# plotted. (only for off-line usage) *
# 2. With the plotting options one can set the number of plots for each *
# of these functions. *
# 3. One has to specify for each variable which particles from which *
# class are used to set the plots. Syntax: *
# et 2 4 *
# means that the transverse energy of the first four particles in the *
# second class will be plotted. *
# mij 1 3 *
# mij 2 2 *
# means that for the invariant mass plots the first three particles *
# from the first class and the first two from the second class will be *
# used to plot the invariant mass of two particles. (10 plots) *
# 4. The ordering of the particles in a class can be set with the *
# 'ordering_function'. pt, e and et are valid functions. (For off-line *
# users X1, X2 and X3 can also be used, if defined in kin_func.f.) *
# 5. Max number of plots is 200. *
# *
# *
#**************************************************************************
# Put here your list of classes
#**************************************************************************
# Do NOT put spaces before class names!
# Begin Classes # This is TAG. Do not modify this line
jet 1 -1 2 -2 3 -3 4 -4 21 # Class number 1
b 5 -5 # Class number 2
mET 12 -12 14 -14 16 -16 1000022 # Missing ET class, name is reserved
# End Classes # This is TAG. Do not modify this line
#**************************************************************************
ordering_function pt # orders particles in classes according to their pt
normalization xsec # histogram normalization, xsec or number (e.g. 1)
#**************************************************************************
# Put here list of minimum pt for the classes
#**************************************************************************
# Begin Minpts # This is TAG. Do not modify this line
#1 30
#2 40
#3 10
# End Minpts # This is TAG. Do not modify this line
#**************************************************************************
# Cuts on plotted events
#**************************************************************************
# Modify the cuts and remove the pounds/hashes to apply those cuts
# Do NOT put spaces at the beginning of the following lines!
# Begin Cuts # This is TAG. Do not modify this line
#etmin 2 2 40d0
#etmin 2 1 80d0
#etmin 1 3 20d0
#etmax 2 1 200d0
#ptmin 3 1 0d0
#etmissmin 20d0
#etmissmax 80d0
#etamax 1 1 1d0
#etamax 2 1 2d0
#etamin 2 2 1.5d0
#etamin 2 1 2d0
#mijmax 2 1 2 2 200d0
#mijmin 2 1 2 2 100d0
#X1min 2 1 40d0
#X1max 2 2 50d0
#dRijmin 2 1 2 2 0.7d0
#dRijmax 1 3 2 2 0.7d0
#XY1min 2 2 2 2 20d0
#XYZA2max 2 2 2 2 4 1 5 1 40d0
# End Cuts # This is TAG. Do not modify this line
#**************************************************************************
# Put here the required plots
#**************************************************************************
# Do NOT put spaces at the beginning of the following lines!
# Begin PlotDefs # This is TAG. Do not modify this line
pt 1 4 # plot pt for the first four particles in class 1
pt 2 4 # plot pt for the first four particles in class 2
pt 3 4 # plot pt for the first four particles in class 3
pt 4 4 # plot pt for the first four particles in class 4
pt 5 4 # etc.
pt 6 4
pt 7 4
#e 2 2
y 1 4 # plot rapidity for the first four particles in class 1
y 2 4
y 3 4
y 4 4
y 5 4
y 6 4
y 7 4
#eta 2 2 # plot pseudo-rapidity for the first two part in the 2nd class
#mom 4 1
#costh 5 1
#phi 2 2
#delta_eta 2 2
#delta_eta 4 1
mij 1 4 # use the first four particles in the 1st class to plot inv. mass
mij 2 2 # use the first two particles from the second class as well
mij 3 1 # etc.
mij 4 1
mij 5 1
mij 6 1
mij 7 1
#cosij 1 2
#cosij 2 2
#cosij 3 1
#cosij 4 1
dRij 1 4
dRij 2 2
dRij 3 1
dRij 4 1
dRij 5 1
dRij 6 1
dRij 7 1
#delta_phi 2 2
#delta_phi 4 1
#delta_phi 5 1
#X1 2 2 # plot X1 (defined in kin_func.f)
#XYZA1 2 2
#XYZA1 4 1
#XYZA1 5 1
# End PlotDefs # This is TAG. Do not modify this line
#**************************************************************************
#**************************************************************************
# Put here the plot ranges
#**************************************************************************
# Do NOT put spaces at the beginning of the following lines!
# Begin PlotRange # This is TAG. Do not modify this line
pt 10 0 500 # bin size, min value, max value
et 10 0 500 # bin size, min value, max value
etmiss 10 0 500 # bin size, min value, max value
ht 20 0 1500
y 0.2 -5 5 # etc.
mij 20 0 1500
dRij 0.1 0 5
#delta_phi 0.1 0 3.1
#X1 1 0 100
#XYZA1 1 0 100
# End PlotRange # This is TAG. Do not modify this line
#**************************************************************************
#**************************************************************************
# Output for plots
#**************************************************************************
# Do NOT put spaces at the beginning of the following lines!
# Begin PlotOutput # This is TAG. Do not modify this line
output topdrawer # set to topdrawer or gnuplot
plot_decayed no # plot (and cut) dec. res.? (Only for LHE events)
# End PlotOutput # This is TAG. Do not modify this line
#**************************************************************************
#
#
4 changes: 4 additions & 0 deletions generators/madgraph5/src/WAB/Cards/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This directory contains samples for all the cards which are used by
MadGraph5_aMC@NLO during the various stages of code operation.


Loading

0 comments on commit 81c21da

Please sign in to comment.