Commit e2c7f731 authored by MC JO registration's avatar MC JO registration
Browse files

add 346485, 346599, 411178-80,275, 312371-3, 346603-4, update 346588

parent 23b84149
2019-06-27 Evelina Bouhova-Thacker <e.bouhova@cern.ch>
* tagging MC15JobOptions-01-00-60
* add 346485, 346599, 411178-80,275, 312371-3, 346603-4
* update 346588
* update MadGraphControl_tHjb_NLO.py, MadGraphControl_ttH_gamgam_NLO.py
2019-06-26 Evelina Bouhova-Thacker <e.bouhova@cern.ch>
* tagging MC15JobOptions-01-00-58
* add 420287-8, 346600, 312356-70, update 346601-2
......
from MadGraphControl.MadGraphUtils import *
import os
import fileinput
import re
nevents=10000
evgenConfig.minevents=5000
mode=0
gridpack_dir='madevent/'
qCut=25
#---------------------------------------------------------------------------
# Process type based on runNumber:
#---------------------------------------------------------------------------
if runArgs.runNumber==346485:
process1='generate p p > h a j j [QCD] @0'
evgenConfig.keywords = ['Higgs','photon','bottom','VBFHiggs']
evgenConfig.contact = ['Carolyn Gee <Carolyn.Mei.Gee@cern.ch>']
description='MadGraph_aMC@NLO h->jj 0,2jets@NLO'
ptgmin=19
name='MG5_aMCatNLO262.346485.VBFhajj_PDF4LHC_13TeV'
gridpack='MG5_aMCatNLO262.346485.VBFhajj_PDF4LHC_13TeV'
else:
raise RuntimeError("runNumber %i not recognised in these jobOptions."%runArgs.runNumber)
if hasattr(runArgs, 'inputGenConfFile'):
if not gridpack in runArgs.inputGenConfFile:
raise RuntimeError("Please use the correct gridpack for this DSID.")
#---------------------------------------------------------------------------
# MG5 Proc card
#---------------------------------------------------------------------------
fcard = open('proc_card_mg5.dat','w')
fcard.write("""
import model loop_sm-no_b_mass
define p = g u c d s b u~ c~ d~ s~ b~
define j = g u c d s b u~ c~ d~ s~ b~
define vl = ve vm vt
define vl~ = ve~ vm~ vt~
"""+process1+"""
output -f
""")
fcard.close()
#----------------------------------------------------------------------------
# Run Number
#----------------------------------------------------------------------------
if not hasattr(runArgs,'runNumber'):
raise RunTimeError("No run number found.")
#----------------------------------------------------------------------------
# Random Seed
#----------------------------------------------------------------------------
randomSeed = 0
if hasattr(runArgs,'randomSeed'): randomSeed = runArgs.randomSeed
#----------------------------------------------------------------------------
# Beam energy
#----------------------------------------------------------------------------
if hasattr(runArgs,'ecmEnergy'):
beamEnergy = int(runArgs.ecmEnergy) / 2.
else:
raise RunTimeError("No center of mass energy found.")
#---------------------------------------------------------------------------
# Number of Events
#---------------------------------------------------------------------------
skip_events=0
if hasattr(runArgs,'skipEvents'): skip_events=runArgs.skipEvents
#---------------------------------------------------------------------------
# MG5 Run Card
#---------------------------------------------------------------------------
extras = { 'lhe_version' : '3.0',
'parton_shower' :'HERWIGPP',
'pdlabel' :"'lhapdf'",
'lhaid' :"90000",
'ptj' :"15.0",
'etaj' :"-1.0",
'ptgmin' :ptgmin,
'epsgamma' :'1.0', #'0.1',
'R0gamma' :'0.4',#'0.1',
'xn' :'1', #'2',
'isoEM' :'True',
'etagamma' :'3.0',
'bwcutoff' :'15',
'maxjetflavor' :'5',
'reweight_scale':'True',
'rw_Rscale_down':0.5,
'rw_Rscale_up' :2.0,
'rw_Fscale_down':0.5,
'rw_Fscale_up' :2.0,
'reweight_PDF' :'True',
'PDF_set_min' :90001,
'PDF_set_max' :90100,
'dynamical_scale_choice' : '-1', #default value
'store_rwgt_info':'True'
}
process_dir = new_process(grid_pack=gridpack_dir)
with open("PROCNLO_loop_sm-no_b_mass_0/Cards/FKS_params.dat","rw") as file:
for line in file:
print line
print "editing FKS file"
for line in fileinput.input("PROCNLO_loop_sm-no_b_mass_0/Cards/FKS_params.dat", inplace=2):
line = re.sub('1.0d-5', '-1d0', line.rstrip())
print(line)
print line
build_run_card(run_card_old=get_default_runcard(proc_dir=process_dir),
run_card_new='run_card.dat',
xqcut=15,
nevts=nevents,
rand_seed=randomSeed,
beamEnergy=beamEnergy,
extras=extras)
print_cards()
#---------------------------------------------------------------------------
# MG5 + Pythia8 setup and process (lhe) generation
#---------------------------------------------------------------------------
generate(run_card_loc='run_card.dat',param_card_loc=None,mode=mode,proc_dir=process_dir,run_name=name,grid_pack=True,gridpack_dir=gridpack_dir,nevents=nevents,random_seed=runArgs.randomSeed)
if 'ATHENA_PROC_NUMBER' in os.environ:
print 'Noticed that you have run with an athena MP-like whole-node setup. Will re-configure now to make sure that the remainder of the job runs serially.'
njobs = os.environ.pop('ATHENA_PROC_NUMBER')
# Try to modify the opts underfoot
if not hasattr(opts,'nprocs'): print 'Did not see option!'
else: opts.nprocs = 0
print opts
#--------------------------------------------------------------------------------------------------------------------
# Shower
#--------------------------------------------------------------------------------------------------------------------
stringy = 'madgraph.'+str(runArgs.runNumber)+'.MadGraph_'+str(name)
arrange_output(run_name=name,
proc_dir=process_dir,
outputDS=name+'._00001.events.tar.gz'
# outputDS=stringy+'._00001.events.tar.gz',
)
evgenConfig.generators += ["aMcAtNlo","Herwig7"]
evgenConfig.description = 'MadGraph_higgs_NLO_Herwigpp'
evgenConfig.keywords+=['jets']
evgenConfig.inputfilecheck = name
runArgs.inputGeneratorFile=name+'._00001.events.tar.gz'
evgenConfig.tune = "PDF4LHC15_nlo_mc_pdfas" #"MMHT2014nlo68cl"
print "runArgs.inputGeneratorFile",runArgs.inputGeneratorFile
lhe_filename=runArgs.inputGeneratorFile
print "lhe_file print test",lhe_filename
from Herwig7_i.Herwig7_iConf import Herwig7
from Herwig7_i.Herwig7ConfigBuiltinME import Hw7ConfigBuiltinME
from Herwig7_i.Herwig7ConfigLHEF import Hw7ConfigLHEF
genSeq += Herwig7()
Herwig7Config = Hw7ConfigLHEF(genSeq,runArgs)
HERWIGPP_qCut=qCut
HERWIGPP_nJetMax=1
# configure Herwig7
Herwig7Config.me_pdf_commands(order="NLO", name="PDF4LHC15_nlo_mc_pdfas")
Herwig7Config.tune_commands()
Herwig7Config.lhef_mg5amc_commands(lhe_filename='tmp_'+runArgs.inputGeneratorFile, me_pdf_order="NLO")
# add EvtGen
include("MC15JobOptions/Herwig71_EvtGen.py")
import os
if "HERWIG7VER" in os.environ:
version = os.getenv("HERWIG7VER")
verh7 = version.split(".")[1]
else:
verh7 = 0
if int(verh7 == 0):
# Herwig7Config.add_commands("""
# insert /Herwig/MatrixElements/SubProcess:MatrixElements[0] /Herwig/MatrixElements/MEQCD2to2
#set /Herwig/UnderlyingEvent/MPIHandler:IdenticalToUE 0
#set /Herwig/Cuts/JetKtCut:MinKT 0.0*GeV
Herwig7Config.add_commands("""
do /Herwig/Particles/h0:SelectDecayModes h0->b,bbar; h0->b,bbar;
do /Herwig/Particles/h0:PrintDecayModes
set /Herwig/Shower/KinematicsReconstructor:ReconstructionOption General
set /Herwig/Shower/KinematicsReconstructor:InitialInitialBoostOption LongTransBoost
cd /Herwig/Shower
library FxFxHandler.so
create Herwig::FxFxHandler FxFxHandler
set /Herwig/Shower/FxFxHandler:ShowerModel /Herwig/Shower/ShowerModel
set /Herwig/Shower/FxFxHandler:SplittingGenerator /Herwig/Shower/SplittingGenerator
set /Herwig/Shower/FxFxHandler:HardProcessDetection Automatic
#set /Herwig/Shower/FxFxHandler:ihrd 3
#set /Herwig/Shower/FxFxHandler:njetsmax 3
#set /Herwig/Shower/FxFxHandler:HeavyQVeto Yes
#set /Herwig/Shower/FxFxHandler:VetoingIsOn
#set /Herwig/Shower/FxFxHandler:MergeMode FxFx #merging mode
#set /Herwig/Shower/FxFxHandler:ETClus 15.0*GeV #Merging scale
#set /Herwig/Shower/FxFxHandler:RClus .4 #jet radius used in clustering merging
#set /Herwig/Shower/FxFxHandler:EtaClusMax 10.0 #max eta for jets in clustering in merging
#set /Herwig/Shower/FxFxHandler:RClusFactor 1.5 #default 1.5 factor to decide if a jet matches a parton in merging: if DR(parton,jet)<rclusfactor*rclus the parton and jet are said to have been matched
""")
else:
# Herwig7Config.add_commands("""
Herwig7Config.add_commands("""
## ------------------
## Hard process setup
## ------------------
do /Herwig/Particles/h0:SelectDecayModes h0->b,bbar; h0->b,bbar;
do /Herwig/Particles/h0:PrintDecayModes
set /Herwig/Shower/KinematicsReconstructor:ReconstructionOption General
set /Herwig/Shower/KinematicsReconstructor:InitialInitialBoostOption LongTransBoost
cd /Herwig/Shower
library FxFxHandler.so
create Herwig::FxFxHandler FxFxHandler
set /Herwig/Shower/FxFxHandler:ShowerModel /Herwig/Shower/ShowerModel
set /Herwig/Shower/FxFxHandler:SplittingGenerator /Herwig/Shower/SplittingGenerator
set /Herwig/Shower/FxFxHandler:HardProcessDetection Automatic
#set /Herwig/Shower/FxFxHandler:ihrd 3
#set /Herwig/Shower/FxFxHandler:njetsmax 3
#set /Herwig/Shower/FxFxHandler:HeavyQVeto Yes
#set /Herwig/Shower/FxFxHandler:VetoingIsOn
#set /Herwig/Shower/FxFxHandler:MergeMode FxFx #merging mode
#set /Herwig/Shower/FxFxHandler:ETClus 15.0*GeV #Merging scale
#set /Herwig/Shower/FxFxHandler:RClus .4 #jet radius used in clustering merging
#set /Herwig/Shower/FxFxHandler:EtaClusMax 10.0 #max eta for jets in clustering in merging
#set /Herwig/Shower/FxFxHandler:RClusFactor 1.5 #default 1.5 factor to decide if a jet matches a parton in merging: if DR(parton,jet)<rclusfactor*rclus the parton and jet are said to have been matched
""")
# run Herwig7
Herwig7Config.run()
#--------------------------------------------------------------------------------------------------------------------
# Mjj filtering:
#--------------------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------------------------
# Sample information:
#--------------------------------------------------------------------------------------------------------------------
"""evgenConfig.generators = ["aMcAtNlo", "Herwig7"]
evgenConfig.contact = ['Carolyn Gee <Carolyn.Mei.Gee@cern.ch>']
evgenConfig.description = description
runArgs.inputGeneratorFile=name+'._00001.events.tar.gz'
evgenConfig.minevents=minevents"""
from MadGraphControl.MadGraphUtils import *
import re
from VLQCouplingCalculator import VLQCouplingCalculator as vlq
import subprocess
import lhe_hacker
import sys
# import lheparser
reMass = int(re.findall(r'\d+',re.findall(r'\d+LH',runArgs.jobConfig[0])[0])[0])
reKappa = int(re.findall(r'\d+', runArgs.jobConfig[0])[-1])
runArgs.mass = reMass
runArgs.kappa = reKappa*0.01
def rewtcardmaker(m, K):
#print m
#print K_grid
launch_line = "launch --rwgt_name="
tagname = ('M' + str(int(m/100)) + 'K{0:03d}').format(int(K*100))
if float(m) == float(reMass) and float(K) == float(int(runArgs.kappa*100)/100.0):
return [False, tagname]
f = open("reweight_card.dat", "w")
print tagname
c = vlq(float(m), 'T')
c.setKappaxi(K, 0.5, 0.25)
gamma = c.getGamma()
print K, gamma
f.write(launch_line + tagname + '\n')
f.write('\tset KT ' + str(K) + '\n')
f.write('\tset MTP ' + str(m) + '\n')
f.write('\tset WTP ' + str(gamma) + '\n')
f.flush()
f.close()
return [True, tagname]
M_grid = [reMass-100., reMass]
K_grid = [0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6]
rewtcardmaker(reMass,0.5)
MAX_TRIAL = 50
##Figure out what kind of process we have (from file name)
runArgs.proc = "add process p p > j VLQ bb / tp tp~ p t t~ y y~ bp bp~ x x~ z h a, (VLQ > WW bb, WW > ferm ferm)"
#runArgs.proc = "add process p p > j VLQ bb / tp tp~ p t t~ y y~ bp bp~ x x~ z h a, (VLQ > z tt)"
print ("Mass: ", runArgs.mass)
print ("Kappa: ", runArgs.kappa)
print ("Proc: ", runArgs.proc)
fcard = open('proc_card_mg5_fullDecay.dat','w')
fcard.write("""
import model /cvmfs/atlas.cern.ch/repo/sw/Generators/madgraph/models/latest/VLQ_UFO
define p = g u c d s u~ c~ d~ s~
define j = g u c d s u~ c~ d~ s~
define bb = b b~
define WW = w+ w-
define tt = t t~
define ferm = ve vm vt ve~ vm~ vt~ mu- ta- e- mu+ ta+ e+ u c d s u~ c~ d~ s~
define VLQ = tp tp~
%s
output -f
"""%(runArgs.proc))
fcard.close()
fcard = open('proc_card_mg5_minDecay.dat','w')
fcard.write("""
import model /cvmfs/atlas.cern.ch/repo/sw/Generators/madgraph/models/latest/VLQ_UFO
define p = g u c d s u~ c~ d~ s~
define j = g u c d s u~ c~ d~ s~
define bb = b b~
define WW = w+ w-
define tt = t t~
define ferm = ve vm vt ve~ vm~ vt~ mu- ta- e- mu+ ta+ e+ u c d s u~ c~ d~ s~
define VLQ = tp tp~
%s
output -f
"""%("add process p p > j VLQ bb / tp tp~ p t t~ y y~ bp bp~ x x~ z h a, (VLQ > WW bb)"))
fcard.close()
process_dir_fullDecay = new_process(card_loc='proc_card_mg5_fullDecay.dat')
if hasattr(runArgs,'ecmEnergy'):
beamEnergy = runArgs.ecmEnergy / 2.
else:
beamEnergy = 6500.
# allow usage of all PDF sets
os.environ['LHAPATH']=os.environ["LHAPDF_DATA_PATH"]=(os.environ['LHAPATH'].split(':')[0])+":/cvmfs/sft.cern.ch/lcg/external/lhapdfsets/current/"
# especially 263400 = NNPDF30_lo_as_0130_nf_4
extras = { 'lhe_version' : '3.0',
'cut_decays' : 'F',
'pdlabel' : "'lhapdf'",
'lhaid' : '263400',
'bwcutoff' : '10000',
'event_norm' : 'average',
'use_syst' : 'False',
'drjj' : -1.0,
'drll' : -1.0,
'draa' : -1.0,
'draj' : -1.0,
'drjl' : -1.0,
'dral' : -1.0,
'etal' : -1.0,
'etaj' : -1.0,
'etaa' : -1.0,
}
safe_factor = 1.1
build_run_card(run_card_old=get_default_runcard(proc_dir=process_dir_fullDecay), run_card_new='run_card.dat', nevts=runArgs.maxEvents * safe_factor, rand_seed=runArgs.randomSeed, beamEnergy=beamEnergy, xqcut=0., extras=extras)
if not os.access(process_dir_fullDecay+'/Cards/param_card.dat',os.R_OK):
print 'ERROR: Could not get param card'
elif os.access('param_card.dat',os.R_OK):
print 'ERROR: Old run card in the current directory. Dont want to clobber it. Please move it first.'
else:
oldcard = open(process_dir_fullDecay+'/Cards/param_card.dat','r')
newcard = open('param_card.dat','w')
for line in oldcard:
if ' # MX ' in line:
newcard.write(' 6000005 %i # MX \n'%(runArgs.mass))
elif ' # MTP ' in line:
newcard.write(' 6000006 %i # MTP \n'%(runArgs.mass))
elif ' # MBP ' in line:
newcard.write(' 6000007 %i # MBP \n'%(runArgs.mass))
elif ' # MY ' in line:
newcard.write(' 6000008 %i # MY \n'%(runArgs.mass))
elif ' # KX ' in line:
newcard.write(' 1 %e # KX \n'%(runArgs.kappa))
elif ' # KT ' in line:
newcard.write(' 2 %e # KT \n'%(runArgs.kappa))
elif ' # KB ' in line:
newcard.write(' 3 %e # KB \n'%(runArgs.kappa))
elif ' # KY ' in line:
newcard.write(' 4 %e # KY \n'%(runArgs.kappa))
elif ' # WX ' in line:
newcard.write('DECAY 6000005 auto # WX \n')
elif ' # WTP ' in line:
newcard.write('DECAY 6000006 auto # WTP \n')
elif ' # WBP ' in line:
newcard.write('DECAY 6000007 auto # WBP \n')
elif ' # WY ' in line:
newcard.write('DECAY 6000008 auto # WY \n')
elif ' # zetaXuL ' in line:
newcard.write(' 1 0.000000e-01 # zetaXuL \n')
elif ' # zetaXcL ' in line:
newcard.write(' 2 0.000000e-01 # zetaXcL \n')
elif ' # zetaXtL ' in line:
newcard.write(' 3 1.000000e+00 # zetaXtL \n')
elif ' # zetaTuL ' in line:
newcard.write(' 4 0.000000e-01 # zetaTuL \n')
elif ' # zetaTcL ' in line:
newcard.write(' 5 0.000000e-01 # zetaTcL \n')
elif ' # zetaTtL ' in line:
newcard.write(' 6 1.000000e+00 # zetaTtL \n')
elif ' # zetaBdL ' in line:
newcard.write(' 7 0.000000e-01 # zetaBdL \n')
elif ' # zetaBsL ' in line:
newcard.write(' 8 0.000000e-01 # zetaBsL \n')
elif ' # zetaBbL ' in line:
newcard.write(' 9 1.000000e+00 # zetaBdL \n')
elif ' # zetaYdL ' in line:
newcard.write(' 10 0.000000e+00# zetaYdL \n')
elif ' # zetaYsL ' in line:
newcard.write(' 11 0.000000e+00 # zetaYsL \n')
elif ' # zetaYbL ' in line:
newcard.write(' 12 0.000000e+00 # zetaYbL \n')
elif ' # zetaXuR ' in line:
newcard.write(' 13 0.000000e+00 # zetaXuR \n')
elif ' # zetaXcR ' in line:
newcard.write(' 14 0.000000e+00 # zetaXcR \n')
elif ' # zetaXtR ' in line:
newcard.write(' 15 0.000000e+00 # zetaXtR \n')
elif ' # zetaTuR ' in line:
newcard.write(' 16 0.000000e+00 # zetaTuR \n')
elif ' # zetaTcR ' in line:
newcard.write(' 17 0.000000e+00 # zetaTcR \n')
elif ' # zetaTtR ' in line:
newcard.write(' 18 0.000000e+00 # zetaTtR \n')
elif ' # zetaBdR ' in line:
newcard.write(' 19 0.000000e+00 # zetaBdR \n')
elif ' # zetaBsR ' in line:
newcard.write(' 20 0.000000e+00 # zetaBsR \n')
elif ' # zetaBbR ' in line:
newcard.write(' 21 0.000000e+00 # zetaBdR \n')
elif ' # zetaYdR ' in line:
newcard.write(' 22 0.000000e+00 # zetaYdR \n')
elif ' # zetaYsR ' in line:
newcard.write(' 23 0.000000e+00 # zetaYsR \n')
elif ' # zetaYbR ' in line:
newcard.write(' 24 0.000000e+00 # zetaYbR \n')
elif '# xitpw' in line:
newcard.write(' 1 5.000000e-01 # xitpw \n')
elif '# xitpz' in line:
newcard.write(' 2 2.500000e-01 # xitpz \n')
elif '# xitph' in line:
newcard.write(' 3 2.500000e-01 # xitph \n')
# set some sm parameters to atlas defaults
elif ' # MB ' in line:
newcard.write(' 5 4.950000e+00 # MB \n')
elif ' # MT ' in line:
newcard.write(' 6 1.725000e+02 # MT \n')
elif ' # WT ' in line:
newcard.write('DECAY 6 1.350000e+00 # WT \n')
elif ' # WZ ' in line:
newcard.write('DECAY 23 2.495200e+00 # WZ \n')
elif ' # WW ' in line:
newcard.write('DECAY 24 2.085000e+00 # WW \n')
else:
newcard.write(line)
oldcard.close()
newcard.close()
runName='run_01'
#generate(run_card_loc='./run_card.dat',param_card_loc='./param_card.dat',run_name=runName+'_fullDecay',proc_dir=process_dir_fullDecay)
trial_count = 0
while os.path.exists(process_dir_fullDecay + '/Events/' + runName + '_fullDecay/unweighted_events.lhe.gz') == False and os.path.exists(process_dir_fullDecay + '/Events/' + runName + '_fullDecay/unweighted_events.lhe') == False and trial_count < MAX_TRIAL:
generate(run_card_loc='./run_card.dat',param_card_loc='./param_card.dat',run_name=runName+'_fullDecay',proc_dir=process_dir_fullDecay)
trial_count += 1
arrange_output(run_name=runName+'_fullDecay',proc_dir=process_dir_fullDecay,outputDS=runName+'_fullDecay._00001.events.tar.gz',saveProcDir=True)
process_dir_minDecay = new_process(card_loc='proc_card_mg5_minDecay.dat')
#generate(run_card_loc='./run_card.dat',param_card_loc='./param_card.dat',run_name=runName+'_minDecay',proc_dir=process_dir_minDecay)
trial_count = 0
while os.path.exists(process_dir_minDecay + '/Events/' + runName + '_minDecay/unweighted_events.lhe') == False and os.path.exists(process_dir_minDecay + '/Events/' + runName + '_minDecay/unweighted_events.lhe.gz') == False and trial_count < MAX_TRIAL:
generate(run_card_loc='./run_card.dat',param_card_loc='./param_card.dat',reweight_card_loc='./reweight_card.dat',run_name=runName+'_minDecay',proc_dir=process_dir_minDecay)
trial_count += 1
arrange_output(run_name=runName+'_minDecay',proc_dir=process_dir_minDecay,outputDS=runName+'_minDecay._00001.events.tar.gz',saveProcDir=True)
#runName='run_01'
#process_dir_fullDecay = 'PROC_VLQ_UFO_0'
#process_dir_minDecay = 'PROC_VLQ_UFO_1'
#Refurbishing
status = lhe_hacker.lhe_hacker(lhe_minDecay=process_dir_minDecay+'/Events/run_01_minDecay/unweighted_events.lhe', lhe_fullDecay=process_dir_fullDecay+'/Events/run_01_fullDecay/unweighted_events.lhe',vlq='T',decay='W')
status_2 = False
ME_script = open('script.txt','w')
ME_script.write('''
reweight run_RWT -f
done
''')
#for ii in range(31):
# ME_script.write('done\n')
ME_script.flush()
ME_script.close()
if status:
subprocess.call('mkdir -p ' + process_dir_minDecay+'/Events/run_RWT/', shell=True)
subprocess.call('cp unweighted_events.lhe ' + process_dir_minDecay+'/Events/run_RWT/', shell=True)
for m in M_grid:
for K in K_grid:
[is_ok, tagname] = rewtcardmaker(m,K)
if is_ok:
subprocess.call('cp reweight_card.dat ' + process_dir_minDecay+'/Cards/', shell=True)
did_it_work = False
trial_count = 0
while not did_it_work and trial_count < MAX_TRIAL:
trial_count += 1
subprocess.call('cp reweight_card.dat ' + process_dir_minDecay+'/Cards/', shell=True)
subprocess.call('export CC=gcc && ' + process_dir_minDecay + '/bin/madevent script.txt -f', shell=True)
sys.stdout.flush()
try:
subprocess.call('gunzip ' + process_dir_minDecay + '/Events/run_RWT/unweighted_events.lhe.gz', shell=True)
print "found gzipped file in run_RWT and unzipped it"
except:
print "did not find gzipped file. Already unzipped?"
pass
thisfile = open(process_dir_minDecay + '/Events/run_RWT/unweighted_events.lhe' , 'r')
for line in thisfile:
if "<weight id='" + tagname +"'" in line:
print tagname, " reweighting worked"
did_it_work = True
break