Commit 5a846b66 authored by Shayma Wahdan's avatar Shayma Wahdan Committed by Christian Gutschow
Browse files

aMC@NLO tW DRx/DSx and ttbar samples

parent a577c002
Pipeline #2918175 passed with stages
in 1 minute and 7 seconds
from MadGraphControl.MadGraphUtils import *
from MadGraphControl.MadGraphParamHelpers import set_top_params
import fileinput
# Make some excess of events - make sure we protect against maxEvents=-1
nevents=1.1*runArgs.maxEvents if runArgs.maxEvents>0 else 1.1*evgenConfig.nEventsPerJob
import MadGraphControl.MadGraphUtils
MadGraphControl.MadGraphUtils.MADGRAPH_PDFSETTING={
'central_pdf':260000,
'scale_variations':[0.5,1.,2.],
}
process="""
import model loop_sm-no_b_mass
define p = g u c d s u~ c~ d~ s~ b b~
define j = g u c d s u~ c~ d~ s~ b b~
generate p p > t t~ [QCD]
output -f"""
process_dir = new_process(process)
#Fetch default NLO run_card.dat and set parameters
settings = {'parton_shower' : 'PYTHIA8',
'maxjetflavor' : 5,
'dynamical_scale_choice' : '10', #user-defined scale -> Dominic's definition of mt+1/2*(pt^2+ptx^2)
'jetalgo' : '-1', # use anti-kT jet algorithm
'jetradius' : '0.4', # set jet cone size of 0.4
'ptj' : '0.1', # minimum jet pT
'req_acc' : '0.001',
'bwcutoff' : '50',
'nevents':int(nevents)
}
modify_run_card(process_dir=process_dir,runArgs=runArgs,settings=settings)
# Modify the param card
set_top_params(process_dir,mTop=172.5,FourFS=False)
# Cook the setscales file for the user defined dynamical scale
fileN = process_dir+'/SubProcesses/setscales.f'
mark = ' elseif(dynamical_scale_choice.eq.10) then'
rmLines = ['ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',
'cc USER-DEFINED SCALE: ENTER YOUR CODE HERE cc',
'cc to use this code you must set cc',
'cc dynamical_scale_choice = 0 cc',
'cc in the run_card (run_card.dat) cc',
'write(*,*) "User-defined scale not set"',
'stop 1',
'temp_scale_id=\'User-defined dynamical scale\' ! use a meaningful string',
'tmp = 0',
'cc USER-DEFINED SCALE: END OF USER CODE cc'
]
for line in fileinput.input(fileN, inplace=1):
toKeep = True
for rmLine in rmLines:
if line.find(rmLine) >= 0:
toKeep = False
break
if toKeep:
print line,
if line.startswith(mark):
print """
c Q^2= mt^2 + 0.5*(pt^2+ptbar^2)
xm2=dot(pp(0,3),pp(0,3))
tmp=sqrt(xm2+0.5*(pt(pp(0,3))**2+pt(pp(0,4))**2))
temp_scale_id='mt**2 + 0.5*(pt**2+ptbar**2)'
"""
### Decay with MadSpin
madspin_card_loc=process_dir + '/Cards/madspin_card.dat'
mscard = open(madspin_card_loc,'w')
mscard.write("""#************************************************************
#* MadSpin *
#* *
#* P. Artoisenet, R. Frederix, R. Rietkerk, O. Mattelaer *
#* *
#* Part of the MadGraph5_aMC@NLO Framework: *
#* The MadGraph5_aMC@NLO Development Team - Find us at *
#* https://server06.fynu.ucl.ac.be/projects/madgraph *
#* *
#************************************************************
set Nevents_for_max_weight 250 # number of events for the estimate of the max. weight
set max_weight_ps_point 1000 # number of PS to estimate the maximum for each event
set BW_cut 50
set seed %i
define j = g u c d s b u~ c~ d~ s~ b~
define lv = e+ mu+ ta+ ve vm vt e- mu- ta- ve~ vm~ vt~
decay t > w+ b, w+ > lv lv
decay t~ > w- b~, w- > lv lv
launch
"""%(runArgs.randomSeed))
mscard.close()
generate(process_dir=process_dir,runArgs=runArgs)
arrange_output(process_dir=process_dir,runArgs=runArgs,lhe_version=3,saveProcDir=False)
### Shower
include("Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py")
include("Pythia8_i/Pythia8_aMcAtNlo.py")
### Metadata
evgenConfig.description = 'MG5_aMC@NLO+MadSpin+Pythia8+EvtGen ttbar dilepton'
evgenConfig.generators = ['aMcAtNlo', 'Pythia8', 'EvtGen']
evgenConfig.keywords+=['ttbar','jets']
evgenConfig.contact = [ "dominic.hirschbuehl.cern.ch", "jens.roggel@cern.ch" ]
import MadGraphControl.MadGraphUtils
from MadGraphControl.MadGraphUtils import *
from MadGraphControl.DiagramRemoval import do_MadSpin_DRX
# General settings
nevents = runArgs.maxEvents*1.1 if runArgs.maxEvents>0 else 1.1*evgenConfig.nEventsPerJob
MadGraphControl.MadGraphUtils.MADGRAPH_PDFSETTING={
'central_pdf':260000,
'scale_variations':[0.5,1.,2.],
}
process_dir = MADGRAPH_GRIDPACK_LOCATION
#Fetch default run_card.dat and set parameters
settings = {'parton_shower':'PYTHIA8',
'nevents' :int(nevents)}
modify_run_card(process_dir=process_dir,runArgs=runArgs,settings=settings)
generate(process_dir=process_dir,runArgs=runArgs,grid_pack=False)
arrange_output(process_dir=process_dir,runArgs=runArgs,lhe_version=3,saveProcDir=True)
# MadSpin settings
madspin_dir = process_dir +"/MadSpin"
madspin_card=process_dir+'/Cards/madspin_card.dat'
if os.access(madspin_card,os.R_OK):
os.unlink(madspin_card)
fMadSpinCard = open(madspin_card,'w')
fMadSpinCard.write("""#************************************************************
#* MadSpin *
#* *
#* P. Artoisenet, R. Frederix, R. Rietkerk, O. Mattelaer *
#* *
#* Part of the MadGraph5_aMC@NLO Framework: *
#* The MadGraph5_aMC@NLO Development Team - Find us at *
#* https://server06.fynu.ucl.ac.be/projects/madgraph *
#* *
#************************************************************
#Some options (uncomment to apply)
#
set Nevents_for_max_weight 250 # number of events for the estimate of the max. weight
set max_weight_ps_point 1000 # number of PS to estimate the maximum for each event
set seed %i
set ms_dir %s
#set use_old_dir True
set bw_cut 50
# specify the decay for the final state particles
define l+ = e+ mu+ ta+
define l- = e- mu- ta-
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
decay t > w+ b, w+ > l+ vl
decay t~ > w- b~, w- > l- vl~
decay w+ > l+ vl
decay w- > l- vl~
# running the actual code
launch"""%(int(runArgs.randomSeed),madspin_dir))
fMadSpinCard.close()
# run MadSpin to create MadSpin files
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=True)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# apply hacks on MadSpin files
do_MadSpin_DRX(1,madspin_dir)
# Make sure the code is taken from the madspin directory and not overwritten when you redo the decays
msfile=madspin_card
mstilde=madspin_card+"~"
shutil.copyfile(msfile,mstilde)
with open(msfile,"w") as myfile, open(mstilde,'r') as f:
for line in f:
if '#set use_old_dir True' in line:
line = line.replace('#',' ') #uncomment set use_old_dir True
myfile.write(line)
os.remove(mstilde)
# hack to be able to redecay the events
if os.path.isfile("tmp_LHE_events.events"):
os.remove("tmp_LHE_events.events")
else:
raise RuntimeError("tmp_LHE_events.events not found!")
subprocess.call(["cp", "tmp_LHE_events.events.original", "tmp_LHE_events.events"])
subprocess.call(["rm", "tmp_LHE_events.events.original"])
subprocess.call(["cp", process_dir+"/madspin_makefile", madspin_dir+"/makefile"])
subprocess.call(["make","clean"],cwd=madspin_dir)
subprocess.call(["make"],cwd=madspin_dir)
# re-run MadSpin on undecayed lhe files with hack applied
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=False)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# remove process dir and madspin dir
shutil.rmtree(process_dir,ignore_errors=True)
if os.path.isdir('MGC_LHAPDF/'):
shutil.rmtree('MGC_LHAPDF/',ignore_errors=True)
shutil.rmtree(madspin_dir,ignore_errors=True)
# Shower Pythia8
include("Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py")
include("Pythia8_i/Pythia8_aMcAtNlo.py")
# Metadata
evgenConfig.generators += ["aMcAtNlo", "Pythia8", "EvtGen"]
evgenConfig.description = "MG5aMCatNLO+MadSpin+Pythia8+EvtGen tW DR1 dilepton"
evgenConfig.keywords = ["SM","top"]
evgenConfig.contact = ['dominic.hirschbuehl@cern.ch','jens.roggel@cern.ch']
/eos/user/s/swahdan/mc/mc_13TeV.aMCPy8EG_tW_DR1_dil.GRID.tar.gz
\ No newline at end of file
import MadGraphControl.MadGraphUtils
from MadGraphControl.MadGraphUtils import *
from MadGraphControl.DiagramRemoval import do_MadSpin_DRX
# General settings
nevents = runArgs.maxEvents*1.1 if runArgs.maxEvents>0 else 1.1*evgenConfig.nEventsPerJob
MadGraphControl.MadGraphUtils.MADGRAPH_PDFSETTING={
'central_pdf':260000,
'scale_variations':[0.5,1.,2.],
}
process_dir = MADGRAPH_GRIDPACK_LOCATION
#Fetch default run_card.dat and set parameters
settings = {'parton_shower':'PYTHIA8',
'nevents' :int(nevents)}
modify_run_card(process_dir=process_dir,runArgs=runArgs,settings=settings)
generate(process_dir=process_dir,runArgs=runArgs,grid_pack=False)
arrange_output(process_dir=process_dir,runArgs=runArgs,lhe_version=3,saveProcDir=True)
# MadSpin settings
madspin_dir = process_dir +"/MadSpin"
madspin_card=process_dir+'/Cards/madspin_card.dat'
if os.access(madspin_card,os.R_OK):
os.unlink(madspin_card)
fMadSpinCard = open(madspin_card,'w')
fMadSpinCard.write("""#************************************************************
#* MadSpin *
#* *
#* P. Artoisenet, R. Frederix, R. Rietkerk, O. Mattelaer *
#* *
#* Part of the MadGraph5_aMC@NLO Framework: *
#* The MadGraph5_aMC@NLO Development Team - Find us at *
#* https://server06.fynu.ucl.ac.be/projects/madgraph *
#* *
#************************************************************
#Some options (uncomment to apply)
#
set Nevents_for_max_weight 250 # number of events for the estimate of the max. weight
set max_weight_ps_point 1000 # number of PS to estimate the maximum for each event
set seed %i
set ms_dir %s
#set use_old_dir True
set bw_cut 50
# specify the decay for the final state particles
define l+ = e+ mu+ ta+
define l- = e- mu- ta-
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
decay t > w+ b, w+ > l+ vl
decay t~ > w- b~, w- > l- vl~
decay w+ > l+ vl
decay w- > l- vl~
# running the actual code
launch"""%(int(runArgs.randomSeed),madspin_dir))
fMadSpinCard.close()
# run MadSpin to create MadSpin files
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=True)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# apply hacks on MadSpin files
do_MadSpin_DRX(1,madspin_dir)
# Make sure the code is taken from the madspin directory and not overwritten when you redo the decays
msfile=madspin_card
mstilde=madspin_card+"~"
shutil.copyfile(msfile,mstilde)
with open(msfile,"w") as myfile, open(mstilde,'r') as f:
for line in f:
if '#set use_old_dir True' in line:
line = line.replace('#',' ') #uncomment set use_old_dir True
myfile.write(line)
os.remove(mstilde)
# hack to be able to redecay the events
if os.path.isfile("tmp_LHE_events.events"):
os.remove("tmp_LHE_events.events")
else:
raise RuntimeError("tmp_LHE_events.events not found!")
subprocess.call(["cp", "tmp_LHE_events.events.original", "tmp_LHE_events.events"])
subprocess.call(["rm", "tmp_LHE_events.events.original"])
subprocess.call(["cp", process_dir+"/madspin_makefile", madspin_dir+"/makefile"])
subprocess.call(["make","clean"],cwd=madspin_dir)
subprocess.call(["make"],cwd=madspin_dir)
# re-run MadSpin on undecayed lhe files with hack applied
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=False)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# remove process dir and madspin dir
shutil.rmtree(process_dir,ignore_errors=True)
if os.path.isdir('MGC_LHAPDF/'):
shutil.rmtree('MGC_LHAPDF/',ignore_errors=True)
shutil.rmtree(madspin_dir,ignore_errors=True)
# Shower Pythia8
include("Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py")
include("Pythia8_i/Pythia8_aMcAtNlo.py")
# Metadata
evgenConfig.generators += ["aMcAtNlo", "Pythia8", "EvtGen"]
evgenConfig.description = "MG5aMCatNLO+MadSpin+Pythia8+EvtGen tW DR1 dilepton dynamic scales"
evgenConfig.keywords = ["SM","top"]
evgenConfig.contact = ['dominic.hirschbuehl@cern.ch','jens.roggel@cern.ch']
/eos/user/s/swahdan/mc/mc_13TeV.aMCPy8EG_tW_DR1_dyn_dil.GRID.tar.gz
\ No newline at end of file
import MadGraphControl.MadGraphUtils
from MadGraphControl.MadGraphUtils import *
from MadGraphControl.DiagramRemoval import do_MadSpin_DRX
# General settings
nevents = runArgs.maxEvents*1.1 if runArgs.maxEvents>0 else 1.1*evgenConfig.nEventsPerJob
MadGraphControl.MadGraphUtils.MADGRAPH_PDFSETTING={
'central_pdf':260000,
'scale_variations':[0.5,1.,2.],
}
process_dir = MADGRAPH_GRIDPACK_LOCATION
#Fetch default run_card.dat and set parameters
settings = {'parton_shower':'PYTHIA8',
'nevents' :int(nevents)}
modify_run_card(process_dir=process_dir,runArgs=runArgs,settings=settings)
generate(process_dir=process_dir,runArgs=runArgs,grid_pack=False)
arrange_output(process_dir=process_dir,runArgs=runArgs,lhe_version=3,saveProcDir=True)
# MadSpin settings
madspin_dir = process_dir +"/MadSpin"
madspin_card=process_dir+'/Cards/madspin_card.dat'
if os.access(madspin_card,os.R_OK):
os.unlink(madspin_card)
fMadSpinCard = open(madspin_card,'w')
fMadSpinCard.write("""#************************************************************
#* MadSpin *
#* *
#* P. Artoisenet, R. Frederix, R. Rietkerk, O. Mattelaer *
#* *
#* Part of the MadGraph5_aMC@NLO Framework: *
#* The MadGraph5_aMC@NLO Development Team - Find us at *
#* https://server06.fynu.ucl.ac.be/projects/madgraph *
#* *
#************************************************************
#Some options (uncomment to apply)
#
set Nevents_for_max_weight 250 # number of events for the estimate of the max. weight
set max_weight_ps_point 1000 # number of PS to estimate the maximum for each event
set seed %i
set ms_dir %s
#set use_old_dir True
set bw_cut 50
# specify the decay for the final state particles
define l+ = e+ mu+ ta+
define l- = e- mu- ta-
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
decay t > w+ b, w+ > l+ vl
decay t~ > w- b~, w- > l- vl~
decay w+ > l+ vl
decay w- > l- vl~
# running the actual code
launch"""%(int(runArgs.randomSeed),madspin_dir))
fMadSpinCard.close()
# run MadSpin to create MadSpin files
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=True)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# apply hacks on MadSpin files
do_MadSpin_DRX(1,madspin_dir)
# Make sure the code is taken from the madspin directory and not overwritten when you redo the decays
msfile=madspin_card
mstilde=madspin_card+"~"
shutil.copyfile(msfile,mstilde)
with open(msfile,"w") as myfile, open(mstilde,'r') as f:
for line in f:
if '#set use_old_dir True' in line:
line = line.replace('#',' ') #uncomment set use_old_dir True
myfile.write(line)
os.remove(mstilde)
# hack to be able to redecay the events
if os.path.isfile("tmp_LHE_events.events"):
os.remove("tmp_LHE_events.events")
else:
raise RuntimeError("tmp_LHE_events.events not found!")
subprocess.call(["cp", "tmp_LHE_events.events.original", "tmp_LHE_events.events"])
subprocess.call(["rm", "tmp_LHE_events.events.original"])
subprocess.call(["cp", process_dir+"/madspin_makefile", madspin_dir+"/makefile"])
subprocess.call(["make","clean"],cwd=madspin_dir)
subprocess.call(["make"],cwd=madspin_dir)
# re-run MadSpin on undecayed lhe files with hack applied
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=False)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# remove process dir and madspin dir
shutil.rmtree(process_dir,ignore_errors=True)
if os.path.isdir('MGC_LHAPDF/'):
shutil.rmtree('MGC_LHAPDF/',ignore_errors=True)
shutil.rmtree(madspin_dir,ignore_errors=True)
# Shower Pythia8
include("Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py")
include("Pythia8_i/Pythia8_aMcAtNlo.py")
# Metadata
evgenConfig.generators += ["aMcAtNlo", "Pythia8", "EvtGen"]
evgenConfig.description = "MG5aMCatNLO+MadSpin+Pythia8+EvtGen tW DR2 dilepton"
evgenConfig.keywords = ["SM","top"]
evgenConfig.contact = ['dominic.hirschbuehl@cern.ch','jens.roggel@cern.ch']
/eos/user/s/swahdan/mc/mc_13TeV.aMCPy8EG_tW_DR2_dil.GRID.tar.gz
\ No newline at end of file
import MadGraphControl.MadGraphUtils
from MadGraphControl.MadGraphUtils import *
from MadGraphControl.DiagramRemoval import do_MadSpin_DRX
# General settings
nevents = runArgs.maxEvents*1.1 if runArgs.maxEvents>0 else 1.1*evgenConfig.nEventsPerJob
MadGraphControl.MadGraphUtils.MADGRAPH_PDFSETTING={
'central_pdf':260000,
'scale_variations':[0.5,1.,2.],
}
process_dir = MADGRAPH_GRIDPACK_LOCATION
#Fetch default run_card.dat and set parameters
settings = {'parton_shower':'PYTHIA8',
'nevents' :int(nevents)}
modify_run_card(process_dir=process_dir,runArgs=runArgs,settings=settings)
generate(process_dir=process_dir,runArgs=runArgs,grid_pack=False)
arrange_output(process_dir=process_dir,runArgs=runArgs,lhe_version=3,saveProcDir=True)
# MadSpin settings
madspin_dir = process_dir +"/MadSpin"
madspin_card=process_dir+'/Cards/madspin_card.dat'
if os.access(madspin_card,os.R_OK):
os.unlink(madspin_card)
fMadSpinCard = open(madspin_card,'w')
fMadSpinCard.write("""#************************************************************
#* MadSpin *
#* *
#* P. Artoisenet, R. Frederix, R. Rietkerk, O. Mattelaer *
#* *
#* Part of the MadGraph5_aMC@NLO Framework: *
#* The MadGraph5_aMC@NLO Development Team - Find us at *
#* https://server06.fynu.ucl.ac.be/projects/madgraph *
#* *
#************************************************************
#Some options (uncomment to apply)
#
set Nevents_for_max_weight 250 # number of events for the estimate of the max. weight
set max_weight_ps_point 1000 # number of PS to estimate the maximum for each event
set seed %i
set ms_dir %s
#set use_old_dir True
set bw_cut 50
# specify the decay for the final state particles
define l+ = e+ mu+ ta+
define l- = e- mu- ta-
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
decay t > w+ b, w+ > l+ vl
decay t~ > w- b~, w- > l- vl~
decay w+ > l+ vl
decay w- > l- vl~
# running the actual code
launch"""%(int(runArgs.randomSeed),madspin_dir))
fMadSpinCard.close()
# run MadSpin to create MadSpin files
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=True)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# apply hacks on MadSpin files
do_MadSpin_DRX(1,madspin_dir)
# Make sure the code is taken from the madspin directory and not overwritten when you redo the decays
msfile=madspin_card
mstilde=madspin_card+"~"
shutil.copyfile(msfile,mstilde)
with open(msfile,"w") as myfile, open(mstilde,'r') as f:
for line in f:
if '#set use_old_dir True' in line:
line = line.replace('#',' ') #uncomment set use_old_dir True
myfile.write(line)
os.remove(mstilde)
# hack to be able to redecay the events
if os.path.isfile("tmp_LHE_events.events"):
os.remove("tmp_LHE_events.events")
else:
raise RuntimeError("tmp_LHE_events.events not found!")
subprocess.call(["cp", "tmp_LHE_events.events.original", "tmp_LHE_events.events"])
subprocess.call(["rm", "tmp_LHE_events.events.original"])
subprocess.call(["cp", process_dir+"/madspin_makefile", madspin_dir+"/makefile"])
subprocess.call(["make","clean"],cwd=madspin_dir)
subprocess.call(["make"],cwd=madspin_dir)
# re-run MadSpin on undecayed lhe files with hack applied
if os.path.isfile("tmp_LHE_events.events"):
madspin_on_lhe("tmp_LHE_events.events",madspin_card,runArgs=runArgs,keep_original=False)
else:
raise RuntimeError("tmp_LHE_events.events not found!")
# remove process dir and madspin dir
shutil.rmtree(process_dir,ignore_errors=True)
if os.path.isdir('MGC_LHAPDF/'):
shutil.rmtree('MGC_LHAPDF/',ignore_errors=True)
shutil.rmtree(madspin_dir,ignore_errors=True)
# Shower Pythia8